/* Standings Redesign CSS */

.standings-page-container {
    min-height: calc(100vh - 120px);
    width: 100%;
    margin: 0 auto;
    padding-bottom: 60px;
}

.standings-header {
    padding: 0 16px 16px;
    margin-bottom: 8px;
    width: 100%;
}

.standings-header-inner {
    max-width: 1240px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.standings-header-title {
    margin: 0;
    font-size: clamp(1.65rem, 3vw, 2.15rem);
    font-weight: 900;
    line-height: 1.1;
    color: var(--ice-white);
    text-wrap: balance;
}

.standings-header-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    width: 100%;
    margin: 0 0 24px 0;
    line-height: 1.65;
    font-weight: 500;
    text-wrap: pretty;
}

/* Controls Placeholder */
.standings-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 10px;
}

.standings-controls-left {
    display: flex;
    gap: 8px;
    background: var(--bg-surface-elevated);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}

.control-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    color: var(--text-main);
}

.control-btn.active {
    background: var(--bg-surface-active);
    color: var(--ice-white);
}

.standings-controls-right .standings-search {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 8px 16px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.standings-controls-right .standings-search:focus {
    border-color: var(--mhl-gold);
}

/* Standings Panel Wrapper */
.standings-wrapper {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 16px;
}

.standings-only-panel {
    border-radius: 12px;
    overflow: hidden;
}

/* Custom Scrollbar */
.custom-scrollbar {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(71, 85, 105, 0.72) rgba(11, 18, 32, 0.72);
}
.custom-scrollbar::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(11, 18, 32, 0.72);
    border-radius: 999px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(71, 85, 105, 0.82);
    border: 2px solid rgba(11, 18, 32, 0.72);
    border-radius: 999px;
}

/* Table Enhancements */
.standings-table {
    width: 100%;
    border-collapse: collapse;
}

.standings-table th {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 16px;
    text-align: right;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
}
.standings-table th.col-rank,
.standings-table th.col-team {
    text-align: left;
}

.standings-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background-color 0.15s ease;
}
.standings-row:last-child {
    border-bottom: none;
}
.standings-row:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.standings-table td {
    padding: 18px 16px;
    vertical-align: middle;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
}
.standings-table td.col-rank,
.standings-table td.col-team {
    text-align: left;
}

.rank-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg-surface-elevated);
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}
.standings-row:nth-child(-n+8) .rank-pill {
    background: rgba(255, 255, 255, 0.1);
    color: var(--ice-white);
}

.col-team .team-line {
    display: flex;
    align-items: center;
    gap: 18px;
    text-decoration: none;
}

.team-line-copy {
    display: flex;
    flex-direction: column;
}
.team-abbr {
    font-weight: 700;
    color: var(--ice-white);
    font-size: 1rem;
}
.team-full {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Points Highlighting */
.col-pts strong {
    color: var(--mhl-gold);
    font-size: 1.05rem;
}

/* Differential Coloring */
.diff-pos { color: #4ade80 !important; }
.diff-neg { color: #f87171 !important; }
.diff-neutral { color: var(--text-muted) !important; }

/* Empty state */
.empty-standings {
    padding: 60px 20px;
}


/* --- MOBILE CARDS --- */
.standings-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
}

.standings-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 16px;
    text-decoration: none;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.standings-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-team {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    margin: 0 12px;
}

.card-pts {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.pts-val {
    color: var(--mhl-gold);
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
}
.pts-lbl {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.card-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.stat-lbl {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 4px;
}
.stat-val {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ice-white);
}

/* Visibility Toggles */
.hide-on-mobile { display: block; }
.show-on-mobile { display: none; }

@media (max-width: 768px) {
    .hide-on-mobile { display: none !important; }
    .show-on-mobile { display: block !important; }
    
    .standings-header {
        padding: 0 16px 12px;
    }

    .standings-header-inner {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .standings-context-pills {
        justify-content: flex-start;
    }
    
    .standings-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .standings-controls-left {
        justify-content: center;
    }
}

/* Segmented Control & Search */
.segmented-control {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 4px;
}

.segment-btn {
    background: transparent;
    border: none;
    color: var(--cool-gray);
    font-size: 0.88rem;
    font-weight: 700;
    padding: 8px 18px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.segment-btn:hover {
    color: var(--ice-white);
    background: rgba(255, 255, 255, 0.05);
}

.segment-btn.is-active {
    background: var(--victory-gold);
    color: #07111f;
    box-shadow: 0 2px 8px rgba(233, 191, 69, 0.2);
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--cool-gray);
    opacity: 0.6;
}

.standings-search-input {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 14px 10px 38px;
    color: var(--ice-white);
    font-size: 0.9rem;
    font-weight: 600;
    width: 240px;
    outline: none;
    transition: all 0.2s ease;
}

.standings-search-input:focus {
    border-color: var(--victory-gold);
    box-shadow: 0 0 0 2px rgba(233, 191, 69, 0.15);
    background: rgba(15, 23, 42, 0.8);
}

/* Logos & Monograms */
.standings-team-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.standings-team-monogram {
    height: 28px;
    padding: 0 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--ice-white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-muted {
    color: var(--cool-gray);
}

/* Mobile cards overhaul */
.standings-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 20px;
}
.card-header {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 12px;
    justify-content: flex-start;
}
.card-rank-wrap {
    margin-right: 14px;
}
.card-primary-stats {
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 900;
    margin-bottom: 8px;
}
.mobile-pts {
    color: var(--victory-gold);
}
.mobile-record {
    color: var(--ice-white);
}
.mobile-sep {
    margin: 0 8px;
    color: rgba(255,255,255,0.15);
}
.card-secondary-stats {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--cool-gray);
    font-weight: 600;
}

/* Select Pills */
.select-pill {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 16px;
    display: inline-flex;
    align-items: center;
    color: var(--ice-white);
    font-size: 0.9rem;
    font-weight: 700;
}

.standings-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.standings-controls-left {
    display: flex;
    gap: 8px;
    background: none;
    padding: 0;
    border: none;
}

@media (max-width: 768px) {
    .standings-controls {
        flex-direction: column;
        gap: 16px;
    }
    .standings-controls-right {
        width: 100%;
        display: flex;
        justify-content: center;
    }
}

/* Standings context */
.standings-context-pills {
    margin: 0;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
    width: auto;
}

.standings-context-pill {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 7px 11px;
    color: #9fb0c7;
    font-size: 0.78rem;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.standings-selectors {
    display: none;
}

.standings-select-wrap {
    position: relative;
}

.standings-select-wrap::after {
    content: "▼";
    font-size: 0.65rem;
    color: var(--cool-gray);
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.standings-select {
    appearance: none;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 40px 10px 20px;
    font-size: 0.95rem;
    color: var(--ice-white);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.standings-select:hover, .standings-select:focus {
    border-color: rgba(255, 255, 255, 0.2);
    outline: none;
}

.standings-select option {
    background: #0f172a;
    color: var(--ice-white);
}

.standings-select option:disabled {
    color: rgba(255, 255, 255, 0.2);
}

/* Stats Page Basic/Advanced Toggle */
.view-toggle-tabs {
    display: flex;
    gap: 6px;
    background: rgba(15, 23, 42, 0.8);
    padding: 6px;
    border-radius: 10px;
    border: 2px solid var(--border-subtle);
    margin-left: auto; /* Push it towards the right to make it stand out from pos filters */
    margin-right: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}
.view-toggle-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s ease;
}
.view-toggle-tab:hover {
    color: var(--ice-white);
}
.view-toggle-tab.is-active {
    background: var(--mhl-gold);
    color: var(--bg-surface-active);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Hide advanced columns if in basic view */
.is-basic-view .col-advanced {
    display: none !important;
}

/* T-G Colors */
.t-g-pos { color: #4ade80 !important; font-weight: 700; }
.t-g-neg { color: #f87171 !important; font-weight: 700; }
.t-g-neutral { color: var(--text-muted) !important; }



/* Row Highlight Selection */
.data-table tbody tr.is-selected-row {
    background: rgba(250, 204, 21, 0.15) !important;
    outline: 2px solid var(--mhl-gold);
    outline-offset: -2px;
}
.data-table tbody tr.is-selected-row:hover {
    background: rgba(250, 204, 21, 0.2) !important;
}

/* Sticky Table Headers & Clamped Height for Scroll */
.table-scroll {
    max-height: calc(100vh - 260px); /* Keeps horizontal scrollbar in view */
    overflow-y: auto;
    overflow-x: auto;
    padding: 0 !important; /* Removes gap above sticky header */
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    /* Use an opaque background so rows don't show through the header when scrolling */
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
}
/* Ensure the corner headers and sorting columns keep their styles */
.data-table thead tr {
    box-shadow: 0 1px 0 rgba(203, 213, 225, 0.1); /* Replace bottom border with shadow for sticky */
}

/* Full custom scrollbar for table-scroll */
.table-scroll::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.table-scroll::-webkit-scrollbar-track {
    background: rgba(11, 18, 32, 0.72);
    border-radius: 999px;
}
.table-scroll::-webkit-scrollbar-thumb {
    background: rgba(71, 85, 105, 0.82);
    border: 2px solid rgba(11, 18, 32, 0.72);
    border-radius: 999px;
}
.table-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.95);
}
.table-scroll::-webkit-scrollbar-corner {
    background: rgba(11, 18, 32, 0.72);
}

/* Sort Direction Arrows */
.stat-sortable-col {
    position: relative;
    padding-right: 20px !important; /* Make room for the arrow */
}
.stat-sortable-col::after {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Descending (Best): Down arrow */
.stat-sortable-col.is-sort-active[data-sort-dir="desc"]::after,
.stat-sortable-col.is-sort-active:not([data-sort-dir])::after {
    content: '▲';
    color: var(--mhl-gold);
    opacity: 1;
}

/* Ascending (Worst): Up arrow */
.stat-sortable-col.is-sort-active[data-sort-dir="asc"]::after {
    content: '▼';
    color: var(--mhl-gold);
    opacity: 1;
}

/* Hover hint for inactive columns */
.stat-sortable-col:not(.is-sort-active):hover::after {
    content: '▼';
    color: rgba(255, 255, 255, 0.3);
    opacity: 1;
}
