/**
 * CSS Mobile FLUIDE - Version optimisée pour les performances
 * Règles essentielles seulement pour une fluidité maximale
 */

/* MOBILE - Styles essentiels uniquement */
@media screen and (max-width: 767px) {
    /* Container modal - Centrage simple et efficace */
    #ps-chatbot-search-modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        display: none; /* Caché par défaut */
        align-items: center !important;
        justify-content: center !important;
        padding: 20px !important;
        z-index: 999999 !important;
        background: rgba(0, 0, 0, 0.6) !important;
    }
    
    /* Quand la modal est visible */
    #ps-chatbot-search-modal[style*="display: flex"],
    #ps-chatbot-search-modal[style*="display:flex"] {
        display: flex !important;
    }
    
    /* Contenu de la modal - FORCE RESPONSIVE avec hauteur contrôlée */
    html body #ps-chatbot-search-modal .ps-chatbot-modal-content,
    body #ps-chatbot-search-modal .ps-chatbot-modal-content,
    #ps-chatbot-search-modal .ps-chatbot-modal-content,
    div.ps-chatbot-modal-content {
        width: calc(100% - 40px) !important;
        max-width: 480px !important;
        min-width: 0 !important;
        height: auto !important;
        max-height: calc(100vh - 60px) !important;
        max-height: calc(100dvh - 60px) !important;
        margin: 0 auto !important;
        border-radius: 12px !important;
        background: white !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        position: relative !important;
        flex-shrink: 0 !important;
    }
    
    /* Suppression FORCÉE de la largeur fixe 1100px avec spécificité maximum */
    html body #ps-chatbot-search-modal .ps-chatbot-modal-content[style*="1100px"],
    html body #ps-chatbot-search-modal .ps-chatbot-modal-content[style*="width: 1100px"],
    html body #ps-chatbot-search-modal .ps-chatbot-modal-content[style*="min-width: 1100px"],
    body #ps-chatbot-search-modal .ps-chatbot-modal-content[style*="1100px"],
    body #ps-chatbot-search-modal .ps-chatbot-modal-content[style*="width: 1100px"],
    body #ps-chatbot-search-modal .ps-chatbot-modal-content[style*="min-width: 1100px"],
    #ps-chatbot-search-modal .ps-chatbot-modal-content[style*="1100px"],
    #ps-chatbot-search-modal .ps-chatbot-modal-content[style*="width: 1100px"],
    #ps-chatbot-search-modal .ps-chatbot-modal-content[style*="min-width: 1100px"] {
        width: calc(100% - 40px) !important;
        min-width: 0 !important;
        max-width: 480px !important;
    }
    
    /* Header mobile */
    #ps-chatbot-search-modal .ps-chatbot-modal-header {
        padding: 16px 20px !important;
        flex-shrink: 0 !important;
    }
    
    /* Body scrollable avec hauteur contrôlée */
    #ps-chatbot-search-modal .ps-chatbot-modal-body {
        flex: 1 !important;
        padding: 16px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        max-height: calc(100vh - 120px) !important;
        max-height: calc(100dvh - 120px) !important;
    }
    
    /* Input de recherche */
    #ps-chatbot-search-modal .ps-chatbot-modal-search-input,
    #ps-chatbot-modal-search-input {
        width: 100% !important;
        font-size: 16px !important;
        box-sizing: border-box !important;
    }
    
    /* Grille de produits - 2 colonnes */
    #ps-chatbot-search-modal .ps-chatbot-products-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    /* Cartes produits */
    #ps-chatbot-search-modal .ps-chatbot-product-card {
        width: 100% !important;
        height: 240px !important;
    }
    
    #ps-chatbot-search-modal .ps-chatbot-product-image {
        width: 100% !important;
        height: 140px !important;
        object-fit: cover !important;
    }
}

/* PETIT MOBILE - Ajustements mineurs avec hauteur adaptée */
@media screen and (max-width: 479px) {
    #ps-chatbot-search-modal {
        padding: 10px !important;
    }
    
    #ps-chatbot-search-modal .ps-chatbot-modal-content {
        width: calc(100% - 20px) !important;
        max-height: calc(100vh - 40px) !important;
        max-height: calc(100dvh - 40px) !important;
    }
    
    #ps-chatbot-search-modal .ps-chatbot-modal-body {
        padding: 12px !important;
        max-height: calc(100vh - 100px) !important;
        max-height: calc(100dvh - 100px) !important;
    }
    
    #ps-chatbot-search-modal .ps-chatbot-product-card {
        height: 200px !important;
    }
    
    #ps-chatbot-search-modal .ps-chatbot-product-image {
        height: 110px !important;
    }
}

/* TRÈS PETIT MOBILE - Protection pour écrans courts */
@media screen and (max-height: 600px) {
    #ps-chatbot-search-modal .ps-chatbot-modal-content {
        max-height: calc(100vh - 30px) !important;
        max-height: calc(100dvh - 30px) !important;
    }
    
    #ps-chatbot-search-modal .ps-chatbot-modal-body {
        max-height: calc(100vh - 90px) !important;
        max-height: calc(100dvh - 90px) !important;
    }
    
    #ps-chatbot-search-modal .ps-chatbot-product-card {
        height: 180px !important;
    }
    
    #ps-chatbot-search-modal .ps-chatbot-product-image {
        height: 100px !important;
    }
}

/* Bloquer le scroll du body quand la modal est ouverte */
body.ps-chatbot-modal-open,
body.modal-open {
    overflow: hidden !important;
}