/**
 * Адаптивные стили для main.css
 * Все медиа-запросы вынесены в отдельный файл для лучшей организации
 * Медиа-запросы отсортированы по убыванию брейкпоинтов (от большего к меньшему)
 */

/* ============================================
   Брейкпоинт: 1200px и меньше
   ============================================ */
@media screen and (max-width: 1200px) {
  th, td {
    padding: 10px 8px;
    font-size: 14px;
  }
}

/* ============================================
   Брейкпоинт: 992px и меньше
   ============================================ */
@media (max-width: 992px) {
  .dashboard {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .dashboard__sidebar {
    width: 100%;
    height: max-content;
    position: relative;
    padding: 1rem;
  }

  /* Переносим "шестерёнку" в поток, чтобы не перекрывала навигацию */
  .sidebar-admin-link {
    position: static;
    text-align: center;
    padding: 0.5rem 0 0;
    order: 2;
  }

  .sidebar-admin-link__icon {
    font-size: 42px;
  }

  .dashboard__main {
    padding: 0 3px;
  }

  .team-logo {
    justify-content: center;
  }

  .nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    align-items: center;
  }

  .nav__item {
    margin-bottom: 0;
  }

  .nav__link {
    padding: 0.5rem 1rem;
  }
}

/* ============================================
   Брейкпоинт: 768px и меньше
   ============================================ */
@media (max-width: 768px) {
  /* Детальная страница игрока */
  .player-header {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .stats-grid-detailed {
    grid-template-columns: 1fr;
  }

  .personal-info {
    grid-template-columns: 1fr;
  }

  /* Карточки игроков */
  .main-title {
    font-size: 2.2rem;
  }

  .player-cards-container {
    grid-template-columns: 1fr;
  }

  .player-card {
    max-width: 100%;
  }

  .photo-container {
    width: 120px;
    height: 120px;
  }

  .player-name {
    font-size: 1rem;
  }

  .player-position {
    font-size: 0.7rem;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .video-section__title {
    font-size: 1.6rem;
  }

  .video-gallery {
    grid-template-columns: 1fr;
    gap: 16px;
    justify-content: center;
  }

  .video-card {
    width: 100%;
    max-width: 100%;
  }

  /* Адаптивные стили для видео-плеера */
  .video-player__play-btn {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
  }

  .video-player__controls {
    padding: 0.75rem;
  }

  .video-player__controls-bottom {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .video-player__time {
    font-size: 0.8rem;
  }

  .video-player__btn {
    font-size: 1rem;
    min-width: 32px;
    height: 32px;
    padding: 0.4rem;
  }

  .video-player__volume-slider {
    width: 60px;
  }
}

/* ============================================
   Брейкпоинт: 600px и меньше
   ============================================ */
@media screen and (max-width: 600px) {
  :root {
    /* Чуть уменьшаем смещение второй строки заголовка,
       чтобы ряд с "Эйс", "Выбито" и т.п. не уезжал вниз */
    --players-header-second-row-offset: 26px;
  }

  body {
    padding: 10px;
  }

  .table-players-stats {
    font-size: 11px;
  }

  .table-players-stats th,
  .table-players-stats td {
    padding: 4px 2px;
  }

  .table-container {
    width: 100%;
    border-radius: 4px;
    position: relative;
  }

  .table-container:not(.table-box) {
    overflow-x: visible;
    margin-bottom: 16px;
  }

  .table-container:not(.table-box) table {
    width: 100%;
    min-width: 100%;
    table-layout: auto;
  }

  .table-container:not(.table-box) .table-teams th:first-child,
  .table-container:not(.table-box) .table-teams td:first-child {
    width: 60px;
    min-width: 60px;
  }

  .table-container:not(.table-box) .table-teams th:nth-child(2),
  .table-container:not(.table-box) .table-teams td:nth-child(2) {
    min-width: 150px;
  }

  .table-container:not(.table-box) th,
  .table-container:not(.table-box) td {
    white-space: normal;
    word-break: normal;
  }

  .table-container:not(.table-box) .team-name-teams {
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
  }

  .table-container.table-box {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-container.table-box .table-highlight {
    width: max-content;
    min-width: unset;
    max-width: none;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
  }

  .table-container.table-box .table-highlight th,
  .table-container.table-box .table-highlight td {
    white-space: nowrap;
  }

  .table-highlight th:first-child,
  .table-highlight td:first-child {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
    box-sizing: border-box;
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
  }

  .table-highlight th:nth-child(2),
  .table-highlight td:nth-child(2) {
    min-width: 150px;
    box-sizing: border-box;
    position: sticky;
    left: 60px;
    z-index: 2;
    background: #fff;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
  }

  .table-highlight th:first-child,
  .table-highlight td:first-child {
    border-left: 1px solid var(--cell-collor);
    border-right: 1px solid var(--cell-collor);
  }

  .table-highlight th:nth-child(2),
  .table-highlight td:nth-child(2) {
    border-right: 1px solid var(--cell-collor);
  }

  .table-highlight th:first-child::before,
  .table-highlight td:first-child::before,
  .table-highlight th:nth-child(2)::before,
  .table-highlight td:nth-child(2)::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -1px;
    width: 1px;
    background: var(--cell-collor);
    pointer-events: none;
  }

  .table-highlight th:nth-child(2)::before,
  .table-highlight td:nth-child(2)::before {
    left: 0;
  }

  .table-highlight thead th:first-child {
    z-index: 3;
    background: var(--primary-red);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.15);
  }

  .table-highlight thead th:nth-child(2) {
    z-index: 3;
    background: var(--primary-red);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.15);
  }

  .matches-table {
    font-size: 12px;
  }

  .matches-table th,
  .matches-table td {
    padding: 10px 12px;
  }

  /* Таблица статистики игроков */
  .players-stats-section .table-container {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
  }

  .table-container .table-players-stats {
    width: max-content;
    min-width: 100%;
  }

  .table-players-stats th:first-child,
  .table-players-stats td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #fff;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
  }

  .table-players-stats thead th:first-child {
    background: var(--primary-red);
    color: #fff;
    z-index: 4;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.15);
  }

  .table-players-stats th,
  .table-players-stats td {
    white-space: nowrap;
    padding: 8px 10px;
    font-size: 11px;
  }

  /* Адаптивные стили для таблицы статистики */
  .players-stats-title {
    font-size: 1.4rem;
    margin-bottom: 1rem;
  }

  .stats-tabs-container {
    gap: 0.25rem;
    margin-bottom: 1rem;
    justify-content: center;
  }

  .stats-tab-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }

  .table-players-stats th,
  .table-players-stats td {
    padding: 8px 6px;
    font-size: 11px;
    white-space: nowrap;
  }

  .table-players-stats .th-player-name {
    min-width: 120px;
  }

  /* Адаптивные стили для диаграмм */
  .charts-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
  }

  .chart-wrapper-item {
    padding: 1rem;
    gap: 0.6rem;
  }

  .chart-category-title {
    font-size: 1rem;
  }

  .chart-container {
    min-height: 240px;
    height: auto;
    padding: 0.75rem;
    overflow: visible; /* Позволяет видеть подписи, выходящие за границы */
  }

  .charts-title {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }

  .chart-total-info {
    padding: 0.6rem 0.75rem;
    min-width: 90px;
  }

  .chart-total-label {
    font-size: 0.7rem;
  }

  .chart-total-value {
    font-size: 1.3rem;
  }

  .fixed-column,
  .team-name {
    position: sticky !important;
    left: 0;
    background: white;
    z-index: 10;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
  }

  .team-name {
    left: 50px;
    /* Ширина первого столбца */
    min-width: 150px;
    z-index: 11;
  }
}

/* ============================================
   Брейкпоинт: 576px и меньше
   ============================================ */
@media (max-width: 576px) {
  .dashboard__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .matches__item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .card-header {
    display: flex;
    align-items: center;
    padding: 10px;
    height: 100%;
  }

  .player-card {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    justify-content: flex-start;
    height: auto;
    padding: 15px;
  }

  .card-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 0;
    width: 100%;
  }

  .photo-container {
    width: 80px;
    height: 80px;
    border-width: 3px;
    margin: 0;
  }

  .player-number {
    display: none;
  }

  .player-name {
    font-size: 0.9rem;
    text-align: center;
  }

  .player-position {
    font-size: 0.7rem;
    text-align: center;
  }

  .card-content {
    padding: 0;
    width: 100%;
    text-align: center;
  }

  .stats-grid {
    min-width: 1200;
    margin: 0;
    padding: 10px;
    gap: 5px;
    box-sizing: border-box;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .stat-item {
    padding: 0px;
  }

  .stat-label {
    font-size: 0.6rem;
  }
}

/* ============================================
   Брейкпоинт: 480px и меньше
   ============================================ */
@media screen and (max-width: 480px) {
  .card {
    padding: 0.1rem;
  }

  th, td {
    padding: 8px 6px;
    font-size: 0.7rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  .legend {
    flex-direction: column;
    gap: 10px;
    align-items: center;
  }

  .matches-table td {
    font-size: 12px;
  }

   /* Адаптивные стили для диаграмм на очень маленьких экранах */
   .charts-grid {
     grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
     gap: 0.5rem;
   }

   .chart-container {
     min-height: 120px;
     height: auto;
     padding: 0.4rem;
     overflow: visible; /* Позволяет видеть подписи, выходящие за границы */
   }

  .charts-title {
    font-size: 0.85rem;
  }

  .chart-total-info {
    padding: 0.35rem 0.4rem;
    min-width: 60px;
  }

  .chart-total-label {
    font-size: 0.6rem;
  }

  .chart-total-value {
    font-size: 0.9rem;
  }

  /* Видео-плеер на очень маленьких экранах */
  .video-player__play-btn {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }

  .video-player__controls {
    padding: 0.5rem;
  }

  .video-player__controls-bottom {
    gap: 0.25rem;
  }

  .video-player__controls-left,
  .video-player__controls-right {
    gap: 0.5rem;
  }

  .video-player__time {
    font-size: 0.75rem;
  }

  .video-player__speed-menu {
    min-width: 70px;
    padding: 0.4rem;
  }

  .video-player__speed-option {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
  }
}
