/*
 * La bulle du chatbot de Sentinelle. Tout est préfixé `vsc-` et posé en `all: initial` à la
 * racine : un thème ne doit pas la déformer, et elle ne doit rien déformer du thème.
 */
#vsc-root {
  all: initial;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: #1f2937;
  /* La couleur du site, posée par le script quand sa charte en donne une lisible sous du blanc ;
     ses nuances en découlent. `all: initial` ne touche pas les propriétés personnalisées. */
  --vsc-accent: #1d4ed8;
  --vsc-accent-soft: color-mix(in srgb, var(--vsc-accent) 8%, #fff);
  --vsc-focus: color-mix(in srgb, var(--vsc-accent) 45%, #fff);
}

#vsc-root *,
#vsc-root *::before,
#vsc-root *::after {
  box-sizing: border-box;
}

/*
 * Les boutons et les champs repartent de zéro : le thème du site les habille aussi. Celui de TAP
 * donne 30 px de marge intérieure à gauche et à droite à tout bouton — sur le bouton rond de 60 px,
 * l'icône tombait à zéro de large (4 octobre 2026). Les règles de la bulle, toutes préfixées par
 * `#vsc-root`, passent ensuite devant cette remise à zéro comme devant le thème.
 *
 * **Un identifiant, pas une classe.** Préfixées par `.vsc-root`, elles égalaient
 * `.elementor-kit-6 button` : la dernière feuille chargée gagnait, et celle d'Elementor se charge
 * après la bulle. Le Kraken donnait ainsi 40 px de marge à chaque côté du bouton, qui faisait 80 px
 * de large malgré son `width` (5 octobre 2026). Un identifiant passe devant toute combinaison de
 * classes, quel que soit l'ordre des feuilles.
 */
#vsc-root button,
#vsc-root input,
#vsc-root textarea {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
  min-height: 0;
  width: auto;
  height: auto;
  font: inherit;
  line-height: inherit;
  letter-spacing: normal;
  text-transform: none;
  text-shadow: none;
  box-shadow: none;
  background: none;
  color: inherit;
}

#vsc-root svg {
  display: block;
  flex: none;
}

#vsc-root .vsc-toggle {
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--vsc-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#vsc-root .vsc-toggle svg {
  width: 28px;
  height: 28px;
}

/* Le bouton, et à sa gauche l'aide proposée sur la page d'un formulaire. */
#vsc-root .vsc-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
}

#vsc-root .vsc-teaser {
  display: flex;
  align-items: center;
  max-width: calc(100vw - 110px);
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  animation: vsc-teaser-in 0.3s ease-out;
}

#vsc-root .vsc-teaser-text,
#vsc-root .vsc-teaser-close {
  cursor: pointer;
}

#vsc-root .vsc-teaser-text {
  padding: 8px 4px 8px 14px;
  font-size: 13px;
  text-align: left;
}

#vsc-root .vsc-teaser-close {
  padding: 8px 12px 8px 6px;
  font-size: 16px;
  line-height: 1;
  color: #6b7280;
}

#vsc-root .vsc-teaser-text:focus-visible,
#vsc-root .vsc-teaser-close:focus-visible {
  outline: 3px solid var(--vsc-focus);
  outline-offset: 2px;
  border-radius: 999px;
}

@keyframes vsc-teaser-in {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #vsc-root .vsc-teaser {
    animation: none;
  }
}

#vsc-root .vsc-toggle:focus-visible,
#vsc-root .vsc-expand:focus-visible,
#vsc-root .vsc-close:focus-visible,
#vsc-root .vsc-action:focus-visible {
  outline: 3px solid var(--vsc-focus);
  outline-offset: 2px;
}

#vsc-root .vsc-panel {
  width: 370px;
  max-width: calc(100vw - 40px);
  height: 540px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

#vsc-root .vsc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--vsc-accent);
  color: #fff;
}

#vsc-root .vsc-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

#vsc-root .vsc-restart {
  margin-left: auto;
  margin-right: 8px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

/* « Être rappelé » et « Parler à un conseiller » : des icônes dans l'en-tête. */
#vsc-root .vsc-talk,
#vsc-root .vsc-callme {
  display: inline-flex;
  align-items: center;
  margin: 0 6px 0 0;
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

#vsc-root .vsc-talk svg,
#vsc-root .vsc-callme svg {
  width: 18px;
  height: 18px;
}

/* La carte de la demande de rappel, dans la conversation. */
#vsc-root .vsc-callback {
  align-self: stretch;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
  font-size: 13px;
}

#vsc-root .vsc-callback-title {
  margin: 0;
  font-weight: 600;
  font-size: 14px;
}

#vsc-root .vsc-callback-label {
  display: grid;
  gap: 4px;
  margin: 0;
  color: #374151;
}

#vsc-root .vsc-callback-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 34px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
  font: inherit;
  color: #111827;
}

#vsc-root .vsc-callback-privacy {
  margin: 0;
  color: #6b7280;
  font-size: 12px;
}

#vsc-root .vsc-callback-error {
  margin: 0;
  color: #b91c1c;
}

#vsc-root .vsc-callback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#vsc-root .vsc-chip.vsc-chip-primary {
  background: var(--vsc-accent);
  border-color: var(--vsc-accent);
  color: #fff;
}

#vsc-root .vsc-expand {
  display: inline-flex;
  align-items: center;
  margin: 0 6px 0 0;
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: #fff;
  line-height: 1;
  cursor: pointer;
}

#vsc-root .vsc-expand-offer {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px dashed var(--vsc-accent);
  font-size: 13px;
}

#vsc-root .vsc-expand-offer-text {
  flex: 1 1 100%;
}

#vsc-root .vsc-expand-offer-accept,
#vsc-root .vsc-expand-offer-dismiss {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--vsc-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#vsc-root .vsc-expand-offer-accept {
  background: var(--vsc-accent);
  color: #fff;
}

#vsc-root .vsc-expand-offer-dismiss {
  background: transparent;
  color: var(--vsc-accent);
}

/* En grand, sur ordinateur : un panneau à droite, sur toute la hauteur. Il passe par-dessus la
   page plutôt que de la pousser : décaler le site casse les en-têtes fixes et les thèmes Elementor. */
@media (min-width: 1024px) {
  #vsc-root.vsc-is-open.vsc-is-expanded {
    top: 0;
    right: 0;
    bottom: 0;
    width: 440px;
    gap: 0;
    align-items: stretch;
  }

  #vsc-root.vsc-is-open.vsc-is-expanded .vsc-panel {
    flex: 1;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: none;
    border-radius: 0;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.18);
  }

  #vsc-root.vsc-is-open.vsc-is-expanded .vsc-launcher {
    display: none;
  }

  #vsc-root.vsc-is-expanded .vsc-message {
    max-width: 92%;
  }
}

#vsc-root .vsc-close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

#vsc-root .vsc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f3f4f6;
}

#vsc-root .vsc-message {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

#vsc-root .vsc-assistant {
  align-self: flex-start;
  background: #fff;
}

/* Une réponse en paragraphes et en listes : la liste à part, dans un encadré, pour que la phrase
   qui la suit se lise. Tout est redéfini : un thème met ses marges et ses puces sur ul et li. */
#vsc-root .vsc-assistant {
  white-space: normal;
}

#vsc-root .vsc-paragraph {
  display: block;
  margin: 0;
  padding: 0;
}

#vsc-root .vsc-paragraph + .vsc-paragraph,
#vsc-root .vsc-list + .vsc-paragraph {
  margin-top: 8px;
}

#vsc-root .vsc-list {
  display: block;
  margin: 8px 0 0;
  padding: 8px 10px 8px 26px;
  border-left: 3px solid var(--vsc-accent);
  border-radius: 8px;
  background: #f5f7fb;
  list-style: disc outside;
  font-size: 14px;
  line-height: 1.4;
}

#vsc-root .vsc-item {
  display: list-item;
  margin: 0;
  padding: 0;
  list-style: inherit;
}

#vsc-root .vsc-item + .vsc-item {
  margin-top: 4px;
}

#vsc-root .vsc-visitor {
  align-self: flex-end;
  background: var(--vsc-accent);
  color: #fff;
}

#vsc-root .vsc-typing {
  align-self: flex-start;
  color: #6b7280;
  font-style: italic;
  font-size: 13px;
  background: transparent;
}

#vsc-root .vsc-note {
  align-self: flex-start;
  background: #ecfdf5;
  color: #065f46;
  font-size: 13px;
}

#vsc-root .vsc-link {
  color: var(--vsc-accent);
  text-decoration: underline;
}

/*
 * Les réponses à cliquer ont leur place, réservée sur deux lignes : elles disparaissent à chaque
 * envoi et reviennent avec la réponse, et la conversation sautait d'autant (essai du 9 octobre
 * 2026). Au-delà de deux lignes, la zone grandit.
 */
#vsc-root .vsc-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  min-height: 72px;
  box-sizing: border-box;
  padding: 8px 10px 0;
  /* Le fond de la conversation : la place réservée ne fait plus une bande blanche (essai d'Adrien
     du 9 octobre 2026). */
  background: #f3f4f6;
}

#vsc-root .vsc-chip {
  border: 1px solid var(--vsc-accent);
  border-radius: 999px;
  background: #fff;
  color: var(--vsc-accent);
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* Une page à ouvrir : un bouton plein, carré, avec sa flèche — pas une réponse à cliquer. */
#vsc-root .vsc-page-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  background: var(--vsc-accent);
  color: #fff;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

#vsc-root .vsc-page-link::after {
  content: '→';
}

#vsc-root .vsc-page-link:hover,
#vsc-root .vsc-page-link:focus-visible {
  color: #fff;
  opacity: 0.9;
  outline: none;
}

#vsc-root .vsc-chip:hover,
#vsc-root .vsc-chip:focus,
#vsc-root .vsc-chip:focus-visible {
  color: var(--vsc-accent);
  background: var(--vsc-accent-soft);
  outline: none;
}

#vsc-root .vsc-preparing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 10px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--vsc-accent-soft);
  color: #4b5563;
  font-size: 12px;
}

#vsc-root .vsc-preparing-stop {
  border: 0;
  background: none;
  padding: 2px 0;
  color: #6b7280;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

#vsc-root .vsc-preparing-stop:hover,
#vsc-root .vsc-preparing-stop:focus-visible {
  color: #111827;
  outline: none;
}

#vsc-root .vsc-inline {
  display: flex;
  gap: 6px;
  width: 100%;
}

#vsc-root .vsc-inline-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 5px 8px;
  font: inherit;
  color: inherit;
}

/*
 * Le champ (8 octobre 2026, maquette « Le champ de saisie et la voix ») : une zone arrondie qui
 * grandit avec le texte, et un bouton rond à l'intérieur — le micro quand le champ est vide, la
 * flèche dès qu'il y a de quoi envoyer, le carré rouge pendant l'écoute.
 */
/* Un élément masqué le reste, quel que soit son affichage ordinaire. */
#vsc-root [hidden] {
  display: none !important;
}

#vsc-root .vsc-form {
  padding: 10px 12px 0;
  border-top: 1px solid #e5e7eb;
}

#vsc-root .vsc-field {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 5px 5px 5px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 22px;
  background: #fff;
}

#vsc-root .vsc-field:focus-within {
  border-color: var(--vsc-accent);
}

#vsc-root .vsc-field.vsc-is-listening {
  align-items: center;
  padding-left: 5px;
  border-color: #dc2626;
}

#vsc-root .vsc-input {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  padding: 8px 0;
  font: inherit;
  font-size: 15px;
  line-height: 20px;
  color: inherit;
  max-height: 100px;
  box-shadow: none;
}

#vsc-root .vsc-action,
#vsc-root .vsc-cancel {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--vsc-accent);
  color: #fff;
  cursor: pointer;
}

#vsc-root .vsc-action svg,
#vsc-root .vsc-cancel svg {
  width: 18px;
  height: 18px;
}

#vsc-root .vsc-action.vsc-is-stop {
  background: #dc2626;
}

#vsc-root .vsc-action:disabled {
  background: #d1d5db;
  cursor: default;
}

#vsc-root .vsc-cancel {
  background: #6b7280;
}

/* L'écoute, puis la transcription : à la place du texte, dans le même champ. */
#vsc-root .vsc-listening {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 0;
  font-size: 15px;
  color: #111827;
}

#vsc-root .vsc-rec-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: #dc2626;
  animation: vsc-blink 1s ease-in-out infinite;
}

#vsc-root .vsc-wave {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 3px;
  min-width: 0;
  height: 22px;
  overflow: hidden;
}

#vsc-root .vsc-wave span {
  width: 3px;
  height: 100%;
  flex: none;
  border-radius: 2px;
  background: #dc2626;
  opacity: 0.7;
  animation: vsc-wave 0.9s ease-in-out infinite;
}

#vsc-root .vsc-timer {
  flex: none;
  font-size: 13px;
  color: #6b7280;
}

#vsc-root .vsc-listening.vsc-is-ending .vsc-listening-label,
#vsc-root .vsc-listening.vsc-is-ending .vsc-timer {
  color: #b91c1c;
  font-weight: 600;
}

#vsc-root .vsc-listening.vsc-is-transcribing {
  color: #9ca3af;
}

@keyframes vsc-blink {
  50% { opacity: 0.3; }
}

@keyframes vsc-wave {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

#vsc-root .vsc-notice {
  margin: 0;
  padding: 6px 12px 10px;
  font-size: 11px;
  color: #6b7280;
}

/*
 * Survol et focus : le thème colore aussi les boutons à ces états — Hello Elementor peint en rose
 * tout `[type=button]:hover`, d'une spécificité égale aux règles de la bulle (revue du 5 octobre
 * 2026). Chaque bouton redit donc ses couleurs, à une spécificité qui passe devant.
 */
#vsc-root .vsc-toggle:hover,
#vsc-root .vsc-toggle:focus,
#vsc-root .vsc-action:hover,
#vsc-root .vsc-action:focus {
  background: var(--vsc-accent);
  color: #fff;
}

#vsc-root .vsc-action.vsc-is-stop:hover,
#vsc-root .vsc-action.vsc-is-stop:focus {
  background: #dc2626;
}

#vsc-root .vsc-action:disabled:hover,
#vsc-root .vsc-action:disabled:focus {
  background: #d1d5db;
}

#vsc-root .vsc-cancel:hover,
#vsc-root .vsc-cancel:focus {
  background: #6b7280;
  color: #fff;
}

#vsc-root .vsc-talk:hover,
#vsc-root .vsc-talk:focus,
#vsc-root .vsc-callme:hover,
#vsc-root .vsc-callme:focus,
#vsc-root .vsc-expand:hover,
#vsc-root .vsc-expand:focus,
#vsc-root .vsc-restart:hover,
#vsc-root .vsc-restart:focus,
#vsc-root .vsc-close:hover,
#vsc-root .vsc-close:focus {
  background: transparent;
  color: #fff;
}

#vsc-root .vsc-teaser-text:hover,
#vsc-root .vsc-teaser-text:focus {
  background: transparent;
  color: #1f2937;
}

#vsc-root .vsc-teaser-close:hover,
#vsc-root .vsc-teaser-close:focus {
  background: transparent;
  color: #6b7280;
}

@media (max-width: 480px) {
  #vsc-root {
    right: 12px;
    bottom: 12px;
  }

  #vsc-root.vsc-is-open {
    left: 12px;
    top: 12px;
  }

  #vsc-root.vsc-is-open .vsc-panel {
    width: 100%;
    max-width: none;
    height: auto;
    max-height: none;
    flex: 1;
  }

  #vsc-root.vsc-is-open .vsc-toggle {
    display: none;
  }

  /* Sous 16 px, Safari grossit toute la page quand le champ prend la main : la conversation
     part hors de l'écran avec le zoom. */
  #vsc-root .vsc-input {
    font-size: 16px;
  }
}

/* Hors de la bulle : sur la page du formulaire prérempli. */
.vsc-prefilled {
  outline: 2px solid #34d399 !important;
  outline-offset: 1px;
}

.vsc-prefill-notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #065f46;
  font-size: 14px;
}

.vsc-asking,
.vsc-documents {
  outline: 3px solid #f59e0b !important;
  outline-offset: 4px;
  border-radius: 6px;
}

/* Un conseiller qui a pris la main : sa bulle, signée de son prénom. */
#vsc-root .vsc-advisor {
  align-self: flex-start;
  white-space: normal;
  background: #e7f6ec;
  color: #1f2933;
  border: 1px solid #b7e1c4;
}

#vsc-root .vsc-author {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 600;
  color: #166534;
}
