/* ==========================================================================
   Assistant virtuel — fenêtre de discussion flottante
   Utilise les jetons du design system (design-system.css). Chargé seulement si
   FEATURES.assistant est actif. Le bandeau de consentement (z-index 200) reste au-dessus.
   ========================================================================== */
.assistant { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 150; font-family: var(--font-body); }
.assistant[hidden], .assistant [hidden] { display: none !important; }

/* ---------- bouton flottant */
.assistant-launcher {
  position: relative; display: grid; place-items: center; width: 3.75rem; height: 3.75rem; margin-left: auto;
  padding: 0; border: 0; border-radius: 50%; cursor: pointer; color: #fff;
  background: radial-gradient(circle at 30% 25%, var(--pad-sea) 0%, var(--pad-sea-strong) 42%, var(--pad-navy) 100%);
  box-shadow: 0 10px 28px rgba(5, 38, 96, .35), inset 0 -4px 10px rgba(0, 0, 0, .22);
  transition: transform .2s ease, box-shadow .2s ease;
}
.assistant-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 32px rgba(5, 38, 96, .45); }
.assistant-launcher svg { width: 1.7rem; height: 1.7rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.assistant-ic-close { display: none; }
.assistant.is-open .assistant-ic-open { display: none; }
.assistant.is-open .assistant-ic-close { display: block; }
.assistant.is-new .assistant-launcher::after {
  content: ""; position: absolute; inset: 0; border: 2px solid var(--pad-sea); border-radius: 50%;
  animation: assistant-pulse 2.4s ease-out infinite; pointer-events: none;
}
.assistant.is-open .assistant-launcher::after { display: none; }
@keyframes assistant-pulse { from { transform: scale(1); opacity: .7; } to { transform: scale(1.6); opacity: 0; } }

.assistant-teaser {
  position: absolute; right: 0; bottom: 4.6rem; width: max-content; max-width: 15rem; margin: 0;
  padding: .65rem .9rem; border-radius: var(--radius); background: var(--surface); color: var(--ink);
  box-shadow: 0 8px 24px rgba(5, 38, 96, .2); font-size: .9rem; line-height: 1.4; cursor: pointer;
}
.assistant-teaser strong { color: var(--pad-sea-strong); }

/* ---------- panneau */
.assistant-panel {
  position: absolute; right: 0; bottom: 4.75rem; display: flex; flex-direction: column;
  width: 23.5rem; height: min(38rem, calc(100vh - 7rem)); overflow: hidden;
  background: var(--surface); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(5, 38, 96, .3), 0 0 0 1px rgba(5, 38, 96, .08);
  animation: assistant-in .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes assistant-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

.assistant-head {
  position: relative; display: flex; align-items: center; gap: .7rem; padding: .95rem 1rem;
  color: #fff; background: linear-gradient(135deg, var(--pad-navy) 0%, var(--pad-sea-strong) 100%);
}
.assistant-head::after { content: ""; position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: linear-gradient(90deg, var(--pad-sea), transparent 75%); }
.assistant-avatar { display: grid; place-items: center; flex: none; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: rgba(255, 255, 255, .15); }
.assistant-avatar svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.assistant-who { flex: 1; min-width: 0; }
.assistant-who h2 { margin: 0; color: #fff; font-size: 1rem; }
.assistant-who p { display: flex; align-items: center; gap: .4rem; margin: .1rem 0 0; font-size: .78rem; opacity: .9; }
.assistant-dot { width: .5rem; height: .5rem; border-radius: 50%; background: #40c057; box-shadow: 0 0 0 2px rgba(64, 192, 87, .3); }
.assistant-icon-btn {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: #fff; cursor: pointer; opacity: .85;
}
.assistant-icon-btn:hover { opacity: 1; background: rgba(255, 255, 255, .14); }
.assistant-icon-btn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- messages */
.assistant-log { flex: 1; overflow-y: auto; padding: 1rem .85rem .5rem; background: var(--ground); font-size: .92rem; line-height: 1.5; }
.assistant-row { display: flex; margin-bottom: .75rem; }
.assistant-row-user { justify-content: flex-end; }
.assistant-bubble { max-width: 85%; padding: .6rem .8rem; border-radius: 16px; overflow-wrap: anywhere; }
.assistant-row-bot .assistant-bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; color: var(--ink); }
.assistant-row-user .assistant-bubble { background: var(--pad-navy); color: #fff; border-bottom-right-radius: 4px; }
.assistant-bubble p { margin: 0 0 .4rem; }
.assistant-bubble p:last-child { margin-bottom: 0; }
.assistant-bubble ul { margin: .25rem 0 .4rem; padding-left: 1.1rem; }
.assistant-bubble a { color: var(--pad-sea-strong); font-weight: 600; }
.assistant-row-user .assistant-bubble a { color: #fff; }
.assistant-bubble-error { background: #fdf0ef !important; border-color: #f1c4c0 !important; color: var(--crit) !important; }

.assistant-sources { margin-top: .6rem; padding-top: .5rem; border-top: 1px solid var(--line); font-size: .82rem; }
.assistant-sources p { margin: 0 0 .2rem; color: var(--ink-2); font-weight: 700; }
.assistant-sources ul { margin: 0; padding-left: 1rem; }

.assistant-typing { display: inline-flex; gap: .25rem; padding: .2rem 0; }
.assistant-typing i { width: .45rem; height: .45rem; border-radius: 50%; background: #93a3b8; animation: assistant-blink 1.2s infinite; }
.assistant-typing i:nth-child(2) { animation-delay: .15s; }
.assistant-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes assistant-blink { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

.assistant-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .6rem; }
.assistant-chip {
  padding: .4rem .75rem; border: 1px solid #b9d7ea; border-radius: 999px; background: var(--surface);
  color: var(--pad-navy); font: inherit; font-size: .84rem; text-align: left; cursor: pointer;
}
.assistant-chip:hover { border-color: var(--pad-navy); background: var(--pad-navy); color: #fff; }

/* ---------- saisie */
.assistant-form {
  display: flex; align-items: flex-end; gap: .5rem; margin: .65rem .75rem 0; padding: .35rem .35rem .35rem .8rem;
  border: 1px solid var(--line); border-radius: 14px; background: var(--ground);
}
.assistant-form:focus-within { border-color: var(--pad-sea-strong); box-shadow: 0 0 0 3px rgba(37, 174, 242, .2); }
.assistant-form textarea {
  flex: 1; min-height: 1.5rem; max-height: 7.5rem; padding: .4rem 0; border: 0; outline: 0; resize: none;
  background: transparent; color: var(--ink); font: inherit; font-size: .92rem;
}
.assistant-form textarea::placeholder { color: #6b7a8f; }
.assistant-send {
  display: grid; place-items: center; flex: none; width: 2.5rem; height: 2.5rem; padding: 0; border: 0;
  border-radius: 10px; background: var(--pad-navy); color: #fff; cursor: pointer;
}
.assistant-send:hover { background: var(--pad-sea-strong); }
.assistant-send:disabled { opacity: .4; cursor: not-allowed; }
.assistant-send svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.assistant-legal { margin: .4rem .9rem .65rem; color: var(--ink-2); font-size: .7rem; line-height: 1.35; text-align: center; }

/* ---------- mobile : plein écran */
@media (max-width: 520px) {
  .assistant { right: 1rem; bottom: 1rem; }
  .assistant-panel { position: fixed; inset: 0; width: 100%; height: 100%; border-radius: 0; }
  .assistant.is-open .assistant-launcher { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .assistant *, .assistant *::after { animation: none !important; transition: none !important; }
}
@media print { .assistant { display: none !important; } }
