/* ===========================================================================
   Assistant de chat flottant (API Claude)
   ---------------------------------------------------------------------------
   Feuille autonome, comme whatsapp.css : la bulle est presente sur les deux
   gabarits du site public (site.css et rnb.css/Bootstrap). Elle se place
   juste au-dessus du bouton WhatsApp (24px + 60px + 12px).
   Empilement : 190 comme WhatsApp (sous la visionneuse de la galerie, 200).
   =========================================================================== */

.assist {
    --assist-fonce: #2c2320;   /* espresso */
    --assist-accent: #5c4f44;  /* taupe fonce (contraste AA sur blanc) */
    --assist-lagune: #245448;
    --assist-fond: #f5f2ec;    /* lin pale */
    --assist-trait: #e2dcd1;   /* lin clair */
    --assist-texte: #3b2f29;
    --assist-doux: #756658;

    position: fixed;
    right: 24px;
    bottom: 96px;
    z-index: 190;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

.assist *, .assist *::before, .assist *::after { box-sizing: border-box; }

/* --- Pastille --------------------------------------------------------- */
.assist-bouton {
    display: inline-flex;
    align-items: center;
    gap: 0;
    height: 60px;
    min-width: 60px;
    padding: 0 17px;
    border: 0;
    border-radius: 999px;
    background: var(--assist-accent);
    color: #fffdfa;
    cursor: pointer;
    box-shadow: 0 10px 26px -8px rgb(44 35 32 / .55), 0 2px 6px rgb(0 0 0 / .12);
    transition: gap .3s cubic-bezier(.2, .7, .3, 1), padding .3s cubic-bezier(.2, .7, .3, 1),
                background .25s, transform .2s;
}
.assist-bouton:hover, .assist-bouton:focus-visible {
    background: var(--assist-fonce);
    transform: translateY(-2px);
    gap: 10px;
    padding-right: 22px;
}
.assist-bouton:focus-visible { outline: 3px solid #c8873f; outline-offset: 3px; }
.assist-bouton svg { flex: 0 0 auto; display: block; }
.assist-ic-fermer { display: none !important; }
.assist.ouvert .assist-ic-ouvrir { display: none !important; }
.assist.ouvert .assist-ic-fermer { display: block !important; }

.assist-bouton-texte {
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: .95rem;
    font-weight: 700;
    opacity: 0;
    transition: max-width .3s cubic-bezier(.2, .7, .3, 1), opacity .25s;
}
.assist-bouton:hover .assist-bouton-texte,
.assist-bouton:focus-visible .assist-bouton-texte { max-width: 160px; opacity: 1; }
.assist.ouvert .assist-bouton-texte { display: none; }
.assist.ouvert .assist-bouton { gap: 0; padding-right: 17px; }

/* --- Panneau ---------------------------------------------------------- */
.assist-panneau {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: min(370px, calc(100vw - 32px));
    height: min(540px, calc(100vh - 200px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fffdfa;
    border: 1px solid var(--assist-trait);
    border-radius: 16px;
    box-shadow: 0 26px 50px -20px rgb(44 35 32 / .55);
    animation: assist-entree .18s ease-out;
}
.assist-panneau[hidden] { display: none !important; }
@keyframes assist-entree { from { transform: translateY(10px); opacity: .6; } to { transform: none; opacity: 1; } }

.assist-tete {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px 12px 14px;
    background: var(--assist-fonce);
    color: #fffdfa;
}
.assist-avatar {
    flex: 0 0 auto;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--assist-lagune);
}
.assist-titre { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.assist-titre strong { font-size: 14.5px; }
.assist-titre span { font-size: 12px; opacity: .78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assist-fermer {
    background: transparent; border: 0; color: inherit; cursor: pointer;
    padding: 8px; border-radius: 8px; opacity: .8; display: flex;
}
.assist-fermer:hover, .assist-fermer:focus-visible { opacity: 1; background: rgb(255 253 250 / .12); }

.assist-fil {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    background: var(--assist-fond);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.assist-msg {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 14px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.assist-msg.bot {
    align-self: flex-start;
    background: #fff;
    color: var(--assist-texte);
    border: 1px solid var(--assist-trait);
    border-bottom-left-radius: 4px;
}
.assist-msg.moi {
    align-self: flex-end;
    background: var(--assist-accent);
    color: #fffdfa;
    border-bottom-right-radius: 4px;
}
.assist-msg.ecrit { color: var(--assist-doux); font-style: italic; }
.assist-msg a { color: var(--assist-lagune); font-weight: 600; text-decoration: underline; }
.assist-msg.moi a { color: inherit; }
.assist-wa {
    align-self: flex-start;
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    background: #25d366;
    color: #06301b;
    font-weight: 700;
    font-size: 13.5px;
    text-decoration: none;
}
.assist-wa:hover { background: #1fbe58; color: #06301b; }

.assist-suggestions {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 8px 12px 2px;
    background: var(--assist-fond);
}
.assist-suggestions[hidden] { display: none; }
.assist-suggestions button {
    border: 1px solid var(--assist-accent);
    background: #fff;
    color: var(--assist-accent);
    border-radius: 999px;
    padding: 5px 11px;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.assist-suggestions button:hover, .assist-suggestions button:focus-visible { background: var(--assist-accent); color: #fffdfa; }

.assist-saisie {
    display: flex; gap: 8px;
    padding: 10px 12px;
    margin: 0;
    background: #fffdfa;
    border-top: 1px solid var(--assist-trait);
}
.assist-saisie input {
    flex: 1; min-width: 0;
    border: 1px solid var(--assist-trait);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    font-size: 15px; /* >= 15px : evite le zoom automatique sur iPhone */
    color: var(--assist-texte);
    background: #fff;
    outline: none;
}
.assist-saisie input:focus { border-color: var(--assist-accent); box-shadow: 0 0 0 3px rgb(92 79 68 / .15); }
.assist-saisie button {
    flex: 0 0 auto;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border: 0; border-radius: 10px;
    background: var(--assist-accent);
    color: #fffdfa;
    cursor: pointer;
}
.assist-saisie button:disabled, .assist-saisie input:disabled { opacity: .55; cursor: default; }

.assist-pied {
    margin: 0;
    padding: 0 12px 10px;
    background: #fffdfa;
    color: var(--assist-doux);
    font-size: 11.5px;
    text-align: center;
}
.assist-pied a { color: var(--assist-lagune); font-weight: 600; }

/* --- Mobile : pastille alignee sur celle de WhatsApp, panneau pleine largeur */
@media (max-width: 680px) {
    .assist { right: 16px; bottom: 82px; }
    .assist-bouton { height: 54px; min-width: 54px; padding: 0 15px; }
    .assist-bouton-texte { display: none; }
    .assist-bouton:hover { gap: 0; padding-right: 15px; }
    .assist-panneau {
        position: fixed;
        left: 12px; right: 12px; bottom: 148px;
        width: auto;
        height: min(520px, calc(100dvh - 170px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .assist-bouton, .assist-bouton-texte, .assist-panneau { transition: none; animation: none; }
    .assist-bouton:hover { transform: none; }
}

@media print {
    .assist { display: none; }
}
