:root {
    --bg-color: #F5F5F7;
    --card-bg: #FFFFFF;
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --accent: #0071E3;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --font-main: 'Inter', sans-serif;
    --tag-bg: #F2F2F7;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-width: 1200px;
    padding-bottom: 0;       /* On supprime l'ancien espace de 60px */
    min-height: 100vh;       /* Force le corps à prendre toute la hauteur de l'écran */
    display: flex;           /* Active le mode Flexbox */
    flex-direction: column;
    opacity: 0; 
    transition: opacity 0.3s ease-in-out;
}

body.loaded {
    opacity: 1; /* Deviendra visible quand le JS ajoutera cette classe */
}

header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(245, 245, 247, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s ease;
    width: 100%;
}

header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.95);
}

.header-top, .header-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    width: 100%;          /* Force les conteneurs à prendre toute la place */
    box-sizing: border-box;
}


.brand { 
    font-size: 20px; 
    font-weight: 700; 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    cursor: pointer; 
    min-width: 200px;
}
.brand i { color: var(--accent); }

.nav-controls { display: flex; gap: 12px; align-items: center; }

.search-group { position: relative; display: flex; align-items: center; }
.search-group i { position: absolute; left: 12px; font-size: 13px; color: var(--text-secondary); }

.location-group { display: flex; gap: 8px; }

.loc-input {
    padding: 6px 12px; border: 1px solid var(--border-color); border-radius: 8px;
    font-family: var(--font-main); font-size: 13px; color: var(--text-primary);
    background: #FFF; outline: none; transition: border 0.2s;
    width: 160px; 
}
.search-input { padding-left: 32px !important; width: 220px; }

.icon-btn {
    width: 36px; height: 36px; border: 1px solid var(--border-color); border-radius: 8px;
    background: #FFF; color: var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.icon-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.icon-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Bouton Calcul */
.calc-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0 16px;
    font-weight: 600;
    font-size: 13px;
    width: auto;
    gap: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    height: 36px;
}
.calc-btn:hover:not(:disabled) { background: #005bb7; }

.filter-group { display: flex; align-items: center; gap: 12px; }
.control-input {
    padding: 0 10px; border: 1px solid var(--border-color); border-radius: 8px;
    font-family: var(--font-main); font-size: 13px; color: var(--text-primary);
    background: #FFF; outline: none; height: 32px;
}

.filter-label { font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; margin-right: 4px; }

.ui-group {
    display: flex; align-items: center; gap: 8px; background: #FFF;
    padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-color); height: 32px;
}

.switch { position: relative; display: inline-block; width: 30px; height: 16px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: .3s; border-radius: 34px;
}
.slider:before {
    position: absolute; content: ""; height: 12px; width: 12px; left: 2px; bottom: 2px;
    background-color: white; transition: .3s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(14px); }

.filters { 
    display: flex; 
    gap: 6px; 
    background: #E8E8ED; 
    padding: 3px; 
    border-radius: 10px; 
    position: relative;
    isolation: isolate;
}

.filter-slider {
    position: absolute;
    height: calc(100% - 6px); /* Prend toute la hauteur moins le padding */
    top: 3px;
    left: 3px;
    background: #FFFFFF;
    border-radius: 7px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); /* Animation fluide */
    z-index: 0; /* Se place derrière les textes des boutons */
}

.filter-btn { 
    /* --- CORRECTION D'ALIGNEMENT --- */
    display: flex;             /* Active Flexbox */
    align-items: center;       /* Centre verticalement l'émoji et le texte */
    justify-content: center;   /* Centre horizontalement */
    gap: 8px;                  /* Espace propre entre l'émoji et le texte */
    
    /* --- STYLES VISUELS --- */
    border: none; 
    background: transparent; 
    padding: 6px 16px; 
    font-family: var(--font-main); 
    font-size: 13px; 
    font-weight: 600; 
    color: var(--text-secondary); 
    border-radius: 7px; 
    cursor: pointer; 
    
    /* Important pour qu'il soit au-dessus du fond blanc glissant */
    z-index: 1;
    position: relative; 
    transition: color 0.2s ease;
}
.filter-btn.active { background: #FFFFFF; color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.container { max-width: 1800px; margin: 30px auto; padding: 0 40px; flex: 1; /* C'est magique : ça force ce bloc à prendre tout l'espace disponible */
    width: 100%}
.matches-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); 
    gap: 20px; 
}

.card { 
    background: var(--card-bg); border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); 
    display: flex; flex-direction: column; gap: 12px; transition: transform 0.2s; 
    position: relative; 
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }

.match-header { display: flex; justify-content: space-between; align-items: center; }
.team { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 42%; text-align: center; }
.team-logo { width: 42px; height: 42px; object-fit: contain; } 
.team-name { font-weight: 600; font-size: 13px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; height: 28px; }

/* Modifié pour l'affichage de l'heure */
.match-center { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.match-time { font-weight: 800; font-size: 14px; color: var(--text-primary); line-height: 1.2; margin-bottom: 2px; }
.vs { font-size: 10px; color: var(--text-secondary); font-weight: 700; text-transform: uppercase; }

.match-meta { 
    display: flex; justify-content: space-between; align-items: center; 
    border-top: 1px solid var(--border-color); padding-top: 10px; 
}
.badge { 
    padding: 3px 8px; border-radius: 6px; font-size: 10px; font-weight: 700; 
    text-transform: uppercase; background: var(--tag-bg); color: var(--text-primary); 
    display: flex; align-items: center; gap: 5px;
}
.date-time { font-size: 12px; color: var(--text-primary); font-weight: 500; }

.transport-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.transport-block { 
    background: #FAFAFA; 
    border-radius: 8px; 
    padding: 8px 12px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    transition: all 0.2s;
}

/* Style de la flèche Google Maps */
.maps-arrow {
    color: var(--accent);
    font-size: 14px;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.maps-arrow:hover {
    transform: translateX(3px);
}

.maps-arrow.disabled {
    opacity: 0.2;
    pointer-events: none;
    color: var(--text-secondary);
}

.distance { font-weight: 700; font-size: 12px; }
.modes { display: flex; gap: 10px; }
.mode { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-secondary); }
.mode i { color: var(--accent); font-size: 10px; }

.accred-footer { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border-color); font-size: 11px; display: flex; justify-content: space-between; align-items: center;}
.accred-status { display: flex; align-items: center; gap: 6px; font-weight: 500; width: 100%; }
.accred-available { color: #34C759; }
.fa-external-link-alt {
    color: #34C759 !important; /* Vert Apple/Succès */
}
.accred-unavailable { color: var(--text-secondary); opacity: 0.7; }
.accred-email-text{
    color: var(--text-primary);
}
.accred-email { color: var(--text-primary); text-decoration: none; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }

.error-msg { grid-column: 1 / -1; text-align: center; color: #ef4444; background: #fee2e2; padding: 20px; border-radius: 12px; }

/* Menu Toggle Mobile (Caché sur desktop) */
.menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-primary); }

.weather-icon {
    font-size: 1.2em;
    margin-right: 5px;
    vertical-align: middle;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.1));
}

.weather-badge {
    font-size: 14px;
    background: #FFFFFF;
    padding: 2px 6px;
    border-radius: 6px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease-out;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

#sortFilter.control-input {
    border: none !important;           /* Supprime la bordure double */
    background: transparent !important; /* Laisse voir le fond du bloc parent */
    box-shadow: none !important;      /* Enlève toute ombre interne */
    height: 100% !important;          /* Utilise toute la hauteur du conteneur */
    flex-grow: 1;                     /* Prend l'espace à droite du mot "TRI" */
    padding-left: 5px !important;     /* Petit espacement avec le label */
}



#themeToggle, #gpsBtn {
    display: flex;
    align-items: center;
    justify-content: center;
}

body.dark-mode {
    --bg-color: #121212;          /* Fond de page sombre */
    --card-bg: #1C1C1E;           /* Fond des cartes */
    --text-primary: #FFFFFF;      /* Texte blanc */
    --text-secondary: #A1A1A6;    /* Texte gris clair */
    --border-color: rgba(255, 255, 255, 0.1);
    --tag-bg: #2C2C2E;            /* Fond des badges */
}

body.dark-mode header {
    background: #1C1C1E !important;
    border-bottom-color: #2C2C2E;
}

body.dark-mode .menu-toggle {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

body.dark-mode .search-input {
    background: #2C2C2E !important;
}

body.dark-mode select.control-input option {
    background-color: #2C2C2E; /* Utilise la même couleur que tes autres badges */
    color: #FFFFFF;           /* Assure que le texte reste blanc sur le fond sombre */
}

body.dark-mode .control-input:focus {
    background-color: var(--tag-bg) !important;
}

body.dark-mode .control-input, 
body.dark-mode .loc-input,
body.dark-mode .icon-btn,
body.dark-mode #gpsBtn, 
body.dark-mode .ui-group,
body.dark-mode .transport-block,
body.dark-mode .weather-badge {
    background-color: var(--tag-bg) !important; /* Utilise le gris foncé #2C2C2E */
    color: var(--text-primary);               /* Texte en blanc */
    
    /* On assombrit l'ombre pour qu'elle soit visible sur fond noir */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); 
    
    /* Optionnel : ajout d'une fine bordure pour détacher le badge */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* On ajuste aussi l'icône à l'intérieur pour enlever son ombre portée claire */
body.dark-mode .weather-icon {
    filter: drop-shadow(0 0 1px rgba(0,0,0,0.5));
}
body.dark-mode #themeToggle {
    background: #2C2C2E !important; /* Le !important assure la priorité, mais cibler l'ID suffit */
    color: var(--text-primary);
    border-color: var(--border-color);
}
body.dark-mode .filters {
    background: #2C2C2E;
}

body.dark-mode .filter-btn.active {
    background: #48484A;
    color: #FFF;
}
body.dark-mode .filter-slider {
    background: #48484A; /* Couleur grise pour le thème sombre */
}

/* --- CORRECTION GLOBALE BOUTON CALENDRIER --- */
/* Réinitialise le style par défaut du navigateur pour le bouton */
.calendar-btn {
    background: none;      /* Enlève le fond gris/noir */
    border: none;          /* Enlève la bordure */
    padding: 0;            /* Enlève le remplissage par défaut */
    margin: 0;
    font: inherit;         /* Hérite de la police */
    cursor: pointer;       /* Curseur main au survol */
    outline: inherit;      /* Enlève le contour de focus parfois moche */
    
    color: var(--accent);  /* Applique la couleur bleue définie dans vos variables */
    
    /* Centrage de l'icône */
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Petit effet au survol optionnel */
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.calendar-btn:hover {
    transform: scale(1.1); /* Léger zoom au survol */
    opacity: 0.8;
}

/* En mode sombre, on s'assure que l'icône ressort bien */
body.dark-mode .calendar-btn {
    color: var(--accent);
}

#gpsBtn.active ~ .city-input-wrapper {
    display: none;
}

.fav-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 18px;
    color: #D1D1D6; /* Gris (Défaut) */
    cursor: pointer;
    z-index: 10;
    transition: transform 0.2s, color 0.2s;
    padding: 0;
}

.fav-btn:hover { transform: scale(1.2); }

/* ÉTAT 1 : ENVIE (Étoile Jaune) */
.fav-btn.status-envie { color: #FFD700; }

/* ÉTAT 2 : DEMANDÉE (Orange) */
.fav-btn.status-asked { color: #FF9500; }

/* ÉTAT 3 : REÇUE (Vert) */
.fav-btn.status-received { color: #34C759; }

.fav-btn.status-refused { color: #FF3B30; }

/* Mode sombre */
body.dark-mode .fav-btn { color: #48484A; }
body.dark-mode .fav-btn.status-envie { color: #FFD700; }
body.dark-mode .fav-btn.status-asked { color: #FF9F0A; }
body.dark-mode .fav-btn.status-received { color: #32D74B; }

/* --- FOOTER STYLES --- */

footer {
    background-color: #FFFFFF;
    border-top: 1px solid var(--border-color);
    margin-top: 60px; /* Espace avec la grille de matchs */
    padding: 40px 40px 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.footer-brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.footer-brand i { color: var(--accent); }

.footer-desc {
    line-height: 1.6;
    max-width: 300px;
}

.footer-col h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-links a {
    text-decoration: none;
    color: var(--text-secondary);
    transition: color 0.2s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.footer-links a:hover {
    color: var(--accent);
    transform: translateX(4px); /* Petit mouvement vers la droite au survol */
}

.footer-bottom {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    text-align: center;
    font-size: 12px;
    opacity: 0.8;
}

/* --- FOOTER DARK MODE --- */

body.dark-mode footer {
    background-color: #1C1C1E; /* Même fond que le header en dark mode */
    border-top-color: rgba(255, 255, 255, 0.1);
    color: #A1A1A6;
}

body.dark-mode .footer-brand,
body.dark-mode .footer-col h4 {
    color: #FFFFFF;
}

body.dark-mode .footer-links a {
    color: #A1A1A6;
}

body.dark-mode .footer-links a:hover {
    color: var(--accent);
}

body.dark-mode .footer-bottom {
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* 1. Modifiez ceci pour permettre à l'élément de droite d'exister */
.accred-status { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    font-weight: 500; 
    width: auto;      /* Changé de 100% à auto */
    flex: 1;          /* Prend tout l'espace disponible restant */
    overflow: hidden; /* Évite que ça pousse l'icône hors cadre si le mail est long */
}

/* 2. Ajoutez le style pour le nouveau lien */
.source-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    padding: 4px;
    margin-left: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.source-link:hover {
    color: var(--accent);
    transform: scale(1.1);
}

/* 3. Ajustement Dark Mode (optionnel, car utilise déjà les variables) */
body.dark-mode .source-link:hover {
    color: #FFF;
}

/* --- VUE LISTE CONDENSÉE --- */

/* 1. La grille devient une colonne unique */
.matches-grid.list-view {
    grid-template-columns: 1fr;
    gap: 10px;
}

/* 2. La carte devient une ligne horizontale */
.matches-grid.list-view .card {
    flex-direction: row;
    align-items: center;
    padding: 8px 16px;
    gap: 20px;
    height: auto;
    min-height: 60px;
}

/* 3. Réorganisation du Header (Equipes + Score/Heure) */
.matches-grid.list-view .match-header {
    flex: 2; /* Prend le plus de place */
    justify-content: flex-start;
    gap: 15px;
    margin-bottom: 0; /* Annule la marge mobile */
}

.matches-grid.list-view .team {
    flex-direction: row;
    width: auto;
    gap: 8px;
}

/* On inverse l'ordre pour l'équipe domicile : Nom - Logo */
.matches-grid.list-view .team:first-child {
    flex-direction: row-reverse; 
}

.matches-grid.list-view .team-logo {
    width: 24px;
    height: 24px;
}

.matches-grid.list-view .team-name {
    font-size: 13px;
    text-align: right;
    width: auto;
    max-width: 150px;
    height: auto;
    -webkit-line-clamp: 1; /* Une seule ligne */
}
.matches-grid.list-view .team:last-child .team-name {
    text-align: left;
}

/* Centre (VS / Heure) */
.matches-grid.list-view .match-center {
    min-width: 50px;
}
.matches-grid.list-view .match-time {
    font-size: 13px;
    background: var(--tag-bg);
    padding: 2px 6px;
    border-radius: 4px;
}
.matches-grid.list-view .vs { display: none; } /* On cache le "VS" pour gagner de la place */

/* 4. Métadonnées (Date, Badge) */
.matches-grid.list-view .match-meta {
    flex: 1;
    border-top: none;
    padding-top: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 140px;
}
.matches-grid.list-view .calendar-btn {
    display: none; /* Optionnel : on cache le bouton calendrier si trop chargé */
}

/* 5. Transports */
.matches-grid.list-view .transport-block {
    flex: 1.5;
    background: transparent;
    padding: 0;
    border: none;
    justify-content: flex-end;
    gap: 20px;
}

/* 6. Footer Accréditation */
.matches-grid.list-view .accred-footer {
    flex: 1;
    border-top: none;
    margin-top: 0;
    padding-top: 0;
    justify-content: flex-end;
    max-width: 200px;
}
.matches-grid.list-view .accred-status {
    justify-content: flex-end;
}
.matches-grid.list-view .accred-email {
    display: none; /* On cache l'email en texte pour ne garder que les icônes */
}

/* 7. Bouton Favoris */
.matches-grid.list-view .fav-btn {
    position: static; /* Remet le bouton dans le flux */
    order: -1; /* Le met tout à gauche */
    margin-right: 10px;
    font-size: 14px;
}
.matches-grid.list-view .card:hover {
    transform: none; /* Enlève l'effet de levée en mode liste pour plus de sobriété */
    background-color: rgba(0,0,0,0.02); /* Légère surbrillance */
}

/* --- RESPONSIVE : RETOUR EN GRILLE SUR MOBILE --- */
@media (max-width: 768px) {
    .matches-grid.list-view {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
    .matches-grid.list-view .card {
        flex-direction: column;
        padding: 16px;
        gap: 12px;
        height: auto;
    }
    /* On réinitialise tous les styles forcés ci-dessus pour le mobile */
    .matches-grid.list-view .match-header { margin-bottom: 0; width: 100%; justify-content: space-between; }
    .matches-grid.list-view .team { flex-direction: column; width: 42%; }
    .matches-grid.list-view .team:first-child { flex-direction: column; }
    .matches-grid.list-view .team-name { text-align: center; max-width: none; -webkit-line-clamp: 2; }
    .matches-grid.list-view .team-logo { width: 42px; height: 42px; }
    .matches-grid.list-view .match-meta { flex-direction: row; border-top: 1px solid var(--border-color); padding-top: 10px; width: 100%; }
    .matches-grid.list-view .transport-block { background: #FAFAFA; padding: 8px 12px; width: 100%; }
    .matches-grid.list-view .accred-footer { border-top: 1px solid var(--border-color); padding-top: 10px; width: 100%; justify-content: space-between; max-width: none; }
    .matches-grid.list-view .accred-email { display: block; }
    .matches-grid.list-view .fav-btn { position: absolute; }
    .matches-grid.list-view .vs { display: block; }
    
    /* Dark mode fix pour mobile */
    body.dark-mode .matches-grid.list-view .transport-block { background: var(--tag-bg); }
}
/* --- MODALE CARTE --- */
.map-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.map-modal.hidden {
    display: none !important; /* Ajout de !important pour forcer le masquage */
    opacity: 0;
    pointer-events: none;
}

.map-container {
    width: 90%;
    height: 90%;
    background: var(--card-bg);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
}

#leafletMap {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.close-map {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000; /* Au-dessus de Leaflet */
    background: white;
    color: #1D1D1F;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.close-map:hover {
    transform: scale(1.1);
}

/* Style des Popups Leaflet */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    font-family: var(--font-main);
    padding: 0;
    overflow: hidden;
}
.leaflet-popup-content {
    margin: 0;
    width: 260px !important;
}

/* Customisation du contenu de la popup pour ressembler à tes cartes */
.map-popup-card {
    padding: 12px;
}
.map-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 13px;
}
.map-popup-btn {
    display: block;
    width: 100%;
    background: var(--accent);
    color: white;
    text-align: center;
    padding: 8px;
    text-decoration: none;
    border-radius: 6px;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 500;
    border: none;
    cursor: pointer;
}

.map-popup-btn:hover {
    background: #005bb7;
}

/* Adaptation Dark Mode */
body.dark-mode .leaflet-tile {
    filter: invert(1) hue-rotate(180deg) brightness(0.8); /* Astuce pour assombrir la carte gratuitement */
}
body.dark-mode .leaflet-popup-content-wrapper {
    background: #1C1C1E;
    color: white;
}
body.dark-mode .leaflet-popup-tip {
    background: #1C1C1E;
}

/* État par défaut (Ouvert) */
#advancedFilters {
    max-height: 500px; /* Valeur arbitraire suffisante pour le contenu */
    opacity: 1;
    overflow: hidden; /* Nécessaire pour l'animation */
    transition: all 0.3s ease-in-out;
    margin-top: 12px; /* Espace si nécessaire */
}

/* Garde l'icône blanche quand le bouton est actif (fond bleu) */
#advFiltersBtn.active {
    color: #FFFFFF; 
}
/* --- ANIMATION DU MENU FILTRES & LOCALISATION --- */

/* État par défaut (OUVERT) */
.header-bottom {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* État fermé (MODE COMPACT) */
#mainHeader.compact-mode .header-bottom {
    max-height: 0;      /* Réduit la hauteur à 0 */
    opacity: 0;         /* Rend transparent */
    margin: 0;          /* Supprime les marges pour coller au haut */
    transform: translateY(-10px); /* Petit effet de glissement vers le haut */
    pointer-events: none; /* Empêche de cliquer sur les éléments invisibles */
}

/* Dans index.css, à la fin */

/* Header spécifique quand il y a plusieurs matchs */
.map-popup-header.multi-header {
    border-bottom: 2px solid var(--accent);
    padding-bottom: 8px;
    margin-bottom: 0;
    color: var(--accent);
}

/* Conteneur avec scroll pour la liste */
.map-scroll-container {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px; /* Espace pour la scrollbar */
}

/* Scrollbar fine et propre (Webkit) */
.map-scroll-container::-webkit-scrollbar {
    width: 4px;
}
.map-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}
.map-scroll-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* Élément de la liste */
.map-list-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.map-list-item:last-child {
    border-bottom: none;
}

.map-list-title {
    font-weight: 600;
    font-size: 12px;
    line-height: 1.2;
}

.map-list-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Bouton plus petit pour la liste */
.map-popup-btn.small-btn {
    padding: 4px 0;
    font-size: 11px;
    margin-top: 4px;
    width: 100%;
}

/* Dark Mode fixes pour la popup liste */
body.dark-mode .map-list-item {
    border-color: rgba(255, 255, 255, 0.1);
}
body.dark-mode .map-scroll-container::-webkit-scrollbar-thumb {
    background: #48484A;
}

/* --- STYLE MODALE LOGIN --- */
.login-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 380px;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    text-align: center;
    border: 1px solid var(--border-color);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.login-header { margin-bottom: 25px; }
.login-header h2 { font-size: 24px; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }
.login-header p { color: var(--text-secondary); font-size: 14px; }

.login-icon-circle {
    width: 60px; height: 60px;
    background: var(--tag-bg);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 15px;
    font-size: 24px; color: var(--accent);
}

.input-group {
    position: relative;
    margin-bottom: 15px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 14px;
}

.input-group input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #FAFAFA;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    color: var(--text-primary);
}

.input-group input:focus {
    border-color: var(--accent);
    background: #FFF;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.login-submit-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

.login-submit-btn:hover { background: #005bb7; }

.login-footer-text { margin-top: 20px; font-size: 12px; color: var(--text-secondary); }
.login-footer-text a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* Dark Mode pour Login */
body.dark-mode .input-group input { background: #2C2C2E; border-color: rgba(255,255,255,0.1); color: white; }
body.dark-mode .input-group input:focus { background: #3A3A3C; }

/* Gestion de l'affichage Desktop/Mobile des boutons */
#loginBtnMobile { display: none; } /* Caché par défaut sur PC */

/* Style état connecté */
.logged-in-icon {
    color: #34C759 !important; /* Vert */
    position: relative;
}
.logged-in-icon::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 8px; height: 8px;
    background: #34C759;
    border: 1px solid var(--card-bg);
    border-radius: 50%;
}

/* Animation douce entre les vues */
#loginView, #signupView {
    animation: fadeInView 0.3s ease-in-out;
}

@keyframes fadeInView {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Style spécifique pour le bouton vert de l'inscription au survol */
#signupForm .login-submit-btn:hover {
    background: #2da84a !important; /* Vert un peu plus foncé */
}

/* Style spécifique Bouton Google */
.google-btn {
    background-color: #ffffff !important;
    color: #1f1f1f !important;
    border: 1px solid #dadce0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 500 !important;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.google-btn:hover {
    background-color: #f8f9fa !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    cursor: pointer;
}

/* Ajustement Dark Mode pour le bouton Google */
body.dark-mode .google-btn {
    background-color: #4285F4 !important; /* Bleu Google en mode sombre */
    color: #ffffff !important;
    border: none !important;
}
body.dark-mode .google-btn:hover {
    background-color: #3367D6 !important;
}
/* On met un fond blanc derrière le logo SVG en mode sombre pour qu'il ressorte */
body.dark-mode .google-btn img {
    background: white;
    border-radius: 50%;
    padding: 2px;
}

/* Animation de vibration en cas d'erreur */
@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-5px); }
  100% { transform: translateX(0); }
}
.shake {
  animation: shake 0.3s ease-in-out;
}

/* Bouton suppression de compte */
.delete-btn {
    background: #FFF !important;
    color: #FF3B30 !important;
    border: 1px solid #FF3B30 !important;
    transition: all 0.2s;
}
.delete-btn:hover {
    background: #FF3B30 !important;
    color: white !important;
}
/* Mode sombre */
body.dark-mode .delete-btn {
    background: transparent !important;
}
body.dark-mode .delete-btn:hover {
    background: #FF3B30 !important;
}

/* Cette classe remplace le style="background..." */
.bg-secondary-adaptive {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

/* Ajustement spécifique pour l'icône ronde */
.login-icon-circle.bg-secondary-adaptive {
    border: none !important; /* Pas de bordure pour le rond */
}
/* --- OPTIMISATION VUE LISTE (Cacher textes accréditation) --- */

/* Cible tous les textes d'accréditation (Email ET "Plateforme") 
   UNIQUEMENT quand la grille est en mode 'list-view' */
.matches-grid.list-view .card .accred-text {
    display: none !important;
}

/* Ajustement optionnel : Agrandir légèrement les icônes en mode liste 
   pour qu'elles soient plus faciles à cliquer maintenant qu'elles sont seules */
@media (min-width: 768px) {
    .matches-grid.list-view .card .accred-status i {
        font-size: 1.1rem;
    }
}

/* Gère l'espacement entre les icônes (Copie / Mail / Lien) */
.matches-grid.list-view .card .accred-status {
    gap: 12px; /* Espace confortable entre les icônes */
    
}

/* --- STYLE STATISTIQUES --- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 25px;
    text-align: center;
}

.stat-item {
    background: var(--bg-color);
    padding: 10px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stat-val {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 2px;
    font-weight: 600;
}

.stats-badges-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-badge-row {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--card-bg); /* Fond carte */
    border: 1px solid var(--border-color);
    padding: 10px 15px;
    border-radius: 12px;
}

.stat-icon {
    width: 36px;
    height: 36px;
    background: #EEF2FF;
    color: #6366F1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-title {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}

.stat-data {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Dark Mode Adaptation */
body.dark-mode .stat-item {
    background: #2C2C2E;
}
body.dark-mode .stat-icon {
    background: #2C2C2E;
    color: #8B5CF6;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Titre de section */
.stat-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin: 15px 0 10px;
    letter-spacing: 0.5px;
}

/* Conteneur Camembert + Légende */
.pie-container {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-color);
    padding: 15px;
    border-radius: 12px;
}

/* app.css */

.pie-chart {
    width: 80px; /* Un peu plus grand pour bien voir les détails */
    height: 80px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    /* On enlève la bordure car le SVG gère ses propres marges */
    border: none; 
    
    display: flex;
    align-items: center;
    justify-content: center;
}

.pie-chart svg {
    width: 100%;
    height: 100%;
    display: block;
    /* Le SVG est déjà circulaire, pas besoin de border-radius ici */
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1)); /* Ombre portée sur le SVG complet */
}

/* SUPPRIMER L'ANCIEN TROU DU DONUT CSS */
.pie-chart::after {
    display: none;
}

/* Légende */
.pie-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 500;
}

.legend-color {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    display: inline-block;
    margin-right: 6px;
}

/* Adaptation Dark Mode */
body.dark-mode .pie-container {
    background: #2C2C2E;
}
body.dark-mode .pie-chart::after {
    background: #2C2C2E;
}

/* --- NOUVEAU LAYOUT STATS (Plus large) --- */
.stats-content-row {
    display: flex;
    gap: 25px; /* Espace entre Camembert et Badges */
    margin-top: 15px;
    align-items: center; /* Centrage vertical */
}

/* Colonne Gauche (Camembert) */
.stats-left-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center; /* Centre le camembert */
}

/* Colonne Droite (Badges) */
.stats-right-col {
    flex: 1.4; /* Prend un peu plus de place pour le texte */
    display: flex;
    flex-direction: column;
    gap: 8px; /* Espace réduit entre les badges */
}

/* Ajustement des badges pour qu'ils soient moins hauts */
.stat-badge-row {
    padding: 8px 12px; /* Moins de padding */
}

/* Responsive : Sur mobile, on repasse en colonne */
@media (max-width: 600px) {
    .stats-content-row {
        flex-direction: column;
    }
    .stats-right-col {
        width: 100%;
    }
}

/* --- EFFET DE BRILLANCE STATS --- */
/* Badge pour le niveau du meilleur match dans les stats */
.stat-level-badge {
    background-color: var(--tag-bg); /* Gris clair adaptatif */
    color: var(--text-primary);      /* Texte principal */
    padding: 2px 8px;                /* Espacement interne */
    border-radius: 6px;              /* Bords arrondis */
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;           /* Pour que le padding s'applique bien */
    border: 1px solid var(--border-color); /* Optionnel : fine bordure pour le relief */
}

/* Adaptation spécifique au mode sombre */
body.dark-mode .stat-level-badge {
    background-color: #2C2C2E;       /* Gris plus foncé en mode sombre */
    border-color: rgba(255, 255, 255, 0.1);
}

/* Style pour le badge du nombre de visites dans les stats */
.stat-count-badge {
    background-color: var(--tag-bg); /* Gris clair adaptatif */
    color: var(--text-primary);      /* Texte principal */
    padding: 2px 8px;                /* Espacement interne */
    border-radius: 6px;              /* Bords arrondis */
    font-size: 14px;                 /* Légèrement plus grand pour le chiffre */
    font-weight: 800;
    display: inline-block;
    border: 1px solid var(--border-color);
    min-width: 28px;                 /* Assure une forme consistante */
    text-align: center;
}

/* Mode sombre */
body.dark-mode .stat-count-badge {
    background-color: #2C2C2E;
    border-color: rgba(255, 255, 255, 0.1);
}

/* Force l'alignement vertical parfait dans les lignes de stats */
.stat-badge-row {
    display: flex;
    align-items: center; /* Centre verticalement tous les enfants directs */
    gap: 15px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 10px 15px;
    border-radius: 12px;
    min-height: 54px; /* Assure une hauteur constante */
}


/* Style pour tronquer le nom du club avec '...' */
.stat-club-name {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.2;
    
    /* Tronquage magique */
    white-space: nowrap;      /* Empêche le retour à la ligne */
    overflow: hidden;         /* Cache ce qui dépasse */
    text-overflow: ellipsis;  /* Affiche les '...' */
    
    max-width: 140px;         /* Ajustez selon la largeur souhaitée */
}

/* On s'assure que le conteneur flex ne s'écrase pas */
.stat-info-main {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden; /* Important pour que l'enfant puisse tronquer */
    flex: 1;
}

/* --- VUE MOBILE EXPANSÉE (TOGGLE) --- */
    
    /* Quand la carte a la classe .mobile-expanded, elle reprend le look "Grille" */
    .matches-grid.list-view .card.mobile-expanded {
        flex-direction: column !important;
        align-items: stretch !important; /* Prend toute la largeur */
        gap: 12px !important;
        padding: 16px !important;
        background-color: var(--card-bg) !important;
        /* Petit effet d'élévation pour montrer qu'elle est ouverte */
        box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
        border-color: var(--accent) !important;
        z-index: 10;
        position: relative;

        animation: cardExpandPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
        /* L'animation part du centre haut de la carte */
        transform-origin: center top !important;
        /* S'assurer que l'accélération matérielle est utilisée pour la fluidité */
        will-change: transform, opacity;
    }

    /* 1. Header : On remet espace entre équipes et score */
    .matches-grid.list-view .card.mobile-expanded .match-header {
        justify-content: space-between !important;
        width: 100% !important;
        margin-bottom: 0 !important;
    }

    /* 2. Équipes : Retour en colonne (Logo au-dessus du nom) */
    .matches-grid.list-view .card.mobile-expanded .team {
        flex-direction: column !important;
        width: 40% !important;
    }
    .matches-grid.list-view .card.mobile-expanded .team:first-child {
        flex-direction: column !important; /* Annule le row-reverse */
    }

    /* Réafficher le nom des équipes */
    .matches-grid.list-view .card.mobile-expanded .team-name {
        display: -webkit-box !important; /* Pour le clamp */
        -webkit-line-clamp: 2 !important;
        text-align: center !important;
        font-size: 13px !important;
        margin-top: 4px;
        height: auto !important;
    }

    /* Logos un peu plus grands comme en vue grille */
    .matches-grid.list-view .card.mobile-expanded .team-logo {
        width: 42px !important;
        height: 42px !important;
    }

    /* Score / Heure et VS */
    .matches-grid.list-view .card.mobile-expanded .match-center {
        flex-direction: column !important;
    }
    .matches-grid.list-view .card.mobile-expanded .match-time {
        background: none !important; /* Enlève le badge gris */
        padding: 0 !important;
        font-size: 14px !important;
    }
    .matches-grid.list-view .card.mobile-expanded .vs {
        display: block !important;
    }

    /* 3. Métadonnées : Badges et Dates */
    .matches-grid.list-view .card.mobile-expanded .match-meta {
        flex-direction: row !important;
        border-top: 1px solid var(--border-color) !important;
        padding-top: 10px !important;
        width: 100% !important;
        justify-content: space-between !important;
    }

    /* Bascule Badge Court -> Long */
    .matches-grid.list-view .card.mobile-expanded .badge-short { display: none !important; }
    .matches-grid.list-view .card.mobile-expanded .badge-long { display: flex !important; }

    /* Bascule Date Courte -> Longue */
    .matches-grid.list-view .card.mobile-expanded .date-short { display: none !important; }
    .matches-grid.list-view .card.mobile-expanded .date-long { display: block !important; }

    /* 4. Transports & Source : Réafficher */
    .matches-grid.list-view .card.mobile-expanded .transport-block {
        display: flex !important;
        width: 100% !important;
    }

    .matches-grid.list-view .card.mobile-expanded .source-link {
        display: flex !important;
    }

    /* 5. Footer Accréditation : Réafficher le texte */
    .matches-grid.list-view .card.mobile-expanded .accred-footer {
        justify-content: space-between !important;
        border-top: 1px solid var(--border-color) !important;
        padding-top: 10px !important;
    }
    
    .matches-grid.list-view .card.mobile-expanded .accred-text {
        display: block !important;
    }
    
    .matches-grid.list-view .card.mobile-expanded .accred-email {
        display: flex !important; /* Ou block */
    }

    /* Remettre le bouton favori en haut à droite */
    .matches-grid.list-view .card.mobile-expanded .fav-btn {
        position: absolute !important;
        top: 12px !important;
        right: 12px !important;
        margin: 0 !important;
    }

    /* --- DÉFINITION DE L'ANIMATION D'APPARITION --- */
@keyframes cardExpandPop {
    0% {
        opacity: 0;
        /* La carte commence légèrement plus petite et décalée vers le bas */
        transform: scale(0.96) translateY(15px);
    }
    60% {
        /* Léger dépassement pour l'effet de rebond */
        transform: scale(1.01) translateY(-2px);
    }
    100% {
        opacity: 1;
        /* Position et taille finales normales */
        transform: scale(1) translateY(0);
    }
}