/* ============================================
   STATS PAGE - TEAM & PLAYER STATISTICS
   ============================================ */

:root {
    --predators-gold: #FFB81C;
    --predators-navy: #041E42;
}

.page-stats {
    background: #f8f9fa;
    min-height: 100vh;
}

/* ============================================
   PAGE HEADER
   ============================================ */

.stats-page-header {
    background: linear-gradient(135deg, var(--predators-navy) 0%, #052a5c 100%);
    color: white;
    padding: 24px 24px 20px;
}

.stats-header-content {
    max-width: 1400px;
    margin: 0 auto;
}

.stats-page-header h1 {
    font-size: 32px;
    font-weight: 900;
    margin: 0 0 8px 0;
}

.season-subtitle {
    font-size: 16px;
    opacity: 0.9;
    margin: 0;
}

/* ============================================
   STATS CONTAINER
   ============================================ */

.stats-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
}

.section-heading {
    font-size: 24px;
    font-weight: 800;
    color: var(--predators-navy);
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--predators-gold);
}

.team-overview-section {
    margin-bottom: 40px;
}

.player-stats-section {
    margin-bottom: 48px;
}

.standings-cards-section {
    margin-bottom: 48px;
}

/* ============================================
   TEAM OVERVIEW GRID
   ============================================ */

.overview-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

@media (max-width: 1400px) {
    .overview-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {
    .overview-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.overview-stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    border-top: 4px solid var(--predators-gold);
}

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 900;
    color: var(--predators-navy);
}

.stat-secondary {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    margin-top: 4px;
}

/* ============================================
   PLAYER STATS TABLES
   ============================================ */

.stats-with-sidebar {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    align-items: start;
}

.stats-table-wrapper {
    background: white;
    border-radius: 12px;
    overflow-x: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stats-sidebar {
    position: sticky;
    top: 20px;
}

.stats-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-top: 4px solid var(--predators-gold);
}

.stats-card-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--predators-navy);
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--predators-gold);
}

.leader-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    background: #f8f9fa;
    transition: all 0.2s ease;
}

.leader-item:hover {
    background: rgba(255, 184, 28, 0.1);
    transform: translateX(4px);
}

.leader-item:last-child {
    margin-bottom: 0;
}

.leader-rank {
    font-size: 20px;
    font-weight: 900;
    color: var(--predators-gold);
    min-width: 30px;
    text-align: center;
}

.leader-player-info {
    flex: 1;
    min-width: 0;
}

.leader-player-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--predators-navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.leader-stat-label {
    font-size: 10px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.leader-stat-value {
    font-size: 22px;
    font-weight: 900;
    color: var(--predators-navy);
    text-align: right;
    min-width: 45px;
}

.leader-category-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--predators-navy);
    margin: 20px 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #e9ecef;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.leader-category-title:first-child {
    margin-top: 0;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.stats-table th {
    background: linear-gradient(135deg, var(--predators-navy) 0%, #052a5c 100%);
    color: white;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 8px 6px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

.stats-table th:last-child {
    border-right: none;
}

.stats-table th:hover {
    background: linear-gradient(135deg, #052a5c 0%, var(--predators-navy) 100%);
}

.stats-table th.sortable::after {
    content: ' ⇅';
    opacity: 0.5;
}

.stats-table th.sorted-asc::after {
    content: ' ▲';
    opacity: 1;
}

.stats-table th.sorted-desc::after {
    content: ' ▼';
    opacity: 1;
}

.stats-table th.text-left {
    text-align: left;
}

.stats-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background 0.2s ease;
}

.stats-table tbody tr:hover {
    background: #f8f9fa;
}

.stats-table td {
    padding: 6px 6px;
    font-size: 12px;
    color: #1a1a1a;
    text-align: center;
    border-right: 1px solid #e9ecef;
}

.stats-table td:last-child {
    border-right: none;
}

.player-name-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
}

.player-headshot-tiny {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--predators-gold);
    object-fit: cover;
}

.player-name-wrapper {
    display: flex;
    flex-direction: column;
}

.player-name-link {
    font-weight: 600;
    font-size: 13px;
    color: var(--predators-navy);
    text-decoration: none;
}

.player-name-link:hover {
    color: var(--predators-gold);
}

.player-position-tiny {
    font-size: 10px;
    color: #6b7280;
    font-weight: 600;
}

/* Tooltip styling */
.stats-table th {
    position: relative;
}

.stats-table th[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 8px;
    letter-spacing: normal;
    text-transform: none;
    pointer-events: none;
}

.stats-table th[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    margin-bottom: 2px;
    z-index: 1000;
}

/* ============================================
   STANDINGS CARDS
   ============================================ */

.standings-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.standings-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    max-height: 600px;
}

.standings-card > div {
    overflow-y: auto;
    max-height: 520px;
}

.standings-card-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--predators-navy);
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--predators-gold);
    flex-shrink: 0;
}

.standings-mini-table {
    width: 100%;
    border-collapse: collapse;
}

.standings-mini-table th {
    background: var(--predators-navy);
    color: white;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 8px;
    text-align: left;
}

.standings-mini-table th.text-center {
    text-align: center;
}

.standings-mini-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background 0.2s ease;
}

.standings-mini-table tbody tr:hover {
    background: #f8f9fa;
}

.standings-mini-table tbody tr.predators-row {
    background: rgba(255, 184, 28, 0.1);
    font-weight: 700;
}

.standings-mini-table tbody tr.predators-row:hover {
    background: rgba(255, 184, 28, 0.15);
}

.standings-mini-table td {
    padding: 10px 8px;
    font-size: 13px;
    color: #1a1a1a;
}

.standings-mini-table td.text-center {
    text-align: center;
}

.team-name-cell-mini {
    display: flex;
    align-items: center;
    gap: 8px;
}

.team-logo-mini {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.team-name-mini {
    font-weight: 600;
    font-size: 12px;
}


/* ============================================
   LOADING & ERROR STATES
   ============================================ */

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--predators-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    color: #6b7280;
    font-size: 14px;
}

.error-message {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
    font-size: 16px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
    .overview-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 12px;
    }

    .stat-value {
        font-size: 28px;
    }

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

    .stats-sidebar {
        position: static;
    }
}

@media (max-width: 768px) {
    .stats-page-header {
        padding: 20px 16px 16px;
    }

    .stats-page-header h1 {
        font-size: 24px;
    }

    .stats-container {
        padding: 24px 16px;
    }

    .section-heading {
        font-size: 20px;
    }

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

    .overview-stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 24px;
    }

    .stats-table-wrapper {
        position: relative;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Visual indicator for horizontal scrolling */
    .stats-table-wrapper::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 40px;
        background: linear-gradient(to left, rgba(255, 255, 255, 0.95), transparent);
        pointer-events: none;
        z-index: 5;
    }

    .stats-table th {
        padding: 12px 8px;
        font-size: 13px;
    }

    .stats-table td {
        padding: 10px 8px;
        font-size: 14px;
    }

    .player-headshot-tiny {
        width: 28px;
        height: 28px;
    }

    .standings-cards-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .standings-card {
        padding: 16px;
    }

    .standings-card-title {
        font-size: 16px;
    }

    /* Make first column (Player name) sticky on stats tables for tablets/landscape */
    .stats-table th:first-child,
    .stats-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 10;
        background-color: #ffffff;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    }

    .stats-table thead th:first-child {
        z-index: 11;
        background-color: #041E42;
    }

    .stats-table tbody tr:hover td:first-child {
        background-color: #f8f9fa;
    }
}

@media (max-width: 480px) {
    .overview-grid {
        grid-template-columns: 1fr;
    }

    /* Make first column (Player name) sticky on stats tables */
    .stats-table th:first-child,
    .stats-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 10;
        background-color: #ffffff;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
        max-width: 120px;
        min-width: 120px;
        width: 120px;
        padding: 8px 4px !important;
    }

    .stats-table thead th:first-child {
        z-index: 11;
        background-color: #041E42;
    }

    .stats-table tbody tr:hover td:first-child {
        background-color: #f8f9fa;
    }

    /* Smaller player info in stats tables */
    .player-name-cell {
        gap: 4px;
    }

    .player-headshot-tiny {
        width: 24px !important;
        height: 24px !important;
    }

    .player-name-text {
        font-size: 11px;
        line-height: 1.2;
    }

    .player-number {
        font-size: 10px;
    }

    /* Make first column (Team) sticky on standings tables */
    .standings-mini-table th:first-child,
    .standings-mini-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 10;
        background-color: #ffffff;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    }

    .standings-mini-table thead th:first-child {
        z-index: 11;
        background-color: #f8f9fa;
    }

    .standings-mini-table tbody tr:hover td:first-child {
        background-color: #f0f0f0;
    }

    .standings-mini-table tbody tr.predators-row td:first-child {
        background-color: #041E42;
        color: #FFB81C;
    }

    .standings-mini-table tbody tr.predators-row:hover td:first-child {
        background-color: #062952;
    }
}
