/* VEXMOD WebChat — Widget Styles
   Isolé : préfixe vx-, aucune dépendance aux styles de la landing,
   compatible CSP style-src 'self', prefers-reduced-motion respecté. */

/* ── Helper classes for CSP compliance (no inline styles) ──────── */
.vx-hidden { display: none !important; }
.vx-visible { display: flex !important; }
.vx-sr-only {
  position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden;
}
.vx-body-lock { overflow: hidden; }
.vx-textarea-auto { height: auto; }
.vx-input {
  min-height: 48px;
  max-height: 140px;
  overflow-y: auto;
  field-sizing: content; /* Modern CSS for auto-sizing textareas */
}
/* ── Tokens locaux ──────────────────────────────────────────── */
:root {
  --vx-bg: #050d1c;
  --vx-surface: #0a1730;
  --vx-surface-2: #102244;
  --vx-line: #1d3357;
  --vx-fg: #eef4fb;
  --vx-muted: #a9bcd6;
  --vx-accent: #22c9f0;
  --vx-accent-strong: #67e8f9;
  --vx-accent-fg: #04101f;
  --vx-gold: #d4a843;
  --vx-gold-strong: #e8c56d;
  --vx-ok: #34d399;
  --vx-err: #f87171;
  --vx-warn: #fbbf24;
  --vx-radius: 16px;
  --vx-radius-sm: 10px;
  --vx-radius-lg: 22px;
  --vx-shadow: 0 12px 40px -12px rgba(0, 6, 20, 0.8), 0 4px 16px -4px rgba(0, 6, 20, 0.6);
  --vx-shadow-lg: 0 20px 60px -16px rgba(0, 6, 20, 0.9), 0 8px 24px -8px rgba(0, 6, 20, 0.7);
  --vx-transition: 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --vx-transition-fast: 140ms ease-out;
  --vx-z-widget: 1000;
  --vx-z-backdrop: 999;
  --vx-width: 400px;
  --vx-height: 600px;
  --vx-btn-size: 64px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  :root {
    --vx-transition: 0ms;
    --vx-transition-fast: 0ms;
  }
  .vx-steam, .vx-genie, .vx-pulse { animation: none !important; }
}

/* ── Floating Button ───────────────────────────────────────── */
.vx-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: var(--vx-btn-size);
  height: var(--vx-btn-size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--vx-gold) 0%, var(--vx-gold-strong) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--vx-shadow);
  z-index: var(--vx-z-widget);
  transition: transform var(--vx-transition), box-shadow var(--vx-transition), opacity var(--vx-transition);
  color: var(--vx-accent-fg);
}
.vx-fab:hover { transform: scale(1.08); box-shadow: var(--vx-shadow-lg); }
.vx-fab:focus-visible { outline: 3px solid var(--vx-accent); outline-offset: 3px; }
.vx-fab:active { transform: scale(0.95); }
.vx-fab[aria-expanded="true"] { transform: rotate(45deg) scale(1.08); }
.vx-fab.vx-hidden { opacity: 0; pointer-events: none; transform: scale(0.6); }
.vx-fab svg { width: 30px; height: 30px; transition: transform var(--vx-transition); }
.vx-fab[aria-expanded="true"] svg { transform: rotate(-45deg); }

/* Pulse ring when idle */
.vx-fab::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--vx-accent);
  opacity: 0;
  animation: vx-pulse-ring 3s ease-out infinite;
  pointer-events: none;
}
@keyframes vx-pulse-ring {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.6); opacity: 0; }
}
.vx-fab[aria-expanded="true"]::before,
.vx-fab:hover::before { animation: none; opacity: 0; }

/* ── Backdrop (mobile) ─────────────────────────────────────── */
.vx-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 13, 28, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  z-index: var(--vx-z-backdrop);
  transition: opacity var(--vx-transition), visibility var(--vx-transition);
}
.vx-backdrop.vx-visible { opacity: 1; visibility: visible; }

/* ── Panel ──────────────────────────────────────────────────── */
.vx-panel {
  position: fixed;
  right: 24px;
  bottom: calc(var(--vx-btn-size) + 32px);
  width: var(--vx-width);
  height: var(--vx-height);
  max-height: calc(100vh - 120px);
  max-width: calc(100vw - 48px);
  background: var(--vx-surface);
  border: 1px solid var(--vx-line);
  border-radius: var(--vx-radius-lg);
  box-shadow: var(--vx-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  z-index: var(--vx-z-widget);
  transition: opacity var(--vx-transition), visibility var(--vx-transition), transform var(--vx-transition);
}
.vx-panel.vx-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Mobile fullscreen */
@media (max-width: 480px) {
  .vx-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    max-width: 100%;
    border-radius: var(--vx-radius-lg) var(--vx-radius-lg) 0 0;
    height: 100dvh;
  }
  .vx-fab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}

/* ── Header ────────────────────────────────────────────────── */
.vx-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(180deg, var(--vx-surface-2) 0%, var(--vx-surface) 100%);
  border-bottom: 1px solid var(--vx-line);
  flex-shrink: 0;
}
.vx-header-avatar { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; background: linear-gradient(135deg, var(--vx-gold), var(--vx-gold-strong)); display: flex; align-items: center; justify-content: center; color: var(--vx-accent-fg); box-shadow: 0 0 16px rgba(34, 201, 240, 0.3); }
.vx-header-avatar svg { width: 22px; height: 22px; }
.vx-header-title { flex: 1; min-width: 0; }
.vx-header-name { font-weight: 700; font-size: 1rem; color: var(--vx-fg); line-height: 1.2; }
.vx-header-sub { font-size: 0.8rem; color: var(--vx-muted); line-height: 1.2; }
.vx-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--vx-line);
  background: transparent;
  color: var(--vx-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--vx-transition-fast), color var(--vx-transition-fast), border-color var(--vx-transition-fast);
  flex-shrink: 0;
}
.vx-close:hover { background: var(--vx-surface-2); color: var(--vx-fg); border-color: var(--vx-accent); }
.vx-close:focus-visible { outline: 2px solid var(--vx-accent); outline-offset: 2px; }
.vx-close svg { width: 20px; height: 20px; }

/* ── Messages Area ─────────────────────────────────────────── */
.vx-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.vx-messages::-webkit-scrollbar { width: 6px; }
.vx-messages::-webkit-scrollbar-track { background: transparent; }
.vx-messages::-webkit-scrollbar-thumb { background: var(--vx-line); border-radius: 3px; }
.vx-messages::-webkit-scrollbar-thumb:hover { background: var(--vx-muted); }

/* ── Message Bubbles ───────────────────────────────────────── */
.vx-msg { display: flex; gap: 10px; max-width: 85%; animation: vx-msg-in 200ms ease-out; }
@keyframes vx-msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.vx-msg.vx-user { align-self: flex-end; flex-direction: row-reverse; }
.vx-msg.vx-assistant { align-self: flex-start; }
.vx-msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
}
.vx-msg.vx-user .vx-msg-avatar { background: var(--vx-accent); color: var(--vx-accent-fg); }
.vx-msg.vx-assistant .vx-msg-avatar { background: linear-gradient(135deg, var(--vx-gold), var(--vx-gold-strong)); color: var(--vx-accent-fg); }
.vx-msg-bubble {
  padding: 12px 16px;
  border-radius: var(--vx-radius);
  font-size: 0.9rem;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.vx-msg.vx-user .vx-msg-bubble {
  background: var(--vx-accent);
  color: var(--vx-accent-fg);
  border-bottom-right-radius: 4px;
}
.vx-msg.vx-assistant .vx-msg-bubble {
  background: var(--vx-surface-2);
  color: var(--vx-fg);
  border: 1px solid var(--vx-line);
  border-bottom-left-radius: 4px;
}
.vx-msg.vx-assistant .vx-msg-bubble.vx-streaming { border-color: var(--vx-accent); box-shadow: 0 0 0 1px var(--vx-accent); }
.vx-msg.vx-error .vx-msg-bubble { background: rgba(248, 113, 113, 0.15); border-color: var(--vx-err); color: var(--vx-err); }
.vx-msg.vx-system .vx-msg-bubble { background: transparent; border: none; color: var(--vx-muted); font-size: 0.8rem; padding: 4px 12px; max-width: 100%; }

/* Typing indicator */
.vx-typing { display: inline-flex; gap: 4px; padding: 8px 12px; }
.vx-typing span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--vx-accent);
  animation: vx-typing 1.4s ease-in-out infinite both;
}
.vx-typing span:nth-child(2) { animation-delay: 0.2s; }
.vx-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes vx-typing { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

/* ── Suggestions ───────────────────────────────────────────── */
.vx-suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 16px; }
.vx-suggestion {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--vx-line);
  background: var(--vx-surface-2);
  color: var(--vx-fg);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--vx-transition-fast), background var(--vx-transition-fast), color var(--vx-transition-fast);
  white-space: nowrap;
}
.vx-suggestion:hover { border-color: var(--vx-accent); background: var(--vx-surface); }
.vx-suggestion:focus-visible { outline: 2px solid var(--vx-accent); outline-offset: 2px; }

/* ── Composer ──────────────────────────────────────────────── */
.vx-composer {
  display: flex;
  gap: 10px;
  padding: 16px;
  background: var(--vx-surface);
  border-top: 1px solid var(--vx-line);
  flex-shrink: 0;
}
.vx-input-wrap { flex: 1; display: flex; gap: 8px; }
.vx-input {
  flex: 1;
  min-height: 48px;
  max-height: 140px;
  padding: 10px 14px;
  border-radius: var(--vx-radius);
  border: 1.5px solid var(--vx-line);
  background: var(--vx-surface-2);
  color: var(--vx-fg);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: none;
  transition: border-color var(--vx-transition-fast), box-shadow var(--vx-transition-fast);
}
.vx-input::placeholder { color: var(--vx-muted); opacity: 0.7; }
.vx-input:focus { outline: none; border-color: var(--vx-accent); box-shadow: 0 0 0 3px rgba(34, 201, 240, 0.15); }
.vx-input:disabled { opacity: 0.5; cursor: not-allowed; }
.vx-send, .vx-cancel {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform var(--vx-transition-fast), background var(--vx-transition-fast);
}
.vx-send { background: var(--vx-accent); color: var(--vx-accent-fg); }
.vx-send:hover:not(:disabled) { background: var(--vx-accent-strong); transform: scale(1.05); }
.vx-send:disabled { opacity: 0.4; cursor: not-allowed; }
.vx-cancel { background: var(--vx-surface-2); color: var(--vx-muted); border: 1px solid var(--vx-line); }
.vx-cancel:hover { background: var(--vx-err); border-color: var(--vx-err); color: #fff; }
.vx-send svg, .vx-cancel svg { width: 20px; height: 20px; }

/* ── Status bar (connection state) ────────────────────────── */
.vx-status {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  font-size: 0.75rem;
  color: var(--vx-muted);
  border-top: 1px solid var(--vx-line);
  background: var(--vx-surface);
  flex-shrink: 0;
}
.vx-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--vx-muted);
  transition: background var(--vx-transition-fast);
}
.vx-status-dot.vx-connected { background: var(--vx-ok); box-shadow: 0 0 8px var(--vx-ok); }
.vx-status-dot.vx-connecting { background: var(--vx-warn); animation: vx-blink 1.2s ease-in-out infinite; }
.vx-status-dot.vx-error { background: var(--vx-err); }
@keyframes vx-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.vx-status-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Empty state ───────────────────────────────────────────── */
.vx-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; color: var(--vx-muted); }
.vx-empty svg { width: 64px; height: 64px; opacity: 0.3; }
.vx-empty-title { font-weight: 600; color: var(--vx-fg); font-size: 1rem; }
.vx-empty-desc { font-size: 0.85rem; max-width: 280px; line-height: 1.5; }

/* ── Genie animation overlay ───────────────────────────────── */
.vx-genie-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: calc(var(--vx-z-widget) + 10);
  opacity: 0;
  visibility: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 300ms ease, visibility 300ms ease;
}
.vx-genie-overlay.vx-active { opacity: 1; visibility: visible; }
.vx-genie-overlay svg { width: 180px; height: 180px; transform: scale(0.5); opacity: 0; transition: transform 500ms cubic-bezier(0.2, 1.2, 0.4, 1), opacity 400ms ease; }
.vx-genie-overlay.vx-active svg { transform: scale(1); opacity: 1; }

/* Steam animation on teapot */
.vx-steam path { animation: vx-steam-rise 2.5s ease-in-out infinite; transform-origin: center bottom; }
.vx-steam .vx-steam-1 { animation-delay: 0.3s; }
.vx-steam .vx-steam-2 { animation-delay: 0.6s; }
@keyframes vx-steam-rise {
  0% { transform: translateY(0) scale(1); opacity: 0.7; }
  50% { transform: translateY(-24px) scale(1.2); opacity: 0.4; }
  100% { transform: translateY(-40px) scale(1.4); opacity: 0; }
}

/* ── Root container ────────────────────────────────────────── */
.vx-root { position: relative; }
.vx-root * { box-sizing: border-box; }