/* =========================================================
   Assistant SO Performance : widget de conversation (js/chatbot.js)
   Bouton aligné au-dessus du bouton WhatsApp (.wa-float : 58px, bottom 32px, right 32px)
   ========================================================= */
.sop-chat-root {
    --c-gold: var(--gold, #C7A03E);
    --c-gold-dark: var(--gold-dark, #9B7A20);
    --c-gold-light: var(--gold-light, #E0C36A);
    --c-gold-pale: var(--gold-pale, #FBF6E9);
    --c-black: var(--black, #0a0a0a);
    --c-text: #16161a;
    --c-text-2: #45454c;
    --c-muted: #7a7a82;
    --c-line: #e6e6ea;
    --c-field: #dcdce2;
    --c-bg: #f5f5f7;
    --c-danger: #c62828;
    --c-online: #34c759;
    --ease: cubic-bezier(.2, .8, .2, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.sop-chat-root [hidden] { display: none !important; }
.sop-chat-root button { font-family: inherit; }

/* ── Bouton d'ouverture ─────────────────────────────────── */
.sop-chat-launcher {
    position: fixed; right: 32px; bottom: 104px; z-index: 1000;
    width: 58px; height: 58px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--c-black);
    background: linear-gradient(145deg, var(--c-gold-light), var(--c-gold) 55%, var(--c-gold-dark));
    box-shadow: 0 10px 30px rgba(199, 160, 62, .38), 0 2px 6px rgba(0, 0, 0, .14);
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), opacity .2s ease;
}
.sop-chat-launcher:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 14px 36px rgba(199, 160, 62, .45), 0 2px 6px rgba(0, 0, 0, .14); }
.sop-chat-launcher:focus-visible { outline: 3px solid var(--c-black); outline-offset: 3px; }
.sop-chat-launcher svg { width: 27px; height: 27px; }
.sop-chat-launcher::after {
    content: ''; position: absolute; top: 2px; right: 2px;
    width: 13px; height: 13px; border-radius: 50%;
    background: var(--c-online); border: 2.5px solid #fff;
}
.sop-chat-root.is-open .sop-chat-launcher { opacity: 0; transform: scale(.8); pointer-events: none; }

/* ── Bulle d'invitation ─────────────────────────────────── */
.sop-chat-teaser {
    position: fixed; right: 102px; bottom: 112px; z-index: 1000;
    width: 280px; display: flex; gap: 11px; align-items: flex-start;
    padding: 13px 36px 13px 13px; cursor: pointer;
    background: #fff; border-radius: 18px 18px 6px 18px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .16), 0 0 0 1px rgba(0, 0, 0, .05);
    opacity: 0; transform: translateY(10px) scale(.97); transform-origin: bottom right;
    transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.sop-chat-teaser.is-visible { opacity: 1; transform: none; }
.sop-chat-teaser:focus-visible { outline: 3px solid var(--c-gold); outline-offset: 2px; }
.sop-chat-teaser img { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }
.sop-chat-teaser p { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--c-text-2); }
.sop-chat-teaser strong { display: block; margin-bottom: 2px; font-size: 13px; color: var(--c-text); }
.sop-chat-teaser-close {
    position: absolute; top: 7px; right: 7px; width: 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: transparent; color: var(--c-muted);
}
.sop-chat-teaser-close:hover { background: var(--c-bg); color: var(--c-text); }
.sop-chat-teaser-close svg { width: 14px; height: 14px; }

/* ── Fenêtre ────────────────────────────────────────────── */
.sop-chat {
    position: fixed; right: 24px; bottom: 24px; z-index: 1001;
    width: 400px; height: min(700px, calc(100vh - 48px));
    margin: 0; padding: 0; /* neutralise la règle « section { padding: 110px 0 } » du site */
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--c-bg); color: var(--c-text); line-height: 1.5;
    border-radius: 24px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, .24), 0 0 0 1px rgba(0, 0, 0, .06);
    opacity: 0; transform: translateY(16px) scale(.98); transform-origin: bottom right;
    transition: opacity .24s var(--ease), transform .24s var(--ease);
}
.sop-chat.is-open { opacity: 1; transform: none; }

/* En-tête */
.sop-chat-head {
    position: relative; flex-shrink: 0;
    display: flex; align-items: center; gap: 12px;
    padding: 15px 14px 15px 18px;
    background: var(--c-black); color: #fff;
}
.sop-chat-head::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(199, 160, 62, .8), transparent);
}
.sop-chat-root.is-welcome .sop-chat-head::after { display: none; }
.sop-chat-avatar { position: relative; width: 42px; height: 42px; flex-shrink: 0; }
.sop-chat-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1.5px rgba(199, 160, 62, .6); }
.sop-chat-avatar::after {
    content: ''; position: absolute; right: -1px; bottom: -1px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--c-online); border: 2.5px solid var(--c-black);
}
.sop-chat-title { flex: 1; min-width: 0; }
.sop-chat-title strong {
    display: block; font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 15.5px; font-weight: 700; letter-spacing: -.2px; line-height: 1.25; color: #fff;
}
.sop-chat-title span { display: block; margin-top: 1px; font-size: 12.5px; color: #b4b4ba; }
.sop-chat-icon-btn {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .08); color: #fff;
    transition: background .2s ease, color .2s ease;
}
.sop-chat-icon-btn:hover { background: rgba(255, 255, 255, .16); }
.sop-chat-icon-btn:focus-visible { outline: 2px solid var(--c-gold); outline-offset: 2px; }
.sop-chat-icon-btn.is-call { color: var(--c-gold-light); }
.sop-chat-icon-btn svg { width: 18px; height: 18px; }

/* ── Écran d'accueil ────────────────────────────────────── */
.sop-chat-welcome { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.sop-chat-hero {
    padding: 4px 22px 66px; color: #fff;
    background: var(--c-black) radial-gradient(120% 90% at 100% 0%, rgba(199, 160, 62, .26), transparent 60%);
}
.sop-chat-hero h2 {
    margin: 0; font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 25px; font-weight: 800; line-height: 1.2; letter-spacing: -.5px; color: #fff;
}
.sop-chat-hero h2 em { font-style: normal; color: var(--c-gold-light); }
.sop-chat-hero p { margin: 8px 0 0; font-size: 14px; line-height: 1.55; color: #cfcfd5; }

.sop-chat-card {
    position: relative; margin: -46px 14px 0; padding: 18px;
    background: #fff; border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .08), 0 0 0 1px rgba(0, 0, 0, .04);
}
.sop-chat-card h3 { margin: 0; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--c-text); }
.sop-chat-hint { margin: 3px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--c-muted); }
.sop-chat-notice {
    margin: 12px 0 0; padding: 9px 12px; border-radius: 10px;
    font-size: 12.5px; line-height: 1.45; color: var(--c-gold-dark); background: var(--c-gold-pale);
}
.sop-chat-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.sop-chat-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sop-chat-field.is-wide { grid-column: 1 / -1; }
.sop-chat-field label { font-size: 12.5px; font-weight: 600; color: var(--c-text-2); }
.sop-chat-field input {
    width: 100%; height: 44px; padding: 0 13px;
    font: inherit; font-size: 15px; color: var(--c-text);
    background: #fafafb; border: 1px solid var(--c-field); border-radius: 12px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.sop-chat-field input:hover { border-color: #c8c8d0; }
.sop-chat-field input:focus { outline: none; background: #fff; border-color: var(--c-gold); box-shadow: 0 0 0 4px rgba(199, 160, 62, .18); }
.sop-chat-field input[aria-invalid="true"] { background: #fff; border-color: var(--c-danger); }
.sop-chat-field input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(198, 40, 40, .12); }
.sop-chat-field-error { font-size: 12px; line-height: 1.35; color: var(--c-danger); }
.sop-chat-field-error:empty { display: none; }
.sop-chat-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.sop-chat-form-error {
    margin: 14px 0 0; padding: 10px 12px; border-radius: 10px;
    font-size: 13px; line-height: 1.45; color: #7a1c1c; background: #fdf1f1;
}
.sop-chat-submit {
    width: 100%; height: 48px; margin-top: 16px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 15px; font-weight: 700; color: var(--c-black); background: var(--c-gold);
    transition: background .2s ease, transform .1s ease;
}
.sop-chat-submit:hover { background: var(--c-gold-light); }
.sop-chat-submit:active { transform: scale(.99); }
.sop-chat-submit:focus-visible { outline: 3px solid var(--c-black); outline-offset: 2px; }
.sop-chat-submit:disabled { cursor: wait; opacity: .85; }
.sop-chat-submit svg { width: 18px; height: 18px; }
.sop-chat-legal { margin: 12px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--c-muted); text-align: center; }
.sop-chat-legal a { color: var(--c-gold-dark); text-decoration: underline; text-underline-offset: 2px; }

.sop-chat-points { list-style: none; margin: 0; padding: 18px 26px 22px; display: grid; gap: 11px; }
.sop-chat-points li { display: flex; gap: 11px; align-items: flex-start; font-size: 13px; line-height: 1.45; color: var(--c-text-2); }
.sop-chat-points li span { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex-shrink: 0; border-radius: 8px; color: var(--c-gold-dark); background: var(--c-gold-pale); }
.sop-chat-points svg { width: 15px; height: 15px; }
.sop-chat-points a { color: var(--c-gold-dark); font-weight: 600; white-space: nowrap; }
.sop-chat-points p { margin: 3px 0 0; }

/* ── Conversation ───────────────────────────────────────── */
.sop-chat-thread {
    flex: 1; overflow-y: auto; overscroll-behavior: contain;
    display: flex; flex-direction: column; gap: 14px;
    padding: 18px 16px 10px;
}
.sop-chat-day {
    align-self: center; padding: 3px 11px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; color: var(--c-muted);
    background: #fff; box-shadow: 0 0 0 1px var(--c-line);
}
.sop-row { display: flex; align-items: flex-end; gap: 8px; animation: sopIn .26s var(--ease) both; }
.sop-row.is-user { justify-content: flex-end; }
.sop-row-avatar { width: 28px; height: 28px; margin-bottom: 20px; flex-shrink: 0; border-radius: 50%; }
.sop-row-col { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: 84%; }
.sop-row.is-user .sop-row-col { align-items: flex-end; }
.sop-bubble { padding: 10px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.sop-row.is-bot .sop-bubble {
    color: var(--c-text); background: #fff; border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 0 0 1px rgba(0, 0, 0, .045);
}
.sop-row.is-user .sop-bubble { color: #fff; background: var(--c-black); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.sop-bubble p { margin: 0; }
.sop-bubble p + p, .sop-bubble p + ul, .sop-bubble p + ol, .sop-bubble ul + p, .sop-bubble ol + p { margin-top: 8px; }
.sop-bubble ul, .sop-bubble ol { margin: 0; padding-left: 19px; }
.sop-bubble ul { list-style: disc; }
.sop-bubble ol { list-style: decimal; }
.sop-bubble li + li { margin-top: 4px; }
.sop-bubble li::marker { color: var(--c-gold-dark); }
.sop-bubble strong { font-weight: 700; }
.sop-bubble a {
    font-weight: 600; color: var(--c-gold-dark);
    text-decoration: underline; text-decoration-color: rgba(155, 122, 32, .4); text-underline-offset: 2px;
}
.sop-bubble a:hover { text-decoration-color: currentColor; }
.sop-meta { margin-top: 4px; padding: 0 4px; font-size: 11px; color: var(--c-muted); }

.sop-row.is-error .sop-bubble { color: #7a1c1c; background: #fdf3f3; box-shadow: 0 0 0 1px rgba(198, 40, 40, .16); }
.sop-retry {
    margin-top: 8px; padding: 6px 13px 6px 10px; border-radius: 999px;
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 600; color: var(--c-text); background: #fff; box-shadow: 0 0 0 1px var(--c-field);
}
.sop-retry:hover { box-shadow: 0 0 0 1px var(--c-gold); }
.sop-retry svg { width: 15px; height: 15px; }

.sop-typing { display: inline-flex; align-items: center; gap: 4px; padding: 14px 16px; }
.sop-typing span { width: 7px; height: 7px; border-radius: 50%; background: #b9b9c0; animation: sopDot 1.2s infinite ease-in-out; }
.sop-typing span:nth-child(2) { animation-delay: .15s; }
.sop-typing span:nth-child(3) { animation-delay: .3s; }

.sop-chips-wrap { padding-left: 36px; animation: sopIn .3s var(--ease) both; }
.sop-chips-label { margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--c-muted); }
.sop-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sop-chip {
    padding: 8px 13px; border-radius: 999px; text-align: left;
    font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--c-text);
    background: #fff; box-shadow: 0 0 0 1px rgba(199, 160, 62, .55);
    transition: background .15s ease, box-shadow .15s ease;
}
.sop-chip:hover { background: var(--c-gold-pale); box-shadow: 0 0 0 1px var(--c-gold); }
.sop-chip:focus-visible { outline: 2px solid var(--c-gold); outline-offset: 2px; }

/* Zone de saisie */
.sop-chat-composer { flex-shrink: 0; padding: 8px 14px 12px; background: var(--c-bg); }
.sop-chat-inputbox {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 6px 6px 6px 15px; border-radius: 20px;
    background: #fff; box-shadow: 0 0 0 1px var(--c-field), 0 2px 8px rgba(0, 0, 0, .04);
    transition: box-shadow .15s ease;
}
.sop-chat-inputbox:focus-within { box-shadow: 0 0 0 1.5px var(--c-gold), 0 0 0 5px rgba(199, 160, 62, .15); }
.sop-chat-inputbox textarea {
    flex: 1; min-height: 38px; max-height: 120px; padding: 8px 0;
    font: inherit; font-size: 15px; line-height: 1.45; color: var(--c-text);
    border: 0; outline: 0; resize: none; background: transparent;
}
.sop-chat-inputbox textarea::placeholder { color: #9a9aa2; }
.sop-chat-send {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--c-black); background: var(--c-gold);
    transition: background .15s ease, color .15s ease, transform .1s ease;
}
.sop-chat-send:hover:not(:disabled) { background: var(--c-gold-light); }
.sop-chat-send:active:not(:disabled) { transform: scale(.94); }
.sop-chat-send:disabled { cursor: default; color: #a6a6ae; background: #ececef; }
.sop-chat-send:focus-visible { outline: 2px solid var(--c-black); outline-offset: 2px; }
.sop-chat-send svg { width: 18px; height: 18px; }
.sop-chat-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; padding: 0 6px; font-size: 11px; line-height: 1.4; color: var(--c-muted); }
.sop-chat-foot a { font-weight: 600; color: var(--c-gold-dark); white-space: nowrap; }
.sop-chat-count { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.sop-chat-count.is-warn { color: var(--c-danger); font-weight: 600; }

.sop-spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .2); border-top-color: var(--c-black); animation: sopSpin .7s linear infinite; }

@keyframes sopIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sopDot { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes sopSpin { to { transform: rotate(360deg); } }

/* ── Mobile : plein écran, ajusté au clavier par js/chatbot.js ── */
@media (max-width: 520px) {
    .sop-chat { top: 0; left: 0; right: 0; bottom: auto; width: 100%; height: 100%; border-radius: 0; transform: translateY(24px); }
    .sop-chat-head { padding-top: calc(13px + env(safe-area-inset-top)); }
    .sop-chat-composer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
    .sop-chat-field input, .sop-chat-inputbox textarea { font-size: 16px; } /* évite le zoom automatique d'iOS */
    .sop-chat-hero h2 { font-size: 23px; }
    .sop-chat-teaser { display: none !important; }
    html.sop-chat-locked, html.sop-chat-locked body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
    .sop-chat, .sop-chat-launcher, .sop-chat-teaser { transition: none; }
    .sop-row, .sop-chips-wrap { animation: none; }
    .sop-typing span, .sop-spin { animation-duration: 2.4s; }
}
