/* --- AFFICHAGE DES FILTRES SUR MOBILE (HIÉRARCHIE STRICTE) --- */
@media (max-width: 767px) {
    
    /* 1. On suit la hiérarchie exacte de la capture pour forcer l'affichage du parent */
    body#category #content-wrapper #main #js-product-list-filters-container #search_filters_wrapper.hidden-sm-down {
        display: block !important;
    }

    /* 2. On applique le design en liste sur le bloc des filtres interne */
    body#category #content-wrapper #main #js-product-list-filters-container #search_filters {
        display: flex !important; 
        flex-direction: column !important;
        gap: 20px !important;
        padding: 15px !important;
        background: #f8f9fa;
        border-radius: 5px;
        margin-bottom: 25px;
    }

    /* 3. On gère le comportement d'accordéon des facettes */
    body#category #search_filters .facet {
        padding: 12px 0;
        border-bottom: 1px solid #e5e5e5;
        margin: 0 !important;
    }
    
    body#category #search_filters .facet .title {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
    }

    body#category #search_filters .facet .title .facet-title {
        margin: 0;
        font-weight: 600;
        font-size: 14px;
        text-transform: uppercase;
    }

    /* 4. Sécurité pour masquer les boutons OK natifs du mobile */
    #search_filter_controls {
        display: none !important;
    }
}

/* ==========================================================================
   RECHERCHE PLEIN ÉCRAN (OVERLAY ROOT)
   ========================================================================== */

/* Le widget est désormais un enfant direct de <body> : il prend tout l'écran sans contrainte */
#search_widget.search-widgets {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    background: rgba(255, 255, 255, 0.98) !important; /* Magnifique fond blanc transparent */
    z-index: 999999 !important; /* Priorité absolue */
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    
    /* Gestion de l'affichage */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Affichage au clic */
#search_widget.search-widgets.is-open {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Formulaire centré */
#search_widget.search-widgets form {
    position: relative !important;
    width: 90% !important;
    max-width: 650px !important;
    border-bottom: 2px solid #232323 !important;
    padding-bottom: 10px !important;
    background: transparent !important;
    transform: translateY(-30px);
    transition: transform 0.4s ease;
}

#search_widget.search-widgets.is-open form {
    transform: translateY(0);
}

/* Input de texte épuré */
#search_widget.search-widgets input[type="text"] {
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    font-size: 28px !important;
    color: #232323 !important;
    outline: none !important;
    box-shadow: none !important;
    padding-right: 50px !important;
}

/* Bouton loupe de validation */
#search_widget .saoya-submit-search {
    background: transparent !important;
    border: none !important;
    position: absolute !important;
    right: 0 !important;
    bottom: 10px !important;
    cursor: pointer !important;
}
#search_widget .saoya-submit-search i {
    font-size: 32px !important;
    color: #232323 !important;
}

/* Bouton de fermeture (La croix ×) placé en haut à droite de l'écran */
#search_widget .saoya-close-search {
    position: absolute !important;
    top: 30px !important;
    right: 40px !important;
    background: transparent !important;
    border: none !important;
    font-size: 55px !important;
    color: #777 !important;
    cursor: pointer !important;
    line-height: 1 !important;
    transition: color 0.2s ease;
}
#search_widget .saoya-close-search:hover {
    color: #000 !important;
}

/* Bloquer le défilement arrière */
body.search-overlay-active {
    overflow: hidden !important;
}
/* On cible l'icône générée par le module dans la grille */
.wishlist-button button i.material-icons,
.wishlist-button-add i.material-icons {
    /* Propriété moderne : le navigateur remplace le texte par le SVG */
    content: url('/themes/saoya/assets/img/picto-coeur.svg') !important;
    
    width: 22px !important;
    height: 22px !important;
    vertical-align: middle;
    transition: transform 0.2s ease;
}

/* Effet de survol propre */
.wishlist-button button:hover i.material-icons,
.wishlist-button-add:hover i.material-icons {
    transform: scale(1.15);
}

/* Nettoyage cosmétique du bouton du module */
.wishlist-button button,
.wishlist-button-add {
    background: transparent !important;
    border: none !important;
    padding: 5px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

.sticky-header-wrapper.is-open-sticky {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    z-index: 9999 !important;
    background-color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
}


/* ---------------------------------------- */

/* ========================================================
   MODALE DE ZOOM PRODUIT (PRODUCT-MODAL) - CORRECTIF ANTI-DÉBORDEMENT
   ======================================================== */

/* Remplacement de vw par % pour éviter le conflit avec la barre de défilement */
#product-modal .modal-dialog {
    max-width: 95% !important;
    width: 95% !important;
    margin: 2.5vh auto !important;
    display: flex;
    align-items: center;
    min-height: 95vh;
}

#product-modal .modal-content {
    background: transparent;
    border: none;
    box-shadow: none;
    width: 100%;
}

/* Grille Flexbox */
#product-modal .custom-modal-body {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: space-between;
    gap: 20px;
    height: 95vh;
    max-width: 100% !important;
    overflow: hidden !important; /* Empêche tout dépassement global */
    margin-left: 0 !important;
}

/* Zone de la grande image (gauche) */
#product-modal .custom-modal-figure {
    margin: 0;
    flex: 1 1 auto; /* Permet au bloc de grandir ET de rétrécir */
    min-width: 0 !important; /* LA MAGIE EST ICI : force Flexbox à rétrécir l'image si besoin */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

#product-modal .custom-modal-picture {
    width: 100% !important;
    max-width: 100% !important;
    height: calc(100% - 40px);
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0 !important;
}

/* L'image principale elle-même */
#product-modal .js-modal-product-cover {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    margin: 0 auto;
    display: block;
}

#product-modal .image-caption {
    margin-top: 15px;
    font-weight: bold;
    text-align: center;
    height: 25px;
}

/* Zone des vignettes (droite) */
#product-modal .custom-modal-aside {
    flex: 0 0 130px !important; /* Ne peut ni grandir, ni rétrécir */
    width: 130px !important;
    min-width: 130px !important; /* Interdit à Flexbox de l'écraser */
    max-width: 130px !important;
    box-sizing: border-box !important;
    border-left: 1px solid #eee !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    background: #fff; /* Cache ce qui pourrait baver en dessous */
}

#product-modal .js-modal-mask {
    width: 100%;
}

/* Liste des vignettes */
#product-modal .js-modal-product-images {
    width: 100% !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 0;
    margin: 0;
    list-style: none;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden !important; /* Coupe tout débordement horizontal fantôme */
}

#product-modal .thumb-container {
    display: block;
    width: 100% !important;
    max-width: 90px !important; /* La vignette a la place de respirer dans les 130px */
    margin: 0;
    box-sizing: border-box !important;
}

#product-modal .modal-content .modal-body .mask {
    overflow: visible !important;
    max-height: none !important;
    position: static !important;
}

#product-modal .modal-content .modal-body .product-images img.thumb {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 120px !important; /* Évite qu'elles ne deviennent trop hautes */
    object-fit: contain !important;
    display: block !important;
    margin: 0 auto !important;
}

/* Les petites images (vignettes) */
#product-modal .thumb-container img {
    cursor: pointer;
    border: 2px solid #ddd;
    border-radius: 4px;
    width: 100%;
    height: auto;
    object-fit: contain;
    background: #fff;
    transition: all 0.2s ease;
}

#product-modal .thumb-container img:hover,
#product-modal .thumb-container img.selected {
    border-color: #333;
}

/* Résolution Mobile */
@media (max-width: 768px) {
    #product-modal .custom-modal-body {
        flex-direction: column;
        height: auto;
        min-height: 90vh;
        overflow-y: auto !important;
    }

    #product-modal .custom-modal-picture {
        height: 60vh;
    }

    #product-modal .custom-modal-aside {
        flex: 1 1 auto;
        max-width: 100%;
        border-left: none;
        padding-left: 0;
        border-top: 1px solid #eee;
        padding-top: 15px;
        width: 100%;
    }

    #product-modal .js-modal-product-images {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 10px;
    }

    #product-modal .thumb-container {
        width: 80px;
        flex: 0 0 80px;
    }
}
