/* ============================================================
   1. CONTENEUR CARTE
   ============================================================ */
#map-mas-apt {
    width: 100%;
    max-width: 100%;
    height: 480px;
    border-radius: 8px;
    z-index: 1;
}

/* ============================================================
   2. STRUCTURE DES POPUPS LEAFLET (RESET & PREMIUM)
   ============================================================ */
/* Supprime les marges par défaut pour que l'image touche les bords */
.leaflet-popup-content-wrapper {
    padding: 0 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 280px !important; /* Largeur fixe pour un aspect Premium */
    font-family: "Arial", sans-serif;
}

/* Masque le bouton de fermeture par défaut si nécessaire */
.leaflet-popup-close-button {
    padding: 8px 8px 0 0 !important;
    color: #fff !important; /* Pour qu'il soit visible sur l'image */
    z-index: 10;
}

/* ============================================================
   3. CONTENU DE LA POPUP PREMIUM
   ============================================================ */
.popup-premium img {
    width: 100% !important;
    max-width: none !important; /* Retire toute limitation précédente */
    height: 160px !important;
    object-fit: cover; /* L'image remplit le cadre sans déformation */
    display: block;
}

.popup-body {
    padding: 15px 18px;
    background: #fff;
}

.popup-title {
    font-size: 1.15rem;
    font-weight: bold;
    margin-bottom: 6px;
    color: #1a2a40; /* Bleu foncé */
}

.popup-text {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #444;
    margin-bottom: 12px;
}

/* ============================================================
   4. BOUTONS IDENTIQUES (PIED DE POPUP)
   ============================================================ */
.popup-footer {
    display: flex;
    gap: 8px; /* Espace entre les boutons */
    margin-top: 10px;
}

.popup-footer a {
    flex: 1; /* Force les deux boutons à avoir la même largeur exacte */
    display: inline-block;
    padding: 10px 4px;
    text-align: center;
    text-decoration: none !important;
    color: white !important;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

/* Couleurs spécifiques aux boutons */
.btn-details {
    background: #1a2a40; /* Bleu foncé */
}

.btn-go-green {
    background: #27ae60; /* Vert pour l'itinéraire */
}

.popup-footer a:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ============================================================
   5. CONTROLES DE LA CARTE (BOUTONS FLOTTANTS & TOGGLE)
   ============================================================ */
.map-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
}

.btn-map {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.4);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-map:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
}

/* Toggle iOS pour le changement de couche */
.toggle-container {
    position: relative;
    display: inline-flex;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(6px);
    border-radius: 20px;
    padding: 4px;
    border: 1px solid rgba(255,255,255,0.5);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.toggle-option {
    position: relative;
    z-index: 2;
    padding: 6px 14px;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
    transition: color 0.3s;
}

.toggle-option.active {
    color: white;
    font-weight: 600;
}

.toggle-pill {
    position: absolute;
    top: 3px;
    left: 3px;
    height: calc(100% - 6px);
    background: #2b6cb0;
    border-radius: 16px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

/* ============================================================
   6. PANNEAU LATERAL LIEUX
   ============================================================ */
.side-panel {
    position: absolute;
    bottom: 80px;
    left: 10px;
    width: 240px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: all 0.3s ease;
}

.side-panel.hidden {
    transform: translateX(-120%);
    opacity: 0;
}

.side-panel h3 {
    margin: 0 0 10px 0;
    font-size: 1rem;
    color: #1a2a40;
}

.side-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.side-panel li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    cursor: pointer;
    font-size: 0.85rem;
}

.side-panel li:hover {
    color: #2b6cb0;
    padding-left: 5px;
    transition: all 0.2s;
}
/* Style du bouton plein écran */
#btn-fullscreen {
    font-weight: bold;
    font-size: 18px;
    background: #fff;
    color: #333;
}

/* Force la carte à prendre tout l'espace en mode plein écran */
#map-mas-apt:fullscreen {
    width: 100vw;
    height: 100vh;
}
#map-mas-apt:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
}
/* Force le bouton à être visible et au-dessus */
#btn-fullscreen {
    display: flex !important; /* Force l'affichage */
    z-index: 2000 !important;
    background-color: #ffffff !important;
    color: #1a2a40 !important;
    border: 2px solid #2b6cb0 !important; /* Un petit bord bleu pour le repérer */
}
/* ============================================================
   OPTIMISATION MOBILE (Smartphone)
   ============================================================ */
@media (max-width: 768px) {
    /* 1. On donne plus d'espace à la carte */
    #map-mas-apt {
        height: 70vh !important; /* 70% de la hauteur de l'écran */
    }

    /* 2. Popup plus large pour éviter de trop scroller dans la bulle */
    .leaflet-popup-content {
        width: 260px !important;
    }

    /* 3. On réorganise les contrôles en bas pour l'accès au pouce */
    .map-controls {
        flex-direction: row !important; /* Boutons alignés horizontalement */
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
        background: rgba(255,255,255,0.7);
        padding: 8px;
        border-radius: 12px;
    }

    .btn-map {
        padding: 10px 12px !important; /* Cibles tactiles plus grandes */
        font-size: 0.8rem !important;
        flex: 1 1 auto; /* Les boutons se répartissent l'espace */
        justify-content: center;
    }

    /* 4. Le panneau "Lieux" s'affiche en grand en bas */
    .side-panel {
        width: 90% !important;
        left: 5% !important;
        bottom: 70px !important;
        max-height: 40vh;
        overflow-y: auto;
    }

    /* 5. On masque le bouton plein écran sur mobile (souvent problématique avec iOS) */
    #btn-fullscreen {
        display: none !important;
    }
}