/**
 * AP-Briefing — hardcoded AP-Farben + color-scheme:light damit der Block
 * auch auf Mobile-Dark-Mode lesbar bleibt. Die fruehere Token-Variante
 * (--tb-primary-50, --tb-ink-900, --tb-bg-card) hat im OS-Dark-Mode invertiert
 * und Chat-Bubbles unlesbar gemacht (gleiche Klasse Bug wie bei concierge.css
 * im Notfall-Chat).
 *
 * AP-Brand-Palette:
 *   Beige BG:       #FBF8F2
 *   Card BG:        #FFFFFF
 *   Dunkelblau:     #0E1A2A   (Text-primaer)
 *   AP-Blau:        #0E3F73   (CTA/Akzent)
 *   AP-Blau-Hover:  #1F4D80
 *   Gelb-Akzent:    #F2C94C
 *   Rot:            #D9261C
 *   Line:           #E7E1D4
 *   Muted:          #5C6A7A
 */

[data-ap-briefing] {
  max-width: 760px;
  margin: 0 auto;
  color-scheme: light;
  color: #0E1A2A;
}

.tb-br-progress { display: flex; gap: .25rem; margin-bottom: 1.5rem; }
.tb-br-progress span { flex: 1; height: 6px; background: #E7E1D4; border-radius: 999px; transition: background 200ms; }
.tb-br-progress span.active { background: #0E3F73; }

.tb-br-step { display: none; animation: tbbr-fade 200ms ease both; }
.tb-br-step.active { display: block; }
@keyframes tbbr-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.tb-br-step h2 { margin-top: 0; color: #0E1A2A; }

.tb-br-field { margin-bottom: 1rem; }
.tb-br-field label { display: block; font-weight: 600; margin-bottom: .35rem; color: #0E1A2A; }
.tb-br-field input,
.tb-br-field select,
.tb-br-field textarea {
  width: 100%;
  padding: .75rem .85rem;
  border: 1px solid #E7E1D4;
  border-radius: 10px;
  background: #FFFFFF;
  color: #0E1A2A;
  font: inherit;
  font-size: 16px;            /* 16px verhindert iOS-Safari Zoom on focus */
  line-height: 1.4;
  box-sizing: border-box;
}
.tb-br-field textarea { min-height: 120px; resize: vertical; }
.tb-br-field input:focus,
.tb-br-field select:focus,
.tb-br-field textarea:focus {
  outline: 2px solid #0E3F73;
  outline-offset: 1px;
  border-color: #0E3F73;
}

.tb-br-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.tb-br-checks label {
  padding: .75rem .85rem;
  border: 1px solid #E7E1D4;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; gap: .5rem;
  background: #FFFFFF;
  color: #0E1A2A;
  font-size: 15px;
  line-height: 1.35;
  min-height: 44px;           /* Touch-Ziel */
  box-sizing: border-box;
}
.tb-br-checks input { margin: 0; flex-shrink: 0; }
.tb-br-checks label:hover { border-color: #0E3F73; }
.tb-br-checks input:checked + span { font-weight: 700; color: #0E3F73; }

.tb-br-radios { display: flex; gap: .5rem; flex-wrap: wrap; }
.tb-br-radios label {
  padding: .65rem 1rem;
  border: 1px solid #E7E1D4;
  border-radius: 999px;
  cursor: pointer;
  background: #FFFFFF;
  color: #0E1A2A;
  font-size: 15px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
}
.tb-br-radios label.is-active { background: #0E3F73; color: #FFFFFF; border-color: #0E3F73; }

.tb-br-actions { display: flex; justify-content: space-between; gap: .5rem; margin-top: 2rem; flex-wrap: wrap; }
.tb-br-actions .tb-btn { min-height: 48px; padding: .75rem 1.25rem; }

.tb-br-suggestions { margin-top: .75rem; display: grid; gap: .5rem; }
.tb-br-suggestion {
  border: 1px dashed #0E3F73;
  background: #FBF8F2;
  color: #0E1A2A;
  padding: .75rem .85rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1.45;
  text-align: left;
}
.tb-br-suggestion:hover { background: #F2EBDC; }

/* Honeypot */
.tb-br-hp { position: absolute; left: -9999px; opacity: 0; pointer-events: none; height: 0; overflow: hidden; }

.tb-br-success { text-align: center; padding: 3rem 1rem; color: #0E1A2A; }
.tb-br-success h2 { color: #1F7A3B; }

/* Intro-Hinweis am Anfang des ersten Steps */
.tb-br-intro {
  background: #FBF8F2;
  border: 1px solid #E7E1D4;
  border-left: 4px solid #0E3F73;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 14.5px;
  line-height: 1.6;
  color: #0E1A2A;
  margin: 0 0 1.5rem;
}
.tb-br-intro strong { color: #0E1A2A; }
.tb-br-intro em { color: #0E3F73; font-style: normal; font-weight: 600; }

/* Validation-Error */
.tb-br-error {
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  border-left: 4px solid #D9261C;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14.5px;
  line-height: 1.5;
  color: #991b1b;
  margin: 1rem 0;
  font-weight: 500;
}

/* ── Modus-Toggle (KI ↔ Formular) ─────────────────────────────────── */
.tb-br-modes {
  display: flex;
  gap: 8px;
  margin: 0 0 1.5rem;
  flex-wrap: wrap;
}
.tb-br-mode {
  flex: 1 1 220px;
  appearance: none;
  background: #FFFFFF;
  border: 1px solid #E7E1D4;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 15px;
  color: #0E1A2A;
  cursor: pointer;
  text-align: left;
  font-weight: 600;
  min-height: 48px;
  box-sizing: border-box;
  transition: border-color .15s, background .15s, color .15s;
}
.tb-br-mode:hover { border-color: #0E3F73; }
.tb-br-mode.is-active {
  background: #FBF8F2;
  border-color: #0E3F73;
  color: #0E3F73;
}
.tb-br-mode__hint {
  font-weight: 400;
  color: #5C6A7A;
  font-size: 0.85em;
}

/* ── Chat-Modus ──────────────────────────────────────────────────── */
.tb-br-chat {
  background: #FFFFFF;
  border: 1px solid #E7E1D4;
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  color: #0E1A2A;
  color-scheme: light;
}
.tb-br-chat__head h2 { margin: 0 0 6px; font-size: 1.2rem; color: #0E1A2A; line-height: 1.3; }
.tb-br-chat__head p { margin: 0; color: #5C6A7A; font-size: 14.5px; line-height: 1.55; }
.tb-br-chat__head a { color: #0E3F73; }

.tb-br-extracted {
  background: #FBF8F2;
  border: 1px solid #E7E1D4;
  border-radius: 10px;
  padding: 8px 14px;
}
.tb-br-extracted summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: #0E1A2A;
  list-style: revert;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tb-br-extracted__count {
  color: #0E3F73;
  font-weight: 700;
}
.tb-br-extracted__list {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 4px 18px;
  margin: 10px 0 4px;
  font-size: 13.5px;
}
.tb-br-extracted__list dt {
  font-weight: 700;
  color: #5C6A7A;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
  align-self: center;
}
.tb-br-extracted__list dd {
  margin: 0;
  color: #0E1A2A;
  align-self: center;
}

.tb-br-cost {
  background: #ECFDF5;
  border: 1px solid #6EE7B7;
  border-left: 4px solid #16A34A;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: #064E3B;
}
.tb-br-cost strong { color: #15803d; }
.tb-br-cost small {
  display: block;
  margin-top: 4px;
  color: #047857;
  font-size: 12px;
  line-height: 1.4;
}

.tb-br-chat__log {
  min-height: 220px;
  max-height: 50vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 0;
  background: #FBF8F2;
  border: 1px solid #E7E1D4;
  border-radius: 10px;
  padding: 12px;
}
.tb-br-chat__msg { display: flex; }
.tb-br-chat__msg--user { justify-content: flex-end; }
.tb-br-chat__msg--assistant { justify-content: flex-start; }
.tb-br-chat__bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 15px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.tb-br-chat__msg--user .tb-br-chat__bubble {
  background: #0E3F73;
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}
.tb-br-chat__msg--assistant .tb-br-chat__bubble {
  background: #FFFFFF;
  color: #0E1A2A;
  border: 1px solid #E7E1D4;
  border-bottom-left-radius: 4px;
}
.tb-br-chat__msg--assistant .tb-br-chat__bubble a { color: #0E3F73; }
.tb-br-chat__loading .tb-br-chat__bubble {
  color: #5C6A7A;
  font-style: italic;
}
.tb-br-chat__loading .tb-br-chat__bubble small {
  display: block;
  margin-top: 4px;
  font-style: normal;
  font-size: 12px;
  color: #5C6A7A;
}

.tb-br-chat__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tb-br-chat__form textarea {
  resize: vertical;
  min-height: 80px;
  padding: 12px;
  border: 1px solid #E7E1D4;
  border-radius: 10px;
  font: inherit;
  font-size: 16px;             /* 16px = kein iOS-Safari Zoom */
  line-height: 1.45;
  background: #FFFFFF;
  color: #0E1A2A;
  box-sizing: border-box;
  width: 100%;
}
.tb-br-chat__form textarea:focus {
  outline: 2px solid #0E3F73;
  outline-offset: 1px;
  border-color: #0E3F73;
}
.tb-br-chat__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tb-br-chat__actions .tb-btn {
  font-size: 15px;
  min-height: 48px;
  padding: .75rem 1.25rem;
  flex: 1 1 auto;
}
.tb-br-chat__hint {
  margin: 0;
  font-size: 12.5px;
  color: #5C6A7A;
  line-height: 1.5;
}

/* Default-Button-Styles falls Theme keine .tb-btn-Klasse liefert */
.tb-br-chat__actions .tb-btn--primary,
.tb-br-actions .tb-btn--primary {
  background: #0E3F73;
  color: #FFFFFF;
  border: 1px solid #0E3F73;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.tb-br-chat__actions .tb-btn--primary:hover,
.tb-br-actions .tb-btn--primary:hover {
  background: #1F4D80;
  border-color: #1F4D80;
}
.tb-br-chat__actions .tb-btn--ghost,
.tb-br-actions .tb-btn--ghost {
  background: #FFFFFF;
  color: #0E1A2A;
  border: 1px solid #E7E1D4;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.tb-br-chat__actions .tb-btn--ghost:hover,
.tb-br-actions .tb-btn--ghost:hover {
  background: #FBF8F2;
  border-color: #0E3F73;
  color: #0E3F73;
}
.tb-br-chat__actions .tb-btn--secondary,
.tb-br-actions .tb-btn--secondary {
  background: #F2C94C;
  color: #0E1A2A;
  border: 1px solid #E5B82A;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

/* E-Mail-Preview nach Done */
.tb-br-email-preview {
  background: #FBF8F2;
  border: 2px solid #0E3F73;
  border-radius: 14px;
  padding: 1.25rem;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: #0E1A2A;
}
.tb-br-email-preview__head h3 { margin: 0 0 6px; font-size: 1.15rem; color: #0E3F73; }
.tb-br-email-preview__head p { margin: 0; color: #0E1A2A; font-size: 14.5px; line-height: 1.55; }
.tb-br-email-preview__head strong { color: #0E1A2A; }
.tb-br-email-preview__label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5C6A7A;
  margin-bottom: 4px;
}
.tb-br-email-preview__label small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: #5C6A7A;
  letter-spacing: 0;
  text-transform: none;
  margin-top: 2px;
}
.tb-br-email-preview__from,
.tb-br-email-preview__subject {
  width: 100%;
  padding: 12px;
  border: 1px solid #E7E1D4;
  border-radius: 8px;
  font: inherit;
  font-size: 16px;
  background: #FFFFFF;
  color: #0E1A2A;
  box-sizing: border-box;
}
.tb-br-email-preview__body {
  width: 100%;
  padding: 12px;
  border: 1px solid #E7E1D4;
  border-radius: 8px;
  font: 14px/1.55 ui-monospace, 'SF Mono', Consolas, monospace;
  resize: vertical;
  background: #FFFFFF;
  color: #0E1A2A;
  white-space: pre-wrap;
  box-sizing: border-box;
  min-height: 240px;
}
.tb-br-email-preview__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.tb-br-email-preview__actions .tb-btn { min-height: 48px; padding: .75rem 1.25rem; flex: 1 1 auto; }
.tb-br-email-preview__legal {
  margin: 0;
  font-size: 12px;
  color: #5C6A7A;
  line-height: 1.45;
  font-style: italic;
}

/* Step-Validation Shake */
.tb-br-step--invalid { animation: tb-br-shake 0.4s cubic-bezier(.36,.07,.19,.97); }
.tb-br-step--invalid input:invalid:required,
.tb-br-step--invalid textarea:invalid:required,
.tb-br-step--invalid select:invalid {
  border-color: #D9261C;
  box-shadow: 0 0 0 3px rgba(217, 38, 28, 0.10);
}
@keyframes tb-br-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}
@media (prefers-reduced-motion: reduce) {
  .tb-br-step--invalid { animation: none; }
}

/* ── Mobile-Tweaks ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .tb-br-chat { padding: 1rem; }
  .tb-br-chat__log { min-height: 180px; max-height: 45vh; padding: 10px; }
  .tb-br-chat__bubble { max-width: 92%; font-size: 14.5px; padding: 9px 12px; }
  .tb-br-chat__actions { flex-direction: column; }
  .tb-br-chat__actions .tb-btn { width: 100%; }
  .tb-br-modes .tb-br-mode { flex: 1 1 100%; font-size: 14px; }
  .tb-br-actions { flex-direction: column-reverse; }
  .tb-br-actions .tb-btn { width: 100%; }
  .tb-br-checks { grid-template-columns: 1fr; }
  .tb-br-email-preview__actions { flex-direction: column; }
  .tb-br-email-preview__actions .tb-btn { width: 100%; }
}
