/* AutoSystems — habillage épuré du widget officiel n8n 2.4.1.
   Ce fichier ne contient aucune logique de session ou de communication. */
:root {
  --chat--color--primary: #1463ff;
  --chat--color--primary-shade-50: #0f56dc;
  --chat--color--primary--shade-100: #0a47bb;
  --chat--color--secondary: #1463ff;
  --chat--color-secondary-shade-50: #0f56dc;
  --chat--color-white: #ffffff;
  --chat--color-light: #f7f9fc;
  --chat--color-light-shade-50: #e8edf5;
  --chat--color-light-shade-100: #d3dae6;
  --chat--color-medium: #c3cada;
  --chat--color-dark: #111827;
  --chat--spacing: 1rem;
  --chat--border-radius: 18px;
  --chat--window--width: 420px;
  --chat--window--height: 620px;
  --chat--window--bottom: 20px;
  --chat--window--right: 20px;
  --chat--window--border: 1px solid rgba(17, 24, 39, 0.1);
  --chat--window--border-radius: 26px;
  --chat--window--margin-bottom: 14px;
  --chat--header--padding: 10px 18px;
  --chat--header--background: #131722;
  --chat--header--color: #ffffff;
  --chat--heading--font-size: 1.12rem;
  --chat--subtitle--font-size: 0.95rem;
  --chat--message--font-size: 0.84rem;
  --chat--message--padding: 9px 12px;
  --chat--message--border-radius: 16px;
  --chat--message-line-height: 1.4;
  --chat--message--margin-bottom: 0.55rem;
  --chat--message--bot--background: #edf1f7;
  --chat--message--bot--color: #192334;
  --chat--message--user--background: #1463ff;
  --chat--message--user--color: #ffffff;
  --chat--toggle--size: 60px;
  --chat--toggle--background: #1463ff;
  --chat--toggle--hover--background: #0f56dc;
  --chat--toggle--active--background: #0a47bb;
  --chat--textarea--height: 48px;
  --chat--input--padding: 0.85rem 0.9rem;
  --chat--input--container--background: #ffffff;
  --chat--input--container--border: 1px solid #d5deeb;
  --chat--input--container--border-radius: 999px;
  --chat--input--container--padding: 5px;
  --chat--input--button--border-radius: 999px;
  --chat--input--send--button--background: #1463ff;
  --chat--input--send--button--color: #ffffff;
  --chat--input--send--button--background-hover: #0f56dc;
  --chat--input--send--button--color-hover: #ffffff;
  --chat--input--file--button--background: transparent;
  --chat--input--file--button--color: #66748c;
  --chat--body--background: #ffffff;
  --chat--footer--padding: 12px 14px 14px;
  --chat--footer--background: #ffffff;
  --chat--footer--border-top: 1px solid #eef2f6;
}

html, body { min-height: 100%; margin: 0; }
body {
  background: #ffffff; /* Page blanche pour éviter tout fond gris visible */
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Uniquement la présentation de l'interface officielle. */
.n8n-chat .chat-window-wrapper .chat-window {
  box-shadow: 0 20px 60px rgba(13, 22, 38, .14);
}
.n8n-chat .chat-layout .chat-header {
  min-height: 40px;
  gap: 0;
  padding: 10px 18px !important;
}
.n8n-chat .chat-layout .chat-header h1 {
  font-size: 1.12rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
  font-weight: 600;
  margin: 0;
}
/* Masque intégralement le sous-titre (y compris son espace). */
.n8n-chat .chat-layout .chat-header p {
  display: none;
}
.n8n-chat .chat-layout .chat-body {
  background: #ffffff;
  padding-top: 5px !important;
}
.n8n-chat .chat-message.chat-message-from-bot {
  border-bottom-left-radius: 20px;
}
.n8n-chat .chat-message.chat-message-from-user {
  border-bottom-right-radius: 20px;
  box-shadow: 0 6px 16px rgba(20, 99, 255, .13);
}
.n8n-chat .chat-input-send-button {
  width: 44px;
  height: 44px;
  margin: 2px;
}
.n8n-chat .chat-window-wrapper .chat-window-toggle {
  box-shadow: 0 12px 28px rgba(20, 99, 255, .22);
}

@media (max-width: 640px) {
  :root {
    --chat--window--width: calc(100vw - 24px);
    --chat--window--height: min(78vh, 650px);
    --chat--window--bottom: 12px;
    --chat--window--right: 12px;
  }
}

/* Largeur intrinsèque : les bulles suivent leur texte.
   La largeur maximale s'applique uniquement aux messages longs. */
.n8n-chat .chat-message {
  width: fit-content;
  max-width: 85% !important;
  overflow-wrap: anywhere;
}
.n8n-chat .chat-message p {
  margin: 0;
}

/* AutoSystems v6 — animation visible sur le véritable bouton n8n.
   IMPORTANT : n8n conserve .chat-window dans le DOM même lorsque le chat est fermé
   (v-show / display:none). Il ne faut donc PAS tester son absence dans :has(). */
.chat-window-wrapper .chat-window-toggle {
  position: relative;
  box-shadow: 0 10px 24px rgba(20, 99, 255, .30);
  animation: autosystems-launcher-pulse 2.8s ease-in-out infinite;
}

/* Lorsque le panneau du chat est ouvert, on coupe l'animation.
   La règle générale ci-dessus reste compatible avec des navigateurs sans :has(). */
@supports selector(:has(*)) {
  .chat-window-wrapper:has(.chat-window:not([style*="display: none"])) .chat-window-toggle {
    animation: none;
    box-shadow: 0 10px 24px rgba(20, 99, 255, .22);
  }
}

@keyframes autosystems-launcher-pulse {
  0%, 12%, 100% {
    box-shadow: 0 10px 24px rgba(20, 99, 255, .30), 0 0 0 0 rgba(20, 99, 255, .28);
  }
  48% {
    box-shadow: 0 14px 30px rgba(20, 99, 255, .42), 0 0 0 12px rgba(20, 99, 255, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-window-wrapper .chat-window-toggle {
    animation: none !important;
  }
}

/* AutoSystems v7 — pastille de réponse non lue native au composant ChatWindow.
   Visible UNIQUEMENT quand le moteur a reçu une réponse pendant que la fenêtre était fermée.
   L'ouverture du chat efface le signal ; le chargement de l'historique ne le déclenche pas. */
.n8n-chat .chat-window-toggle .autosystems-unread-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 15px;
  height: 15px;
  border: none;
  border-radius: 50%;
  background: #ff0000;
  box-shadow: none;
  pointer-events: none;
  z-index: 3;
  animation: none;
}


.n8n-chat .chat-messages-list {
  background: #ffffff;
}
.n8n-chat .chat-message.autosystems-has-carousel,
.n8n-chat .chat-message.autosystems-has-carousel.chat-message-from-bot {
  background-color: transparent !important;
  box-shadow: none !important;
}
.n8n-chat .chat-message.autosystems-has-carousel > *,
.n8n-chat .chat-message.autosystems-has-carousel .autosystems-rich-message,
.n8n-chat .chat-message.autosystems-has-carousel .as-carousel-section,
.n8n-chat .chat-message.autosystems-has-carousel .as-carousel-track {
  background: transparent !important;
}

/* AutoSystems v8 — carrousel équilibré.
   Le style ne s'applique qu'aux nouveaux messages enrichis, jamais aux bulles classiques. */
.n8n-chat .chat-message.autosystems-has-carousel {
  box-sizing: border-box;
  width: 100%;
  max-width: 100% !important;
  padding: 0;
  overflow: visible;
  background: transparent !important;
  border: none;
}
.n8n-chat .autosystems-rich-message,
.n8n-chat .autosystems-rich-message * { box-sizing: border-box; }
.n8n-chat .autosystems-rich-message {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  min-width: 0;
}
.n8n-chat .as-rich-text {
  width: fit-content;
  max-width: 90%;
  padding: 10px 13px;
  background: #edf1f7;
  color: #192334;
  line-height: 1.45;
  border-radius: 16px 16px 16px 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.n8n-chat .as-carousel-section { width: 100%; min-width: 0; background: transparent; }
.n8n-chat .as-carousel-track {
  display: flex;
  gap: 10px;
  width: 100%;
  background: transparent;
  padding: 2px 2px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.n8n-chat .as-carousel-track::-webkit-scrollbar { display: none; }
.n8n-chat .as-carousel-card {
  flex: 0 0 min(232px, 78vw);
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e3e8f2;
  border-radius: 16px;
  overflow: hidden;
  scroll-snap-align: start;
  box-shadow: 0 4px 14px rgba(21, 33, 54, 0.075);
}
.n8n-chat .as-carousel-image-wrap {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: transparent;
  overflow: hidden;
}
.n8n-chat .as-carousel-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.n8n-chat .as-carousel-image-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 12px;
  color: #69758b;
  text-align: center;
  font-size: 0.78rem;
}
.n8n-chat .as-carousel-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 5px;
  min-height: 68px;
  padding: 12px 12px 8px;
}
.n8n-chat .as-carousel-description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  color: #3b465b;
  font-size: 0.82rem;
  line-height: 1.4;
  margin: 0;
}
.n8n-chat .as-carousel-price {
  margin: auto 0 0;
  padding-top: 6px;
  color: #172033;
  font-size: 0.87rem;
  line-height: 1.35;
  font-weight: 700;
}
.n8n-chat .as-carousel-action {
  display: block;
  width: calc(100% - 24px);
  min-height: 39px;
  margin: 0 12px 12px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: #1463ff;
  color: #fff;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.14s ease;
}
.n8n-chat .as-carousel-action:hover:not(:disabled) { background: #0f56dc; }
.n8n-chat .as-carousel-action:focus-visible,
.n8n-chat .as-carousel-nav:focus-visible,
.n8n-chat .as-carousel-track:focus-visible {
  outline: 2px solid #1463ff;
  outline-offset: 2px;
}
.n8n-chat .as-carousel-action:disabled { opacity: 0.6; cursor: wait; }
@media (prefers-reduced-motion: reduce) {
  .n8n-chat .as-carousel-action { transition: none; }
  .n8n-chat .as-carousel-track { scroll-behavior: auto; }
}


/* AutoSystems v11 — boutons de choix indépendants des carrousels.
   Pas de fond gris autour des choix, pas de style bleu plein. */
.n8n-chat .as-choice-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: min(100%, 292px);
  min-width: 0;
  max-width: 100%;
  background: transparent !important;
}
.n8n-chat .as-choice-question {
  width: fit-content;
  max-width: 100%;
}
.n8n-chat .as-choice-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 0;
  background: transparent !important;
}
.n8n-chat .as-choice-button {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  margin: 0;
  border: 1px solid #1463ff;
  border-radius: 12px;
  background: #ffffff;
  color: #1463ff;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
  box-shadow: none;
  transition: none;
  -webkit-tap-highlight-color: transparent;
}
.n8n-chat .as-choice-button:hover:not(:disabled) {
  background: #f3f7ff;
}
.n8n-chat .as-choice-button:focus-visible {
  outline: 2px solid #1463ff;
  outline-offset: 3px;
}
.n8n-chat .as-choice-button:disabled {
  color: #607da9;
  border-color: #b6c8e5;
  background: #ffffff;
  opacity: 0.72;
  cursor: default;
}
.n8n-chat .as-choice-group-inline {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
