/* PEV — widget chat. Aligné sur le design system du site (surface sombre
   signature, dégradé violet→bleu nuit, Raleway + Rubik, easing feutré). */

.pev-chat {
  /* Tokens repris à l'identique de la surface sombre du site (global.css). */
  --pev-surface: #0f0120;      /* fond de page sombre */
  --pev-raised: #1f063e;       /* cartes / bulles surélevées */
  --pev-heading: #f5f2fa;      /* titres (blanc cassé, jamais blanc pur) */
  --pev-body: #d1cce0;         /* corps */
  --pev-muted: #b2aac7;        /* secondaire */
  --pev-line: rgba(137, 125, 180, 0.24); /* filet discret sur sombre */
  --pev-accent: #bfabff;       /* violet éclairci (liens sur sombre) */
  --pev-grad: linear-gradient(118deg, #3b0086 0%, #4a1fb5 42%, #1d4ed8 100%);
  --pev-radius: 16px;
  --pev-radius-bubble: 14px;
  --pev-ease: cubic-bezier(0.22, 1, 0.36, 1);

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483000;
  font-family: "Rubik", ui-sans-serif, system-ui, sans-serif;
  color: var(--pev-body);
}

/* Lanceur : pilule au dégradé signature, sobre (pas de halo criard). */
.pev-chat__launcher {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 20px;
  border: none;
  border-radius: 999px;
  background-color: #2a1aa0;
  background-image: var(--pev-grad);
  background-size: 160% 160%;
  background-position: 0% 50%;
  color: #fff;
  font-family: "Raleway", ui-sans-serif, system-ui, sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: 0.1px;
  cursor: pointer;
  box-shadow: 0 14px 34px -18px rgba(29, 78, 216, 0.7),
    0 2px 8px -3px rgba(15, 1, 32, 0.5);
  transition: transform 0.4s var(--pev-ease), background-position 0.5s var(--pev-ease);
}
.pev-chat__launcher:hover { transform: translateY(-2px); background-position: 100% 50%; }
.pev-chat__launcher:active { transform: translateY(0) scale(0.98); transition-duration: 0.12s; }
.pev-chat__launcher[hidden] { display: none; }
.pev-chat__launcher svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Panneau : carte sombre signature avec voile aurora très discret en tête. */
.pev-chat__panel {
  display: none;
  flex-direction: column;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100dvh - 48px);
  background-color: var(--pev-surface);
  background-image: radial-gradient(120% 60% at 92% -8%, rgba(124, 58, 237, 0.28), transparent 60%),
    radial-gradient(120% 70% at -10% 4%, rgba(37, 99, 235, 0.18), transparent 62%);
  border: 1px solid var(--pev-line);
  border-radius: var(--pev-radius);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(245, 242, 250, 0.05) inset,
    0 30px 70px -32px rgba(0, 0, 0, 0.85);
}
.pev-chat__panel[data-open="true"] { display: flex; }

.pev-chat__header {
  position: relative;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--pev-line);
}
/* Filet dégradé signature sous l'en-tête (rappel des title-rule du site). */
.pev-chat__header::after {
  content: "";
  position: absolute;
  left: 20px;
  bottom: -1px;
  width: 44px;
  height: 2px;
  border-radius: 999px;
  background-image: var(--pev-grad);
}
.pev-chat__title {
  font-family: "Raleway", ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  color: var(--pev-heading);
  margin: 0;
}
.pev-chat__subtitle { color: var(--pev-muted); font-size: 12px; margin: 3px 0 0; }
.pev-chat__controls {
  position: absolute; top: 12px; right: 12px;
  display: inline-flex; gap: 2px;
}
.pev-chat__min,
.pev-chat__close {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--pev-muted);
  font-size: 20px; cursor: pointer; line-height: 1; border-radius: 8px;
  transition: color 0.3s ease, background-color 0.3s ease;
}
.pev-chat__min { font-size: 22px; }
.pev-chat__min:hover,
.pev-chat__close:hover { color: var(--pev-heading); background-color: rgba(137, 125, 180, 0.14); }

/* Corps */
.pev-chat__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(137, 125, 180, 0.35) transparent;
}
.pev-chat__body::-webkit-scrollbar { width: 8px; }
.pev-chat__body::-webkit-scrollbar-thumb {
  background-color: rgba(137, 125, 180, 0.32);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.pev-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: var(--pev-radius-bubble);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.pev-msg--bot {
  align-self: flex-start;
  background-color: var(--pev-raised);
  border: 1px solid var(--pev-line);
  border-bottom-left-radius: 5px;
  color: var(--pev-body);
}
.pev-msg--user {
  align-self: flex-end;
  background-image: var(--pev-grad);
  border-bottom-right-radius: 5px;
  color: #fff;
}
.pev-msg--bot a {
  color: var(--pev-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}
.pev-msg--bot a:hover { text-decoration-thickness: 2px; }
.pev-disclaimer {
  align-self: flex-start;
  max-width: 86%;
  margin-top: -6px;
  padding: 0 14px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--pev-muted);
}

/* Indicateur de frappe : trois points qui respirent. */
.pev-typing { display: inline-flex; gap: 5px; align-items: center; padding: 3px 0; }
.pev-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background-color: var(--pev-accent);
  animation: pev-typing-bounce 1.2s infinite ease-in-out;
}
.pev-typing span:nth-child(2) { animation-delay: 0.15s; }
.pev-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pev-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Consentement */
.pev-consent {
  padding: 16px 18px 18px;
  border-top: 1px solid var(--pev-line);
  font-size: 12px;
  color: var(--pev-muted);
}
.pev-consent p { margin: 0 0 12px; line-height: 1.55; }
.pev-consent label { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; line-height: 1.5; }
.pev-consent a { color: var(--pev-accent); text-decoration: underline; text-underline-offset: 2px; }
.pev-consent__check { margin-top: 2px; accent-color: #6d28d9; flex-shrink: 0; }
.pev-consent__btn {
  margin-top: 14px; width: 100%;
  padding: 12px; border: none; border-radius: 12px;
  background-color: #2a1aa0;
  background-image: var(--pev-grad);
  background-size: 160% 160%;
  background-position: 0% 50%;
  color: #fff;
  font-family: "Raleway", ui-sans-serif, system-ui, sans-serif; font-weight: 600; font-size: 14px;
  cursor: pointer;
  transition: transform 0.4s var(--pev-ease), background-position 0.5s var(--pev-ease);
}
.pev-consent__btn:hover:not(:disabled) { transform: translateY(-2px); background-position: 100% 50%; }
.pev-consent__btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Saisie */
.pev-chat__composer {
  display: none;
  border-top: 1px solid var(--pev-line);
  padding: 14px;
  gap: 9px;
  align-items: flex-end;
}
.pev-chat__composer[data-active="true"] { display: flex; }
.pev-chat__input {
  flex: 1; resize: none;
  background-color: var(--pev-raised); color: var(--pev-heading);
  border: 1px solid var(--pev-line); border-radius: 12px;
  padding: 11px 13px; font-family: inherit; font-size: 14px; line-height: 1.5;
  max-height: 110px;
  transition: border-color 0.3s ease;
}
.pev-chat__input::placeholder { color: var(--pev-muted); }
.pev-chat__input:focus,
.pev-consent__check:focus-visible,
.pev-consent__btn:focus-visible,
.pev-chat__send:focus-visible,
.pev-chat__launcher:focus-visible {
  outline: 2px solid #7abcf6;
  outline-offset: 2px;
}
.pev-chat__input:focus { border-color: rgba(122, 188, 246, 0.6); }
.pev-chat__send {
  border: none; border-radius: 12px; padding: 0 18px; height: 44px;
  background-color: #2a1aa0;
  background-image: var(--pev-grad);
  background-size: 160% 160%;
  background-position: 0% 50%;
  color: #fff; cursor: pointer;
  font-family: "Raleway", ui-sans-serif, system-ui, sans-serif; font-weight: 600; font-size: 14px;
  transition: transform 0.4s var(--pev-ease), background-position 0.5s var(--pev-ease), opacity 0.3s ease;
}
.pev-chat__send:hover:not(:disabled) { transform: translateY(-2px); background-position: 100% 50%; }
.pev-chat__send:disabled { opacity: 0.4; cursor: not-allowed; }

.pev-chat__footer {
  padding: 9px 14px; font-size: 10px; color: var(--pev-muted);
  text-align: center; border-top: 1px solid var(--pev-line);
}

/* Mobile : le panneau occupe quasi tout l'écran (marges de 10px), le lanceur
   reste ancré en bas à droite mais plus compact. */
@media (max-width: 480px) {
  .pev-chat { right: 14px; bottom: 14px; }
  .pev-chat__launcher { padding: 12px 16px; font-size: 14px; }
  .pev-chat__panel {
    position: fixed;
    inset: 10px 10px 10px 10px;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
  }
}

/* Entrée du panneau : montée + fondu feutrés (grammaire motion du site). */
@media (prefers-reduced-motion: no-preference) {
  .pev-chat__panel[data-open="true"] {
    animation: pev-panel-in 0.5s var(--pev-ease) both;
  }
  @keyframes pev-panel-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: none; }
  }
}
