/* 
 * LumiereV2 - Centralized Mobile Styles
 * Handles responsiveness for core theme and main plugins (SearchUi, PoiEdit, Meteo)
 */

/* ==========================================================================
   Global & Layout Resets
   ========================================================================== */

@media (max-width: 991px) {
    #header .header-search-form button {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        width: 36px !important;
        height: 36px !important;
    }

    #header .header-search-form i {
        margin: 0 !important;
        display: block !important;
        text-align: center !important;
        width: 100% !important;
    }

    /* ... */

    html,
    body {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }

    #container {
        overflow-x: hidden;
        width: 100%;
    }

    /* Stack layout */
    #body-page {
        flex-direction: column !important;
        flex-wrap: wrap;
    }

    #content {
        width: 100% !important;
        padding: 0 !important;
        /* Remove lateral padding — let child elements control their own spacing */
    }

    /* ===== SOURCE DES MARGES LATÉRALES =====
       #body (main) a padding: 32px 24px — les 24px créent les marges bleues.
       On les supprime en mobile pour que le contenu soit plein écran comme le header/footer. */
    #body {
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-top: 0 !important;
        max-width: 100% !important;
    }

    /* #body-page : supprimer le centrage/max-width en mobile */
    #body-page {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        gap: 0 !important;
    }

    .sidebar {
        width: 100% !important;
        margin-top: 20px;
    }

    /* Reset problematic min-widths uniquement sur les conteneurs connus */
    .container,
    .main-container,
    .content-panel,
    section {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    img,
    video,
    iframe {
        max-width: 100%;
        height: auto;
    }

    /* Scroll lock for menu - Force fixed to prevent any scroll */
    body.menu-open {
        overflow: hidden !important;
        touch-action: none;
        position: fixed;
        width: 100%;
    }
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

@media (max-width: 991px) {
    #header {
        height: auto !important;
        min-height: 70px !important;
        padding: 5px 10px !important;
        background: var(--header-bg) !important;
        display: flex !important;
        flex-direction: column !important;
        /* Allow wrapping if needed */
        position: sticky !important;
        top: 0;
        z-index: 1000;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    }

    #header_content {
        display: flex !important;
        width: 100% !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0 !important;
        min-height: 60px;
    }

    .header-brand {
        display: flex !important;
        align-items: center !important;
        flex: 0 0 auto !important;
        max-width: 50% !important;
    }

    .brand-logo {
        display: flex !important;
        align-items: center !important;
    }

    .brand-logo img.site-logo {
        height: 40px !important;
        max-width: 150px !important;
        width: auto !important;
        object-fit: contain !important;
    }

    .nav-wrapper {
        display: flex !important;
        gap: 5px !important;
        flex: 1 !important;
        justify-content: space-around;
        align-items: baseline;
    }

    /* Mobile Menu Toggle Icon */
    #mobile_menu {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        font-size: 20px;
        color: #fff !important;
        cursor: pointer;
        order: 3;
        /* Keep it first in flex if needed, or stick it last */
        background: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
        margin-left: 5px;
    }

    /* Weather widget must stay outside or be forced visible */
    .header-links {
        display: flex !important;
        align-items: center !important;
        order: 2;
        background: transparent !important;
        padding: 0 !important;
        position: static !important;
    }

    /* Weather widget forced visible */
    .meteo-widget-compact,
    [data-plugin="meteo"],
    #header .header-links>div:not(#navigation) {
        display: flex !important;
        align-items: center !important;
    }

    #navigation {
        display: none !important;
        position: fixed !important;
        /* Overlay whole screen or dropdown */
        width: 100% !important;
        left: 0 !important;
        top: 70px !important;
        /* Match header height */
        background: var(--header-bg, #1a3a5c) !important;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3) !important;
        z-index: 9999;
        flex-direction: column !important;
        padding: 20px 0 !important;
        margin: 0 !important;
        list-style: none !important;
    }

    #navigation li {
        width: 100% !important;
        text-align: center !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    }

    #navigation li a {
        display: block !important;
        padding: 15px !important;
        color: #fff !important;
        font-size: 1.1rem !important;
        text-decoration: none !important;
    }

    /* Show menu when toggle is checked */
    #nav_toggle:checked~.header-links #navigation {
        display: flex !important;
    }
}

/* ==========================================================================
   Hero & Banner
   ========================================================================== */

@media (max-width: 991px) {

    /* Hero & Search Fixes */
    .landing-hero {
        padding: 30px 10px !important;
        margin-bottom: 20px !important;
        border-radius: 0 !important;
        /* Full width look on mobile */
    }

    .landing-hero-content {
        padding: 0 !important;
    }

    .landing-hero-title {
        font-size: 1.5rem !important;
        padding: 0 10px;
    }

    .landing-hero-subtitle {
        font-size: 0.9rem !important;
        margin-bottom: 1.5rem !important;
        padding: 0 10px;
    }

    /* Search Form Stacking & Clipping */
    .search-container-inner {
        padding: 0 5px !important;
    }

    .search-main-form {
        flex-direction: column !important;
        padding: 15px !important;
        gap: 12px !important;
        background: #fff !important;
        border-radius: 15px !important;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2) !important;
    }

    .search-input-group-query,
    .search-input-group-location {
        height: 50px !important;
        border: 1px solid #ddd !important;
        border-radius: 8px !important;
        width: 100% !important;
    }

    .search-submit-btn {
        width: 100% !important;
        height: 50px !important;
        border-radius: 8px !important;
    }

    /* Dashboard/CTA spacing under search bar in Hero */
    .hero-dashboard,
    .landing-hero-cta,
    .lumiere-dashboard-container,
    .gamification-welcome-box,
    .welcome-dashboard-container,
    [id*="gamification-container"] {
        padding: 5px 10px !important;
        margin-top: 50px !important;
        /* Force space from search form */
        clear: both !important;
        display: block !important;
        position: relative !important;
        z-index: 5 !important;
    }

    .profile-summary-card {
        padding: 20px 15px !important;
        margin: 0 auto !important;
        width: 100% !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
    }

    .activity-stats {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }
}

/* ==========================================================================
   Carousel (Landing) - Scroll-snap Slider for Mobile
   ========================================================================== */

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    /* ── Container ── */
    .poi-carousel-container {
        position: relative;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        /* clip the scrolling slider's siblings from going outside */
        /* No overflow:hidden on height — bullets must be visible below the slider */
    }

    /* Wrapper around slider + arrows to contain absolute positioning */
    .poi-carousel-slider-wrap {
        position: relative;
        overflow: hidden;
        width: 100%;
        height: 350px;
    }

    /* ── 3D Slider Container for Mobile ── */
    .poi-carousel.slider {
        display: flex !important;
        justify-content: center;
        align-items: center;
        height: 350px;
        position: relative;
        perspective: 1200px;
        transform-style: preserve-3d;
        overflow: visible !important;
    }

    .poi-card-wrapper {
        position: absolute !important;
        top: 0;
        bottom: 0;
        left: 50% !important;
        margin: auto !important;
        margin-left: -140px !important;
        width: 280px !important;
        max-width: 80vw !important;
        height: max-content;
        /* Let JS control transform and opacity inline! No !important overrides here */
        pointer-events: auto;
        transition: transform 0.6s ease-out, opacity 0.6s ease-out, box-shadow 0.6s ease-out;
    }

    /* ── Arrow buttons: positioned over the slider ── */
    .carousel-navigation {
        position: absolute;
        top: 175px;
        /* vertical center of 350px slider */
        left: 0;
        right: 0;
        transform: translateY(-50%);
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        pointer-events: none;
        z-index: 100;
        padding: 0 8px;
    }

    .carousel-btn {
        pointer-events: auto;
        width: 42px;
        height: 42px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.95);
        border: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
        font-size: 1.1rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--primary-color, #ff8c42);
    }

    /* ── Bullet dots ── */
    #carousel-bullets {
        display: flex !important;
        justify-content: center;
        gap: 8px;
        padding: 20px 0 6px;
        position: relative;
        z-index: 150;
    }

    .carousel-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        border: none;
        background: rgba(0, 0, 0, 0.2);
        cursor: pointer;
        padding: 0;
        transition: background 0.3s;
    }

    .carousel-dot.active {
        background: var(--primary-color, #ff8c42);
    }

    /* Card inner styling on mobile */
    .poi-discovery-card {
        height: 100%;
        overflow: hidden;
    }

    .poi-discovery-image {
        height: 250px;
    }
}




@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }

    .desktop-only {
        display: block !important;
    }
}

/* ==========================================================================
   SearchUi Plugin Overrides
   ========================================================================== */

@media (max-width: 768px) {

    /* Search Form Stacking */
    .search-main-form {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .search-input-group-query,
    .search-input-group-location,
    .search-submit-btn {
        width: 100% !important;
        max-width: none !important;
    }

    /* Filter Bar */
    .search-status-bar {
        flex-wrap: wrap !important;
        height: auto !important;
        padding: 10px !important;
    }

    .search-active-badges {
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
    }

    /* SearchUi Hero Refinements */
    .search-hero-wrapper {
        text-align: center !important;
        padding: 40px 20px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }

    .search-hero-title-text {
        color: #fff !important;
        text-shadow: var(--hero-text-shadow) !important;
        font-size: 1.8rem !important;
        margin-bottom: 20px !important;
        width: 100% !important;
        text-align: center !important;
        font-weight: 800 !important;
    }

    .search-hero-subtitle {
        color: #fff !important;
        text-shadow: var(--hero-subtitle-shadow) !important;
        font-size: 1rem !important;
        max-width: 90%;
        margin: 0 auto !important;
        text-align: center !important;
        line-height: 1.4 !important;
    }

    /* Search Result Items */
    .search-result-item {
        flex-direction: column !important;
        padding: 15px !important;
    }

    .result-image {
        width: 100% !important;
        height: 180px !important;
        margin-bottom: 15px;
        position: relative;
        overflow: hidden;
        background: #f0f0f0;
        /* See the box even if map empty */
    }

    .poi-minimap.result-minimap {
        width: 100% !important;
        height: 180px !important;
        /* Force height here too */
        display: block !important;
    }

    .search-result-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
}

/* ==========================================================================
   PoiEdit Plugin Overrides
   ========================================================================== */

@media (max-width: 768px) {

    /* Form sections */
    .field-row {
        flex-direction: column !important;
        gap: 15px !important;
    }

    .field-row .field {
        width: 100% !important;
    }

    /* Opening Hours Grid -> Column */
    .opening-hours-header {
        display: none !important;
        /* Hide header, label inputs instead */
    }

    .opening-hour-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        padding: 15px !important;
        background: #f9f9f9;
        margin-bottom: 10px;
        border: 1px solid #eee;
    }

    .opening-hour-row>* {
        width: 100% !important;
    }

    /* Add labels via pseudo-elements if needed, or rely on icons/placeholder */
}

/* ==========================================================================
   Meteo Plugin Overrides
   ========================================================================== */

@media (max-width: 480px) {

    .meteo-forecast-list,
    .forecast-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .meteo-widget__current {
        flex-direction: column !important;
        text-align: center;
    }
}

/* ==========================================================================
   Mobile Layout — Container Padding Reset & Full-Bleed
   ========================================================================== */

@media (max-width: 991px) {

    /* Supprime les padings latéraux des conteneurs principaux pour que
       le contenu plein-écran (carte, hero) touche vraiment les bords */
    .main-container,
    .wrapper {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Utilitaire : ajouter .content-padded aux sections qui ont besoin de marges */
    .content-padded {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Hero/banners : plein bord */
    .landing-hero,
    .search-hero-wrapper,
    .poi-detail-header,
    .page-hero {
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 0 !important;
        width: 100% !important;
    }

    /* Cards sans border-radius en mobile */
    .module-card {
        border-radius: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* ==========================================================================
   Cartes Leaflet — Pleine Largeur Mobile
   Utilise des sélecteurs PRÉCIS pour éviter de cibler les boutons
   ========================================================================== */

@media (max-width: 991px) {

    /* Conteneurs de carte Leaflet connus */
    .leaflet-container,
    #home-map-container,
    #poi-map,
    #home-map,
    .search-map-container,
    .universal-map-container {
        width: 100% !important;
        max-width: 100vw !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 0 !important;
    }

    /* Minimaps des résultats (dans les cartes résultat) */
    .poi-minimap,
    .result-minimap {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
    }

    /* =============================================================
       Boutons Layer sur la carte (Plan / Nuit / Satellite)
       IMPORTANT : les remettre en taille compacte — mon sélecteur
       [class*="-map"] précédent les avait mis à width:100%
       ============================================================= */
    .map-layer-btn,
    .search-map-layer-btn {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex: 0 0 36px !important;
    }

    /* Conteneur des boutons layer : affichage horizontal compact */
    .search-map-controls {
        display: flex !important;
        flex-direction: column !important;
        gap: 4px !important;
        width: auto !important;
    }

    /* Légende Leaflet : réduire la taille sur mobile */
    .leaflet-control-attribution {
        font-size: 9px !important;
        padding: 2px 4px !important;
        max-width: 60vw !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        opacity: 0.7 !important;
    }

    /* Réduire les contrôles Leaflet (zoom +/-) */
    .leaflet-control-zoom a {
        width: 28px !important;
        height: 28px !important;
        line-height: 28px !important;
        font-size: 14px !important;
    }
}

/* ==========================================================================
   Header Mobile — Température / Burger
   ========================================================================== */

@media (max-width: 991px) {

    /* Séparer clairement le widget météo du burger */
    .meteo-widget-compact {
        margin-right: 8px !important;
        flex-shrink: 0 !important;
        max-width: 60px !important;
    }

    /* Sur très petits écrans (< 380px) : cacher le texte de température, garder icône */
    @media (max-width: 380px) {

        .meteo-widget-compact__temp {
            display: none !important;
        }

        .meteo-widget-compact {
            max-width: 32px !important;
        }
    }
}