/* ═══════════════════════════════════════════════════════════════════
   lf-coach.css — Zentrales LILA-Coach-Modul (V3, 2026-09-12)
   Auftrag: Prompt 25 §5 / Prompt 26 §4.2 — Coach auf JEDER öffentlichen
   Seite als echtes Dialog-Modal, EINE Instanz, kein kopierter Inline-Code.

   REGELN (Projekt-Designregeln, Startseite = Design-Master):
   - Farben, Radien und Schriften kommen aus lf-design.css (:root-Tokens).
   - Der Auslöser verwendet das ruhige Website-/Buttonlila #553BA0
     (Nutzerentscheidung 12.09.2026) — kein Verlauf, kein Schatten,
     kein Leuchteffekt.
   - Die Innenansicht (.conc-*) ist unverändert aus index.html übernommen,
     damit sich der Coach optisch nicht ändert.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --lfcoach-accent: #553BA0;   /* ruhiges Website-/Buttonlila */
  --lfcoach-z: 8000;
}

/* ── Sichtbar nur für Screenreader ────────────────────────────────── */
.lfcoach-sr {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ═══ 1. AUSLÖSER — Pille mit Icon + Text ═══════════════════════════ */
.lfcoach-trigger {
  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: var(--lfcoach-z);
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 52px; padding: 0 20px;
  border: none; border-radius: 26px;
  background: var(--lfcoach-accent);
  color: #fff;
  font-family: inherit; font-size: 15px; font-weight: 700;
  letter-spacing: 0.2px; line-height: 1;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease;
}
.lfcoach-trigger:hover { background: #4A3390; }
.lfcoach-trigger:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.lfcoach-trigger svg { width: 22px; height: 22px; fill: #fff; flex: 0 0 auto; }
.lfcoach-trigger-label { white-space: nowrap; }

/* Auf der Startseite ersetzt die große Coach-Sektion den festen Auslöser,
   solange diese tatsächlich im sichtbaren Bereich liegt. */
.lfcoach-trigger.lfcoach-trigger--teaser-visible { display: none; }

/* Sehr kleine Displays: auf das Icon schrumpfen, damit die Pille keinen
   wichtigen CTA verdeckt. Zugänglicher Name bleibt über aria-label
   erhalten; Trefferfläche bleibt 52×52 px. */
@media (max-width: 420px) {
  .lfcoach-trigger {
    padding: 0; width: 52px; min-height: 52px;
    justify-content: center; border-radius: 50%;
    right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .lfcoach-trigger-label { display: none; }
}

/* Bei jedem offenen Modal (body.lf-modal-open wird von lf-core.js
   gesetzt) verschwindet der Auslöser vollständig — verdeckt damit weder
   Consent-Banner, Navigation, Formulare noch mobile CTAs. */
.lf-modal-open .lfcoach-trigger { display: none !important; }

/* ═══ 2. MODAL ═════════════════════════════════════════════════════ */
.lfcoach-overlay {
  position: fixed; inset: 0; z-index: calc(var(--lfcoach-z) + 10);
  background: rgba(10, 8, 20, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.lfcoach-overlay[hidden] { display: none !important; }

.lfcoach-dialog {
  width: 460px; max-width: 100%;
  min-height: min(460px, calc(100vh - 48px));
  max-height: min(640px, calc(100vh - 48px));
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg, 24px);
  overflow: hidden;
  display: flex; flex-direction: column;
}

/* Mobil: nahezu vollflächiges Bottom-Sheet mit Safe Areas.
   100dvh berücksichtigt die eingeblendete Bildschirmtastatur. */
@media (max-width: 700px) {
  .lfcoach-overlay { padding: 0; align-items: flex-end; }
  .lfcoach-dialog {
    width: 100%; max-width: 100%;
    height: 92dvh; min-height: 0; max-height: 92dvh;
    border-radius: var(--radius-lg, 24px) var(--radius-lg, 24px) 0 0;
    border-left: none; border-right: none; border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* ── Kopf (Struktur unverändert aus index.html) ───────────────────── */
.conc-header {
  background: var(--purple); padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  flex: 0 0 auto;
}
.conc-header-left { display: flex; align-items: center; gap: 10px; }
.conc-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.conc-header-info { line-height: 1.3; }
.conc-header-name { font-size: 14px; font-weight: 700; color: var(--white); }
.conc-header-sub  { font-size: 12px; color: var(--text-body); }
.lfcoach-header-actions { display: flex; align-items: center; gap: 8px; }
.lfcoach-new {
  background: none; border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px; color: var(--text-lo);
  font-family: inherit; font-size: 11px; font-weight: 600;
  padding: 6px 10px; cursor: pointer; white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.lfcoach-new:hover { color: var(--text-hi); border-color: rgba(255,255,255,0.35); background: rgba(255,255,255,0.06); }
.lfcoach-new-short { display: none; }
.conc-close-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: none;
  border: 1px solid rgba(255,255,255,0.18); border-radius: 8px;
  color: var(--text-lo); cursor: pointer;
  padding: 0; transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.conc-close-btn:hover { color: var(--text-hi); border-color: rgba(255,255,255,0.35); background: rgba(255,255,255,0.06); }
.lfcoach-new:focus-visible, .conc-close-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ── Verlauf ──────────────────────────────────────────────────────── */
.conc-messages {
  flex: 1 1 auto; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain;
}
.conc-msg { max-width: 85%; display: flex; flex-direction: column; gap: 2px; }
.conc-msg.bot  { align-self: flex-start; }
.conc-msg.user { align-self: flex-end; }
.conc-bubble { padding: 10px 13px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.conc-msg.bot .conc-bubble  { background: var(--bg3); color: var(--white); border-bottom-left-radius: 3px; }
.conc-msg.user .conc-bubble { background: var(--purple); color: var(--text-on-accent); border-bottom-right-radius: 3px; }

/* Strukturierte KI-Antworten: Markdown-Überschriften und -Tabellen werden
   ohne sichtbare Pipes oder Strichreihen als kompakte Karten dargestellt. */
.lfcoach-answer-title {
  display: block;
  margin: 2px 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
}
.lfcoach-data-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}
.lfcoach-data-row {
  padding: 10px 11px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.055);
}
.lfcoach-data-key {
  margin-bottom: 7px;
  font-size: 14px;
  font-weight: 700;
  color: #FFFFFF;
}
.lfcoach-data-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.lfcoach-data-value span,
.lfcoach-data-value strong {
  display: block;
}
.lfcoach-data-value span {
  margin-bottom: 2px;
  color: #C8B58D;
  font-size: 9px;
  line-height: 1.25;
}
.lfcoach-data-value strong {
  color: #F6F4FA;
  font-size: 12px;
  line-height: 1.35;
}

.conc-suggestions { padding: 0 16px 12px; display: flex; flex-wrap: wrap; gap: 6px; flex: 0 0 auto; }
.conc-chip {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--muted2); font-size: 11px; border-radius: 20px;
  padding: 5px 12px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s; font-family: inherit;
}
.conc-chip:hover { border-color: var(--purple); color: var(--white); }
.conc-chip:focus-visible { outline: 2px solid var(--purple-l, #8B30FF); outline-offset: 2px; }

.typing-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.45); margin: 0 2px;
  animation: typingBounce 1.1s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .typing-dot { animation: none; }
  .lfcoach-trigger { transition: none; }
}

.lfcoach-note {
  padding: 2px 14px 9px; font-size: 10px; color: var(--text-hint);
  text-align: center; line-height: 1.35; flex: 0 0 auto;
}

/* ── Eingabe ──────────────────────────────────────────────────────── */
.conc-input-row {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex: 0 0 auto;
}
#conc-input {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px; padding: 9px 12px;
  color: var(--white); font-size: 16px; font-family: inherit;
  outline: none; min-width: 0;
}
#conc-input:focus { border-color: var(--purple); outline: none; box-shadow: none; }
#conc-input:focus-visible { outline: 2px solid var(--purple-l, #8B30FF); outline-offset: 1px; }
#conc-input::placeholder { color: var(--muted); }
#conc-send {
  background: var(--lfcoach-accent); border: none; border-radius: 12px;
  width: 40px; height: 40px; cursor: pointer; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
#conc-send:hover { background: #4A3390; }
#conc-send:focus-visible { outline: 2px solid var(--purple-l, #8B30FF); outline-offset: 2px; }
#conc-send svg { width: 16px; height: 16px; fill: #fff; }

/* ═══ 3. MODAL-CI — ruhig, hochwertig, mailnah ═══════════════════════
   Nur das globale Dialogfenster wird verfeinert. Der eingebettete
   Coach auf der Startseite bleibt als Design-Master unangetastet. */
.lfcoach-dialog {
  background: #242039;
  border-color: rgba(214, 178, 122, 0.24);
  box-shadow: 0 24px 64px rgba(8, 6, 18, 0.36);
}

.lfcoach-dialog .conc-header {
  position: relative;
  padding: 16px 18px;
  background: #1E1B2E;
  border-top: 3px solid #D6B27A;
  border-bottom: 1px solid rgba(214, 178, 122, 0.18);
}
.lfcoach-dialog .conc-avatar {
  width: 30px;
  height: 34px;
  border-radius: 0;
  background: transparent;
}
.lfcoach-dialog .conc-avatar svg {
  width: 26px;
  height: 26px;
  fill: #FFFFFF;
}
.lfcoach-dialog .conc-header-sub { color: #B9B3C8; }
.lfcoach-dialog .lfcoach-new,
.lfcoach-dialog .conc-close-btn {
  border-color: rgba(214, 178, 122, 0.26);
  color: #D9D4E4;
}
.lfcoach-dialog .lfcoach-new:hover,
.lfcoach-dialog .conc-close-btn:hover {
  border-color: rgba(214, 178, 122, 0.58);
  background: rgba(214, 178, 122, 0.07);
  color: #FFFFFF;
}
.lfcoach-dialog .lfcoach-new:focus-visible,
.lfcoach-dialog .conc-close-btn:focus-visible {
  outline-color: #D6B27A;
}

.lfcoach-dialog .conc-msg.bot .conc-bubble {
  background: #302B4B;
  color: #F6F4FA;
}
.lfcoach-dialog .conc-msg.bot {
  width: 100%;
  max-width: 100%;
}
.lfcoach-dialog .conc-msg.user .conc-bubble {
  background: #553BA0;
  color: #FFFFFF;
}
.lfcoach-dialog .conc-chip {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(214, 178, 122, 0.20);
  color: #C9C3D6;
}
.lfcoach-dialog .conc-chip:hover {
  border-color: rgba(214, 178, 122, 0.62);
  color: #FFFFFF;
}
.lfcoach-dialog .conc-chip:focus-visible { outline-color: #D6B27A; }
.lfcoach-dialog .lfcoach-note { color: #9E97B3; }
.lfcoach-dialog .conc-input-row { border-top-color: rgba(214, 178, 122, 0.15); }
.lfcoach-dialog #conc-input {
  background: #2C2745;
  border-color: rgba(214, 178, 122, 0.22);
}
.lfcoach-dialog #conc-input:focus { border-color: #6B56AD; }
.lfcoach-dialog #conc-input:focus-visible {
  outline-color: rgba(214, 178, 122, 0.72);
}
.lfcoach-dialog #conc-send { background: #553BA0; }
.lfcoach-dialog #conc-send:hover { background: #4A3390; }
.lfcoach-dialog #conc-send:focus-visible { outline-color: #D6B27A; }

/* Schmale Mobilansicht: Kopfzeile konsequent auf die wesentlichen
   Bedienelemente reduzieren. Kein gequetschtes Symbol, keine Unterzeile. */
@media (max-width: 420px) {
  .lfcoach-dialog .conc-header { padding: 14px 16px; }
  .lfcoach-dialog .conc-avatar,
  .lfcoach-dialog .conc-header-sub { display: none; }
  .lfcoach-dialog .conc-header-left { min-width: 0; }
  .lfcoach-dialog .conc-header-name { white-space: nowrap; }
  .lfcoach-dialog .lfcoach-header-actions { gap: 7px; }
  .lfcoach-dialog .lfcoach-new { padding: 6px 9px; }
  .lfcoach-dialog .lfcoach-new-long { display: none; }
  .lfcoach-dialog .lfcoach-new-short { display: inline; }
}

/* Touchgeräte (insbesondere iOS Safari): keine dauerhaft haftenden Hover-
   Zustände oder optisch blinkenden Coach-Akzente. Klick-/Fokusfeedback und
   Bedienbarkeit bleiben erhalten; nur Maus-Hover wird neutralisiert. */
@media (hover: none), (pointer: coarse) {
  .lfcoach-trigger,
  .lfcoach-trigger:hover {
    background: var(--lfcoach-accent);
    transition: none;
  }
  .conc-chip,
  .conc-chip:hover {
    border-color: var(--border);
    color: var(--muted2);
    transition: none;
  }
  #conc-send,
  #conc-send:hover {
    background: var(--lfcoach-accent);
    transition: none;
  }
  .lfcoach-dialog .conc-chip,
  .lfcoach-dialog .conc-chip:hover {
    background: rgba(255, 255, 255, 0.035);
    border-color: rgba(214, 178, 122, 0.20);
    color: #C9C3D6;
  }
  .lfcoach-dialog #conc-send,
  .lfcoach-dialog #conc-send:hover {
    background: #553BA0;
  }
}
