/* ==========================================================
   Widget chatbot — réutilisable sur les sites clients.
   Couleurs : variables --sbc-* (par défaut, celles du site).
   ========================================================== */
#sb-chat-root {
  --sbc-brand: var(--c-brand, 13 110 122);
  --sbc-brand-ink: var(--c-brand-ink, 255 255 255);
  --sbc-bg: var(--c-bg, 250 248 244);
  --sbc-surface: var(--c-surface, 255 255 255);
  --sbc-ink: var(--c-ink, 16 24 40);
  --sbc-muted: var(--c-muted, 84 94 112);
  --sbc-line: var(--c-line, 229 225 217);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: rgb(var(--sbc-ink));
}
#sb-chat-root *, #sb-chat-root *::before, #sb-chat-root *::after { box-sizing: border-box; }

.sbc-launcher {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: inline-flex; align-items: center; gap: .55rem; border: 0; cursor: pointer;
  padding: .85rem 1.15rem .85rem .9rem; border-radius: 999px; font: inherit; font-weight: 600; font-size: .95rem;
  background: rgb(var(--sbc-ink)); color: rgb(var(--sbc-bg));
  box-shadow: 0 14px 34px -10px rgb(0 0 0 / .45); transition: transform .2s ease, opacity .2s;
}
.sbc-launcher:hover { transform: translateY(-2px); }
.sbc-launcher .sbc-avatar { width: 1.9rem; height: 1.9rem; font-size: .72rem; }
.sbc-launcher .sbc-online { position: absolute; left: 2.25rem; top: .7rem; width: .6rem; height: .6rem; border-radius: 999px; background: #22c55e; border: 2px solid rgb(var(--sbc-ink)); }
.sbc-launcher.is-hidden { opacity: 0; pointer-events: none; transform: scale(.9); }
@media (max-width: 520px) { .sbc-launcher .sbc-label { display: none; } .sbc-launcher { padding: .8rem; } .sbc-launcher .sbc-online { left: 2.05rem; } }

.sbc-teaser {
  position: fixed; right: 18px; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 60; max-width: 270px;
  background: rgb(var(--sbc-surface)); border: 1px solid rgb(var(--sbc-line)); border-radius: 1rem 1rem .3rem 1rem;
  padding: .8rem 2.2rem .8rem .95rem; font-size: .9rem; line-height: 1.45; cursor: pointer;
  box-shadow: 0 18px 40px -16px rgb(0 0 0 / .35); animation: sbc-pop .35s ease;
}
.sbc-teaser button { position: absolute; top: .35rem; right: .35rem; width: 1.6rem; height: 1.6rem; border: 0; background: none; color: rgb(var(--sbc-muted)); cursor: pointer; border-radius: 999px; font-size: 1.1rem; line-height: 1; }

.sbc-panel {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 61;
  width: min(390px, calc(100vw - 24px)); height: min(620px, calc(100dvh - 36px));
  display: flex; flex-direction: column; overflow: hidden;
  background: rgb(var(--sbc-surface)); border: 1px solid rgb(var(--sbc-line)); border-radius: 1.4rem;
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / .45); animation: sbc-pop .25s ease;
}
.sbc-panel[hidden] { display: none; }
@media (max-width: 520px) {
  .sbc-panel { right: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
}
@keyframes sbc-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.sbc-head { display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem; background: rgb(var(--sbc-ink)); color: rgb(var(--sbc-bg)); }
.sbc-head strong { display: block; font-size: .98rem; }
.sbc-head small { display: flex; align-items: center; gap: .35rem; font-size: .76rem; opacity: .75; }
.sbc-head small::before { content: ""; width: .5rem; height: .5rem; border-radius: 999px; background: #22c55e; }
.sbc-head .sbc-x { margin-left: auto; width: 2.2rem; height: 2.2rem; border-radius: 999px; border: 0; cursor: pointer; background: rgb(255 255 255 / .1); color: inherit; font-size: 1.3rem; line-height: 1; }
.sbc-head .sbc-x:hover { background: rgb(255 255 255 / .2); }
.sbc-avatar {
  flex: none; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .8rem;
  font-weight: 800; font-size: .82rem; color: #fff; background: linear-gradient(135deg, rgb(13 110 122), rgb(226 109 68));
}

.sbc-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; background: rgb(var(--sbc-bg)); scroll-behavior: smooth; }
.sbc-msg { max-width: 86%; padding: .7rem .95rem; border-radius: 1.1rem; font-size: .93rem; line-height: 1.5; word-wrap: break-word; animation: sbc-pop .2s ease; }
.sbc-msg.bot { align-self: flex-start; background: rgb(var(--sbc-surface)); border: 1px solid rgb(var(--sbc-line)); border-bottom-left-radius: .3rem; }
.sbc-msg.user { align-self: flex-end; background: rgb(var(--sbc-brand)); color: rgb(var(--sbc-brand-ink)); border-bottom-right-radius: .3rem; }
.sbc-msg a { color: rgb(var(--sbc-brand)); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.sbc-msg.user a { color: inherit; }
.sbc-msg strong { font-weight: 700; }
.sbc-typing { display: inline-flex; gap: .3rem; padding: .85rem 1rem; }
.sbc-typing i { width: .45rem; height: .45rem; border-radius: 999px; background: rgb(var(--sbc-muted)); animation: sbc-blink 1.2s infinite ease-in-out; }
.sbc-typing i:nth-child(2) { animation-delay: .15s; }
.sbc-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes sbc-blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.sbc-quick { display: flex; gap: .45rem; overflow-x: auto; padding: .65rem 1rem; border-top: 1px solid rgb(var(--sbc-line)); background: rgb(var(--sbc-surface)); scrollbar-width: none; }
.sbc-quick::-webkit-scrollbar { display: none; }
.sbc-quick[hidden], .sbc-teaser[hidden] { display: none; }
.sbc-quick button {
  flex: none; border: 1.5px solid rgb(var(--sbc-line)); background: rgb(var(--sbc-surface)); color: rgb(var(--sbc-ink));
  border-radius: 999px; padding: .42rem .85rem; font: inherit; font-size: .83rem; font-weight: 500; cursor: pointer; transition: border-color .15s, color .15s;
}
.sbc-quick button:hover { border-color: rgb(var(--sbc-brand)); color: rgb(var(--sbc-brand)); }

.sbc-form { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid rgb(var(--sbc-line)); background: rgb(var(--sbc-surface)); }
.sbc-form textarea {
  flex: 1; resize: none; max-height: 7rem; min-height: 2.75rem; border-radius: .9rem; border: 1.5px solid rgb(var(--sbc-line));
  background: rgb(var(--sbc-bg)); color: rgb(var(--sbc-ink)); padding: .65rem .85rem; font: inherit; font-size: .95rem; line-height: 1.4;
}
.sbc-form textarea:focus { outline: none; border-color: rgb(var(--sbc-brand)); box-shadow: 0 0 0 3px rgb(var(--sbc-brand) / .15); }
.sbc-form button { flex: none; width: 2.75rem; height: 2.75rem; border-radius: 999px; border: 0; cursor: pointer; background: rgb(var(--sbc-brand)); color: rgb(var(--sbc-brand-ink)); display: grid; place-items: center; }
.sbc-form button:disabled { opacity: .45; cursor: not-allowed; }
.sbc-foot { padding: 0 1rem .6rem; font-size: .7rem; color: rgb(var(--sbc-muted)); background: rgb(var(--sbc-surface)); text-align: center; }
.sbc-foot a { color: inherit; }

@media (prefers-reduced-motion: reduce) { #sb-chat-root * { animation: none !important; transition: none !important; } }
@media print { #sb-chat-root { display: none !important; } }
