
/* ==========================================================
   MERLIN ADVISOR
   CSS PROPRE
   ========================================================== */

.merlin-advisor {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9998;
    font-family: inherit;
}


/* ---------- LANCEUR ---------- */

.merlin-advisor__launcher {
    border: 0;
    border-radius: 999px;
    background: #111;
    color: #fff;
    padding: 12px 18px;
    box-shadow: 0 8px 30px rgba(0,0,0,.20);
    font-weight: 700;
    cursor: pointer;

    display: flex;
    align-items: center;
    gap: 8px;
}

.merlin-advisor__hat {
    font-size: 20px;
}


/* ==========================================================
   PANEL
   ========================================================== */

.merlin-advisor__panel {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,.22);

    overflow: hidden;
}


/* IMPORTANT :
   hidden doit réellement cacher le panel même si display:flex
*/

.merlin-advisor__panel[hidden] {
    display: none !important;
}


/* ---------- HEADER ---------- */

.merlin-advisor__header {
    flex: 0 0 auto;

    background: #111;
    color: #fff;

    padding: 15px 16px;

    display: flex;
    justify-content: space-between;
    align-items: center;
}

.merlin-advisor__header strong {
    display: block;
}

.merlin-advisor__header small {
    display: block;
    opacity: .75;
    margin-top: 2px;
}

.merlin-advisor__close {
    background: none;
    border: 0;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
}


/* ==========================================================
   CONVERSATION
   ========================================================== */

.merlin-advisor__messages {
    padding: 14px;
    background: #f7f7f7;

    overflow-y: auto;
    overflow-x: hidden;

    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.merlin-advisor__message {
    max-width: 88%;

    padding: 10px 12px;
    margin: 0 0 10px;

    border-radius: 14px;

    white-space: pre-wrap;
    line-height: 1.42;
}

.merlin-advisor__message--bot {
    background: #fff;
    border: 1px solid #e5e5e5;
    color: #222;
}

.merlin-advisor__message--user {
    background: #111;
    color: #fff;
    margin-left: auto;
}


/* ==========================================================
   PRODUITS
   ========================================================== */

.merlin-advisor__products {
    padding: 0 12px 5px;
    background: #f7f7f7;

    overflow-y: auto;
    overflow-x: hidden;

    -webkit-overflow-scrolling: touch;
}


/*
 * IMPORTANT :
 * on cible directement la classe du lien produit.
 * On ne laisse plus le thème PrestaShop contrôler sa couleur.
 */

#merlin-advisor a.merlin-advisor__product,
#merlin-advisor a.merlin-advisor__product:link,
#merlin-advisor a.merlin-advisor__product:visited,
#merlin-advisor a.merlin-advisor__product:hover,
#merlin-advisor a.merlin-advisor__product:active,
#merlin-advisor a.merlin-advisor__product:focus {
    display: grid;

    grid-template-columns: minmax(0,1fr) auto;
    gap: 2px 12px;

    padding: 10px 12px;
    margin-bottom: 7px;

    border-radius: 12px;
    border: 1px solid #e6e6e6;

    background: #fff !important;

    color: #222 !important;

    text-decoration: none !important;

    opacity: 1 !important;
}


/*
 * Le thème ne pourra plus mettre strong/span/em en blanc.
 */

#merlin-advisor a.merlin-advisor__product strong,
#merlin-advisor a.merlin-advisor__product span,
#merlin-advisor a.merlin-advisor__product em,
#merlin-advisor a.merlin-advisor__product:hover strong,
#merlin-advisor a.merlin-advisor__product:hover span,
#merlin-advisor a.merlin-advisor__product:hover em,
#merlin-advisor a.merlin-advisor__product:focus strong,
#merlin-advisor a.merlin-advisor__product:focus span,
#merlin-advisor a.merlin-advisor__product:focus em {
    color: #222 !important;
    opacity: 1;
}


/* nom */

#merlin-advisor .merlin-advisor__product strong {
    grid-column: 1;
}


/* prix */

#merlin-advisor .merlin-advisor__product span {
    grid-column: 2;
    font-weight: 700;
}


/* voir le tour */

#merlin-advisor .merlin-advisor__product em {
    grid-column: 1 / -1;

    font-style: normal;
    font-size: 12px;

    color: #777 !important;
}


/* hover volontairement très léger */

#merlin-advisor a.merlin-advisor__product:hover {
    background: #f1f1f1 !important;
    border-color: #d7d7d7 !important;
}

#merlin-advisor a.merlin-advisor__product:hover em {
    color: #555 !important;
}


/* ==========================================================
   FORMULAIRE
   ========================================================== */

.merlin-advisor__form {
    flex: 0 0 auto;

    display: flex;
    gap: 8px;

    padding: 12px;

    border-top: 1px solid #eee;

    background: #fff;
}

.merlin-advisor__form textarea {
    flex: 1 1 auto;

    min-width: 0;

    resize: none;

    border: 1px solid #d8d8d8;
    border-radius: 10px;

    padding: 9px;

    font: inherit;
}

.merlin-advisor__form button {
    flex: 0 0 auto;

    border: 0;
    background: #111;
    color: #fff;

    border-radius: 10px;

    padding: 0 14px;

    font-weight: 700;
    cursor: pointer;
}

.merlin-advisor__form.is-loading {
    opacity: .65;
    pointer-events: none;
}


/* ---------- NOTE ---------- */

.merlin-advisor__note {
    flex: 0 0 auto;

    padding: 0 12px 10px;

    background: #fff;

    font-size: 10px;
    color: #777;
    text-align: center;
}


/* ==========================================================
   INDICATEUR "MERLIN ÉCRIT..."
   ========================================================== */

.merlin-advisor__typing {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 5px;

    min-width: 52px;
    min-height: 32px;

    padding: 7px 12px;
}

.merlin-advisor__typing-dot {
    display: block;

    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: currentColor;

    opacity: .25;

    animation: merlinAdvisorTyping 1.15s infinite ease-in-out;
}

.merlin-advisor__typing-dot:nth-child(2) {
    animation-delay: .16s;
}

.merlin-advisor__typing-dot:nth-child(3) {
    animation-delay: .32s;
}

@keyframes merlinAdvisorTyping {

    0%,
    60%,
    100% {
        opacity: .22;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}


/* ==========================================================
   PC / TABLETTE LARGE
   ========================================================== */

@media (min-width: 769px) {

    .merlin-advisor {
        right: 18px;
        bottom: 18px;
    }


    /*
     * Le panel est fixé DIRECTEMENT au viewport.
     *
     * 5px en haut
     * 5px en bas
     *
     * Il ne dépend donc plus de la position du launcher.
     */

    #merlin-advisor .merlin-advisor__panel {
        position: fixed !important;

        top: 5px !important;
        bottom: 5px !important;
        right: 18px !important;

        width: min(390px, calc(100vw - 36px)) !important;

        height: calc(100dvh - 10px) !important;
        max-height: calc(100dvh - 10px) !important;

        display: flex !important;
        flex-direction: column !important;

        overflow: hidden !important;
    }


    /*
     * LE POINT IMPORTANT :
     *
     * messages = prend l'espace restant
     * products = hauteur limitée
     * form = ne rétrécit JAMAIS
     * note = ne rétrécit JAMAIS
     */

    #merlin-advisor .merlin-advisor__messages {
        flex: 1 1 0 !important;

        height: 0 !important;
        min-height: 100px !important;
        max-height: none !important;

        overflow-y: auto !important;
    }


    #merlin-advisor .merlin-advisor__products {
        flex: 0 1 auto !important;

        min-height: 0 !important;
        max-height: 245px !important;

        overflow-y: auto !important;
    }


    #merlin-advisor .merlin-advisor__form {
        flex: 0 0 auto !important;

        display: flex !important;

        visibility: visible !important;
        opacity: 1 !important;

        position: relative !important;

        top: auto !important;
        bottom: auto !important;
    }


    #merlin-advisor .merlin-advisor__note {
        flex: 0 0 auto !important;
    }
}


/* ==========================================================
   MOBILE
   ========================================================== */

@media (max-width: 768px) {

    .merlin-advisor {
        right: 10px;
        bottom: 85px;
    }


    /*
     * Launcher ouvert quelques secondes.
     */

    .merlin-advisor__launcher {
        height: 48px;
        min-height: 48px;

        max-width: calc(100vw - 20px);

        overflow: hidden;

        white-space: nowrap;

        transition:
            width .35s ease,
            padding .35s ease;
    }


    /*
     * État rond après rétractation.
     */

    .merlin-advisor__launcher.mm-collapsed {
        width: 48px !important;
        min-width: 48px !important;
        max-width: 48px !important;

        height: 48px !important;

        padding-left: 0 !important;
        padding-right: 0 !important;

        justify-content: center !important;
    }


    .merlin-advisor__launcher.mm-collapsed span:not(.merlin-advisor__hat) {
        display: none !important;
    }


    /*
     * Fenêtre mobile.
     */

    #merlin-advisor .merlin-advisor__panel {
        position: fixed !important;

        left: 10px !important;
        right: 10px !important;

        top: 10px !important;
        bottom: 75px !important;

        width: auto !important;

        height: auto !important;
        max-height: none !important;

        display: flex !important;
        flex-direction: column !important;

        overflow: hidden !important;
    }


    #merlin-advisor .merlin-advisor__messages {
        flex: 1 1 0 !important;

        height: 0 !important;
        min-height: 80px !important;

        overflow-y: auto !important;
    }


    #merlin-advisor .merlin-advisor__products {
        flex: 0 1 auto !important;

        min-height: 0 !important;
        max-height: 190px !important;

        overflow-y: auto !important;
    }


    #merlin-advisor .merlin-advisor__form {
        flex: 0 0 auto !important;
    }


    #merlin-advisor .merlin-advisor__note {
        flex: 0 0 auto !important;
    }
}


/* ==========================================================
   PETITS MOBILES
   ========================================================== */

@media (max-width: 420px) {

    #merlin-advisor .merlin-advisor__panel {
        left: 5px !important;
        right: 5px !important;
        top: 5px !important;
        bottom: 70px !important;
    }

    #merlin-advisor .merlin-advisor__products {
        max-height: 160px !important;
    }
}

