/**
 * VI Search Enhancer — Styles des suggestions FiboSearch.
 *
 * Design inspiré de la maquette : cartes produit aérées avec
 * image large, nom en gras, prix, et bouton "Ajouter".
 *
 * @package VI_Search_Enhancer
 */

/* ---------------------------------------------------------------
 * 0. MASQUER LES ÉLÉMENTS NON-PRODUITS (catégories, headlines)
 * ------------------------------------------------------------- */

/* Masquer les titres de sections ("Catégories", "Produits") */
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-headline {
    display: none !important;
}

/* Masquer les suggestions de catégories / taxonomies */
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-tax {
    display: none !important;
}

/* ---------------------------------------------------------------
 * 1. DROPDOWN — ÉLARGIR ET AÉRER
 * ------------------------------------------------------------- */

.dgwt-wcas-suggestions-wrapp {
    min-width: 480px !important;
    max-width: 600px !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12) !important;
    border: 1px solid #e0e0e0 !important;
    overflow: hidden;
}

/* ---------------------------------------------------------------
 * 2. CHAQUE SUGGESTION PRODUIT — LAYOUT CARTE
 * ------------------------------------------------------------- */

.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    padding: 14px 16px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    gap: 14px !important;
    min-height: 80px !important;
    background: #fff !important;
    transition: background-color 0.15s ease !important;
    text-decoration: none !important;
}

/* Supprimer tout soulignement hérité du lien parent FiboSearch */
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product *,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product a,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-content-wrapp,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-st,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-st-title,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-sp,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-meta,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .vise-atc-wrap,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .vise-atc-btn,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .vise-atc-label,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .vise-qty-btn,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .vise-qty-input,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .woocommerce-Price-amount {
    text-decoration: none !important;
}

.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product:last-child {
    border-bottom: none !important;
}

.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product:hover {
    background-color: #fafafa !important;
}

/* ---------------------------------------------------------------
 * 3. IMAGE PRODUIT — PLUS GRANDE ET VISIBLE
 * ------------------------------------------------------------- */

.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-si {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    width: 70px !important;
    height: 70px !important;
    overflow: hidden !important;
    border-radius: 6px !important;
    background: #f5f5f5 !important;
}

.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-si img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    display: block !important;
}

/* ---------------------------------------------------------------
 * 4. CONTENU TEXTE — NOM + PRIX
 * ------------------------------------------------------------- */

.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-content-wrapp {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: flex-start !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    gap: 2px !important;
}

/* Nom du produit — bien lisible, gras */
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-st {
    margin: 0 !important;
    padding: 0 !important;
}

.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-st-title {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #1a1a1a !important;
    line-height: 1.3 !important;
    letter-spacing: 0.01em !important;
    text-transform: uppercase !important;
}

/* Prix — visible, sous le nom */
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-sp,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-meta {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: #1a1a1a !important;
    line-height: 1.3 !important;
    margin-top: 2px !important;
}

/* ---------------------------------------------------------------
 * 5. BOUTON "AJOUTER AU PANIER"
 * ------------------------------------------------------------- */

.vise-atc-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 6px;
    flex-shrink: 0;
}

/* ---------------------------------------------------------------
 * 5b. SÉLECTEUR DE QUANTITÉ
 * ------------------------------------------------------------- */

.vise-qty-wrap {
    display: inline-flex;
    align-items: center;
    border: 1.5px solid #ccc;
    border-radius: 5px;
    overflow: hidden;
    height: 30px;
}

.vise-qty-btn {
    width: 26px;
    height: 100%;
    border: none !important;
    background: #f5f5f5 !important;
    color: #333 !important;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    line-height: 1;
    box-shadow: none !important;
    transition: background-color 0.15s ease;
}

.vise-qty-btn:hover {
    background: #e8e8e8 !important;
}

.vise-qty-input {
    width: 32px;
    height: 100%;
    border: none !important;
    border-left: 1px solid #ccc !important;
    border-right: 1px solid #ccc !important;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    background: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
    -moz-appearance: textfield;
    box-shadow: none !important;
    outline: none !important;
}

.vise-qty-input::-webkit-outer-spin-button,
.vise-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.vise-atc-btn,
.dgwt-wcas-suggestions-wrapp .vise-atc-btn,
.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion .vise-atc-btn,
button.vise-atc-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    padding: 6px 18px !important;
    border: 1.5px solid #e63946 !important;
    border-radius: 5px !important;
    background-color: #e63946 !important;
    color: #fff !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    transition: all 0.2s ease !important;
    position: relative !important;
    z-index: 10 !important;
    text-decoration: none !important;
    box-shadow: none !important;
    height: 30px !important;
}

.vise-atc-btn:hover,
.dgwt-wcas-suggestions-wrapp .vise-atc-btn:hover,
button.vise-atc-btn:hover {
    background-color: #c62d39 !important;
    border-color: #c62d39 !important;
    color: #fff !important;
    transform: scale(1.02);
}

.vise-atc-btn:active {
    transform: scale(0.97);
}

.vise-atc-btn:focus {
    outline: 2px solid #e63946;
    outline-offset: 2px;
}

.vise-atc-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* --- États du bouton --- */

/* Chargement */
.vise-atc-btn.vise-atc-loading,
button.vise-atc-btn.vise-atc-loading {
    background-color: #ddd !important;
    border-color: #ccc !important;
    color: #888 !important;
    pointer-events: none !important;
    opacity: 0.8 !important;
}

.vise-atc-btn.vise-atc-loading .vise-atc-icon {
    animation: vise-spin 0.8s linear infinite;
}

/* Succès */
.vise-atc-btn.vise-atc-success,
.vise-atc-btn.added,
button.vise-atc-btn.vise-atc-success,
button.vise-atc-btn.added {
    background-color: #2d6a4f !important;
    border-color: #2d6a4f !important;
    color: #fff !important;
}

/* Erreur */
.vise-atc-btn.vise-atc-error,
button.vise-atc-btn.vise-atc-error {
    background-color: #d00000 !important;
    border-color: #d00000 !important;
    color: #fff !important;
}

/* --- Animation spinner --- */
@keyframes vise-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------
 * 6. INTÉGRATION DANS LA SUGGESTION FIBOSEARCH
 * ------------------------------------------------------------- */

/* Forcer le layout flex sur chaque suggestion injectée. */
.dgwt-wcas-suggestion.vise-btn-injected.dgwt-wcas-suggestion-product {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
}

/* Zone texte+bouton : colonne verticale */
.dgwt-wcas-suggestion.vise-btn-injected.dgwt-wcas-suggestion-product .dgwt-wcas-content-wrapp {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

/* ---------------------------------------------------------------
 * 7. "VOIR TOUS LES PRODUITS" — STYLE ÉPURÉ
 * ------------------------------------------------------------- */

.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-more {
    padding: 12px 16px !important;
    text-align: center !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #e63946 !important;
    background: #fafafa !important;
    border-top: 1px solid #eee !important;
}

.dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-more:hover {
    background: #f0f0f0 !important;
    color: #c1121f !important;
}

/* ---------------------------------------------------------------
 * 8. NOTIFICATION TOAST
 * ------------------------------------------------------------- */

.vise-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: 8px;
    background-color: #1d3557;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 999999;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 400px;
}

.vise-toast--visible {
    opacity: 1;
    transform: translateY(0);
}

.vise-toast--success {
    background-color: #2d6a4f;
}

.vise-toast--error {
    background-color: #d00000;
}

.vise-toast svg {
    flex-shrink: 0;
}

.vise-toast-cart-link {
    color: #fff;
    text-decoration: underline;
    font-weight: 600;
    margin-left: 6px;
    white-space: nowrap;
}

.vise-toast-cart-link:hover {
    color: #a8dadc;
}

/* ---------------------------------------------------------------
 * 9. ANIMATION BOUNCE SUR LE COMPTEUR PANIER
 * ------------------------------------------------------------- */

@keyframes vise-bounce {
    0%, 100% { transform: scale(1); }
    30%      { transform: scale(1.35); }
    60%      { transform: scale(0.9); }
}

.vise-cart-bounce {
    animation: vise-bounce 0.6s ease;
}

/* ---------------------------------------------------------------
 * 10. MINI-PANIER LATÉRAL — CORRECTIONS DE Z-INDEX ET CROIX
 * ------------------------------------------------------------- */

/* Le .minicart-aside est à l'intérieur de .header-wrapper (z-index: 99).
   La barre rouge info a z-index: 9999, donc elle recouvre le header-wrapper.
   On booste le z-index du header-wrapper UNIQUEMENT quand le panier est ouvert
   pour le passer au-dessus de la barre rouge. */
.header-wrapper:has(.minicart-aside:not(.hide)) {
    z-index: 10000 !important;
}

/* Le panier lui-même au-dessus de tout dans le header-wrapper */
.minicart-aside {
    z-index: 100000 !important;
}

/* Si l'admin-bar WP est visible, décaler le panneau vers le bas */
body.admin-bar .minicart-aside {
    top: 32px !important;
}

/* Donner des dimensions au bouton fermer (×) qui a width/height: 0 par défaut */
.minicart-aside__header .toggle-close {
    width: 30px !important;
    height: 30px !important;
    position: relative !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ---------------------------------------------------------------
 * 11. MASQUER CRISP CHAT QUAND LE MINI-PANIER EST OUVERT
 * ------------------------------------------------------------- */

/* Quand .minicart-aside n'a PAS la classe "hide", le panneau est ouvert */
body:has(.minicart-aside:not(.hide)) .crisp-client {
    display: none !important;
}

/* ---------------------------------------------------------------
 * 12. RESPONSIVE
 * ------------------------------------------------------------- */

@media (max-width: 768px) {
    .dgwt-wcas-suggestions-wrapp {
        min-width: 320px !important;
        max-width: 100vw !important;
        left: 0 !important;
        right: 0 !important;
    }

    .dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product {
        padding: 10px 12px !important;
        gap: 10px !important;
        min-height: 65px !important;
    }

    .dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-si {
        width: 55px !important;
        height: 55px !important;
    }

    .dgwt-wcas-suggestions-wrapp .dgwt-wcas-suggestion-product .dgwt-wcas-st-title {
        font-size: 13px !important;
    }

    .vise-atc-btn {
        padding: 5px 12px !important;
        font-size: 12px !important;
    }

    .vise-qty-wrap {
        height: 26px;
    }

    .vise-qty-btn {
        width: 22px;
        font-size: 14px;
    }

    .vise-qty-input {
        width: 28px;
        font-size: 12px;
    }

    .vise-toast {
        left: 10px;
        right: 10px;
        bottom: 10px;
        max-width: none;
        font-size: 13px;
    }
}