/* --- Styles Mobile (max-width 768px) --- */
@media screen and (max-width: 768px) {

    /* 1. Reset et Fond de page */
    html, body {
        min-width: 0 !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    /* 2. Header Style Image */
    header {
        position: sticky;
        top: 0;
        padding: 15px !important;
        height: auto;
        min-height: 70px;
        max-height: 70px; /* Fermé par défaut */
        background: #FFFFFF !important;
        overflow: hidden;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
        gap: 15px;
        border-bottom: 1px solid #E5E5E7;
    }

    header.menu-open {
        max-height: 100vh;
        overflow-y: auto;
    }

    /* Top Bar (Logo + Burger) */
    .header-top {
        display: flex;
        flex-direction: column; /* On garde la structure pour le menu déroulant */
    }

    .brand {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 19px;
        font-weight: 700;
        min-width: 0 !important;
        padding-bottom: 5px;
    }

    .menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        background: none;
        font-size: 20px;
    }

    /* 3. Contenu du Menu (Nav + Bottom) */
    .nav-controls, 
    .header-bottom {
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: 100%;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s;
    }

    header.menu-open .nav-controls,
    header.menu-open .header-bottom {
        opacity: 1;
        visibility: visible;
    }

    /* Barre de recherche */
    .search-group { width: 100%; }
    .search-input { 
        width: 100% !important; 
        height: 44px !important;
        background: #F5F5F7 !important;
        border: 1px solid #E5E5E7 !important;
        border-radius: 10px !important;
    }

    /* Groupe GPS + Calculer */
    .location-group {
        display: flex;
        gap: 10px;
        width: 100%;
    }

    #gpsBtn {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
        border: 1px solid #E5E5E7;
        border-radius: 10px;
    }

    .calc-btn {
        flex-grow: 1;
        height: 44px;
        justify-content: center;
        border-radius: 10px;
        font-size: 14px;
        background-color: #0071E3 !important; /* Bleu intense de l'image */
    }

    /* Onglets (Tous, Foot, Basket...) */
    .filters {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        background: #E8E8ED;
        padding: 4px;
        border-radius: 12px;
        gap: 0;
    }

    .filter-btn {
        padding: 8px 0;
        margin-right: 10px;
        margin-left: 10px;
        text-align: center;
        border-radius: 8px;
        font-size: 12px;
        text-overflow: ellipsis; 
    }

    .filter-btn.active {
        background: #FFFFFF;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }

    /* Filtres Selects (Compétition, Semaine, Tri) */
    .filter-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .control-input, .ui-group {
        width: 100%;
        height: 44px !important;
        background: #FFF;
        border: 1px solid #E5E5E7 !important;
        border-radius: 10px !important;
        display: flex;
        align-items: center;
        padding: 0 15px;
    }

    /* Pour aligner le label TRI et ACCRED à gauche comme sur l'image */
    .ui-group {
        justify-content: space-between;
    }

    .filter-label {
        font-size: 12px;
        color: #86868B;
        min-width: 60px;
    }

    select.control-input {
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 15px center;
    }

    /* 4. Grille de matchs */
    .container {
        padding: 15px !important;
        margin: 0 !important;
    }

    .matches-grid {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .card {
        width: 100%;
        margin: 0;
        border-radius: 16px; /* Arrondi plus doux */
    }

    .team-name { font-size: 12px; }

    #themeToggle {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    }

    #viewToggle {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    }


    #mapToggle {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    }

    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 .control-input, 
    body.dark-mode .loc-input,
    body.dark-mode .icon-btn,
    body.dark-mode #gpsBtn, 
    body.dark-mode #themeToggle {
        background: #2C2C2E !important;
        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;
    }

    /* --- FIX MOBILE : BOUTON CALCUL ET CHAMP VILLE --- */

@media (max-width: 768px) {
    /* 1. On transforme le bouton "Calculer" en bouton carré (icône seule) */
    #calcDistBtn {
        font-size: 0 !important; /* Cache le texte "Calculer les distances" */
        padding: 0 !important;
        width: 42px; /* Largeur fixe carrée */
        height: 42px; /* Hauteur fixe */
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 42px; /* Empêche l'écrasement */
    }

    /* 2. On s'assure que l'icône reste visible et de bonne taille */
    #calcDistBtn i {
        font-size: 18px !important;
        margin-right: 0 !important; /* Enlève la marge à droite de l'icône */
    }

    /* 3. On demande au conteneur du champ ville de prendre toute la place libre */
    .city-input-wrapper {
        flex-grow: 1;
        width: auto;
    }

    /* 4. On ajuste l'input lui-même pour qu'il remplisse son conteneur */
    #startCityInput {
        width: 100% !important;
        min-width: 0; /* Important pour éviter le dépassement flexbox */
    }
    
    /* Optionnel : Ajuster l'espacement global du groupe */
    .location-group {
        gap: 8px; /* Un peu d'espace entre les boutons */
    }
}
}
/* --- Styles par défaut (On cache les éléments "courts" sur Desktop) --- */
.badge-short, .date-short {
    display: none;
}
/* --- RESPONSIVE : VUE LISTE MOBILE OPTIMISÉE --- */
@media (max-width: 768px) {

    /* 2. Styles spécifiques à la VUE LISTE */
    .matches-grid.list-view {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .matches-grid.list-view .card {
        flex-direction: row !important;
        align-items: center;
        padding: 8px 12px !important;
        gap: 10px;
        min-height: 50px;
    }

    /* --- EQUIPES : Logos seulement --- */
    .matches-grid.list-view .team {
        width: auto !important;
        flex-direction: row !important;
        margin: 0 !important;
    }
    .matches-grid.list-view .team-name { display: none !important; }
    .matches-grid.list-view .team-logo {
        width: 32px !important;
        height: 32px !important;
        object-fit: contain;
    }

    /* --- HEADER : Logo - Heure - Logo --- */
    .matches-grid.list-view .match-header {
        width: auto !important;
        margin-bottom: 0 !important;
        justify-content: center;
        gap: 8px;
    }
    .matches-grid.list-view .match-center { min-width: auto !important; }
    .matches-grid.list-view .match-time {
        font-size: 12px !important;
        background: #F2F2F7;
        padding: 2px 5px;
        border-radius: 4px;
        font-weight: 700;
    }
    .matches-grid.list-view .vs { display: none !important; }

    /* --- METADONNEES : Badge Court et Date Courte --- */
    .matches-grid.list-view .match-meta {
        flex: 1;
        border-top: none !important;
        padding-top: 0 !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center;
        gap: 2px !important;
        margin-left: 5px;
    }

    /* Affiche uniquement les versions courtes */
    .matches-grid.list-view .badge-long { display: none !important; }
    .matches-grid.list-view .badge-short { display: flex !important; font-size: 10px; font-weight: 700; opacity: 0.8; }
    
    .matches-grid.list-view .date-long { display: none !important; }
    .matches-grid.list-view .date-short { display: block !important; font-size: 11px; color: #86868B; }

    /* --- ACCREDITATION : ICÔNES SEULEMENT --- */
    .matches-grid.list-view .accred-footer {
        width: auto !important;
        border-top: none !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
        flex-direction: row !important;
        justify-content: flex-end !important;
        gap: 12px; /* Espace entre les icônes */
    }

    /* C'est ici que la magie opère : on cache tous les textes marqués dans le JS */
    .matches-grid.list-view .accred-text {
        display: none !important; /* Cache le texte de l'email */
    }

    /* Optionnel : Ajuster l'espacement pour que les icônes ne soient pas trop serrées */
    .matches-grid.list-view .accred-status {
        gap: 15px !important; 
    }
    
    .matches-grid.list-view .accred-email {
        text-decoration: none;
        display: flex;
        align-items: center;
    }   



    /* --- AUTRES ELEMENTS --- */
    .matches-grid.list-view .transport-block { display: none !important; }
    .matches-grid.list-view .source-link { display: none !important; }
    
    .matches-grid.list-view .fav-btn {
        position: static !important;
        font-size: 14px;
        margin-right: 5px;
        background: none !important;
        border: none !important;
    }

    body.dark-mode .matches-grid.list-view .match-time {
        background: var(--tag-bg) !important; /* Devient gris foncé (#2C2C2E) */
        color: var(--text-primary) !important; /* Devient blanc */
    }

    /* ... À insérer AVANT l'accolade fermante du @media (max-width: 768px) ... */

    /* --- FOOTER MOBILE --- */
    
    /* 1. Ajustement du conteneur principal (padding réduit) */
    footer {
        padding: 30px 20px !important;
        margin-top: 30px !important;
    }

    /* 2. Passage en colonne unique verticalement */
    .footer-content {
        grid-template-columns: 1fr !important; /* Force une seule colonne */
        gap: 40px !important;
        text-align: center; /* Centre le texte pour un meilleur rendu mobile */
    }

    /* 3. Centrage du logo et de la marque */
    .footer-brand {
        justify-content: center !important;
    }

    /* 4. Centrage de la description */
    .footer-desc {
        margin: 0 auto !important; /* Centre le bloc de texte */
    }

    /* 5. Centrage des liens (qui sont en flex-column dans app.css) */
    .footer-links {
        align-items: center !important; 
    }
    
    /* 6. Centrage des éléments à l'intérieur des liens */
    .footer-links a {
        justify-content: center;
    }

    /* ... Dans @media (max-width: 768px) ... */

    /* On cache le bouton desktop car il est dans .nav-controls qui est caché/déplacé */
    #loginBtnDesktop { display: none !important; }

    /* On affiche le bouton mobile */
    #loginBtnMobile { 
        display: flex !important;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        color: var(--accent); /* Couleur bleue pour se distinguer du burger */
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        margin-left: 5px;
    }

    /* Ajustement Dark Mode Mobile */
    body.dark-mode #loginBtnMobile {
        color: var(--accent);
    }
}