/**
 * @file
 * The site's colours and fonts for the n8n chat widget.
 *
 * The widget declares its variables on :root and derives some from others
 * there (toggle colour from the primary colour …), so the overrides have to
 * sit on :root as well: "html:root" beats its ":root" regardless of which
 * stylesheet loads last. The theme's custom properties are used where they
 * exist (the names of the Drupal theme of drupal-ai.cz), otherwise the
 * fallback colours. Change the fallbacks here to match another site.
 */
html:root {
  --chat--color--primary: var(--color-primary, #8e1b3d);
  --chat--color--primary-shade-50: var(--color-primary-hover, #74162f);
  --chat--color--primary--shade-100: var(--color-primary-dark, #5c1126);
  --chat--color--secondary: var(--color-navy, #202938);
  --chat--color-secondary-shade-50: var(--color-navy-hover, #111827);
  --chat--color-dark: var(--color-navy, #202938);
  --chat--font-family: var(--font-body, system-ui, -apple-system, "Segoe UI", sans-serif);
  --chat--border-radius: 12px;

  /* Header on the dark gradient, like the dark sections of the site. */
  --chat--header--background: linear-gradient(120deg, var(--color-navy, #202938) 0%, var(--color-navy, #202938) 35%, var(--color-deep, #3d1424) 100%);
  --chat--header--color: #fff;

  /* Round button in the corner. */
  --chat--toggle--background: var(--color-navy, #202938);
  --chat--toggle--hover--background: var(--color-primary, #8e1b3d);
  --chat--toggle--active--background: var(--color-primary-dark, #5c1126);
  --chat--toggle--color: #fff;

  /* Messages: visitor navy, assistant light surface. */
  --chat--message--user--background: var(--color-navy, #202938);
  --chat--message--user--color: #fff;
  --chat--message--bot--background: var(--color-surface, #fcfbfa);
  --chat--message--bot--color: var(--color-text, #364152);
  --chat--message--bot--border: 1px solid var(--color-border, #efe9e8);

  --chat--input--send--button--color: var(--color-primary, #8e1b3d);
  --chat--input--send--button--color-hover: var(--color-primary-dark, #5c1126);

  /* Message field: dark, readable text on white with a visible frame (the
     widget's default is "initial" text colour and no border at all). */
  --chat--input--text-color: var(--color-navy, #202938);
  --chat--input--font-size: 1rem;
  /* Transparent, so the square textarea doesn't cover the frame's corners. */
  --chat--input--background: transparent;
  --chat--input--container--background: #fff;
  --chat--input--container--border: 1px solid var(--color-border-strong, #cdd2da);
  --chat--input--container--border-radius: 12px;
  --chat--footer--background: #fff;
  --chat--footer--padding: 0.75rem;
  --chat--footer--border-top: 1px solid var(--color-border, #efe9e8);

  /* Below the usual offcanvas menus and modal windows of themes. */
  --chat--window--z-index: 1030;
}

/* Header: avatar with an AI icon on the left, a compact title and subtitle
   on the right (the widget stacks them with 1em gaps and a 2em heading). */
html .chat-layout .chat-header {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  row-gap: 2px;
  padding: 14px 16px;
}

html .chat-layout .chat-header::before {
  content: "AI";
  grid-row: 1 / span 2;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font: 800 15px/1 var(--chat--font-family);
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, var(--chat--color--primary) 0%, var(--chat--color--primary--shade-100) 100%);
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.12), 0 4px 12px rgb(0 0 0 / 0.25);
}

html .chat-layout .chat-header .chat-heading {
  grid-column: 2;
  min-width: 0;
}

html .chat-layout .chat-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

html .chat-layout .chat-header p {
  grid-column: 2;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.35;
  opacity: 0.85;
}

/* "Online" dot before the subtitle. */
html .chat-layout .chat-header p::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 3px rgb(52 211 153 / 0.25);
  vertical-align: 1px;
}

html .chat-layout .chat-header .chat-close-button {
  color: inherit;
  opacity: 0.8;
}

html .chat-layout .chat-header .chat-close-button:hover {
  opacity: 1;
}

/* Message field: the text and the send button centred in the frame (the
   widget aligns them to the bottom, and the button's 8px margin makes the
   frame taller than the textarea). */
html .chat-window-wrapper .chat-inputs {
  align-items: center;
  overflow: hidden;
}

html .chat-window-wrapper .chat-inputs textarea {
  color: var(--chat--input--text-color);
  background: transparent;
}

html .chat-window-wrapper .chat-input-send-button,
html .chat-window-wrapper .chat-input-file-button {
  margin: 0 4px 0 0;
}

html .chat-window-wrapper .chat-inputs textarea::placeholder {
  color: var(--color-text-muted, #5d6675);
  opacity: 1;
}

html .chat-window-wrapper .chat-inputs:focus-within {
  border-color: var(--chat--color--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat--color--primary) 20%, transparent);
}

/* Corner button: "AI" badge, and a pulse until the visitor opens the chat
   for the first time (js/n8n-chat.js adds and removes the classes). */
.chat-window-wrapper .chat-window-toggle {
  position: relative;
  overflow: visible;
}

.chat-window-wrapper .chat-window-toggle:focus-visible {
  outline: 3px solid var(--chat--color--primary);
  outline-offset: 3px;
}

.n8n-chat-ai-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 28px;
  padding: 3px 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--chat--color--primary);
  color: #fff;
  font: 700 12px/1 var(--chat--font-family);
  letter-spacing: 0.04em;
  text-align: center;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.25);
  pointer-events: none;
}

/* Hidden while the window is open (the button shows a cross then). */
.n8n-chat-open .n8n-chat-ai-badge {
  display: none;
}

.n8n-chat-attention .chat-window-toggle::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--chat--color--primary) 60%, transparent);
  animation: n8n-chat-pulse 3s ease-out infinite;
  pointer-events: none;
}

.n8n-chat-attention .n8n-chat-ai-badge {
  animation: n8n-chat-badge 3s ease-in-out infinite;
}

/* Pulse in the first part of each cycle, then rest. */
@keyframes n8n-chat-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--chat--color--primary) 60%, transparent);
  }
  45%,
  100% {
    box-shadow: 0 0 0 18px transparent;
  }
}

@keyframes n8n-chat-badge {
  0%,
  60%,
  100% {
    transform: translateY(0) rotate(0);
  }
  10% {
    transform: translateY(-5px) rotate(-8deg);
  }
  20% {
    transform: translateY(0) rotate(6deg);
  }
  30% {
    transform: translateY(-2px) rotate(-3deg);
  }
  40% {
    transform: translateY(0) rotate(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .n8n-chat-attention .chat-window-toggle::before,
  .n8n-chat-attention .n8n-chat-ai-badge {
    animation: none;
  }
}

/* Hidden in print. */
@media print {
  .chat-window-wrapper {
    display: none !important;
  }
}

/* Quick replies: a card with ready-made questions under the welcome
   messages (js/n8n-chat.js), until the visitor's first message. */
html .chat-window-wrapper .n8n-chat-quick-replies {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 4px;
  padding: 14px 16px 16px;
  background: #fff;
  border: 1px solid var(--color-border, #efe9e8);
  border-radius: var(--chat--border-radius);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.06);
}

html .chat-window-wrapper .n8n-chat-quick-replies-title {
  margin: 0 0 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border, #efe9e8);
  color: var(--chat--message--bot--color);
  font-size: 0.95rem;
  line-height: 1.35;
}

html .chat-window-wrapper .n8n-chat-quick-reply {
  width: 100%;
  margin: 0;
  padding: 9px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--chat--color--primary);
  color: #fff;
  font: 500 0.9rem/1.3 var(--chat--font-family);
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

html .chat-window-wrapper .n8n-chat-quick-reply:hover {
  background: var(--chat--color--primary-shade-50);
}

html .chat-window-wrapper .n8n-chat-quick-reply:focus-visible {
  outline: 2px solid var(--chat--color--secondary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html .chat-window-wrapper .n8n-chat-quick-reply {
    transition: none;
  }
}
