/* Адаптивные стили для мобильных устройств */

/* Планшеты и маленькие ноутбуки */
@media (max-width: 1024px) {
  body {
    padding: 16px;
  }

  .container {
    max-width: 100%;
  }

  .header {
    padding: 24px;
  }

  .header h1 {
    font-size: 24px;
  }

  .filters {
    padding: 16px;
  }

  .controls-group {
    flex-direction: column;
    gap: 12px;
  }

  .filter-group {
    width: 100%;
  }

  .filter-group select {
    width: 100%;
  }

  .chart-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .chart-card {
    height: 350px;
    margin: 0;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .stat-card {
    padding: 20px;
  }

  .stat-title {
    font-size: 13px;
  }

  .stat-value {
    font-size: 36px;
  }

  .teacher-stats {
    padding: 16px;
    overflow-x: auto;
  }

  table {
    min-width: 800px;
  }

  .detailed-stats-table table {
    min-width: 600px;
  }

  /* Улучшенная адаптация для детальной статистики */
  .detailed-stats-container {
    margin: 16px 0;
    padding: 16px;
  }

  .toggle-details-button {
    font-size: 15px;
    padding: 10px 20px;
  }

  .detailed-stats-table th,
  .detailed-stats-table td {
    padding: 12px 8px;
    font-size: 16px;
  }

  .active-students {
    font-size: 36px;
  }

  .total-students {
    font-size: 24px;
  }
}

/* Мобильные телефоны и планшеты до 800px */
@media (max-width: 800px) {
  * {
    box-sizing: border-box;
  }

  html body {
    padding: 12px;
    overflow-x: hidden;
    width: 100%;
  }

  html .container {
    max-width: 100%;
    overflow-x: hidden;
    padding: 0;
  }

  html .header {
    padding: 16px;
    margin-bottom: 16px;
  }

  html .header h1 {
    font-size: 18px;
    margin-bottom: 16px;
    text-align: center;
  }

  html .filters {
    padding: 12px;
  }

  .filter-group label {
    font-size: 14px;
  }

  html .controls-group {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  html .filter-group {
    width: 100%;
    margin-bottom: 8px;
  }

  html .filter-group select {
    width: 100%;
    font-size: 14px;
    padding: 10px;
  }

  html .refresh-button {
    padding: 12px;
    font-size: 14px;
    width: 100%;
  }

  .theme-switch-inline {
    margin-left: 0;
    margin-top: 12px;
    width: 100%;
    justify-content: center;
  }

  html .stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 100%;
    padding: 0;
  }

  html .stat-card {
    padding: 20px;
    width: 100%;
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
  }

  .stat-title {
    font-size: 12px;
    margin-bottom: 12px;
  }

  .stat-value {
    font-size: 28px;
  }

  /* Улучшенная адаптация для карточки студентов */
  .numbers-container {
    margin-bottom: 12px;
  }

  .active-students {
    font-size: 32px;
  }

  .total-students {
    font-size: 20px;
  }

  .separator {
    font-size: 20px;
  }

  .stat-labels {
    gap: 12px;
  }

  .stat-label {
    font-size: 12px;
    padding: 3px 8px;
  }

  .stat-percentage {
    font-size: 16px;
    margin-top: 4px;
  }

  /* Графики */
  html .chart-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  html .chart-card {
    height: 300px;
    padding: 12px;
    margin: 0;
  }

  .section-title {
    font-size: 18px;
    margin-bottom: 16px;
  }

  /* ПОЛНАЯ АДАПТАЦИЯ ТАБЛИЦЫ - убираем горизонтальный скролл */
  html .teacher-stats {
    padding: 16px;
    overflow: hidden;
  }

  html .teacher-stats table {
    display: block;
    width: 100%;
    min-width: unset;
  }

  html .teacher-stats thead {
    display: none;
  }

  html .teacher-stats tbody {
    display: block;
    width: 100%;
  }

  html .teacher-stats tr {
    display: block;
    margin-bottom: 16px;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-left: 4px solid #3b82f6;
    width: 100%;
    box-sizing: border-box;
  }

  .teacher-stats tr[data-revision="true"] {
    border-left-color: #f59e0b;
  }

  html .teacher-stats td {
    display: block;
    position: relative;
    padding: 10px 0;
    padding-left: 100px;
    border-bottom: 1px solid #f3f4f6;
    width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: right;
    min-height: 36px;
  }

  html .teacher-stats td:last-child {
    border-bottom: none;
  }

  html .teacher-stats td:nth-child(1)::before,
  html .teacher-stats td:nth-child(2)::before,
  html .teacher-stats td:nth-child(3)::before,
  html .teacher-stats td:nth-child(4)::before,
  html .teacher-stats td:nth-child(5)::before,
  html .teacher-stats td:nth-child(6)::before,
  html .teacher-stats td:nth-child(7)::before {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: #4b5563;
    font-size: 13px;
    width: 90px;
    text-align: left;
  }

  .teacher-stats td:nth-child(1)::before { content: "Студент:"; }
  .teacher-stats td:nth-child(2)::before { content: "Курс:"; }
  .teacher-stats td:nth-child(3)::before { content: "Задание:"; }
  .teacher-stats td:nth-child(4)::before { content: "Дата:"; }
  .teacher-stats td:nth-child(5)::before { content: "Ожидание:"; }
  .teacher-stats td:nth-child(6)::before { content: "Куратор:"; }
  .teacher-stats td:nth-child(7)::before { content: "Действия:"; }

  /* Контент ячеек */
  html .teacher-stats td .student-info {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    max-width: 60%;
  }

  .teacher-stats td .student-name {
    font-size: 14px;
    word-wrap: break-word;
  }

  .teacher-stats td .student-email {
    font-size: 12px;
    word-wrap: break-word;
  }

  .teacher-stats td .wait-time {
    font-size: 13px;
    padding: 4px 8px;
  }

  html .teacher-stats td .action-button {
    font-size: 13px;
    padding: 6px 10px;
    width: auto;
    min-width: 100px;
  }

  /* Детальная статистика для мобильных - карточный формат */
  html .detailed-stats-container {
    margin: 20px auto;
    padding: 16px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-align: center;
  }

  html #dashboard-content .detailed-stats-table,
  html #statistics-content .detailed-stats-table {
    overflow: hidden;
    width: 100%;
    display: block;
  }

  html #dashboard-content .detailed-stats-table table,
  html #statistics-content .detailed-stats-table table {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: unset;
    overflow: hidden;
    margin: 0;
  }

  html #dashboard-content .detailed-stats-table thead,
  html #statistics-content .detailed-stats-table thead {
    display: none;
  }

  html #dashboard-content .detailed-stats-table tbody,
  html #statistics-content .detailed-stats-table tbody {
    display: block;
    width: 100%;
    min-width: unset;
  }

  html #dashboard-content .detailed-stats-table tr,
  html #statistics-content .detailed-stats-table tr {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: unset;
    margin: 0 auto 20px auto;
    padding: 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-left: 4px solid #3b82f6;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
  }

  html #dashboard-content .detailed-stats-table td,
  html #statistics-content .detailed-stats-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 15px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
    min-height: 36px;
    font-weight: 600;
  }

  html #dashboard-content .detailed-stats-table td::before,
  html #statistics-content .detailed-stats-table td::before {
    flex-shrink: 0;
    margin-right: 10px;
  }

  html #dashboard-content .detailed-stats-table td:last-child,
  html #statistics-content .detailed-stats-table td:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  /* ПЕРВАЯ ЯЧЕЙКА - ИМЯ ПРЕПОДАВАТЕЛЯ */
  html #dashboard-content .detailed-stats-table td:first-child,
  html #statistics-content .detailed-stats-table td:first-child {
    display: block;
    font-weight: 700;
    color: #1f2937;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 8px;
    font-size: 18px;
    padding: 0 0 12px 0;
    text-align: left;
  }

  /* ОСТАЛЬНЫЕ ЯЧЕЙКИ - FLEX подход */
  html #dashboard-content .detailed-stats-table td:nth-child(2),
  html #dashboard-content .detailed-stats-table td:nth-child(3),
  html #dashboard-content .detailed-stats-table td:nth-child(4),
  html #dashboard-content .detailed-stats-table td:nth-child(5),
  html #dashboard-content .detailed-stats-table td:nth-child(6),
  html #statistics-content .detailed-stats-table td:nth-child(2),
  html #statistics-content .detailed-stats-table td:nth-child(3),
  html #statistics-content .detailed-stats-table td:nth-child(4),
  html #statistics-content .detailed-stats-table td:nth-child(5),
  html #statistics-content .detailed-stats-table td:nth-child(6) {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
    min-height: 36px;
    font-weight: 700;
    font-size: 16px;
    color: #1f2937;
  }

  /* Метки слева */
  html #dashboard-content .detailed-stats-table td:nth-child(2)::before,
  html #dashboard-content .detailed-stats-table td:nth-child(3)::before,
  html #dashboard-content .detailed-stats-table td:nth-child(4)::before,
  html #dashboard-content .detailed-stats-table td:nth-child(5)::before,
  html #dashboard-content .detailed-stats-table td:nth-child(6)::before,
  html #statistics-content .detailed-stats-table td:nth-child(2)::before,
  html #statistics-content .detailed-stats-table td:nth-child(3)::before,
  html #statistics-content .detailed-stats-table td:nth-child(4)::before,
  html #statistics-content .detailed-stats-table td:nth-child(5)::before,
  html #statistics-content .detailed-stats-table td:nth-child(6)::before {
    position: static;
    transform: none;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    margin-right: 10px;
  }

  html #dashboard-content .detailed-stats-table td:nth-child(2)::before,
  html #statistics-content .detailed-stats-table td:nth-child(2)::before {
    content: "Всего проверок:";
    color: #4b5563;
  }

  html #dashboard-content .detailed-stats-table td:nth-child(3)::before,
  html #statistics-content .detailed-stats-table td:nth-child(3)::before {
    content: "Принято:";
    color: #059669;
  }

  html #dashboard-content .detailed-stats-table td:nth-child(4)::before,
  html #statistics-content .detailed-stats-table td:nth-child(4)::before {
    content: "На доработке:";
    color: #d97706;
  }

  html #dashboard-content .detailed-stats-table td:nth-child(5)::before,
  html #statistics-content .detailed-stats-table td:nth-child(5)::before {
    content: "% доработки:";
    color: #6b7280;
  }

  html #dashboard-content .detailed-stats-table td:nth-child(6)::before,
  html #statistics-content .detailed-stats-table td:nth-child(6)::before {
    content: "Заработано:";
    color: #059669;
  }

  /* СПЕЦИАЛЬНЫЕ ЦВЕТА ДЛЯ ЗНАЧЕНИЙ */
  html #dashboard-content .detailed-stats-table td:nth-child(3),
  html #statistics-content .detailed-stats-table td:nth-child(3) {
    color: rgba(23, 177, 152, 1);
    font-size: 18px;
  }

  html #dashboard-content .detailed-stats-table td:nth-child(4),
  html #statistics-content .detailed-stats-table td:nth-child(4) {
    color: rgba(245, 158, 11, 1);
    font-size: 18px;
  }

  html #dashboard-content .detailed-stats-table td:nth-child(6),
  html #statistics-content .detailed-stats-table td:nth-child(6) {
    color: #059669;
    font-size: 18px;
    font-weight: 700;
  }

  /* КНОПКА ПЕРЕКЛЮЧЕНИЯ */
  html .toggle-details-button {
    font-size: 16px;
    padding: 16px 20px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto 20px auto;
    font-weight: 600;
    box-sizing: border-box;
  }

  .month-label {
    font-size: 12px;
    padding: 2px 6px;
    display: block;
    margin-top: 4px;
  }
}

/* iPhone и маленькие мобильные (<=414px) */
@media (max-width: 414px) {
  body {
    padding: 8px;
  }

  .header {
    padding: 16px;
  }

  .header h1 {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .filters {
    padding: 10px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-title {
    font-size: 11px;
  }

  .stat-value {
    font-size: 24px;
  }

  .active-students {
    font-size: 28px;
  }

  .total-students {
    font-size: 18px;
  }

  .separator {
    font-size: 18px;
  }

  .chart-card {
    height: 250px;
    padding: 10px;
  }

  .teacher-stats tr {
    padding: 12px;
    margin-bottom: 10px;
  }

  .teacher-stats td .student-info {
    max-width: 55%;
  }

  .teacher-stats td:nth-child(1)::before,
  .teacher-stats td:nth-child(2)::before,
  .teacher-stats td:nth-child(3)::before,
  .teacher-stats td:nth-child(4)::before,
  .teacher-stats td:nth-child(5)::before,
  .teacher-stats td:nth-child(6)::before,
  .teacher-stats td:nth-child(7)::before {
    font-size: 12px;
    min-width: 60px;
  }

  .teacher-stats td .action-button {
    font-size: 12px;
    padding: 5px 8px;
    min-width: 90px;
  }

  .detailed-stats-table td {
    font-size: 13px;
    padding: 4px 0;
  }

  .detailed-stats-table td:first-child {
    font-size: 14px;
  }

  /* Улучшенная детальная статистика для iPhone */
  .detailed-stats-container {
    margin: 16px 0;
    padding: 14px;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
  }

  .detailed-stats-table tr {
    margin-bottom: 16px;
    padding: 18px;
    border-radius: 14px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  .detailed-stats-table td {
    position: relative;
    padding: 8px 0;
    font-size: 15px;
    width: 100%;
    border-bottom: 1px solid #f3f4f6;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: right;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  .detailed-stats-table td:first-child {
    font-size: 18px;
    padding-bottom: 10px;
    margin-bottom: 10px;
  }

  .detailed-stats-table td:nth-child(2)::before,
  .detailed-stats-table td:nth-child(3)::before,
  .detailed-stats-table td:nth-child(4)::before,
  .detailed-stats-table td:nth-child(5)::before,
  .detailed-stats-table td:nth-child(6)::before {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
  }

  .detailed-stats-table td:nth-child(6) {
    font-size: 16px;
  }

  .toggle-details-button {
    font-size: 15px;
    padding: 10px 18px;
  }
}

/* Очень маленькие телефоны */
@media (max-width: 375px) {
  body {
    padding: 8px;
  }

  .header {
    padding: 16px;
  }

  .header h1 {
    font-size: 16px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-title {
    font-size: 11px;
  }

  .stat-value {
    font-size: 24px;
  }

  .active-students {
    font-size: 28px;
  }

  .total-students {
    font-size: 18px;
  }

  .separator {
    font-size: 18px;
  }

  .section-title {
    font-size: 16px;
  }

  .filter-group select {
    font-size: 13px;
    padding: 8px 10px;
  }

  .refresh-button {
    font-size: 13px;
    padding: 8px 12px;
  }

  .toggle-details-button {
    font-size: 13px;
    padding: 8px 12px;
  }

  .chart-card {
    height: 250px;
    padding: 8px;
  }

  .detailed-stats-table td {
    font-size: 13px;
  }

  .detailed-stats-table td:first-child {
    font-size: 14px;
  }

  .month-label {
    font-size: 10px;
    padding: 1px 4px;
  }
}

/* Landscape режим для мобильных */
@media (max-width: 768px) and (orientation: landscape) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-value {
    font-size: 24px;
  }

  .active-students {
    font-size: 28px;
  }

  .total-students {
    font-size: 18px;
  }

  .header {
    padding: 12px;
  }

  .header h1 {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .chart-card {
    height: 250px;
  }
}

/* Печать */
@media print {
  body {
    background: white;
    color: black;
  }

  .header {
    background: none;
    color: black;
    box-shadow: none;
  }

  .filters,
  .theme-switch {
    display: none;
  }

  .stat-card {
    box-shadow: none;
    border: 1px solid #e5e7eb;
  }

  .chart-card {
    break-inside: avoid;
  }

  .teacher-stats {
    box-shadow: none;
  }

  .action-button {
    display: none;
  }
}
