/* ===========================================
   Responsive DataTable Styles for Boxscore
   =========================================== */

/* Base boxscore table styles */
.boxscore-table .dash-table-container {
    border-radius: 8px;
    overflow: hidden;
}

/* Default: 11px font - compact by default */
.boxscore-table .dash-cell {
    font-size: 11px !important;
    padding: 4px 3px !important;
}

.boxscore-table .dash-header {
    font-size: 10px !important;
    padding: 4px 3px !important;
}

/* Extra large screens: 1600px+ - slightly larger */
@media (min-width: 1600px) {
    .boxscore-table .dash-cell {
        font-size: 12px !important;
        padding: 5px 4px !important;
    }

    .boxscore-table .dash-header {
        font-size: 11px !important;
        padding: 5px 4px !important;
    }
}

/* Laptop screens: 1366px and below - smaller */
@media (max-width: 1366px) {
    .boxscore-table .dash-cell {
        font-size: 10px !important;
        padding: 3px 2px !important;
    }

    .boxscore-table .dash-header {
        font-size: 9px !important;
        padding: 3px 2px !important;
    }
}

/* Small laptop: 1200px and below */
@media (max-width: 1200px) {
    .boxscore-table .dash-cell {
        font-size: 9px !important;
        padding: 3px 2px !important;
    }

    .boxscore-table .dash-header {
        font-size: 8px !important;
        padding: 3px 2px !important;
    }
}

/* Tablets: 992px and below */
@media (max-width: 992px) {
    .boxscore-table .dash-cell {
        font-size: 9px !important;
        padding: 2px 1px !important;
    }

    .boxscore-table .dash-header {
        font-size: 8px !important;
        padding: 2px 1px !important;
    }
}

/* Mobile: 768px and below */
@media (max-width: 768px) {
    .boxscore-table .dash-cell {
        font-size: 8px !important;
        padding: 2px 1px !important;
    }

    .boxscore-table .dash-header {
        font-size: 7px !important;
        padding: 2px 1px !important;
    }
}

/* ===========================================
   Boxscore Section Styles (unified layout)
   =========================================== */

/* Section container with subtle animation */
.boxscore-section {
    background: transparent;
    border-radius: 12px;
    padding: 20px;
}

/* Responsive: stack tables on small screens */
@media (max-width: 992px) {
    .boxscore-section > div:last-child {
        flex-direction: column !important;
    }

    .boxscore-section > div:last-child > div:first-child,
    .boxscore-section > div:last-child > div:last-child {
        padding: 0 !important;
        margin-bottom: 15px;
    }

    /* Hide vertical separator on mobile */
    .boxscore-section > div:last-child > div:nth-child(2) {
        display: none !important;
    }
}

/* ===========================================
   Games Banner — scoreboard strip
   Style "carousel produit" (Netflix / Apple TV) :
   - cards avec pattern Dark Elevation (BG_ELEVATED + ombre + highlight haut)
   - flèches flottantes rondes sur les 2 cotes
   - fade aux bords pour suggerer du contenu sans barre
   - winner = blanc / loser = gris (plus de bleu PRIMARY accentue)
   =========================================== */

/* Main banner container : transparent, juste un layout horizontal.
   Pas de margin-bottom : l'espacement est gere par le parent flex
   (cf boxscore/callbacks/core.py : gap 16px sur le wrapper content). */
.games-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    overflow: visible;
    position: relative;
}

/* Date section on the left (fond Dark Elevation pour pop subtilement) */
.games-banner-date {
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}
/* Date picker du carousel : meme fond/border/highlight que les cards */
#games-banner-date-picker {
    background: var(--color-bg-elevated) !important;
    border: 1px solid var(--color-border-light) !important;
    border-radius: 10px !important;
    color: var(--color-text-primary) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        var(--shadow-sm) !important;
    padding: 6px 12px !important;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
#games-banner-date-picker:hover,
#games-banner-date-picker:focus {
    border-color: var(--color-border-strong) !important;
}

/* Wrapper carousel : strip + 2 fleches absolues + fade gauche/droit */
.games-banner-carousel {
    position: relative;
    flex: 1;
    min-width: 0;
}

/* Cas peu de matchs : tout tient sans scroll → on cache fleches + fade.
   Class injectee par le clientside callback (cf boxscore/callbacks/core.py). */
.games-banner-carousel.no-overflow .games-banner-arrow,
.games-banner-carousel.no-overflow::before,
.games-banner-carousel.no-overflow::after {
    display: none;
}

/* Fade gauche / droit (overlay degradant) — masque les bords du scroll */
.games-banner-carousel::before,
.games-banner-carousel::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 48px;
    pointer-events: none;
    z-index: 5;
}
.games-banner-carousel::before {
    left: 0;
    background: linear-gradient(90deg, var(--color-bg-page) 0%, transparent 100%);
}
.games-banner-carousel::after {
    right: 0;
    background: linear-gradient(270deg, var(--color-bg-page) 0%, transparent 100%);
}

/* Fleches rondes flottantes (au-dessus du fade) */
.games-banner-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-strong);
    color: var(--color-text-secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease, color 150ms ease, transform 150ms ease;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), var(--shadow-md);
    padding: 0;
}
.games-banner-arrow:hover {
    background: var(--color-bg-surface-hover);
    color: var(--color-text-primary);
    transform: translateY(-50%) scale(1.05);
}
.games-banner-arrow-left  { left: -10px; }
.games-banner-arrow-right { right: -10px; }

/* Games strip - horizontal scrollable (sans scrollbar visible) */
.games-banner-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 5px 8px;
    scroll-behavior: smooth;
    scrollbar-width: none;            /* Firefox */
    -ms-overflow-style: none;          /* IE/Edge */
}
.games-banner-strip::-webkit-scrollbar {
    display: none;                     /* Chrome/Safari */
}

/* Mini game card — pattern Dark Elevation (cf. .depth-chart-player-card) :
   fond plus clair que la page + ombre portee + highlight 1px en haut. */
.mini-game-card {
    display: flex;
    flex-direction: column;
    min-width: 96px;
    padding: 8px 14px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border-light);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        var(--shadow-sm);
    flex-shrink: 0;
}

.mini-game-card:hover {
    transform: translateY(-2px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        var(--shadow-md);
    border-color: var(--color-border-strong);
    text-decoration: none;
    color: inherit;
}

/* Current game highlight — bordure primary subtile (pas de gradient agressif) */
.mini-game-card.current {
    border-color: var(--color-primary);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 0 0 1px var(--color-primary),
        var(--shadow-md);
}

/* Status label (FINAL / A VENIR) */
.mini-card-status {
    font-size: 9px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    text-align: center;
}

/* Teams container */
.mini-card-teams {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Team row */
.mini-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

/* Team code & score — perdant en gris, gagnant en blanc (cf. mockup).
   Plus de couleur PRIMARY sur le winner (reservee a l'interaction). */
.mini-card-team {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-light);
}
.mini-card-score {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-light);
    font-variant-numeric: tabular-nums;
}
.mini-card-team.winner,
.mini-card-score.winner {
    font-weight: 700;
    color: var(--color-text-primary);
}

/* Responsive: games banner on small screens */
@media (max-width: 768px) {
    .mini-game-card {
        min-width: 80px;
        padding: 6px 10px;
    }
    .mini-card-team,
    .mini-card-score {
        font-size: 11px;
    }
    .games-banner-arrow {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
}

/* ===========================================
   Game header — Team name link en blanc
   ===========================================
   .team-name-link est un <a> qui pointe vers /team/<id> dans le header
   de la page game-details. Bootstrap pose color: --bs-link-color (bleu)
   par defaut, et notre reset 01-reset.css fait color: inherit sans
   !important. Ici on force TEXT_PRIMARY (#F8FAFC blanc) avec spec
   suffisante pour gagner. */
.team-name-link,
.team-name-link:link,
.team-name-link:visited,
.team-name-link:hover,
.team-name-link:focus,
.team-name-link:active {
    color: var(--color-text-primary) !important;
}

/* ===========================================
   MATCH — MOBILE (specs/mobile/match/SPEC.md)
   En-tete colle (mobile_header.py), equipe affichee (data-team sur
   #boxscore-tab-content, cartes .tcards), colonnes essentielles (.m-cols),
   rotation en lignes (team/depth_rows.py), stats equipes (mobile_views.py).
   Domicile a gauche, comme le desktop.
   =========================================== */

/* Nom court : colonne propre au mobile */
@media (min-width: 1024px) {
    .boxscore-table [data-dash-column="PLAYER_SHORT"] { display: none; }
}

@media (max-width: 1023.98px) {   /* bp mobile */
    .match-page { --m-head-h: 59px; gap: 10px !important; }   /* hauteur de .mhead */

    /* En-tete colle */
    .mhead {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        gap: 8px;
        margin: 0 -12px;
        padding: 8px 12px;
        border-bottom: 1px solid var(--color-border-light);
    }
    .mh-team,
    .mh-team:visited {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        color: var(--color-text-primary) !important;
        text-decoration: none !important;
    }
        .mh-logo { width: 36px; height: 36px; flex-shrink: 0; }
    .mh-text { display: flex; flex-direction: column; line-height: 1.2; }
    .mh-record { color: var(--color-text-muted); font-size: 11px; }
    .mh-score {
        display: flex;
        gap: 8px;
        font-size: 26px;
        font-weight: 800;
        font-variant-numeric: tabular-nums;
    }
    .mh-win { color: var(--color-text-primary); }
    .mh-lose, .mh-dash, .mh-pending { color: var(--color-text-light); }
    /* Quart-temps pleine largeur */
    .mh-quarters { margin-bottom: 10px; }
    .mh-quarters > div, .mh-quarters table { width: 100%; }
    .mh-quarters th, .mh-quarters td { padding: 6px 4px !important; }

    /* Absents : une carte depliable, le chevron dit qu'on peut l'ouvrir */
    .mh-abs {
        margin-bottom: 8px;
        border: 1px solid var(--color-border);
        border-radius: 10px;
        background: var(--color-bg-surface);
    }
    .mh-abs-summary,
    .mh-h2h-summary {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 0 12px;
        color: var(--color-text-secondary);
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
        list-style: none;
    }
    .mh-abs-summary::-webkit-details-marker,
    .mh-h2h-summary::-webkit-details-marker { display: none; }
    .mh-abs-summary::after { content: "▾"; margin-left: auto; color: var(--color-text-muted); }
    .mh-abs[open] .mh-abs-summary::after { content: "▴"; }
    .mh-abs-body { padding: 0 12px 10px; }
    /* Le panneau d'absents repete le compte deja dans le resume : masque */
    .mh-abs-team + div > div:first-child { display: none; }
    .mh-abs-team {
        margin-top: 8px;
        color: var(--color-text-muted);
        font-size: 11px;
        font-weight: 700;
    }

    /* Confrontations : lien centre */
    .mh-h2h { margin-bottom: 6px; }
    .mh-h2h-summary { justify-content: center; font-weight: 500; }
    .mh-h2h-summary::after { content: " ▾"; white-space: pre; color: var(--color-text-muted); }
    .mh-h2h[open] .mh-h2h-summary::after { content: " ▴"; }

    /* Choix de l'equipe affichee */
    .tcards {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 10px;
    }
    .tcard {
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 48px;
        padding: 6px 10px;
        border: 1px solid var(--color-border);
        border-radius: 10px;
        background: var(--color-bg-surface);
        color: var(--color-text-secondary);
        cursor: pointer;
    }
    .tcard img { width: 28px; height: 28px; }
    .tcard b { margin-left: auto; color: var(--color-text-primary); font-size: 16px; }
    .tcard.on { border: 2px solid var(--color-primary); background: var(--color-primary-subtle); }
    #boxscore-tab-content[data-team="home"] .bx-away,
    #boxscore-tab-content[data-team="away"] .bx-home { display: none !important; }

    /* Boxscore : lisible, colonnes essentielles, toutes les colonnes en option */
    .boxscore-section { padding: 0 0 8px; }
    .boxscore-table .dash-cell {
        font-size: 13px !important;
        padding: 8px 6px !important;
    }
    .boxscore-table .dash-header {
        font-size: 11px !important;
        padding: 6px 4px !important;
    }
    .boxscore-table [data-dash-column="PLAYER"] { display: none; }
    .boxscore-table [data-dash-column="PLAYER_SHORT"] p { margin: 0; }
    .boxscore-table .dash-cell { vertical-align: middle; }
    /* Pleine largeur : le conteneur des deux equipes est une colonne flex
       alignee a gauche (style inline) qui retrecit chaque bloc a son contenu. */
    .boxscore-section > div:last-child { align-items: stretch !important; }
    .m-cols:not(.all-cols) .boxscore-table .dash-spreadsheet-container,
    .m-cols:not(.all-cols) .boxscore-table .dash-spreadsheet-inner,
    .m-cols:not(.all-cols) .boxscore-table .cell-table { width: 100% !important; }
    .m-cols:not(.all-cols) .boxscore-table [data-dash-column]:not([data-dash-column="PLAYER_SHORT"]):not([data-dash-column="MIN"]):not([data-dash-column="PTS"]):not([data-dash-column="REB"]):not([data-dash-column="AST"]):not([data-dash-column="+/-"]) {
        display: none;
    }
    .m-cols.all-cols .boxscore-table .dash-spreadsheet-container,
    .m-cols.all-cols .boxscore-table .dash-table-container {
        overflow-x: auto !important;
    }
    .m-cols.all-cols .boxscore-table [data-dash-column="PLAYER_SHORT"] {
        position: sticky;
        left: 0;
        z-index: 1;
        background: var(--color-bg-surface);
    }
    .col-toggle {
        display: block;
        min-height: 40px;
        margin: 0 0 6px auto;
        padding: 0 4px;
        border: none;
        background: transparent;
        color: var(--color-primary-hover);
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
    }

    /* Rotation : postes en lignes */
    .depth-rows { width: 100%; border-collapse: collapse; font-size: 12px; }
    .depth-rows th {
        padding: 6px 4px;
        color: var(--color-text-muted);
        font-size: 11px;
        text-align: left;
    }
    .depth-rows td {
        padding: 6px 4px;
        border-top: 1px solid var(--color-border-light);
        vertical-align: top;
        color: var(--color-text-light);
    }
    .dr-player,
    .dr-player:visited {
        display: flex;
        flex-direction: column;
        color: var(--color-text-secondary) !important;
        text-decoration: none !important;
    }
    .dr-player small { color: var(--color-text-muted); font-size: 10px; }

    /* Stats equipes */
    .shoot-cards {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 12px;
    }
    .sc-card {
        padding: 8px;
        border: 1px solid var(--color-border);
        border-radius: 10px;
        background: var(--color-bg-surface);
        text-align: center;
    }
    .sc-label { color: var(--color-text-muted); font-size: 11px; font-weight: 600; }
    .sc-values { display: flex; justify-content: space-around; margin-top: 4px; color: var(--color-text-light); }
    .sc-values > div { display: flex; flex-direction: column; align-items: center; }
    .sc-values b { font-size: 15px; }
    .sc-values small { color: var(--color-text-muted); font-size: 10px; font-weight: 600; }
    .sc-values .best, .tl-v.best { color: var(--color-text-primary); }
    .tl { border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-bg-surface); }
    .tl-row {
        display: grid;
        grid-template-columns: 1fr 2fr 1fr;
        align-items: center;
        min-height: 34px;
        padding: 0 10px;
        border-top: 1px solid var(--color-border-light);
        font-size: 13px;
    }
    .tl-row:first-child { border-top: none; }
    .tl-head { color: var(--color-text-secondary); font-size: 13px; font-weight: 700; }
    .tl-team { display: inline-flex; align-items: center; gap: 6px; }
    .tl-team img { width: 22px; height: 22px; }
    .tl-team-away { justify-content: flex-end; }
    /* Face a face en barres : valeur | barre | abreviation | barre | valeur */
    .tl-row.tl-bars, .tl-row.tl-head { grid-template-columns: 34px 1fr 64px 1fr 34px; gap: 6px; }
    .tl-row.tl-head { grid-template-columns: 1fr 0 1fr; }
    .bar-track { height: 8px; border-radius: 4px; background: var(--color-border-light); display: flex; }
    .bar-home { justify-content: flex-end; }
    .bar-fill { height: 100%; border-radius: 4px; background: var(--color-border-strong); }
    .bar-fill.best { background: var(--color-success); }
    .tl-l { text-align: center; color: var(--color-text-muted); font-size: 12px; }
    .tl-v { color: var(--color-text-light); font-variant-numeric: tabular-nums; }
    .tl-v:last-child { text-align: right; }
    .tl-bars .tl-v { font-weight: 700; }

    /* Avant-match : « Rapport de blessures » en dernier */
    .m-last { order: 9; }

    /* En-tete colle : les conteneurs intermediaires (chargement, callback)
       s'effacent pour que .mhead ait la page entiere comme parent (sinon il
       ne colle que le temps de son propre conteneur). */
    .match-page :has(.mhead):not(.mhead) { display: contents; }

    /* Apercu de l'avant-match : une colonne, stats face a face puis temps de
       jeu de chaque equipe ; postes l'un sous l'autre. */
    .preview-stats-grid {
        grid-template-columns: 1fr !important;
        row-gap: 16px;
    }
    .preview-stats-grid > :nth-child(2) { order: -1; }
    .preview-stats-grid > div { padding-top: 0 !important; }
    .position-cards-grid { grid-template-columns: 1fr !important; }
}
