/* ── F1 Statistics ─────────────────────────────────────────────────────── */

#f1-stats-app {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #1a1a1a;
    max-width: 1140px;
    margin: 0 auto;
}

/* ── Onglets ─────────────────────────────────────────────────────────────── */

.f1-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid #e10600;
}

.f1-tab-btn {
    padding: 9px 22px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    font-weight: 700;
    color: #888;
    cursor: pointer;
    transition: color .15s;
}

.f1-tab-btn:hover      { color: #1a1a1a; }
.f1-tab-btn.f1-tab-active {
    color: #e10600;
    border-bottom-color: #e10600;
}

/* ── Contrôles d'ère ─────────────────────────────────────────────────────── */

.f1-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 10px;
}

.f1-era-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.f1-era-group-label {
    font-size: 9.5px;
    color: #aaa;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    line-height: 1;
}

.f1-era-group-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* ── Boutons ─────────────────────────────────────────────────────────────── */

.f1-btn {
    padding: 6px 12px;
    border: 2px solid #e10600;
    background: #fff;
    color: #e10600;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    border-radius: 5px;
    line-height: 1.2;
    transition: background .15s, color .15s;
    min-width: 52px;
}

.f1-btn:hover,
.f1-btn.f1-active { background: #e10600; color: #fff; }

.f1-era-group--solo .f1-btn {
    font-size: 14px;
    padding: 8px 16px;
}

/* ── Textes ──────────────────────────────────────────────────────────────── */

.f1-desc {
    color: #555;
    font-size: 12.5px;
    margin: 0 0 14px;
    font-style: italic;
}

.f1-sys-label {
    font-style: normal;
    font-weight: 600;
    color: #1a1a1a;
    font-size: 13px;
    margin-bottom: 6px;
}

.f1-legend {
    font-size: 12px;
    color: #555;
    margin: 0 0 10px;
    line-height: 1.8;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.f1-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    vertical-align: middle;
}
.f1-swatch-up { background: #1a7f4b; }
.f1-swatch-dn { background: #e10600; }

.f1-row-ex {
    display: inline-block;
    padding: 1px 6px;
    background: #fffaed;
    border-left: 3px solid #f0ad00;
    font-style: normal;
}

/* ── Titres de section ───────────────────────────────────────────────────── */

.f1-h2 {
    font-size: 1.3em;
    font-weight: 800;
    margin: 28px 0 10px;
    padding-bottom: 7px;
    border-bottom: 3px solid #e10600;
    color: #1a1a1a;
}

/* ── Grille palmarès ─────────────────────────────────────────────────────── */

.f1-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.f1-card {
    background: #1a1a1a;
    color: #fff;
    border-radius: 8px;
    padding: 14px 12px;
    text-align: center;
}
.f1-card.f1-card-up { background: #1a7f4b; }
.f1-card.f1-card-dn { background: #e10600; }

.f1-card-img {
    display: block;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
    margin: 0 auto 10px;
    border: 3px solid rgba(255,255,255,.25);
}

.f1-card-n {
    display: block;
    font-size: 2.6em;
    font-weight: 900;
    line-height: 1;
}
.f1-card-name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-top: 6px;
    line-height: 1.35;
}
.f1-card-years {
    display: block;
    font-size: 10.5px;
    opacity: .85;
    margin-top: 4px;
    line-height: 1.4;
}
.f1-card-off {
    display: block;
    font-size: 10px;
    opacity: .75;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,.3);
    line-height: 1.5;
}

/* ── Tableau des championnats ────────────────────────────────────────────── */

.f1-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.f1-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

.f1-table thead th {
    background: #1a1a1a;
    color: #fff;
    padding: 9px 12px;
    text-align: left;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Colonne Année — sticky horizontalement */
.f1-sticky {
    position: sticky;
    left: 0;
    z-index: 2;
}
.f1-table thead .f1-sticky {
    z-index: 3;            /* au-dessus des cellules body */
    background: #1a1a1a;  /* fond explicite requis pour sticky */
}

/* Fond explicite sur chaque état de ligne pour que sticky soit opaque */
.f1-table tbody tr:nth-child(odd)  td.f1-sticky { background: #fff; }
.f1-table tbody tr:nth-child(even) td.f1-sticky { background: #f9f9f9; }
.f1-table tbody tr:hover           td.f1-sticky { background: #eef3ff; }
.f1-table tbody tr.f1-row-champ    td.f1-sticky { background: #fffaed !important; }

.f1-table tbody tr:nth-child(even) { background: #f9f9f9; }
.f1-table tbody tr:hover            { background: #eef3ff; }

/* Ligne où le champion change */
.f1-table tbody tr.f1-row-champ       { background: #fffaed !important; border-left: 4px solid #f0ad00; }
.f1-table tbody tr.f1-row-champ:hover { background: #fff3cc !important; }
.f1-table tbody tr.f1-row-champ:hover td.f1-sticky { background: #fff3cc !important; }

.f1-table tbody td {
    padding: 7px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    white-space: normal;
    min-width: 118px;
}

td.f1-year {
    font-weight: 800;
    color: #e10600;
    white-space: nowrap;
    min-width: 52px;
    font-size: 14px;
}

th.f1-th-year {
    min-width: 52px;
}

/* Couleurs selon montée / descente */
td.f1-cell-up { background: #f0fff6 !important; }
td.f1-cell-dn { background: #fff5f5 !important; }

/* Badges rang officiel */
.f1-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 1px 7px;
    border-radius: 10px;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    white-space: nowrap;
}
.f1-badge-up { background: #1a7f4b; }
.f1-badge-dn { background: #e10600; }

/* ── Cards cliquables ────────────────────────────────────────────────────── */

.f1-card[data-id] {
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
}
.f1-card[data-id]:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
}

/* Image par défaut (SVG casque) — fond légèrement plus clair */
.f1-card-img[src$=".svg"] {
    background: rgba(255,255,255,.08);
    padding: 6px;
    box-sizing: border-box;
}

/* ── Modale ──────────────────────────────────────────────────────────────── */

.f1-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity .2s;
}
.f1-modal-overlay.f1-modal-visible { opacity: 1; }

.f1-modal {
    background: #fff;
    border-radius: 10px;
    max-width: 520px;
    width: 100%;
    max-height: 88vh;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
    transform: translateY(16px);
    transition: transform .2s;
    /* Flex column : barre fixe (bouton fermer) + zone scrollable */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.f1-modal-overlay.f1-modal-visible .f1-modal { transform: translateY(0); }

.f1-modal-close {
    /* Positionné en haut à droite, hors du flux de défilement */
    position: absolute;
    top: 10px;
    right: 10px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.f1-modal-close:hover { background: #e10600; }

.f1-modal-body {
    /* Zone scrollable — prend tout l'espace restant */
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 24px 28px;
    padding-top: 48px;   /* espace pour le bouton ✕ absolu */
}

/* En-tête modale */
.f1-modal-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 20px;
}
.f1-modal-header--co { min-height: 64px; }

.f1-modal-photo {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
    border: 3px solid #e10600;
    flex-shrink: 0;
}
.f1-modal-photo[src$=".svg"] {
    background: #1a1a1a;
    padding: 8px;
    box-sizing: border-box;
}

.f1-modal-title h2 {
    font-size: 1.35em;
    font-weight: 800;
    color: #1a1a1a;
    margin: 0 0 4px;
}
.f1-modal-subtitle {
    font-size: 12px;
    color: #888;
    margin: 0;
}

/* Bloc titres */
.f1-modal-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}
.f1-modal-stat-block {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 10px 14px;
    min-width: 130px;
}
.f1-modal-stat-label {
    font-size: 11px;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 4px;
}
.f1-modal-stat-val {
    font-size: 1.6em;
    font-weight: 900;
    color: #1a1a1a;
    line-height: 1.1;
}
.f1-modal-years {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #666;
    margin-top: 3px;
    line-height: 1.5;
}

/* Ligne de stats de carrière */
.f1-modal-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px 14px;
    background: #1a1a1a;
    border-radius: 8px;
    color: #fff;
}
.f1-modal-stat-cell {
    flex: 1;
    min-width: 70px;
    text-align: center;
}
.f1-modal-stats-row .f1-modal-stat-label { color: #aaa; }
.f1-modal-stats-row .f1-modal-stat-val   { font-size: 1.1em; color: #fff; }
.f1-modal-stats-row .f1-modal-stat-val small { font-size: 11px; color: #ccc; font-weight: 400; }

/* Tableau des saisons dans la modale */
.f1-modal-h3 {
    font-size: 13px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin: 0 0 8px;
}
.f1-modal-table { font-size: 12.5px; }
.f1-modal-table thead th { font-size: 11px; padding: 7px 10px; }
.f1-modal-table tbody td { padding: 5px 10px; min-width: 60px; }

/* ── Tableau Stats (carrière) ────────────────────────────────────────────── */

.f1-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.f1-sortable:hover    { background: #2e2e2e; }
.f1-sort-active       { background: #e10600 !important; }
.f1-sort-arrow        { font-size: 10px; opacity: .85; }

.f1-stats-table td.f1-stat-num {
    text-align: right;
    white-space: nowrap;
    min-width: 90px;
}
.f1-stats-table tbody td small {
    color: #888;
    font-size: 11px;
}

/* ── Drapeaux de nationalité ─────────────────────────────────────────────── */

.f1-flag {
    display: inline-block;
    font-size: 1.15em;
    line-height: 1;
    cursor: default;
    vertical-align: middle;
}

.f1-card-flag {
    display: block;
    margin: 4px 0 2px;
    font-size: 1.3em;
    line-height: 1;
}

/* ── Barème de points structuré ──────────────────────────────────────────── */

.f1-pts-row {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    vertical-align: middle;
    margin: 2px 0;
}

.f1-pts-item {
    display: inline-block;
    background: rgba(0,0,0,.07);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    color: #1a1a1a;
}
.f1-pts-item[data-pos="1"]::before { content: "1er "; }
.f1-pts-item[data-pos="2"]::before { content: "2e "; }
.f1-pts-item[data-pos="3"]::before { content: "3e "; }
.f1-pts-item[data-pos="4"]::before { content: "4e "; }
.f1-pts-item[data-pos="5"]::before { content: "5e "; }
.f1-pts-item[data-pos="6"]::before { content: "6e "; }
.f1-pts-item[data-pos="7"]::before { content: "7e "; }
.f1-pts-item[data-pos="8"]::before { content: "8e "; }
.f1-pts-item[data-pos="9"]::before { content: "9e "; }
.f1-pts-item[data-pos="10"]::before { content: "10e "; }
.f1-pts-item::after { content: " pts"; font-weight: 400; color: #666; }
.f1-pts-fl::before  { content: "FL "; }

.f1-pts-note {
    font-size: 11px;
    color: #888;
    font-style: italic;
    vertical-align: middle;
}

/* ── Année cliquable (éditeur) ───────────────────────────────────────────── */

.f1-year-btn { cursor: pointer; user-select: none; }
.f1-year-btn:hover { background: #fff3e0 !important; color: #c47000 !important; }
.f1-year-edit-icon { font-size: 11px; opacity: 0.4; margin-left: 3px; }
.f1-year-btn:hover .f1-year-edit-icon { opacity: 1; }
.f1-edit-hint { font-size: 11px; color: #aaa; font-style: italic; }

/* ── Bouton taille réduite ───────────────────────────────────────────────── */

.f1-btn--sm {
    padding: 4px 10px;
    font-size: 12px;
    min-width: 0;
}

/* ── Panneau éditeur de courses ──────────────────────────────────────────── */

/* TR wrapper : pas de fond, pas de bordure parasite */
.f1-editor-row {
    background: transparent !important;
}
.f1-editor-row > td {
    padding: 0 !important;
    border: none !important;
}

.f1-editor-panel {
    margin: 6px 0 12px;
    border: 2px solid #e10600;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 24px rgba(0,0,0,.12);
}

.f1-editor-panel--error {
    border-color: #f0ad00;
}

.f1-editor-header {
    background: #1a1a1a;
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.f1-editor-title { font-weight: 700; font-size: 13px; line-height: 1.5; flex: 1; }
.f1-editor-title strong { color: #e10600; }
.f1-editor-era { font-weight: 400; }
.f1-editor-era .f1-pts-item { background: rgba(255,255,255,.15); color: #fff; }
.f1-editor-era .f1-pts-item::after { color: #aaa; }
.f1-editor-era .f1-pts-note { color: #bbb; }

.f1-editor-actions { display: flex; align-items: center; gap: 8px; }

.f1-editor-close-btn {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.f1-editor-close-btn:hover { background: #e10600; }

.f1-editor-loading,
.f1-editor-error {
    padding: 20px 24px;
    font-style: italic;
    color: #888;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.f1-editor-error { color: #c47000; }

.f1-editor-hint {
    padding: 7px 16px;
    background: #fffbf0;
    border-bottom: 1px solid #f0e0a0;
    font-size: 12px;
    color: #7a5500;
    font-style: italic;
}

.f1-editor-body {
    display: flex;
    gap: 0;
    align-items: flex-start;
}

.f1-editor-races {
    flex: 1 1 0;
    min-width: 0;
    border-right: 1px solid #eee;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.f1-editor-standings {
    width: 220px;
    flex-shrink: 0;
    padding: 12px;
    position: sticky;
    top: 0;
    max-height: 80vh;
    overflow-y: auto;
}

.f1-editor-standings-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #888;
    margin-bottom: 8px;
}

/* ── Bloc course ─────────────────────────────────────────────────────────── */

.f1-race-block {
    border: 1px solid #eee;
    border-radius: 6px;
    background: #fafafa;
    overflow: hidden;
    transition: border-color .15s;
}
.f1-race-block--modified {
    border-color: #f0ad00;
    background: #fffdf5;
}

.f1-race-title {
    padding: 6px 10px;
    background: #f0f0f0;
    font-size: 12px;
    font-weight: 700;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 6px;
}
.f1-race-block--modified .f1-race-title { background: #fff3cd; }

.f1-race-round {
    background: #e10600;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
}

.f1-race-date { font-weight: 400; color: #888; }

.f1-race-reset-btn {
    margin-left: auto;
    background: none;
    border: 1px solid #f0ad00;
    color: #c47000;
    border-radius: 4px;
    padding: 1px 7px;
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
}
.f1-race-reset-btn:hover { background: #f0ad00; color: #fff; }

/* ── Chips pilotes (drag-and-drop) ───────────────────────────────────────── */

.f1-race-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 8px 10px;
}

.f1-race-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 8px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    color: #333;
    cursor: grab;
    user-select: none;
    white-space: nowrap;
    transition: background .12s, border-color .12s, box-shadow .12s;
}
.f1-race-chip:hover {
    background: #e4e4e4;
    border-color: #aaa;
}
.f1-race-chip.f1-chip-dragging {
    opacity: .4;
    cursor: grabbing;
}
.f1-race-chip.f1-chip-drag-over {
    background: #fff0f0;
    border-color: #e10600;
    box-shadow: 0 0 0 2px rgba(225,6,0,.2);
}
.f1-race-block--modified .f1-race-chip {
    background: #fff8e0;
    border-color: #f0d060;
}

.f1-chip-pos {
    font-size: 10px;
    font-weight: 800;
    color: #e10600;
    min-width: 11px;
}

.f1-chip-handle {
    color: #bbb;
    font-size: 13px;
    letter-spacing: -1px;
    margin-left: 1px;
}
.f1-race-chip:hover .f1-chip-handle { color: #e10600; }

.f1-race-gp-name { font-weight: 700; }
.f1-race-date    { font-weight: 400; color: #888; font-size: 11px; }

.f1-race-dnf {
    padding: 4px 10px 6px;
    font-size: 10.5px;
    color: #bbb;
    font-style: italic;
    border-top: 1px dashed #eee;
    line-height: 1.6;
}

/* ── Tableau classement éditeur ──────────────────────────────────────────── */

.f1-ed-table-wrap { overflow-y: auto; max-height: 490px; }

.f1-ed-table { font-size: 12px; }
.f1-ed-table thead th { font-size: 11px; padding: 5px 6px; position: sticky; top: 0; z-index: 1; }
.f1-ed-table tbody td { padding: 4px 6px; min-width: 0; }

.f1-ed-rank  { font-weight: 800; color: #e10600; width: 24px; text-align: center; }
.f1-ed-name  { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.f1-ed-pts   { text-align: right; white-space: nowrap; color: #555; }

.f1-ed-delta { font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 3px; white-space: nowrap; }
.f1-ed-up { background: #e8f8ee; color: #1a7f4b; }
.f1-ed-dn { background: #fff0f0; color: #e10600; }

/* ── Bio pilote (modale) ─────────────────────────────────────────────────── */

.f1-modal-bio {
    font-size: 12px;
    color: #666;
    margin: 5px 0 0;
    line-height: 1.4;
}

.f1-modal-teams {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 6px 0 0;
}

.f1-modal-team {
    display: inline-block;
    background: #f0f0f0;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 11.5px;
    font-weight: 600;
    color: #1a1a1a;
}
.f1-modal-team small { font-weight: 400; color: #888; }

.f1-modal-wiki {
    display: inline-block;
    margin-top: 8px;
    font-size: 11.5px;
    color: #e10600;
    text-decoration: none;
    font-weight: 700;
    border-bottom: 1px solid transparent;
}
.f1-modal-wiki:hover { border-bottom-color: #e10600; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .f1-tab-btn  { padding: 8px 14px; font-size: 13px; }
    .f1-btn      { padding: 5px 8px; font-size: 12px; min-width: 42px; }
    .f1-era-group--solo .f1-btn { font-size: 13px; padding: 7px 12px; }
    .f1-grid     { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .f1-table    { font-size: 12px; }

    .f1-editor-body { flex-direction: column; }
    .f1-editor-races { border-right: none; border-bottom: 1px solid #eee; max-height: 380px; }
    .f1-editor-standings { width: 100%; }
    .f1-ed-table-wrap { max-height: 260px; }
    .f1-editor-standings-title { text-align: center; }
    .f1-dr-team { display: none; }
}
