/* ════════════════════════════════════════════════════════════════
   CERFACIL — Chatbot widget (assistant FAQ)
   ════════════════════════════════════════════════════════════════ */
#cfcbBtn { position: fixed; bottom: 24px; right: 24px; width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, #5D6FFF, #4A40FF); color: #fff; border: 0; cursor: pointer; box-shadow: 0 10px 32px rgba(74,64,255,.4); z-index: 9999; display: flex; align-items: center; justify-content: center; font-size: 24px; transition: transform .2s, box-shadow .2s; }
#cfcbBtn:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 14px 40px rgba(74,64,255,.5); }
#cfcbBtn.is-open i::before { content: "\f00d"; }
#cfcbBtn .cfcb-pulse { position: absolute; inset: -4px; border-radius: 50%; border: 2px solid #5D6FFF; opacity: 0; animation: cfcbPulse 2.2s infinite; }
@keyframes cfcbPulse { 0% { transform: scale(.9); opacity: .7; } 100% { transform: scale(1.25); opacity: 0; } }

#cfcbPanel { position: fixed; bottom: 100px; right: 24px; width: min(420px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 130px)); background: #fff; border: 1px solid #ececf5; border-radius: 20px; box-shadow: 0 30px 80px rgba(15,23,42,.25); z-index: 9998; display: flex; flex-direction: column; overflow: hidden; opacity: 0; transform: translateY(20px); transition: opacity .25s, transform .25s; text-align: left; pointer-events: none; }
#cfcbPanel, #cfcbPanel * { text-align: left; }
.cfcb__msgs { align-items: stretch; }
.cfcb__msg--bot { justify-content: flex-start; }
.cfcb__msg--user { justify-content: flex-start; } /* row-reverse place déjà la bulle à droite */
.cfcb__bubble { text-align: left; }
/* Fermé (opacity:0) : ne doit PAS intercepter les taps — sinon cette boîte
   invisible (quasi plein écran sur mobile) bloque tous les boutons dessous. */
#cfcbPanel.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }

.cfcb__head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: linear-gradient(135deg, #5D6FFF, #4A40FF); color: #fff; flex-shrink: 0; }
.cfcb__head-avatar { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.cfcb__head-text { flex: 1; min-width: 0; }
.cfcb__head-text strong { display: block; font-size: 15px; font-weight: 700; }
.cfcb__head-text span { font-size: 11px; opacity: .9; display: inline-flex; align-items: center; gap: 5px; }
.cfcb__head-text span i { font-size: 6px; color: #4ade80; }
.cfcb__head-btn { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.15); color: #fff; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.cfcb__head-btn:hover { background: rgba(255,255,255,.25); }
#cfcbClose { font-size: 22px; line-height: 1; }

.cfcb__msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-height: 0; background: #f7f8ff; }
.cfcb__msg { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; }
.cfcb__msg--user { flex-direction: row-reverse; }
.cfcb__av { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; color: #fff; }
.cfcb__av.bot { background: linear-gradient(135deg, #5D6FFF, #4A40FF); }
.cfcb__av.user { background: linear-gradient(135deg, #ff6b9e, #5D6FFF); font-size: 11px; }
.cfcb__bubble-wrap { display: flex; flex-direction: column; max-width: calc(100% - 44px); min-width: 0; gap: 4px; }
.cfcb__msg--user .cfcb__bubble-wrap { align-items: flex-end; }
.cfcb__bubble { padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.5; max-width: 100%; word-break: break-word; }
.cfcb__msg--bot .cfcb__bubble { background: #fff; color: #1a1c2e; border-bottom-left-radius: 4px; border: 1px solid #ececf5; }
.cfcb__msg--user .cfcb__bubble { background: linear-gradient(135deg, #5D6FFF, #4A40FF); color: #fff; border-bottom-right-radius: 4px; }
.cfcb__bubble a { color: #5D6FFF; font-weight: 600; }
.cfcb__msg--user .cfcb__bubble a { color: #fff; text-decoration: underline; }
.cfcb__bubble p { margin: 0 0 6px; color: inherit; } .cfcb__bubble p:last-child { margin: 0; }
.cfcb__bubble ul, .cfcb__bubble ol { margin: 4px 0 4px 18px; padding: 0; }
.cfcb__bubble li, .cfcb__bubble strong, .cfcb__bubble em { color: inherit; }
.cfcb__bubble strong { font-weight: 700; }
.cfcb__bubble code { background: rgba(93,111,255,.12); color: #4A40FF; padding: 1px 6px; border-radius: 6px; font-size: .9em; font-family: ui-monospace, Menlo, Consolas, monospace; }
.cfcb__msg--user .cfcb__bubble code { background: rgba(255,255,255,.25); color: #fff; }

/* ── Rendu riche du markdown (titres, tableaux, images, code…) ───────────── */
.cfcb__bubble .cfcb__h { margin: 10px 0 6px; line-height: 1.3; font-weight: 700; color: inherit; }
.cfcb__bubble .cfcb__h:first-child { margin-top: 0; }
.cfcb__bubble h1.cfcb__h { font-size: 1.18em; }
.cfcb__bubble h2.cfcb__h { font-size: 1.1em; }
.cfcb__bubble h3.cfcb__h { font-size: 1.02em; }
.cfcb__bubble h4.cfcb__h, .cfcb__bubble h5.cfcb__h, .cfcb__bubble h6.cfcb__h { font-size: .95em; opacity: .9; }
.cfcb__table-wrap { width: 100%; overflow-x: auto; margin: 8px 0; border: 1px solid #e6e6ef; border-radius: 10px; -webkit-overflow-scrolling: touch; }
.cfcb__table-wrap table { border-collapse: collapse; width: 100%; font-size: 12px; background: #fff; }
.cfcb__table-wrap th, .cfcb__table-wrap td { border: 1px solid #e6e6ef; padding: 6px 10px; text-align: left; vertical-align: top; word-break: break-word; }
.cfcb__table-wrap thead th { background: #eef0ff; color: #2b2c50; font-weight: 700; }
.cfcb__table-wrap tbody tr:nth-child(even) td { background: #f6f7ff; }
.cfcb__msg--user .cfcb__table-wrap { border-color: rgba(255,255,255,.35); }
.cfcb__msg--user .cfcb__table-wrap table, .cfcb__msg--user .cfcb__table-wrap th, .cfcb__msg--user .cfcb__table-wrap td { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.cfcb__msg--user .cfcb__table-wrap thead th { background: rgba(255,255,255,.18); }
.cfcb__table-wrap::-webkit-scrollbar { height: 6px; }
.cfcb__table-wrap::-webkit-scrollbar-thumb { background: #cfcde0; border-radius: 3px; }
.cfcb__bubble img { max-width: 100%; height: auto; border-radius: 10px; margin: 6px 0; display: block; border: 1px solid #ececec; }
.cfcb__bubble a i { margin-right: 2px; }
.cfcb__bubble pre { background: #1e1e2e; color: #e6e6f0; padding: 10px 12px; border-radius: 10px; overflow-x: auto; margin: 8px 0; font-size: 12px; }
.cfcb__bubble pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.cfcb__bubble blockquote { margin: 6px 0; padding: 4px 12px; border-left: 3px solid #5D6FFF; background: rgba(93,111,255,.06); border-radius: 0 8px 8px 0; color: inherit; }
.cfcb__msg--user .cfcb__bubble blockquote { border-left-color: rgba(255,255,255,.7); background: rgba(255,255,255,.12); }
.cfcb__bubble hr { border: 0; border-top: 1px solid #e6e6ef; margin: 10px 0; }
.cfcb__bubble del { opacity: .7; }
.cfcb__src { font-size: 10px; padding: 2px 8px; border-radius: 999px; align-self: flex-start; }
.cfcb__src--faq { background: #e3e7ff; color: #4A40FF; }
.cfcb__ts { font-size: 10px; color: #9aa0c4; }
.cfcb__typing { display: inline-flex; gap: 5px; align-items: center; }
.cfcb__typing span { width: 7px; height: 7px; border-radius: 50%; background: #5D6FFF; animation: cfcbBounce 1.2s infinite; }
.cfcb__typing span:nth-child(2) { animation-delay: .15s; }
.cfcb__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cfcbBounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-6px); opacity: 1; } }

.cfcb__chips { padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; border-top: 1px solid #ececf5; background: #fff; flex-shrink: 0; }
.cfcb__chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0; }
.cfcb__chip-row small { font-size: 11px; color: #9aa0c4; font-weight: 600; }
.cfcb__chip { border: 1.5px solid #ececf5; background: #fff; color: #555; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 500; transition: all .15s; font-family: inherit; }
.cfcb__chip:hover { border-color: #5D6FFF; color: #4A40FF; background: #f3f4ff; }
.cfcb__chip--q { border-color: transparent; background: #f3f4ff; color: #4A40FF; text-align: left; font-size: 12px; border-radius: 10px; padding: 8px 12px; width: 100%; }
.cfcb__chip--q:hover { background: #e3e7ff; }
.cfcb__back { background: none; border: 0; cursor: pointer; color: #5D6FFF; font-size: 12px; font-weight: 600; padding: 2px 0; display: inline-flex; gap: 4px; align-items: center; }

/* Saisie libre : champ texte toujours visible (en plus des catégories/questions) */
.cfcb__form, .cfcb__form--visible { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #ececf5; background: #fff; flex-shrink: 0; }
.cfcb__form input { flex: 1; border: 1.5px solid #ececf5; border-radius: 999px; padding: 10px 14px; font-size: 13px; outline: none; transition: border-color .15s; font-family: inherit; }
.cfcb__form input:focus { border-color: #5D6FFF; }
.cfcb__form button { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, #5D6FFF, #4A40FF); color: #fff; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; transition: transform .15s; }
.cfcb__form button:hover { transform: scale(1.08); }
.cfcb__form button:disabled { opacity: .5; cursor: not-allowed; }

.cfcb__foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px 12px; font-size: 11px; color: #9aa0c4; gap: 8px; background: #fff; border-top: 1px solid #ececf5; flex-shrink: 0; flex-wrap: wrap; }
.cfcb__contact { display: inline-flex; gap: 5px; align-items: center; padding: 5px 10px; border: 1px solid #ececf5; border-radius: 999px; color: #4A40FF; font-weight: 600; font-size: 11px; text-decoration: none; }
.cfcb__contact:hover { background: #f3f4ff; }

@media (max-width: 500px) {
  #cfcbBtn { bottom: 16px; right: 16px; width: 54px; height: 54px; font-size: 22px; }
  #cfcbPanel { bottom: 80px; right: 8px; left: 8px; width: auto; max-height: calc(100vh - 100px); }
}
