/* PANEL GLOBAL */
#msaify-ai-panel {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40px;
}

.msaify-ai-panel--open {
    display: flex !important;
}

/* DIALOG */
.msaify-ai-panel__dialog {
    width: 90%;
    max-width: 1180px;
    background: radial-gradient(circle at top left, #ffffff 0, #f9fafb 40%, #f5f5f7 100%);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 26px 80px rgba(15, 23, 42, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.9);
    padding: 14px 18px 16px;
}

/* TOP BAR */
.msaify-ai-panel__top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px 10px;
    border-bottom: 1px solid rgba(15,23,42,0.04);
}

/* INPUT */
#msaify-ai-input {
    flex: 1;
    height: 46px;
    padding: 0 18px;
    font-size: 15px;
    border-radius: 999px;
    border: 1px solid rgba(148,163,184,0.6);
    background: rgba(255,255,255,0.95);
    box-shadow: 0 1px 2px rgba(15,23,42,0.06);
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

#msaify-ai-input::placeholder {
    color: #a0a8b8;
}

#msaify-ai-input:focus {
    background: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37,99,235,0.35), 0 16px 40px rgba(15,23,42,0.22);
}

/* CLOSE BUTTON */
#msaify-ai-close {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(148,163,184,0.35);
    background: rgba(248,250,252,0.96);
    border-radius: 999px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    padding: 0;
    margin-right: 4px;
    transition: background .15s ease, transform .1s ease, box-shadow .1s ease, color .15s ease;
}

#msaify-ai-close:hover {
    background: #e5e9f0;
    color: #0f172a;
    box-shadow: 0 6px 18px rgba(15,23,42,0.20);
    transform: translateY(-1px);
}

/* BODY = 2 COLS (PAS de min-height pour éviter la grosse zone vide) */
.msaify-ai-panel__body {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.2fr);
    max-height: 70vh;
    padding: 14px 14px 8px;
    column-gap: 28px;
    overflow-y: auto;
}

/* COLUMN */
.msaify-ai-panel__col {
    padding: 2px 4px 10px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148,163,184,0.7) transparent;
}

.msaify-ai-panel__col::-webkit-scrollbar {
    width: 6px;
}
.msaify-ai-panel__col::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.8);
    border-radius: 999px;
}
.msaify-ai-panel__col::-webkit-scrollbar-track {
    background: transparent;
}

/* TITRES */
.msaify-ai-panel__col-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #9ca3af;
    margin-bottom: 10px;
}

/* COL PRODUITS */
.msaify-ai-panel__col--products {
    border-right: 1px solid rgba(148,163,184,0.20);
    padding-right: 6px;
}

/* COL SUGGESTIONS */
.msaify-ai-panel__col--suggestions {
    padding-left: 6px;
}

/* LISTE PRODUITS (mode une ligne compact) */
.msaify-ai-list--products {
    margin-top: 4px;
    padding-top: 0.75rem;
}

.msaify-ai-product {
    margin: 0 0 0.75rem;
}

.msaify-ai-product__inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 12px;
    transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.12s ease;
    cursor: pointer;
}

.msaify-ai-product__inner:hover {
    background: #f4f7f7;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15,23,42,0.08);
}

/* IMAGE PRODUIT */
.msaify-ai-product__image {
    flex: 0 0 60px;
    max-width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msaify-ai-product__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(15,23,42,0.08);
}

/* CONTENU PRODUIT */
.msaify-ai-product__content {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-auto-rows: auto;
    column-gap: 0.75rem;
    row-gap: 0.15rem;
    align-items: center;
}

/* Nom */
.msaify-ai-product__name,
.msaify-ai-product-title {
    grid-column: 1 / 2;
    margin: 0;
    font-size: 15px;
    line-height: 1.3;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* SKU */
.msaify-ai-product__sku,
.msaify-ai-product-sku {
    grid-column: 1 / 2;
    font-size: 11px;
    line-height: 1.2;
    color: #7b848f;
}

/* Lien "Voir" */
.msaify-ai-product__link,
.msaify-ai-product-link {
    grid-column: 1 / 2;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #1b7c7c;
}

/* Prix à droite */
.msaify-ai-product__price,
.msaify-ai-product-price {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
    text-align: right;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    color: #2563eb;
}

/* LISTE SUGGESTIONS */
.msaify-ai-list--suggestions {
    list-style: none;
    margin: 0;
    padding: 0;
}

.msaify-ai-list--suggestions li {
    font-size: 14px;
    color: #1f2937;
    margin-bottom: 6px;
    line-height: 1.35;
    padding: 2px 2px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s ease, color .12s ease, transform .08s ease;
}

.msaify-ai-list--suggestions li:hover {
    background: rgba(219,234,254,0.7);
    color: #1d4ed8;
    transform: translateX(1px);
}

/* FOOTER "Voir tous les résultats" */
.msaify-ai-panel__footer {
    border-top: 1px solid rgba(148,163,184,0.20);
    padding: 11px 18px 6px;
    display: flex;
    justify-content: flex-end;
}

.msaify-ai-panel__footer a {
    border-radius: 999px;
    padding: 7px 18px;
    background: #2563eb;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .16em;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(37,99,235,0.40);
    transition: background .15s ease, box-shadow .15s ease, transform .08s ease;
}

.msaify-ai-panel__footer a:hover {
    background: #1d4ed8;
    box-shadow: 0 13px 30px rgba(37,99,235,0.55);
    transform: translateY(-1px);
}

/* ----------------------------------------------------
   Mobile : masquer la colonne suggestions
   et supprimer la séparation
---------------------------------------------------- */
@media (max-width: 768px) {

    .msaify-ai-panel__body {
        grid-template-columns: 1fr !important;
        column-gap: 0;
    }

    .msaify-ai-panel__col--suggestions {
        display: none !important;
        border-left: none !important;
    }

    .msaify-ai-panel__col--products {
        width: 100% !important;
        flex: 1 1 100% !important;
        border-right: none !important;
    }

    .msaify-ai-panel__body::before,
    .msaify-ai-panel__body::after,
    .msaify-ai-panel__col--products::before,
    .msaify-ai-panel__col--suggestions::before {
        content: none !important;
        display: none !important;
    }

    .msaify-ai-product__inner {
        gap: 0.75rem;
        padding: 0.5rem 0.6rem;
    }

    .msaify-ai-product__content {
        grid-template-columns: minmax(0, 1fr);
    }

    .msaify-ai-product__price,
    .msaify-ai-product-price {
        grid-column: 1 / -1;
        grid-row: auto;
        text-align: left;
        margin-top: 0.15rem;
    }
}

/* ============================
   ÉTAT "EMPTY" (JS ajoute
   .msaify-ai-panel--empty)
   ============================ */

/* Quand panel vide : on masque complètement le body (2 colonnes) */
#msaify-ai-panel.msaify-ai-panel--empty .msaify-ai-panel__body {
    display: none;
}

/* Header plus clean + boîte plus compacte */
#msaify-ai-panel.msaify-ai-panel--empty .msaify-ai-panel__top {
    border-bottom: none;
    margin-bottom: 0;
}

#msaify-ai-panel.msaify-ai-panel--empty .msaify-ai-panel__dialog {
    padding-bottom: 32px;
}

/* ============================
   LOADER (décalé plus à gauche)
   ============================ */

#msaify-ai-panel.msaify-ai-panel--loading .msaify-ai-panel__top {
    position: relative;
}

#msaify-ai-panel.msaify-ai-panel--loading .msaify-ai-panel__top::after {
    content: "";
    position: absolute;
    /* plus à gauche (avant c'était trop collé au X) */
    right: 80px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border-radius: 999px;
    border: 2px solid #9ca3af;
    border-top-color: transparent;
    animation: msaify-ai-spin 0.7s linear infinite;
}

@keyframes msaify-ai-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* réserve un peu de place dans l'input quand loader actif */
#msaify-ai-panel.msaify-ai-panel--loading #msaify-ai-input {
    padding-right: 40px;
}
/* =========================================================
   AI Search – Scroll uniquement sur la colonne PRODUITS
   La colonne SUGGESTIONS reste fixe dans le panel
   (override léger, sans casser l'existant)
   ========================================================= */

/* Le body du panel garde une hauteur max mais ne scrolle plus
   en interne : on confie le scroll vertical à la colonne produits. */
.msaify-ai-panel__body {
    max-height: 60vh;
    overflow: hidden;
    align-items: stretch;
}

/* On annule le overflow:auto global sur toutes les colonnes
   si défini plus haut dans le fichier. */
.msaify-ai-panel__col {
    overflow: visible;
}

/* Seule la colonne PRODUITS devient scrollable en interne */
.msaify-ai-panel__col--products {
    max-height: 60vh;
    overflow-y: auto;
}

/* La colonne SUGGESTIONS reste fixe (pas de scroll interne),
   elle suit simplement la hauteur du panel. */
.msaify-ai-panel__col--suggestions {
    overflow: visible;
}

/* ============================
   PROMO PRICE (prix barré)
   ============================ */
.msaify-ai-product__price-old {
    display: inline-block;
    margin-right: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    text-decoration: line-through;
}

.msaify-ai-product__price-current {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    color: #2563eb;
}

/* ============================
   PROMO PRICE (prix barré)
   ============================ */
.msaify-ai-product__price-old {
    display: inline-block;
    margin-right: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    text-decoration: line-through;
}

.msaify-ai-product__price-current {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    color: #2563eb;
}

/* ============================
   PROMO PRICE (prix barré)
   ============================ */
.msaify-ai-product__price-old {
    display: inline-block;
    margin-right: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    text-decoration: line-through;
}

.msaify-ai-product__price-current {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    color: #2563eb;
}

/* ============================
   PROMO PRICE (prix barré)
   ============================ */
.msaify-ai-product__price-old {
    display: inline-block;
    margin-right: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #9ca3af;
    text-decoration: line-through;
}

.msaify-ai-product__price-current {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    color: #2563eb;
}
