/* ZABR — Komponenten (docs/entwurf-ui-komponenten.md, Phase 1). ENTWURF.

   Einbinden NACH den Tokens:

     <link rel="stylesheet" href="/_ds/tokens/fonts.css">
     <link rel="stylesheet" href="/_ds/tokens/colors.css">
     <link rel="stylesheet" href="/_ds/tokens/typography.css">
     <link rel="stylesheet" href="/_ds/komponenten/ui.css">

   Drei Regeln, die diese Datei selbst einhaelt:
   1. Nur Rollen aus colors.css/typography.css — kein Hexwert, keine
      Palettenvariable (--gold, --ink-*), kein Rueckfallwert (Leitfaden §9).
   2. Masse nur ueber die Mass-Tokens unten. `padding: 13px` ist der Anfang
      des naechsten Sonderwegs.
   3. Gold heisst: aktive Auswahl, primaere Aktion, wichtiger Status. Sonst
      nichts. */

/* ── Mass-Tokens ───────────────────────────────────────────── */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --control-h: 44px;
  /* Kantig wie das ZABR Design System 10-2026: 0 oder 2 px, keine Pillen.
     Bis zum 29.10.2026 6 und 8 px (Design-Audit Recht & Nachweise). Die
     Namen bleiben, damit keine App angefasst werden muss. */
  --radius-s: 2px;
  --radius-m: 2px;
  --content-max: 1520px;
}

/* ── Abschnitt: Kopf → Beschreibung/Status → Inhalt/Aktion ──── */
.ui-abschnitt { margin-top: var(--space-6); }
.ui-abschnitt:first-child { margin-top: 0; }
.ui-abschnitt__kopf {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}
.ui-abschnitt__titel {
  margin: 0;
  font-family: var(--font-condensed);
  font-size: 15px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-body);
}
.ui-abschnitt__rechts { display: flex; align-items: center; gap: var(--space-3); }
.ui-abschnitt__beschreibung {
  margin: var(--space-2) 0 0;
  font-family: var(--font-body); font-size: 14px;
  color: var(--text-muted);
}
.ui-abschnitt__inhalt { margin-top: var(--space-4); }

/* ── Zaehler ────────────────────────────────────────────────── */
.ui-zahl {
  font-family: var(--font-condensed); font-size: 13px;
  letter-spacing: .04em;
  color: var(--text-faint);
}

/* ── Leerzustand: ein Satz, hoechstens eine Aktion ──────────── */
.ui-leer {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--surface-card);
  font-family: var(--font-body); font-size: 14px;
  color: var(--text-muted);
}

/* ── Knoepfe: vier Stufen ───────────────────────────────────── */
/* Fokus ueberall: gelber 1-px-Rand (DS 10-2026; bis 29.10.2026 2 px). */
.ui-knopf {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 var(--space-4);
  border-radius: var(--radius-s);
  border: 1px solid var(--border-strong);
  background: var(--surface-card);
  color: var(--text-body);
  /* Versalien in Barlow Condensed, gesperrt wie der Button des ZABR Design
     System 10-2026 (tracking-button .08em). Bis zum 29.10.2026 Barlow 500
     in gemischter Schreibung. */
  font-family: var(--font-condensed); font-size: 15px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  cursor: pointer; white-space: nowrap;
}
.ui-knopf:hover { background: var(--surface-hover); }
.ui-knopf:focus-visible { outline: 1px solid var(--focus-ring); outline-offset: 2px; }
.ui-knopf:disabled { opacity: .45; cursor: default; }
/* primaer: Gold — die eine Aktion, um die es geht */
.ui-knopf--primaer {
  background: var(--interactive-bg); border-color: var(--interactive-bg);
  color: var(--text-on-accent);
}
.ui-knopf--primaer:hover {
  background: var(--interactive-bg-hover); border-color: var(--interactive-bg-hover);
}
/* leise: nur Text — Abbrechen, Verwerfen */
.ui-knopf--leise {
  background: transparent; border-color: transparent; color: var(--text-muted);
}
.ui-knopf--leise:hover { background: var(--surface-hover); color: var(--text-body); }
/* gefahr: nur fuer Unumkehrbares */
.ui-knopf--gefahr { color: var(--status-alert-fg); }
.ui-knopf--gefahr:hover { border-color: var(--status-alert); }
/* klein: in Tabellen- und Abschnittskoepfen */
.ui-knopf--klein { height: 32px; padding: 0 var(--space-3); font-size: 14px; }

/* ── Formular: Inline-Karte, zu, bis man sie oeffnet ────────── */
.ui-formular {
  margin-top: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-m);
  background: var(--surface-card);
}
.ui-formular__titel {
  margin: 0 0 var(--space-4);
  font-family: var(--font-body); font-size: 16px; font-weight: 600;
  color: var(--text-body);
}
.ui-formular__reihe {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.ui-formular__fuss {
  display: flex; justify-content: flex-end; gap: var(--space-2);
  margin-top: var(--space-5);
}

/* ── Feld: Label UEBER dem Feld, eine Hoehe, ein Fokus ─────── */
.ui-feld { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.ui-feld__label {
  font-family: var(--font-condensed); font-size: 13px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-muted);
}
.ui-feld__rahmen {
  display: flex; align-items: center;
  height: var(--control-h);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  background: var(--surface-page);
}
.ui-feld__rahmen:focus-within { outline: 1px solid var(--focus-ring); outline-offset: 1px; }
/* JEDES Eingabefeld, nicht nur [type=text]: an genau dieser Luecke stand in
   der Kalkulation ein weisses Feld im dunklen Modus (01.10.2026).

   Zwei Klassen im Selektor, mit Absicht: Apps tragen eigene Regeln wie
   `input[type=text]` oder `input:focus` (eine Klasse + ein Element), und ihr
   <style> steht NACH dieser Datei. Mit gleicher Spezifitaet gewaenne die App
   — gemessen an der Kalkulation: Goldrahmen im Feld, Kasten im Kasten. */
.ui-feld .ui-feld__rahmen input,
.ui-feld .ui-feld__rahmen select {
  flex: 1; min-width: 0; height: 100%;
  padding: 0 var(--space-3);
  border: 0; outline: 0; background: transparent;
  color: var(--text-body);
  font-family: var(--font-body); font-size: 15px;
  appearance: none;
  border-radius: 0;
}
.ui-feld .ui-feld__rahmen input:focus,
.ui-feld .ui-feld__rahmen select:focus { outline: 0; }
.ui-feld .ui-feld__rahmen input::placeholder { color: var(--text-faint); }
.ui-feld .ui-feld__rahmen select { cursor: pointer; padding-right: var(--space-6); }
.ui-feld__rahmen--auswahl { position: relative; }
.ui-feld__rahmen--auswahl::after {
  content: ""; position: absolute; right: var(--space-3); top: 50%;
  width: 7px; height: 7px; margin-top: -5px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg); pointer-events: none;
}
.ui-feld__einheit {
  padding: 0 var(--space-3);
  font-family: var(--font-body); font-size: 15px;
  color: var(--text-faint);
}
.ui-feld__hinweis { font-family: var(--font-body); font-size: 13px; color: var(--text-faint); }

/* ── Schnellwahl: Vorschlaege, die ein Formular vorbelegen ──── */
.ui-schnellwahl {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  margin-top: var(--space-4);
}
.ui-schnellwahl__label {
  font-family: var(--font-condensed); font-size: 13px;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-faint);
  margin-right: var(--space-1);
}
.ui-schnellwahl .ui-chip {
  height: 32px; padding: 0 var(--space-3);
  border-radius: var(--radius-s);
  border: 1px solid var(--border-strong);
  background: transparent; color: var(--text-muted);
  font-family: var(--font-body); font-size: 14px; cursor: pointer;
}
.ui-schnellwahl .ui-chip:hover { border-color: var(--border-strong); color: var(--text-body); }

/* ── Status: Punkt + Text ───────────────────────────────────── */
.ui-status {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-body); font-size: 14px; color: var(--text-muted);
}
.ui-status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--status-idle);
}
.ui-status--warn::before { background: var(--status-warn); }
.ui-status--run::before { background: var(--status-run); }
.ui-status--alert::before { background: var(--status-alert); }
.ui-status--warn { color: var(--status-warn-fg); }

/* ── Meldung unter einem Formular ───────────────────────────── */
.ui-meldung { margin: var(--space-3) 0 0; font-family: var(--font-body); font-size: 14px; }
.ui-meldung--fehler { color: var(--status-alert-fg); }

/* `hidden` muss gegen `display: flex` gewinnen — sonst bleibt ein
   ausgeblendeter Leerzustand stehen. */
.ui-leer[hidden], .ui-formular[hidden], .ui-abschnitt[hidden] { display: none; }

/* ══ Phase 3 ══════════════════════════════════════════════════ */

/* ── Seitenkopf: Kennung, Wer, Meta-Zeile, Status; Aktionen rechts ── */
.ui-seitenkopf {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap;
}
.ui-seitenkopf__titel {
  margin: 0;
  font-family: var(--font-display); font-size: 44px; line-height: 1;
  letter-spacing: .01em;
  color: var(--text-body);
}
.ui-seitenkopf__wer {
  margin: var(--space-2) 0 0;
  font-family: var(--font-body); font-size: 16px; color: var(--text-body);
}
.ui-seitenkopf__meta {
  margin: var(--space-1) 0 0;
  font-family: var(--font-body); font-size: 14px; color: var(--text-muted);
}
.ui-seitenkopf__status { margin-top: var(--space-3); }
.ui-seitenkopf__aktionen {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
}

/* ── Reiter: Subnavigation ueber die volle Breite ─────────────
   Aktiv = Gold-Unterkante und Gold-Schrift. Keine umrandete Karte. */
.ui-reiter {
  display: flex; gap: var(--space-5);
  margin-top: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto; scrollbar-width: none;
}
.ui-reiter > button {
  position: relative;
  height: var(--control-h); padding: 0;
  border: 0; border-radius: 0; background: none;
  color: var(--text-muted);
  font-family: var(--font-condensed); font-size: 15px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer; white-space: nowrap;
}
.ui-reiter > button:hover { color: var(--text-body); background: none; border: 0; }
.ui-reiter > button[aria-selected="true"] { color: var(--text-accent); }
.ui-reiter > button[aria-selected="true"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--interactive-bg);
}
.ui-reiter > button:focus-visible { outline: 1px solid var(--focus-ring); outline-offset: 2px; }
.ui-reiter .ui-zahl { margin-left: var(--space-1); }

/* ── Abschnittskopf allein (wo eine App Kopf und Inhalt getrennt baut) ── */
.ui-abschnitt__kopf--frei { margin-top: var(--space-6); margin-bottom: var(--space-4); }

/* ── Zweispaltig: Liste + Inhalt ───────────────────────────────
   Unter 950 px wird die Liste eine einklappbare Leiste UEBER dem Inhalt.
   Gemessen 01.10.2026 an der Kalkulation: bei 390 px drueckte die feste
   340-px-Liste die Mappe auf einen Streifen. */
.ui-zweispaltig__umschalter { display: none; }
@media (max-width: 950px) {
  body.ui-zweispaltig { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .ui-zweispaltig > .ui-zweispaltig__liste {
    flex: none; max-height: 45vh;
    border-right: 0; border-bottom: 1px solid var(--border-subtle);
  }
  .ui-zweispaltig > .ui-zweispaltig__liste.ist-zu > :not(:first-child) { display: none; }
  .ui-zweispaltig > .ui-zweispaltig__inhalt {
    overflow: visible; padding: var(--space-4);
  }
  .ui-zweispaltig__umschalter {
    display: inline-flex; align-items: center; gap: var(--space-1);
    background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--text-muted); font-family: var(--font-body); font-size: 14px;
  }
  .ui-seitenkopf__titel { font-size: 34px; }
}

/* ── Zurueck und Pfad (docs/entwurf-zurueck-und-pfad.md) ────────
   Eine Zeile ueber dem Seitentitel: „← Zurueck  |  Sales › Anfragen › A-…".
   Pfeil und Trenner setzt das CSS, nicht der Text -- ein Vorlesewerkzeug
   liest „Pfad, Liste, 3 Eintraege". Das Verhalten in pfad.js. Gold nur am
   Fokus: der Pfad ist keine Auswahl. */
.ui-kopfpfad {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
  font-family: var(--font-body); font-size: 14px; line-height: 1.4;
  min-width: 0;
}
.ui-zurueck {
  display: inline-flex; align-items: center; gap: var(--space-1);
  flex: none;
  color: var(--text-body); font-weight: 600; text-decoration: none;
  border-radius: var(--radius-s);
}
.ui-zurueck::before { content: "←"; font-weight: 400; }
.ui-zurueck:hover { color: var(--text-accent); }
.ui-zurueck:focus-visible { outline: 1px solid var(--focus-ring); outline-offset: 2px; }
.ui-pfad { min-width: 0; padding-left: var(--space-4); border-left: 1px solid var(--border-subtle); }
.ui-pfad:first-child { padding-left: 0; border-left: 0; }
.ui-pfad ol {
  display: flex; align-items: center; flex-wrap: nowrap; min-width: 0;
  list-style: none; margin: 0; padding: 0;
}
.ui-pfad li {
  display: flex; align-items: center; min-width: 0;
  color: var(--text-muted);
}
.ui-pfad li + li::before {
  content: "›"; flex: none; padding: 0 var(--space-2); color: var(--text-faint);
}
.ui-pfad a, .ui-pfad [aria-current] {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 32ch;
}
.ui-pfad a { color: var(--text-muted); text-decoration: none; border-radius: var(--radius-s); }
.ui-pfad a:hover { color: var(--text-body); text-decoration: underline; }
.ui-pfad a:focus-visible { outline: 1px solid var(--focus-ring); outline-offset: 2px; }
.ui-pfad [aria-current] { color: var(--text-body); font-weight: 600; }
/* Schmal: Zurueck und die letzte Stufe -- der Rest steht in der Leiste. */
@media (max-width: 900px) {
  .ui-pfad li:not(:last-child) { display: none; }
  .ui-pfad li + li::before { content: none; }
}
