/* ============================================================
   Crisalida — conseiller formation « Cléa » (bouton flottant et fenêtre de discussion)
   ============================================================ */
.adv { position: fixed; right: 22px; bottom: 22px; z-index: 300; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; font-size: 14px; }
.adv-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; position: relative;
  background: var(--grad-solid); color: #fff; font-family: var(--font-head); font-weight: 800; font-size: 17px; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }
.adv-avatar.sm { width: 28px; height: 28px; font-size: 13px; box-shadow: none; margin-top: 2px; }
.adv-avatar.lg { width: 44px; height: 44px; }
.adv-avatar.lg i { position: absolute; right: 0; bottom: 1px; width: 11px; height: 11px; border-radius: 50%; background: #2fc67c; border: 2px solid var(--charcoal); }

.adv-launcher { position: relative; display: inline-flex; align-items: center; gap: 11px; padding: 7px 18px 7px 7px; border-radius: var(--r-pill);
  background: var(--charcoal); color: #fff; box-shadow: 0 14px 34px rgba(17, 19, 24, .32); transition: transform .2s var(--ease), box-shadow .2s; }
.adv-launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(17, 19, 24, .38); }
.adv-launcher-text { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.adv-launcher-text b { font-family: var(--font-head); font-size: 14px; }
.adv-launcher-text small { font-size: 11.5px; color: #c5c9d3; }
.adv-pulse { position: absolute; left: 7px; top: 7px; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--crimson); animation: advPulse 2.4s ease-out infinite; pointer-events: none; }
@keyframes advPulse { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(1.7); opacity: 0; } }
.adv.is-open .adv-launcher { display: none; }

.adv-teaser { position: relative; max-width: 260px; padding: 14px 34px 14px 16px; border-radius: 16px 16px 4px 16px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--sh-lg); color: var(--text-strong); animation: pop .35s var(--ease); }
.adv-teaser b { display: block; font-family: var(--font-head); font-size: 14px; color: var(--ink); margin-bottom: 3px; }
.adv-teaser span { font-size: 13px; color: var(--slate); }
.adv-teaser-close { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--slate-light); }
.adv-teaser-close svg { width: 13px; height: 13px; }

.adv-panel { width: min(400px, calc(100vw - 28px)); height: min(640px, calc(var(--screen-dh) - 110px)); display: flex; flex-direction: column; overflow: hidden;
  border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(17, 19, 24, .35); animation: pop .3s var(--ease); }
.adv-head { display: flex; align-items: center; gap: 11px; padding: 14px 12px 14px 16px; background: var(--grad-dark); color: #fff; position: relative; overflow: hidden; }
.adv-head::before { content: ""; position: absolute; inset: 0; background: radial-gradient(240px 120px at 100% 0%, rgba(192, 32, 58, .55), transparent 65%); pointer-events: none; }
.adv-head > * { position: relative; }
.adv-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.adv-head-text b { font-family: var(--font-head); font-size: 15px; }
.adv-head-text small { font-size: 12px; color: #c5c9d3; }
.adv-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #c9cdd6; transition: background .15s; }
.adv-icon:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.adv-icon svg { width: 17px; height: 17px; }
.adv-progress { height: 3px; background: var(--line-soft); }
.adv-progress span { display: block; height: 100%; width: 0; background: var(--grad-solid); transition: width .5s var(--ease); }

.adv-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; background: var(--section-alt); scroll-behavior: smooth; }
.adv-msg { display: flex; gap: 8px; max-width: 100%; animation: msgIn .3s var(--ease); }
.adv-msg.user { justify-content: flex-end; }
.adv-bubble { min-width: 0; padding: 10px 13px; border-radius: 16px; line-height: 1.5; color: var(--text-strong); overflow-wrap: anywhere; }
.adv-msg.bot .adv-bubble { background: var(--surface); border: 1px solid var(--line); border-top-left-radius: 4px; max-width: calc(100% - 36px); }
.adv-msg.user .adv-bubble { background: var(--crimson); color: #fff; border-top-right-radius: 4px; max-width: 84%; }
.adv-bubble a { color: var(--crimson); font-weight: 700; }
.adv-bubble strong { color: var(--ink); }
.adv-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.adv-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--slate-light); animation: typing 1.2s infinite; }
.adv-typing i:nth-child(2) { animation-delay: .15s; }
.adv-typing i:nth-child(3) { animation-delay: .3s; }
.adv-q-n { display: block; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--crimson); margin-bottom: 3px; }

.adv-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 10px; background: var(--section-alt); max-height: 190px; overflow-y: auto; }
.adv-chips:empty { display: none; }
.adv-chip { padding: 8px 13px; border-radius: var(--r-pill); border: 1.5px solid color-mix(in srgb, var(--crimson) 45%, var(--line)); background: var(--surface);
  color: var(--crimson); font-weight: 700; font-size: 13px; text-align: left; transition: background .15s, color .15s, transform .15s; }
.adv-chip:hover { background: var(--crimson); color: #fff; transform: translateY(-1px); }
.adv-chip.primary { background: var(--crimson); color: #fff; border-color: var(--crimson); }

.adv-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.adv-input input { flex: 1; min-width: 0; padding: 10px 14px; border-radius: var(--r-pill); border: 1.5px solid var(--line); background: var(--field-bg); color: var(--ink); font-size: 14px; }
.adv-input input:focus { outline: none; border-color: var(--crimson); }
.adv-input button { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-solid); color: #fff; flex: 0 0 auto; }
.adv-input button svg { width: 17px; height: 17px; }

.adv-score { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.adv-score b { font-family: var(--font-head); font-size: 24px; color: var(--crimson); }
.adv-score span { font-size: 13.5px; }
.adv-correction { display: grid; gap: 4px; font-size: 12.5px; }
.adv-correction .ok { color: var(--success); }
.adv-correction .ko { color: var(--slate); }

.adv-diag { display: flex; align-items: center; gap: 14px; }
.adv-diag small { display: block; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--crimson); }
.adv-diag b { display: block; font-family: var(--font-head); color: var(--ink); }
.adv-diag span { font-size: 12.5px; color: var(--slate); }
.adv-ring { --p: 0; width: 58px; height: 58px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--crimson) calc(var(--p) * 1%), var(--mist-2) 0); }
.adv-ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); }
.adv-ring span { position: relative; font-family: var(--font-head); font-weight: 800; font-size: 14px; color: var(--ink); }

.adv-msg.bot .adv-bubble:has(.adv-card) { padding: 0; border: none; background: none; max-width: calc(100% - 36px); width: 100%; }
.adv-card { position: relative; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.adv-card.best { border: 2px solid var(--crimson); box-shadow: 0 10px 26px rgba(192, 32, 58, .14); padding-top: 18px; }
.adv-ribbon { position: absolute; top: -10px; left: 12px; padding: 2px 10px; border-radius: var(--r-pill); background: var(--grad-solid); color: #fff; font-style: normal; font-size: 11px; font-weight: 800; }
.adv-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.adv-ref { font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; color: var(--slate); }
.adv-badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.adv-badges span { font-size: 10.5px; font-weight: 800; padding: 2px 7px; border-radius: var(--r-pill); background: var(--crimson-50); color: var(--crimson); }
.adv-card h4 { font-size: 14.5px; line-height: 1.35; margin-bottom: 6px; }
.adv-card h4 a { color: var(--ink); }
.adv-card h4 a:hover { color: var(--crimson); }
.adv-facts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--slate); margin-bottom: 8px; }
.adv-facts b { color: var(--ink); }
.adv-reasons { display: grid; gap: 4px; margin-bottom: 10px; font-size: 12.5px; color: var(--text-strong); }
.adv-reasons li { position: relative; padding-left: 18px; }
.adv-reasons li::before { content: "✓"; position: absolute; left: 0; color: var(--success); font-weight: 800; }
.adv-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.adv-btn { display: inline-flex; align-items: center; justify-content: center; padding: 7px 11px; border-radius: 9px; font-size: 12.5px; font-weight: 700;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); transition: border-color .15s, background .15s, color .15s; }
.adv-btn:hover { border-color: var(--crimson); color: var(--crimson); }
.adv-btn.primary { background: var(--grad-solid); color: #fff; border-color: transparent; }
.adv-btn.primary:hover { color: #fff; filter: brightness(1.05); }
.adv-btn.ghost { border-color: transparent; color: var(--slate); }
.adv-btn[disabled] { opacity: .7; pointer-events: none; }
.adv-path { display: grid; gap: 6px; margin-top: 6px; }
.adv-path li { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.adv-path span { flex: 0 0 auto; font-size: 10.5px; font-weight: 800; text-transform: uppercase; padding: 1px 7px; border-radius: var(--r-pill); background: var(--mist-2); color: var(--slate); }

.adv-lead { display: grid; gap: 8px; margin-left: 36px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); animation: msgIn .3s var(--ease); }
.adv-lead input[type=text], .adv-lead input:not([type]), .adv-lead input[type=email], .adv-lead input[type=tel] {
  padding: 9px 12px; border-radius: 9px; border: 1.5px solid var(--line); background: var(--field-bg); color: var(--ink); font-size: 13.5px; }
.adv-lead input:focus { outline: none; border-color: var(--crimson); }
.adv-lead label { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--slate); }
.adv-err { font-size: 12.5px; color: var(--danger); font-weight: 600; }

@media (max-width: 600px) {
  .adv { right: 12px; bottom: 12px; }
  /* Pastille ronde : la bulle « Trouver ma formation » masquait les champs et les boutons du bas de l'écran */
  .adv-launcher { padding: 5px; }
  .adv-launcher-text { display: none; }
  .adv-launcher .adv-avatar { width: 46px; height: 46px; font-size: 19px; }
  .adv-pulse { left: 5px; top: 5px; width: 46px; height: 46px; }
  .adv-teaser { max-width: min(260px, calc(100vw - 32px)); }
  /* Discrète quand on remplit un formulaire (pages de connexion, champ en cours de saisie) */
  body:has(.auth) .adv:not(.is-open), body:has(:is(input, textarea, select):focus:not(#adv-q)) .adv:not(.is-open) { visibility: hidden; opacity: 0; }
  /* Plein écran visible, au-dessus du clavier : advisor.js recale --adv-top et --adv-h sur la zone visible (iOS) */
  .adv-panel { position: fixed; left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: auto; width: auto;
    top: calc(var(--adv-top, 0px) + max(8px, env(safe-area-inset-top)));
    height: calc(var(--adv-h, var(--screen-dh)) - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom))); }
}
@media (prefers-reduced-motion: reduce) { .adv-pulse { animation: none; display: none; } }
@media print { .adv { display: none; } }

/* Cohabitation avec le bouton « haut de page » et la barre de réservation mobile */
body:has(.adv) .to-top { bottom: 86px; }
.has-mobile-book .adv { bottom: 86px; }
.has-mobile-book .to-top { bottom: 150px; }

/* Accès au conseiller depuis les pages (accueil, catalogue) */
.adv-cta-hero { display: inline-flex; align-items: center; gap: 10px; margin-top: 18px; padding: 10px 16px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .22); color: #e6e8ee; font-size: 14px; text-align: left; transition: background .2s, border-color .2s; }
.adv-cta-hero:hover { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .4); }
.adv-cta-hero b { color: #fff; }
.adv-cta-hero svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--coral-light); }

/* Liens vers le centre d'aide */
.adv-guides { display: grid; gap: 6px; }
.adv-guides > b { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-light); }
.adv-guides a { display: grid; gap: 2px; padding: 9px 11px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); transition: border-color .15s; }
.adv-guides a:hover { border-color: var(--crimson); }
.adv-guides small { font-size: 11.5px; color: var(--slate-light); }
.adv-guides span { font-size: 13.5px; font-weight: 700; color: var(--crimson); }
