/* ============================================================
   MOBILE — fo76map — inspiré de fo76map.com
   Desktop : inchangé
   Mobile  : carte plein écran + top bar + panel full page
   ============================================================ */

/* ── Barre supérieure mobile ───────────────────────────────── */
#mobileTopBar {
    display: none;
}

@media screen and (max-width: 768px) {

    /* Barre fixe en haut */
    #mobileTopBar {
        display: flex;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 52px;
        background: #0d100a;
        border-bottom: 1px solid rgba(221,183,36,0.35);
        z-index: 9999;
        align-items: center;
        justify-content: flex-end; /* boutons à droite */
        gap: 0.4rem;
        padding: 0 10px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.6);
    }

    #mobileTopBar .mobile-title {
        color: #DDB724;
        font-family: 'Kalam', sans-serif;
        font-size: 1rem;
        font-weight: bold;
        letter-spacing: 0.03em;
        flex: 1; /* prend l'espace restant à gauche */
    }

    #mobileFilterBtn {
        background: rgba(221,183,36,0.07);
        border: 1px solid rgba(221,183,36,0.4);
        color: #DDB724;
        padding: 0 0.9rem;
        height: 34px;
        border-radius: 0;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 0.4rem;
        font-family: 'Share Tech Mono', monospace;
        font-size: 0.7rem;
        letter-spacing: 0.15em;
        text-transform: uppercase;
        white-space: nowrap;
        transition: background 0.2s, box-shadow 0.2s;
    }

    #mobileFilterBtn:active,
    #mobileFilterBtn.active {
        background: rgba(221, 183, 36, 0.18);
        box-shadow: 0 0 12px rgba(221,183,36,0.2);
    }

    /* ── Carte : plein écran sous la top bar ── */
    #mapid {
        margin-top: 52px;
        height: calc(100vh - 52px) !important;
        min-height: calc(100vh - 52px) !important;
    }

    /* ── Panneau gauche : caché par défaut, plein écran quand ouvert ── */
    #leftPanel {
        position: fixed !important;
        top: 52px !important;
        left: 0 !important;
        right: 0;
        bottom: 0;
        width: 100% !important;
        height: calc(100vh - 52px) !important;
        z-index: 9998;
        display: none;
        flex-direction: column;
        transition: none;
    }

    #leftPanel.mobile-open {
        display: flex !important;
    }

    /* Contenu du panneau : pleine largeur, scrollable */
    #leftPanel > .content {
        width: 100% !important;
        height: 100% !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background-color: #0d100a;
    }

    /* Bouton toggle desktop caché sur mobile */
    #leftPanel > .button { display: none !important; }

    /* ── Layout catégories : conserve les 2 colonnes ── */
    #categories .categorie .content {
        grid-template-columns: 1fr 1fr;
    }

    /* Touch targets 44px */
    /* Masquer les contrôles Leaflet desktop sur mobile */
    .mobileHide { display: none !important; }

    #categories .entity            { min-height: 44px; }
    #categories .categorie > .title { min-height: 44px; align-items: center; }
    #selectAll div                 { min-height: 40px; display: flex; align-items: center; justify-content: center; }

    /* ── Éléments desktop cachés ── */
    #rightPanel  { display: none !important; }
    .mobileShow  { display: none !important; }

    /* ── Zoom Leaflet ── */
    .leaflet-bottom.leaflet-right {
        bottom: 12px;
        right: 8px;
    }

    /* ── Popup ── */
    .leaflet-popup-content-wrapper {
        max-width: calc(100vw - 20px);
    }

    .leaflet-control-attribution { font-size: 0.6rem; }
}

/* ── Très petits écrans ────────────────────────────────────── */
@media screen and (max-width: 380px) {
    #categories .categorie .content {
        grid-template-columns: 1fr;
    }
    #categories .categorie .content > .entity:nth-child(odd) { border-right: none; }
}

    /* ── Boutons top bar (login + search) — style unifié ── */
    #mobileLoginBtn,
    #mobileLogoutBtn,
    #mobileSearchBtn {
        background: rgba(221,183,36,0.07);
        border: 1px solid rgba(221,183,36,0.4);
        color: #DDB724;
        width: 34px;
        height: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.8rem;
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.2s;
    }
    /* SVG icons dans les boutons top bar */
    #mobileLoginBtn svg,
    #mobileLogoutBtn svg,
    #mobileSearchBtn svg {
        display: block;
        stroke: #DDB724;
    }
    #mobileLogoutBtn svg { stroke: #e05555; }
    #mobileLoginBtn:active,
    #mobileSearchBtn:active { background: rgba(221,183,36,0.2); }
    #mobileLogoutBtn { border-color: rgba(224,85,85,0.4); color: #e05555; }
    #mobileLogoutBtn:active { background: rgba(224,85,85,0.15); }

    /* ── Panel connexion mobile ── */
    #mobileLoginPanel {
        display: none;
        position: fixed;
        top: 52px;
        left: 0; right: 0;
        z-index: 9996;
        background: #0d100a;
        border-bottom: 1px solid rgba(221,183,36,0.35);
        box-shadow: 0 8px 30px rgba(0,0,0,0.7);
        flex-direction: column;
        max-height: 80vh;
        overflow-y: auto;
    }
    #mobileLoginPanel.open { display: flex; }

    .mlp-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.6rem 1rem;
        background: rgba(221,183,36,0.08);
        border-bottom: 1px solid rgba(221,183,36,0.35);
        flex-shrink: 0;
    }
    .mlp-title {
        font-family: 'Share Tech Mono', monospace;
        font-size: 0.65rem;
        letter-spacing: 0.2em;
        color: #a8881a;
        text-transform: uppercase;
    }
    #mobileLoginClose {
        background: transparent;
        border: 1px solid rgba(221,183,36,0.25);
        color: rgba(221,183,36,0.5);
        width: 22px; height: 22px;
        font-size: 0.7rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .mlp-body {
        padding: 1.2rem 1.2rem 1.5rem;
    }
    .mlp-text {
        font-family: 'Share Tech Mono', monospace;
        font-size: 0.78rem;
        color: #e8e4d8;
        line-height: 1.7;
        margin: 0 0 0.75rem;
    }
    .mlp-text strong { color: #DDB724; font-weight: normal; }
    .mlp-logo {
        text-align: center;
        padding: 0.75rem;
        border: 1px solid rgba(221,183,36,0.2);
        background: rgba(0,0,0,.2);
        margin: 1rem 0;
    }
    .mlp-logo img {
        max-width: 160px;
        max-height: 80px;
        object-fit: contain;
    }
    .mlp-btn {
        display: block;
        text-align: center;
        text-decoration: none;
        font-family: 'Share Tech Mono', monospace;
        font-size: 0.8rem;
        letter-spacing: 0.15em;
        text-transform: uppercase;
        color: #DDB724;
        border: 1px solid rgba(221,183,36,0.5);
        padding: 0.9rem;
        background: rgba(221,183,36,0.07);
        transition: background 0.2s;
    }
    .mlp-btn:active { background: rgba(221,183,36,0.18); }
    .mlp-note {
        font-family: 'Share Tech Mono', monospace;
        font-size: 0.58rem;
        color: rgba(221,183,36,0.3);
        text-align: center;
        margin: 0.75rem 0 0;
        letter-spacing: 0.08em;
        line-height: 1.5;
    }

    /* #mobileSearchBtn : style défini avec #mobileLoginBtn ci-dessus */

    /* ── Overlay recherche mobile ── */
    #mobileSearchOverlay {
        display: none;
        position: fixed;
        top: 52px;
        left: 0; right: 0;
        z-index: 9997;
        background: #0d100a;
        border-bottom: 1px solid rgba(221,183,36,0.35);
        box-shadow: 0 8px 24px rgba(0,0,0,0.7);
        flex-direction: column;
        /* overlay flottant — ne pousse pas la carte */
    }
    #mobileSearchOverlay.open { display: flex; }

    /* Row fixe : input + bouton fermer */
    #mobileSearchInputRow {
        display: flex;
        align-items: center;
        position: relative;
        flex-shrink: 0;
        border-bottom: 1px solid rgba(221,183,36,0.2);
    }
    #mobileSearchInputRow input {
        flex: 1;
        background: transparent;
        border: none;
        color: #DDB724;
        font-family: 'Share Tech Mono', monospace;
        font-size: 0.9rem;
        padding: 0.75rem 3rem 0.75rem 1rem;
        outline: none;
        caret-color: #DDB724;
    }
    #mobileSearchInputRow input::placeholder {
        color: rgba(221,183,36,0.25);
    }
    #mobileSearchClose {
        position: absolute;
        right: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        background: transparent;
        border: none;
        color: rgba(221,183,36,0.4);
        font-size: 0.9rem;
        cursor: pointer;
        padding: 0.5rem;
        line-height: 1;
        flex-shrink: 0;
    }

    #mobileSearchResults {
        max-height: 50vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    #mobileSearchResults .search-item {
        padding: 0.7rem 1rem;
        font-size: 0.85rem;
    }
    #mobileSearchResults .search-noresult {
        padding: 1rem;
        font-size: 0.75rem;
    }
