/* =======================================================================
   FICHIER : styles.css
   Version : VRAI DARK MODE INTÉGRAL + Onglet Règlement
======================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;800&family=Roboto:wght@300;400;500&display=swap');

:root {
    --color-lagon: #00A7BB;       
    --color-lagon-dark: #008c9e;  
    --color-volcan: #D94F00;      
    
    /* PALETTE DARK MODE */
    --color-background-page: #0a0a0a;   /* Noir quasi pur pour le fond */
    --color-background-card: #1e1e1e;   /* Gris anthracite pour les blocs */
    --color-background-row: #252525;    /* Gris pour les lignes du tableau */
    --color-border: #333333;            /* Bordures discrètes */
    
    --color-text: #ecf0f1;              /* Texte CLAIR pour fond sombre */
    --color-text-muted: #bdc3c7;        /* Texte gris clair */
    --color-header-text: #ffffff;

    --color-gold: #f1c40f;
    --color-silver: #bdc3c7;
    --color-bronze: #cd7f32;
}

body {
    font-family: 'Roboto', 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--color-background-page);
    color: var(--color-text);
    line-height: 1.6;
}

h1, h2, h3, h4, th {
    font-family: 'Montserrat', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- HEADER IMMERSIF (Image Seule) --- */
header {
    background-image: url('header-bg.jpg'); 
    background-size: cover;      
    background-position: center; 
    background-repeat: no-repeat;
    background-attachment: scroll; 
    color: var(--color-header-text);
    padding: 40px 20px 140px; 
    text-align: center;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
    position: relative;
    overflow: hidden;
}

h1, h2 {
    text-shadow: 0 3px 15px rgba(0,0,0,1); 
    position: relative;
    z-index: 2;
}

h1 { margin: 0 0 10px 0; font-size: 2.5em; font-weight: 800; }
h2 { margin: 5px 0 20px 0; font-size: 1.2em; font-weight: 400; opacity: 1; }

/* --- BARRE DE RECHERCHE --- */
.search-container {
    margin: 15px auto 25px;
    max-width: 500px;
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 20;
}

#global-search-input {
    width: 100%;
    padding: 12px 20px;
    border-radius: 50px 0 0 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(30, 30, 30, 0.9); /* Fond sombre */
    backdrop-filter: blur(5px);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9em;
    outline: none;
    color: white;
}

#global-search-btn {
    padding: 12px 25px;
    border-radius: 0 50px 50px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: none;
    background: var(--color-volcan);
    color: white;
    cursor: pointer;
    font-size: 1.1em;
    margin-top: 0; 
    transition: background 0.3s;
}

#global-search-btn:hover { background: #c0392b; }

/* --- CONTENEUR PRINCIPAL --- */
main {
    padding: 0 20px;
    max-width: 1200px;
    margin: -80px auto 50px; 
    z-index: 20;
    position: relative;
}

/* Conteneurs SOMBRES (Gris foncé, pas blanc !) */
#classement-container, #calendrier-container, #reglement-container {
    background-color: var(--color-background-card); 
    padding: 40px; 
    border-radius: 25px; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.7); 
    border: 1px solid var(--color-border);
}

#classement-container h3, #calendrier-container h3, #reglement-container h3 { color: var(--color-lagon); margin-top: 0; font-size: 1.5em; }
#classement-container p, #reglement-container p { color: var(--color-text-muted); }

/* --- NAVIGATION --- */
#nav-seasons, #nav-categories, #nav-masters {
    margin: 10px auto; 
    display: block; 
    background-color: transparent; 
    padding: 0;
    text-align: center; 
    position: relative;
    z-index: 10; 
}
#nav-seasons { margin-bottom: 15px; }

#nav-seasons a, #nav-categories a, #nav-masters a {
    display: inline-block;
    text-decoration: none;
    color: var(--color-light); 
    background-color: rgba(0, 0, 0, 0.6); 
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 10px 22px; 
    margin: 5px;
    border-radius: 50px;
    font-size: 0.85em;
    font-weight: 700; 
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5); 
    margin-right: 10px; 
}

#nav-seasons a:hover, #nav-categories a:hover, #nav-masters a:hover {
    background-color: var(--color-lagon);
    color: white;
    border-color: var(--color-lagon);
    transform: translateY(-2px);
}
#nav-seasons a.active, #nav-categories a.active, #nav-masters a.active {
    background-color: var(--color-volcan);
    color: white;
    border-color: var(--color-volcan);
    box-shadow: 0 4px 15px rgba(217, 79, 0, 0.6);
}

/* --- TABS --- */
#main-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 30px;
    position: relative;
    z-index: 20;
}
.main-tab {
    background-color: rgba(30, 30, 30, 0.8); 
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 10px 20px;
    font-size: 1em;
    font-family: 'Montserrat', sans-serif;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    margin-top: 0;
}
.main-tab:hover { background-color: rgba(50, 50, 50, 0.9); }
.main-tab.active {
    background-color: var(--color-volcan);
    border-color: var(--color-volcan);
    font-weight: 800;
    box-shadow: 0 4px 15px rgba(217, 79, 0, 0.5);
}

/* --- CALENDRIER DARK --- */
.calendar-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}
.race-card {
    display: flex;
    align-items: center;
    background: var(--color-background-row); /* Fond sombre */
    padding: 15px;
    border-radius: 12px;
    border-left: 5px solid var(--color-lagon);
    transition: transform 0.2s;
    border: 1px solid var(--color-border);
}
.race-card:hover {
    transform: translateX(5px);
    background: #333;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.race-card.past {
    border-left-color: #555;
    opacity: 0.6;
    background: #1a1a1a;
}
.race-date {
    background: #333;
    color: var(--color-lagon);
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 700;
    text-align: center;
    min-width: 80px;
    margin-right: 20px;
    font-family: 'Montserrat', sans-serif;
    border: 1px solid var(--color-lagon);
}
.race-card.past .race-date { background: #222; border-color: #555; color: #777; }

.race-card.next-race {
    border-left: 6px solid var(--color-volcan);
    background: linear-gradient(90deg, rgba(217, 79, 0, 0.15) 0%, rgba(37, 37, 37, 1) 100%);
    box-shadow: 0 0 25px rgba(217, 79, 0, 0.25);
    z-index: 5;
    padding-top: 35px;
}
.next-badge {
    position: absolute; top: 0; left: 0;
    background: var(--color-volcan); color: white;
    font-size: 0.7em; font-weight: 800;
    padding: 5px 15px; border-bottom-right-radius: 15px; text-transform: uppercase;
}
.countdown-tag {
    display: inline-block; margin-top: 8px; font-size: 0.9em; font-weight: 800; padding: 4px 12px;
    border-radius: 4px; background: rgba(0, 167, 187, 0.1); color: var(--color-lagon); border: 1px solid var(--color-lagon);
}
.race-card.next-race .countdown-tag {
    background: var(--color-volcan); color: white; border-color: var(--color-volcan);
    animation: pulse 2s infinite;
}
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
.race-info h4 { margin: 0; color: var(--color-text); font-size: 1.1em; }
.race-details { font-size: 0.9em; color: var(--color-text-muted); margin-top: 5px; }

/* --- TABLEAUX DARK (FOND SOMBRE) --- */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    margin-top: 30px;
}

.classement-table, .details-table { 
    width: 100%;
    border-collapse: separate; 
    border-spacing: 0 8px; /* Effet cartes */
    min-width: 900px;
    text-align: center;
}

.classement-table th, .details-table th {
    background-color: #2a2a2a; /* En-tête sombre */
    color: var(--color-text-muted);
    font-weight: 700;
    font-size: 0.85em;
    padding: 15px;
    border-bottom: 2px solid var(--color-border);
}

.classement-table td, .details-table td {
    padding: 15px 10px;
    border: none;
    font-size: 0.95em;
    vertical-align: middle;
    color: var(--color-text); /* Texte CLAIR */
    text-align: center;
}

/* Lignes de données : Fond SOMBRE */
.classement-table tbody tr, .details-table tbody tr {
    background-color: var(--color-background-row); /* Fond ligne sombre */
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.classement-table tbody tr:hover, .details-table tbody tr:hover {
    background-color: #333; /* Survol un peu plus clair */
    transform: scale(1.005);
}

/* Alignement Gauche pour Nom et Club (Desktop) */
.classement-table td:nth-child(5), .classement-table td:nth-child(6) {
    text-align: left;
    padding-left: 20px;
}

/* Arrondis */
.classement-table td:first-child, .details-table td:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}
.classement-table td:last-child, .details-table td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* --- PODIUM --- */
.classement-table tbody tr:nth-child(1) td:last-child strong { color: var(--color-gold); font-size: 1.6em; }
.classement-table tbody tr:nth-child(1) td:first-child { border-left: 5px solid var(--color-gold); }

.classement-table tbody tr:nth-child(2) td:last-child strong { color: var(--color-silver); font-size: 1.5em; }
.classement-table tbody tr:nth-child(2) td:first-child { border-left: 5px solid var(--color-silver); }

.classement-table tbody tr:nth-child(3) td:last-child strong { color: var(--color-bronze); font-size: 1.4em; }
.classement-table tbody tr:nth-child(3) td:first-child { border-left: 5px solid var(--color-bronze); }

.classement-table tr td:last-child strong { font-weight: 800; color: var(--color-text); }

/* --- ÉLÉMENTS SPÉCIFIQUES --- */

a.coureur-link, a.club-link {
    color: var(--color-text); 
    text-decoration: none; 
    font-weight: 600;
    border-bottom: 1px dotted #555;
    transition: color 0.2s;
}
a.coureur-link:hover, a.club-link:hover {
    color: var(--color-lagon); 
    border-bottom-color: var(--color-lagon);
}

button {
    background-color: var(--color-lagon);
    color: white;
    border: none;
    padding: 12px 30px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.9em;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 30px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 15px rgba(0, 167, 187, 0.3);
}
button:hover { background-color: var(--color-lagon-dark); transform: translateY(-2px); }

tr.category-separator td {
    background-color: #1a1a1a; /* Fond très sombre pour le titre */
    color: var(--color-lagon);
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    border-top: 1px solid var(--color-border);
    padding-top: 20px;
    display: table-cell;
}

/* --- STATS & GRAPHIQUE --- */
.stats-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background-color: #252525;
    border-radius: 15px;
    border: 1px solid var(--color-border);
}

.participation-chart {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: conic-gradient(var(--color-lagon) 0%, #444 0); 
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 15px rgba(0, 167, 187, 0.2);
    margin: 0 auto;
}

.participation-chart::after {
    content: "";
    position: absolute;
    width: 70%;
    height: 70%;
    background-color: #252525;
    border-radius: 50%;
}

.chart-text { position: absolute; z-index: 2; font-weight: 800; font-size: 1.2em; color: var(--color-text); }

.stats-info { display: flex; flex-direction: column; justify-content: center; text-align: left; }
.stats-info h4 { margin: 0 0 5px; color: var(--color-text-muted); font-size: 0.9em; }
.stats-info .big-number { font-size: 1.8em; font-weight: 800; color: var(--color-lagon); }

/* Badges Écarts */
.gap-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 40px;
}
.gap-card {
    background: #252525;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    font-size: 0.9em;
    border-left: 4px solid #555;
    flex: 1;
    max-width: 250px;
    text-align: center;
    border: 1px solid var(--color-border);
}
.gap-card.chase { border-left-color: #e74c3c; color: #ffcccc; }
.gap-card.lead { border-left-color: #27ae60; color: #ccffcc; }
.gap-card strong { display: block; font-size: 1.2em; margin-bottom: 5px; color: var(--color-text); }
.gap-name { font-size: 0.85em; color: #888; }

/* STYLE PERFORMANCE "JOKER" (Moins bon résultat) */
.worst-performance {
    background-color: #2a1a1a !important; /* Rouge sombre très subtil */
    box-shadow: none !important; 
    border: 1px dashed #e74c3c !important; 
}
.worst-performance td {
    color: #777 !important; /* Texte grisé */
}
.worst-performance strong {
    color: #c0392b !important;
    text-decoration: line-through;
    opacity: 0.7;
}

.joker-badge {
    font-size: 0.7em;
    background-color: #e74c3c;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
    vertical-align: middle;
    text-decoration: none !important;
    display: inline-block;
}


/* --- 9. RESPONSIVE (MOBILE) --- */
@media (max-width: 768px) {
    header { padding: 20px 10px 100px; }
    h1 { font-size: 1.8em; }
    main { margin-top: -60px; padding: 0 10px; }
    
    #classement-container, #calendrier-container, #reglement-container { padding: 10px 0; }

    /* BOUTONS COMPACTS */
    #nav-seasons a, #nav-categories a, #nav-masters a {
        display: inline-block;
        width: auto;
        margin: 3px 2px;
        padding: 6px 12px;
        font-size: 0.75em;
        margin-right: 2px;
    }
    
    /* Masquage Colonnes Portrait */
    .classement-table th:nth-child(1), .classement-table td:nth-child(1),
    .classement-table th:nth-child(2), .classement-table td:nth-child(2),
    .classement-table th:nth-child(3), .classement-table td:nth-child(3),
    .classement-table th:nth-child(4), .classement-table td:nth-child(4) {
        display: none;
    }

    .classement-table td, .classement-table th { padding: 10px 5px; font-size: 0.85em; text-align: center; }
    
    /* NOM aligné à gauche sur mobile */
    .classement-table td:nth-child(5) { text-align: left; padding-left: 5px; }
    
    /* Autres colonnes (Club, Points, Pos) centrées par défaut */
    .classement-table td:nth-child(6), .classement-table td:nth-child(7), .classement-table td:nth-child(8) { text-align: center; }
    
    .classement-table th:last-child, .classement-table td:last-child { width: 30px; white-space: nowrap; }

    /* Vue Détail Mobile */
    .details-table:not(.club-table) th:nth-child(1), .details-table:not(.club-table) td:nth-child(1),
    .details-table th:nth-child(4), .details-table td:nth-child(4) { display: none; }
    
    /* Vue Club Mobile : Affiche Nom et Points */
    .club-table th:nth-child(1), .club-table td:nth-child(1),
    .club-table th:nth-child(2), .club-table td:nth-child(2) { display: table-cell; }
    .club-table td:nth-child(1) { text-align: left; }
    
    /* Correction Recherche Mobile : Force l'affichage des colonnes de recherche */
    .search-results-table th, .search-results-table td {
        display: table-cell !important;
        text-align: left;
    }

    .classement-table, .details-table { min-width: 100%; margin-top: 15px; border-spacing: 0 5px; }
    
    .gap-container { flex-direction: column; gap: 10px; padding: 0; }
    .gap-card { width: 100%; max-width: none; }
    
    .race-card { flex-direction: column; text-align: center; align-items: stretch; padding: 15px; }
    .race-card.next-race { flex-direction: column; text-align: left; }
    .race-card.next-race .race-date { flex-direction: row; width: 100%; justify-content: space-between; margin-right: 0; margin-bottom: 10px; }
    .race-date { margin-right: 0; margin-bottom: 10px; width: 100%; }
}

@media (min-width: 769px) {
    th, td { display: table-cell !important; }
}
