/* ════════════════════════════════════════════════════════════════════
 * Assistant IA — Cabinet Bensimhon · styles du widget chatbot
 * Réutilise les tokens de style.css (--navy, --gold, --cream…) chargés
 * en amont sur chaque page ; fallbacks fournis au cas où.
 * ════════════════════════════════════════════════════════════════════ */
#cb-root {
  --cb-navy: var(--navy, #0B1C2D);
  --cb-navy-mid: var(--navy-mid, #152847);
  --cb-gold: var(--gold, #C9A84C);
  --cb-gold-light: var(--gold-light, #E2C97E);
  --cb-cream: var(--cream, #F8F5EF);
  --cb-text: var(--text, #1A1A2E);
  --cb-text-mid: var(--text-mid, #4A5568);
  --cb-white: #fff;
  --cb-wa: #128C7E;      /* vert WhatsApp foncé — contraste AA avec texte blanc */
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ── Launcher (bulle) ─────────────────────────────────────────────── */
#cb-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 12px 20px 12px 16px; border: none; cursor: pointer;
  border-radius: 999px; color: var(--cb-navy);
  background: linear-gradient(135deg, var(--cb-gold-light), var(--cb-gold));
  box-shadow: 0 8px 26px rgba(11, 28, 45, 0.32);
  font-family: inherit; font-size: 15px; font-weight: 700; line-height: 1;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  animation: cb-pop 0.4s ease both;
}
#cb-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(11, 28, 45, 0.4); }
#cb-launcher:focus-visible { outline: 3px solid var(--cb-navy); outline-offset: 2px; }
.cb-launcher-icon { font-size: 19px; }
.cb-launcher-label { white-space: nowrap; }

/* ── Panneau ──────────────────────────────────────────────────────── */
#cb-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 2147483001;
  width: 384px; max-width: calc(100vw - 32px);
  height: 620px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--cb-cream); color: var(--cb-text);
  border-radius: 16px; box-shadow: 0 18px 60px rgba(11, 28, 45, 0.45);
  animation: cb-slide 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
#cb-panel[hidden] { display: none; }

.cb-header {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 16px; color: var(--cb-white);
  background: linear-gradient(135deg, var(--cb-navy), var(--cb-navy-mid));
  border-bottom: 3px solid var(--cb-gold);
}
.cb-header-txt { flex: 1; min-width: 0; }
.cb-title {
  font-family: "Playfair Display", Georgia, serif; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.cb-badge {
  font-family: "DM Sans", sans-serif; font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--cb-navy); background: var(--cb-gold-light);
  padding: 2px 7px; border-radius: 999px; text-transform: uppercase;
}
.cb-sub { font-size: 12px; color: rgba(255, 255, 255, 0.78); margin-top: 2px; }
.cb-close {
  background: transparent; border: none; color: rgba(255, 255, 255, 0.8);
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 6px;
}
.cb-close:hover { color: #fff; }
.cb-close:focus-visible { outline: 2px solid var(--cb-gold); outline-offset: 2px; }

.cb-body { flex: 1; overflow-y: auto; padding: 16px; scroll-behavior: smooth; }

.cb-foot {
  padding: 9px 14px; font-size: 11px; color: var(--cb-text-mid);
  background: #fff; border-top: 1px solid rgba(11, 28, 45, 0.08); text-align: center;
}

/* ── Messages ─────────────────────────────────────────────────────── */
.cb-row { display: flex; margin-bottom: 10px; }
.cb-row-bot { justify-content: flex-start; }
.cb-row-user { justify-content: flex-end; }
.cb-msg {
  max-width: 86%; padding: 11px 14px; border-radius: 14px;
  font-size: 14px; line-height: 1.55; word-wrap: break-word;
  animation: cb-fade 0.22s ease both;
}
.cb-msg-bot { background: #fff; color: var(--cb-text); border-bottom-left-radius: 4px; box-shadow: 0 1px 3px rgba(11, 28, 45, 0.08); }
.cb-msg-user { background: var(--cb-navy); color: #fff; border-bottom-right-radius: 4px; }
.cb-msg a { color: var(--cb-gold); }
.cb-msg-bot a { color: #7A6314; font-weight: 600; text-decoration: underline; }

/* ── Options ──────────────────────────────────────────────────────── */
.cb-opts { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 14px; }
.cb-opt {
  text-align: left; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 11px 14px; border-radius: 10px; line-height: 1.35;
  color: var(--cb-navy); background: #fff; border: 1.5px solid var(--cb-gold);
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.cb-opt:hover { background: var(--cb-gold); color: var(--cb-navy); }
.cb-opt:active { transform: scale(0.99); }
.cb-opt:focus-visible { outline: 2px solid var(--cb-navy); outline-offset: 1px; }
.cb-opt-primary { background: var(--cb-gold); }
.cb-opt-primary:hover { background: var(--cb-gold-light); }
.cb-opt-ghost { border-style: dashed; font-weight: 500; }

/* ── Saisie libre ─────────────────────────────────────────────────── */
.cb-input-row { display: flex; gap: 8px; margin: 4px 0 14px; align-items: center; flex-wrap: wrap; }
.cb-input {
  flex: 1; min-width: 0; font-family: inherit; font-size: 14px;
  padding: 11px 13px; border-radius: 10px; border: 1.5px solid rgba(11, 28, 45, 0.18);
  background: #fff; color: var(--cb-text);
}
.cb-input:focus { outline: none; border-color: var(--cb-gold); box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.18); }
.cb-input.cb-err { border-color: #C0392B; box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.15); }
.cb-send {
  flex: 0 0 auto; cursor: pointer; border: none; border-radius: 10px;
  width: 44px; height: 44px; font-size: 16px; color: var(--cb-navy);
  background: var(--cb-gold); transition: background 0.15s;
}
.cb-send:hover { background: var(--cb-gold-light); }
.cb-skip {
  flex: 0 0 auto; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 9px 12px; border-radius: 10px; color: var(--cb-text-mid);
  background: transparent; border: 1px solid rgba(11, 28, 45, 0.18);
}
.cb-skip:hover { background: rgba(11, 28, 45, 0.05); }

/* ── Bloc honoraires ──────────────────────────────────────────────── */
.cb-fees {
  background: #fff; border: 1px solid rgba(201, 168, 76, 0.4); border-left: 3px solid var(--cb-gold);
  border-radius: 12px; padding: 13px 14px; margin: 4px 0 10px; font-size: 13.5px;
}
.cb-fees-title { font-weight: 700; color: var(--cb-navy); margin-bottom: 8px; }
.cb-fees-table { width: 100%; border-collapse: collapse; }
.cb-fees-table td { padding: 6px 0; border-bottom: 1px solid rgba(11, 28, 45, 0.07); vertical-align: top; line-height: 1.35; }
.cb-fees-table td:last-child { text-align: right; white-space: nowrap; font-weight: 700; color: var(--cb-navy); padding-left: 10px; }
.cb-fees-table tr:last-child td { border-bottom: none; }
.cb-fees-table em { color: var(--cb-text-mid); font-style: italic; font-weight: 400; }
.cb-fees-note { margin: 8px 0 0; font-size: 12.5px; color: var(--cb-text-mid); line-height: 1.5; }
.cb-fee-when { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; color: var(--cb-text-light, #718096); margin-bottom: 2px; }
.cb-fee-when.cb-now { color: #1b7a3d; }
.cb-fee-opt td:first-child { border-left: 2px dashed var(--cb-gold); padding-left: 9px; }
.cb-fee-opt td { background: rgba(201, 168, 76, 0.06); }

/* ── CTA / WhatsApp ───────────────────────────────────────────────── */
.cb-cta { display: flex; flex-direction: column; gap: 9px; margin: 4px 0 14px; }
.cb-wa {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  text-decoration: none; cursor: pointer; font-family: inherit; font-size: 15px; font-weight: 700;
  padding: 13px 16px; border-radius: 11px; color: #fff; background: var(--cb-wa);
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4); transition: filter 0.15s, transform 0.1s;
}
.cb-wa:hover { filter: brightness(1.05); transform: translateY(-1px); }
.cb-wa:focus-visible { outline: 3px solid var(--cb-navy); outline-offset: 2px; }

/* ── Animations ───────────────────────────────────────────────────── */
@keyframes cb-pop { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
@keyframes cb-slide { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes cb-fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* ── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #cb-panel {
    right: 0; bottom: 0; width: 100vw; max-width: 100vw;
    height: 100dvh; max-height: 100dvh; border-radius: 0;
  }
  #cb-launcher { right: 14px; bottom: 14px; padding: 11px 16px 11px 14px; font-size: 14px; }
}

/* ── Reduced motion ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #cb-launcher, #cb-panel, .cb-msg { animation: none; }
  #cb-launcher:hover, .cb-wa:hover { transform: none; }
  .cb-body { scroll-behavior: auto; }
}
