/* ============================================================
   Automatischer Assistent (Stand 14.11.2026, ADR-003)
   Farben laut Konventionen: Hausfarbe #ED7D31, Aktionsfarbe #B84F12,
   Nachtblau #0F1B2D; Systemschriften. Alle Klassen mit Vorsilbe .ja-
   ============================================================ */
.ja {
  --ja-orange: #ED7D31;
  --ja-action: #B84F12;
  --ja-night: #0F1B2D;
  --ja-paper: #ffffff;
  --ja-surface: #f4f5f7;
  --ja-line: #d5d9e0;
  --ja-muted: #4a5568;
  --ja-radius: 12px;
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ja-night);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.ja-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 22px 8px 16px;
  border: 2px solid #fff;
  border-radius: 32px;
  background: var(--ja-action);
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(15, 27, 45, .32);
}
.ja-toggle:hover { background: #9c420f; }
.ja-toggle:focus-visible { outline: 3px solid var(--ja-night); outline-offset: 2px; }
.ja-toggle[disabled] { cursor: progress; }
.ja-icon { width: 26px; height: 26px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ja-toggle-text { display: flex; flex-direction: column; line-height: 1.2; }
.ja-toggle-label { font-size: 17px; font-weight: 700; }
.ja-toggle-sub { font-size: 13px; font-weight: 500; opacity: .95; }

/* Hinweisblase (nur Desktop, siehe assistent.js addTeaser) */
.ja-teaser {
  position: relative;
  max-width: 300px;
  padding: 14px 40px 14px 16px;
  background: var(--ja-paper);
  border: 1px solid var(--ja-line);
  border-left: 4px solid var(--ja-orange);
  border-radius: var(--ja-radius);
  box-shadow: 0 8px 28px rgba(15, 27, 45, .22);
}
.ja-teaser[hidden] { display: none; }
.ja-teaser-text { all: unset; display: block; font-size: 15px; line-height: 1.45; color: var(--ja-night); cursor: pointer; }
.ja-teaser-text:focus-visible { outline: 3px solid var(--ja-action); outline-offset: 4px; border-radius: 4px; }
.ja-teaser-close {
  position: absolute; top: 4px; right: 4px;
  width: 32px; height: 32px;
  border: 0; border-radius: 16px;
  background: transparent; color: var(--ja-muted);
  font: inherit; font-size: 20px; line-height: 1; cursor: pointer;
}
.ja-teaser-close:hover { background: var(--ja-surface); color: var(--ja-night); }
.ja-teaser-close:focus-visible { outline: 3px solid var(--ja-action); outline-offset: 0; }
.ja-open .ja-toggle { display: none; }

.ja-panel {
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
  background: var(--ja-paper);
  border: 1px solid var(--ja-line);
  border-radius: var(--ja-radius);
  box-shadow: 0 12px 40px rgba(15, 27, 45, .28);
  overflow: hidden;
}
.ja-panel[hidden] { display: none; }

.ja-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 8px 12px 16px;
  background: var(--ja-night);
  color: #fff;
  border-bottom: 4px solid var(--ja-orange);
}
.ja-title { display: flex; flex-direction: column; }
.ja-sub { font-size: 13px; color: #c9d1dc; }
.ja-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.ja-close:hover { background: rgba(255, 255, 255, .12); }

.ja-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--ja-surface);
  overscroll-behavior: contain;
}
.ja-msg {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: var(--ja-radius);
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.ja-msg-bot { align-self: flex-start; background: var(--ja-paper); border: 1px solid var(--ja-line); }
.ja-msg-user { align-self: flex-end; background: var(--ja-night); color: #fff; }
.ja-msg a { color: var(--ja-action); font-weight: 600; }
.ja-msg-user a { color: #fff; }

.ja-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.ja-chip {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--ja-action);
  border-radius: 22px;
  background: var(--ja-paper);
  color: var(--ja-action);
  font: inherit;
  font-size: 15px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.ja-chip:hover { background: #fdf1e9; }
.ja-chip-action { background: var(--ja-action); color: #fff; }
.ja-chip-action:hover { background: #9c420f; }

.ja-form { display: flex; gap: 8px; padding: 12px 12px 4px; border-top: 1px solid var(--ja-line); }
.ja-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #8a94a6;
  border-radius: 8px;
  font: inherit;
  color: var(--ja-night);
  background: var(--ja-paper);
}
.ja-send {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--ja-action);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.ja-send:hover { background: #9c420f; }
.ja-input:disabled { background: #eceef1; color: var(--ja-muted); cursor: not-allowed; }
.ja-send:disabled, .ja-chip:disabled { opacity: .55; cursor: not-allowed; }
.ja-send:disabled:hover { background: var(--ja-action); }
.ja-chip:disabled:hover { background: var(--ja-paper); }

.ja-note { margin: 0; padding: 4px 12px 12px; font-size: 13px; color: var(--ja-muted); white-space: pre-line; }
.ja-note a { color: var(--ja-muted); }

.ja :focus-visible { outline: 3px solid var(--ja-orange); outline-offset: 2px; }

.ja-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  .ja { right: 8px; bottom: 8px; left: 8px; align-items: stretch; }
  .ja-toggle { align-self: flex-end; }
  .ja-panel { width: 100%; height: min(78vh, calc(100vh - 16px)); }
}

@media (prefers-reduced-motion: no-preference) {
  .ja-panel { animation: ja-in 200ms ease-out; }
  .ja-teaser { animation: ja-in 250ms ease-out; }
  @keyframes ja-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

@media print { .ja { display: none; } }
