/* ====================================================================
   Jahresanzeigen.de — V2 · FAQ-Assistent (curated catalog)
   Self-contained, scoped under .ja-bot. Reuses styles.css :root tokens
   but defines local fallbacks so it never depends on load order.
   No new colors are introduced — values mirror the existing tokens.
   ==================================================================== */

.ja-bot {
  /* Local fallbacks that resolve to the global tokens when present. */
  --jb-ink:        var(--ink, #050B1C);
  --jb-ink-1:      var(--ink-1, #08132B);
  --jb-ink-2:      var(--ink-2, #0B1D3A);
  --jb-ink-3:      var(--ink-3, #11264A);
  --jb-brand:      var(--brand, #00B6F0);
  --jb-brand-2:    var(--brand-2, #3D9AFF);
  --jb-glow:       var(--brand-glow, #7FE0FF);
  --jb-text:       var(--text-on-dark, #E9F1FB);
  --jb-text-soft:  var(--text-on-dark-soft, #93AECC);
  --jb-text-mute:  var(--text-on-dark-mute, #5E7CA0);
  --jb-rule:       var(--rule-on-dark, rgba(127, 224, 255, 0.10));
  --jb-glass-bg:   var(--glass-dark-bg, rgba(17, 38, 74, 0.55));
  --jb-glass-bd:   var(--glass-dark-border, rgba(127, 224, 255, 0.14));
  --jb-font-display: var(--font-display, 'Poppins', system-ui, sans-serif);
  --jb-font-body:    var(--font-body, 'Inter', system-ui, sans-serif);
  --jb-font-mono:    var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  --jb-r-md:       var(--r-md, 16px);
  --jb-r-lg:       var(--r-lg, 22px);
  --jb-r-xl:       var(--r-xl, 28px);
  --jb-shadow-xl:  var(--shadow-xl, 0 36px 96px rgba(5, 11, 28, 0.45), 0 12px 32px rgba(5, 11, 28, 0.25));
  --jb-ease-spring: var(--ease-spring, cubic-bezier(0.22, 1.20, 0.36, 1));
  --jb-ease-out:    var(--ease-out, cubic-bezier(0.16, 1, 0.30, 1));
  --jb-t-fast:     var(--t-fast, 150ms);
  --jb-t-base:     var(--t-base, 280ms);

  /* Sizing */
  --jb-launcher:   56px;
  --jb-gap:        24px;            /* distance from viewport edges */
  --jb-panel-w:    min(400px, calc(100vw - 40px));
  --jb-panel-h:    min(620px, calc(100vh - 120px));
  --jb-z:          150;             /* above header (100), below progress (200) */

  position: fixed;
  right: var(--jb-gap);
  bottom: var(--jb-gap);
  z-index: var(--jb-z);
  font-family: var(--jb-font-body);
  /* The wrapper itself is non-interactive padding; children re-enable it. */
  pointer-events: none;
}

.ja-bot *,
.ja-bot *::before,
.ja-bot *::after { box-sizing: border-box; }

/* ------------------------------------------------------------------ */
/* Launcher button                                                     */
/* ------------------------------------------------------------------ */
.ja-bot__launcher {
  pointer-events: auto;
  position: absolute;
  right: 0;
  bottom: 0;
  width: var(--jb-launcher);
  height: var(--jb-launcher);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #001525;
  background: linear-gradient(180deg, #0EC0F7 0%, #0090D6 100%);
  box-shadow:
    0 8px 24px rgba(0, 182, 240, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition:
    transform var(--jb-t-base) var(--jb-ease-spring),
    box-shadow var(--jb-t-base) var(--jb-ease-out),
    opacity var(--jb-t-base) var(--jb-ease-out);
  isolation: isolate;
}
.ja-bot__launcher:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow:
    0 14px 40px rgba(0, 182, 240, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.ja-bot__launcher:focus-visible {
  outline: 3px solid var(--jb-glow);
  outline-offset: 3px;
}
.ja-bot__launcher svg { width: 26px; height: 26px; display: block; }
.ja-bot__launcher .ja-bot__icon--close { display: none; }

/* Soft pulse ring — purely decorative, neutralized by reduced-motion */
.ja-bot__launcher::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(127, 224, 255, 0.45);
  animation: ja-bot-pulse 2.8s var(--jb-ease-out) infinite;
  z-index: -1;
}
@keyframes ja-bot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(127, 224, 255, 0.40); }
  70%  { box-shadow: 0 0 0 16px rgba(127, 224, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(127, 224, 255, 0); }
}

/* Unread / attention dot on the launcher */
.ja-bot__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--jb-glow);
  border: 2px solid var(--jb-ink);
  box-shadow: 0 0 8px rgba(127, 224, 255, 0.8);
}

/* When the panel is open, fade the launcher into a close affordance */
.ja-bot.is-open .ja-bot__launcher::after { animation: none; opacity: 0; }
.ja-bot.is-open .ja-bot__badge { display: none; }
.ja-bot.is-open .ja-bot__icon--chat { display: none; }
.ja-bot.is-open .ja-bot__icon--close { display: block; }

/* ------------------------------------------------------------------ */
/* Panel                                                               */
/* ------------------------------------------------------------------ */
.ja-bot__panel {
  pointer-events: auto;
  position: absolute;
  right: 0;
  bottom: calc(var(--jb-launcher) + 16px);
  width: var(--jb-panel-w);
  height: var(--jb-panel-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--jb-r-xl);
  background:
    linear-gradient(160deg, rgba(17, 38, 74, 0.92) 0%, rgba(8, 19, 43, 0.94) 100%);
  border: 1px solid var(--jb-glass-bd);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  box-shadow: var(--jb-shadow-xl), 0 0 0 1px rgba(127, 224, 255, 0.08);
  color: var(--jb-text);
  /* Hidden state */
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.98);
  transform-origin: bottom right;
  transition:
    opacity var(--jb-t-base) var(--jb-ease-out),
    transform var(--jb-t-base) var(--jb-ease-spring),
    visibility 0s linear var(--jb-t-base);
}
.ja-bot.is-open .ja-bot__panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity var(--jb-t-base) var(--jb-ease-out),
    transform var(--jb-t-base) var(--jb-ease-spring),
    visibility 0s;
}
.ja-bot__panel[hidden] { display: none; }

/* Header */
.ja-bot__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px 18px;
  border-bottom: 1px solid var(--jb-rule);
  background: linear-gradient(180deg, rgba(0, 182, 240, 0.10), transparent);
}
.ja-bot__head-avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #001525;
  background: linear-gradient(180deg, #0EC0F7 0%, #0090D6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.ja-bot__head-avatar svg { width: 20px; height: 20px; }
.ja-bot__head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ja-bot__head-title {
  font-family: var(--jb-font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--jb-text);
}
.ja-bot__head-sub {
  font-family: var(--jb-font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--jb-text-mute);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ja-bot__head-sub .ja-bot__live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--jb-glow);
  box-shadow: 0 0 6px var(--jb-glow);
}
.ja-bot__close {
  margin-left: auto;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--jb-text-soft);
  background: rgba(127, 224, 255, 0.06);
  border: 1px solid var(--jb-rule);
  cursor: pointer;
  transition: background var(--jb-t-fast), color var(--jb-t-fast), border-color var(--jb-t-fast);
}
.ja-bot__close:hover { background: rgba(127, 224, 255, 0.12); color: var(--jb-text); }
.ja-bot__close:focus-visible { outline: 2px solid var(--jb-glow); outline-offset: 2px; }
.ja-bot__close svg { width: 16px; height: 16px; }

/* Message log */
.ja-bot__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(127, 224, 255, 0.25) transparent;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.ja-bot__log::-webkit-scrollbar { width: 8px; }
.ja-bot__log::-webkit-scrollbar-thumb {
  background: rgba(127, 224, 255, 0.22);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.ja-bot__log::-webkit-scrollbar-thumb:hover { background: rgba(127, 224, 255, 0.40); background-clip: padding-box; }

/* Message rows + bubbles */
.ja-bot__msg {
  display: flex;
  max-width: 100%;
  animation: ja-bot-msg-in 0.4s var(--jb-ease-out) both;
}
@keyframes ja-bot-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.ja-bot__msg--bot  { justify-content: flex-start; }
.ja-bot__msg--user { justify-content: flex-end; }

.ja-bot__bubble {
  max-width: 88%;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: var(--jb-r-md);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.ja-bot__msg--bot .ja-bot__bubble {
  background: rgba(127, 224, 255, 0.06);
  border: 1px solid var(--jb-rule);
  border-bottom-left-radius: 6px;
  color: var(--jb-text);
}
.ja-bot__msg--user .ja-bot__bubble {
  background: linear-gradient(180deg, #0EC0F7 0%, #0090D6 100%);
  color: #001525;
  border-bottom-right-radius: 6px;
  font-weight: 500;
  box-shadow: 0 4px 14px rgba(0, 182, 240, 0.30);
}
.ja-bot__bubble p { margin: 0 0 8px; }
.ja-bot__bubble p:last-child { margin-bottom: 0; }
.ja-bot__bubble strong { color: var(--jb-glow); font-weight: 600; }
.ja-bot__msg--user .ja-bot__bubble strong { color: #001525; }
.ja-bot__bubble a {
  color: var(--jb-glow);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(127, 224, 255, 0.45);
  word-break: break-word;
}
.ja-bot__bubble a:hover { text-decoration-color: var(--jb-glow); }
.ja-bot__bubble a:focus-visible { outline: 2px solid var(--jb-glow); outline-offset: 2px; border-radius: 3px; }
.ja-bot__bubble ul { margin: 6px 0 8px; padding-left: 18px; }
.ja-bot__bubble li { margin-bottom: 3px; }

/* Typing indicator */
.ja-bot__typing { display: inline-flex; align-items: center; gap: 5px; padding: 4px 2px; }
.ja-bot__typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--jb-glow); opacity: 0.55;
  animation: ja-bot-typing 1.1s var(--jb-ease-out) infinite;
}
.ja-bot__typing span:nth-child(2) { animation-delay: 0.18s; }
.ja-bot__typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes ja-bot-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* Suggested-question chips */
.ja-bot__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 16px 14px;
}
.ja-bot__chips:empty { display: none; }
.ja-bot__chip {
  font-family: var(--jb-font-body);
  font-size: 12.5px;
  line-height: 1.3;
  text-align: left;
  color: var(--jb-glow);
  background: rgba(127, 224, 255, 0.07);
  border: 1px solid rgba(127, 224, 255, 0.22);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition:
    background var(--jb-t-fast),
    border-color var(--jb-t-fast),
    transform var(--jb-t-fast) var(--jb-ease-spring);
}
.ja-bot__chip:hover {
  background: rgba(127, 224, 255, 0.14);
  border-color: rgba(127, 224, 255, 0.45);
  transform: translateY(-1px);
}
.ja-bot__chip:focus-visible { outline: 2px solid var(--jb-glow); outline-offset: 2px; }

/* Input row */
.ja-bot__form {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--jb-rule);
  background: rgba(5, 11, 28, 0.35);
}
.ja-bot__input {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 96px;
  font-family: var(--jb-font-body);
  font-size: 14px;
  line-height: 1.4;
  color: var(--jb-text);
  background: rgba(127, 224, 255, 0.05);
  border: 1px solid var(--jb-rule);
  border-radius: 14px;
  padding: 11px 14px;
  transition: border-color var(--jb-t-fast), background var(--jb-t-fast);
}
.ja-bot__input::placeholder { color: var(--jb-text-mute); }
.ja-bot__input:focus {
  outline: none;
  border-color: rgba(127, 224, 255, 0.45);
  background: rgba(127, 224, 255, 0.08);
}
.ja-bot__send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #001525;
  background: linear-gradient(180deg, #0EC0F7 0%, #0090D6 100%);
  box-shadow: 0 6px 18px rgba(0, 182, 240, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: transform var(--jb-t-base) var(--jb-ease-spring), box-shadow var(--jb-t-base) var(--jb-ease-out), opacity var(--jb-t-fast);
}
.ja-bot__send:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 182, 240, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
.ja-bot__send:focus-visible { outline: 3px solid var(--jb-glow); outline-offset: 2px; }
.ja-bot__send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.ja-bot__send svg { width: 18px; height: 18px; }

/* Honest microcopy footnote */
.ja-bot__note {
  flex-shrink: 0;
  padding: 0 16px 10px;
  font-family: var(--jb-font-mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: var(--jb-text-mute);
  text-align: center;
  background: rgba(5, 11, 28, 0.35);
}

/* ------------------------------------------------------------------ */
/* Mobile — near-fullscreen bottom sheet                               */
/* ------------------------------------------------------------------ */
@media (max-width: 560px) {
  .ja-bot {
    --jb-gap: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  .ja-bot__panel {
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100vw;
    height: 88vh;
    height: 88svh;
    height: 88dvh;
    max-height: none;
    border-radius: var(--jb-r-xl) var(--jb-r-xl) 0 0;
    transform-origin: bottom center;
    transform: translateY(24px);
  }
  .ja-bot.is-open .ja-bot__panel { transform: none; }
  .ja-bot__bubble { max-width: 92%; }
  .ja-bot__note { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .ja-bot__form { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}

/* Avoid clashing with the bottom-LEFT a11y button on small/medium
   viewports where both corners are near each other. The launcher is
   right-anchored, the a11y button left-anchored, so they never meet —
   but we keep the panel from covering the bottom-left control by not
   stretching full width except on the smallest screens (handled above). */

/* ------------------------------------------------------------------ */
/* Reduced motion — degrade gracefully (the global block also applies) */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .ja-bot__launcher::after { animation: none; box-shadow: none; }
  .ja-bot__launcher:hover { transform: none; }
  .ja-bot__msg { animation: none; }
  .ja-bot__typing span { animation: none; opacity: 0.7; }
  .ja-bot__panel {
    transition: opacity 0.001ms linear, visibility 0s;
    transform: none;
  }
  .ja-bot.is-open .ja-bot__panel { transform: none; }
  .ja-bot__log { scroll-behavior: auto; }
  .ja-bot__send:hover, .ja-bot__chip:hover { transform: none; }
}

/* ---- AI consent prompt (in-bubble) ----------------------------- */
.ja-bot__consent {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.ja-bot__chip--primary {
  background: var(--brand-cyan, #00B6F0);
  color: #03121f;
  border-color: var(--brand-cyan, #00B6F0);
  font-weight: 600;
}
.ja-bot__chip--primary:hover { filter: brightness(1.08); }
.ja-bot__inline-link {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font: inherit;
}
.ja-bot__consent-done {
  display: inline-block;
  margin-top: 8px;
  font-size: .85rem;
  color: var(--brand-glow, #7FE0FF);
}
