/* ============================================================
 *  hw-design.css — „HW Ink": die gemeinsame Designsprache
 *  von Landing UND Dashboard. Wird auf jeder Dashboard-Seite
 *  VOR dem seitenspezifischen CSS geladen.
 *
 *  Grundsätze:
 *  1. Dunkel, ruhig, präzise. Eine Bühne (Ink), Karten aus Glas.
 *  2. Drei Gestaltungsmittel, nie improvisieren:
 *     Glas-Panels · Blau-Glow für den EINEN wichtigen Akzent ·
 *     Uppercase-Status-Pills.
 *  3. Titillium Web nur für Titel, Inter für alles andere.
 *  4. Icons: lokales SVG-Sprite /hw-icons.svg (stroke 2, round) —
 *     keine externen Icon-Kits.
 * ============================================================*/

@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@700;900&family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  /* Farben */
  --ink: #030712;
  --surface: #111827;
  --elevated: #1f2937;
  --text: #f9fafb;
  --muted: #9ca3af;
  --faint: rgba(255, 255, 255, 0.45);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  /* Bedienelemente brauchen 3:1 Kontrast zur Umgebung — dafür
     reicht --border nicht. Nur für Feld- und Knopfränder. */
  --border-control: rgba(255, 255, 255, 0.32);

  --brand: #3b82f6;
  --brand-hover: #2563eb;
  --brand-soft: rgba(59, 130, 246, 0.12);
  --brand-line: rgba(59, 130, 246, 0.35);
  /* Fläche für weiße Schrift: #fff auf --brand ergibt nur 3,7:1 und
     verfehlt damit AA. Auf #2563eb sind es 5,2:1. --brand bleibt
     die Linien- und Textfarbe, --brand-strong die Füllfarbe. */
  --brand-strong: #2563eb;

  --ok: #10b981;   --ok-soft: rgba(16, 185, 129, 0.12);   --ok-line: rgba(16, 185, 129, 0.35);
  --warn: #f59e0b; --warn-soft: rgba(245, 158, 11, 0.12); --warn-line: rgba(245, 158, 11, 0.35);
  --bad: #ef4444;  --bad-soft: rgba(239, 68, 68, 0.12);   --bad-line: rgba(239, 68, 68, 0.35);
  --info: #0ea5e9; --info-soft: rgba(14, 165, 233, 0.12); --info-line: rgba(14, 165, 233, 0.35);

  /* Aufgehellte Varianten für Text auf den weichen Flächen —
     die Vollfarben oben liegen dort knapp unter 4,5:1. */
  --brand-text: #93c5fd;
  --bad-text:   #fca5a5;
  --warn-text:  #fbbf24;
  --ok-text:    #6ee7b7;

  /* Form */
  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  /* Deutlich sichtbarer Fokusring: mit 0.3 Alpha lag er bei 1,5:1
     gegen die Karte und war praktisch unsichtbar. */
  --ring: 0 0 0 3px rgba(96, 165, 250, 0.9);

  /* Ebenen. Die feste Kopfleiste liegt auf 9000 — alles, was über
     ihr liegen muss, gehört über diese Marke. Vorher standen die
     Dialoge auf 999 und verschwanden zur Hälfte unter der Leiste. */
  --z-bar: 9000;
  --z-loader: 9400;
  --z-overlay: 9500;
  --z-menu: 9600;

  /* Schrift */
  --font-display: 'Titillium Web', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  color-scheme: dark;
}

/* ── Basis ──────────────────────────────────────────────── */
* { box-sizing: border-box; }
html { background: var(--ink); }
body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(90% 40% at 50% -10%, rgba(59, 130, 246, 0.09), transparent 70%),
    var(--ink);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}

h1, h2, h3 { margin: 0; font-family: var(--font-display); letter-spacing: -0.01em; }
h1 { font-size: 28px; font-weight: 900; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p  { margin: 0; }
a  { color: var(--brand); }

.hw-page {
  max-width: 1140px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}
.hw-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.hw-page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ── Icons (Sprite /hw-icons.svg) ───────────────────────── */
.hwi {
  width: 18px; height: 18px; flex: none;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -3px;
}
.hwi-sm { width: 15px; height: 15px; }
.hwi-lg { width: 24px; height: 24px; }

/* ── Karten (Glas) ──────────────────────────────────────── */
.hw-card {
  background: rgba(17, 24, 39, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
}
.hw-card-pad { padding: 22px; }
.hw-card:where(a, button, .clickable) { transition: border-color .2s ease, transform .2s ease; cursor: pointer; }
.hw-card:where(a, button, .clickable):hover { border-color: var(--border-strong); transform: translateY(-2px); }

/* ── Buttons ────────────────────────────────────────────── */
.hw-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: 700 14px/1 var(--font-body);
  cursor: pointer; user-select: none;
  transition: background .2s ease, border-color .2s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.hw-btn:hover { background: rgba(255, 255, 255, 0.09); }
.hw-btn:active { transform: scale(0.97); }
.hw-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.hw-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.hw-btn.primary { background: var(--brand-strong); border-color: transparent; color: #fff; }
.hw-btn.primary:hover:not(:disabled) { background: #1d4ed8; }
.hw-btn.ok     { background: var(--ok-soft);   border-color: var(--ok-line);   color: var(--ok); }
.hw-btn.ok:hover     { background: var(--ok);   color: #fff; }
.hw-btn.danger { background: var(--bad-soft);  border-color: var(--bad-line);  color: var(--bad); }
.hw-btn.danger:hover { background: var(--bad); color: #fff; }
.hw-btn.quiet  { border-color: transparent; background: transparent; color: var(--muted); }
.hw-btn.quiet:hover { color: var(--text); background: rgba(255,255,255,.06); }

.hw-ibtn2 {
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: rgba(255,255,255,.04);
  color: var(--text); cursor: pointer; transition: all .2s ease;
}
.hw-ibtn2:hover { background: rgba(255,255,255,.09); }
.hw-ibtn2:active { transform: scale(.94); }
.hw-ibtn2:focus-visible { outline: none; box-shadow: var(--ring); }

/* ── Formulare ──────────────────────────────────────────── */
.hw-field { display: block; margin-bottom: 16px; }
.hw-label {
  display: block; margin-bottom: 7px;
  font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.hw-input, .hw-select, .hw-textarea {
  width: 100%; min-height: 46px; padding: 12px 14px;
  border-radius: 14px;
  /* Eigener, kräftigerer Rahmen: mit --border (0.08 Alpha) hob sich
     ein Eingabefeld nur mit 1,2:1 vom Untergrund ab – man sah nicht,
     wo es anfängt. Deko-Linien behalten --border. */
  border: 1px solid var(--border-control);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: 500 15px/1.4 var(--font-body);
  outline: none;
  transition: border-color .2s ease;
}
.hw-textarea { min-height: 96px; resize: vertical; }
.hw-input:focus, .hw-select:focus, .hw-textarea:focus { border-color: var(--brand); box-shadow: var(--ring); }
.hw-input::placeholder, .hw-textarea::placeholder { color: var(--faint); }
.hw-input.invalid, .hw-select.invalid { border-color: var(--bad); box-shadow: 0 0 0 3px rgba(239,68,68,.25); }
.hw-select { appearance: none; cursor: pointer; }
.hw-select option { background: var(--elevated); color: var(--text); }
input[type='date'].hw-input, input[type='time'].hw-input { color-scheme: dark; }

.hw-check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; }
.hw-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); cursor: pointer; }

.hw-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .hw-row2 { grid-template-columns: 1fr; } }

/* ── Status-Pills ───────────────────────────────────────── */
.hw-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.07em; text-transform: uppercase;
  border: 1px solid var(--border); background: rgba(255,255,255,.06); color: var(--text);
  white-space: nowrap;
}
.hw-pill.brand { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand); }
.hw-pill.ok    { background: var(--ok-soft);    border-color: var(--ok-line);    color: var(--ok); }
.hw-pill.warn  { background: var(--warn-soft);  border-color: var(--warn-line);  color: var(--warn); }
.hw-pill.bad   { background: var(--bad-soft);   border-color: var(--bad-line);   color: var(--bad); }
.hw-pill.info  { background: var(--info-soft);  border-color: var(--info-line);  color: var(--info); }
.hw-pill.muted { color: var(--muted); }

/* ── Schlüssel-Wert-Zeilen ──────────────────────────────── */
.hw-kv { display: flex; flex-direction: column; gap: 8px; }
.hw-kv-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  font-size: 14px;
}
.hw-kv-row > div:first-child { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; min-width: 0; }
.hw-kv-row b { font-weight: 800; color: var(--text); text-align: right; }

/* ── Tabellen ───────────────────────────────────────────── */
.hw-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.hw-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.hw-table th {
  text-align: left; padding: 12px 16px;
  color: var(--muted); font-size: 11.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}
.hw-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.hw-table tr:last-child td { border-bottom: none; }
.hw-table tbody tr { transition: background .15s ease; }
.hw-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

/* ── Modals (Bottom-Sheet mobil, zentriert ab 600px) ────── */
/* Gescrollt wird die HINTERGRUNDFLÄCHE, nicht der Dialog.
 *
 * Dritter Anlauf, und diesmal bewusst die anspruchsloseste Bauweise.
 * Vorher war erst der Rumpf der Scrollcontainer, dann der Dialog
 * selbst. Beides hängt davon ab, dass der Zeiger genau über dem
 * scrollenden Kasten steht — und beides brach in Safari, wo ein
 * scrollender Kasten mit Transformation und `position:sticky`-Kindern
 * die Treffererkennung verliert. Ergebnis: Scrollen ging nur noch am
 * unteren Rand des Dialogs.
 *
 * Jetzt ist der Scrollbereich die gesamte Bildschirmfläche. Der
 * Zeiger steht damit IMMER darüber, egal wo im Dialog er sich
 * befindet. Der Dialog selbst wächst nur noch mit seinem Inhalt und
 * hat weder eine Höhenbegrenzung noch eigenes Scrollen — es gibt also
 * nichts mehr, was ein Browser falsch berechnen könnte.
 *
 * Preis dafür: Kopfzeile und Fußleiste kleben nicht mehr fest, sie
 * scrollen mit. Das ist der übliche Weg für lange Formulare und
 * allemal besser als ein Dialog, der sich nicht bewegen lässt. */
.hw-overlay {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  /* Bewusst KEIN Flexbox-Zentrieren: `margin:auto` bzw.
     `align-items:center` schieben einen Dialog, der höher als das
     Fenster ist, mit dem Kopf über den oberen Rand hinaus — und dorthin
     kann man nicht zurückscrollen. Blocklayout kann das nicht. */
  display: block; text-align: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;       /* die Seite dahinter bleibt stehen */
  scrollbar-width: none;              /* Firefox */
}
.hw-overlay::-webkit-scrollbar { display: none; }   /* Safari, Chrome */

/* Geschlossene Dialoge dürfen nicht in der Tab-Reihenfolge bleiben,
   sonst tabbt man aus der Seite heraus in unsichtbare Formulare.
   Das erledigt das `inert`-Attribut (setzt shell.js) statt
   `visibility` — eine Transition auf visibility friert in
   Hintergrund-Tabs ein und macht den Dialog dann dauerhaft
   unfokussierbar, obwohl er offen ist. */
.hw-overlay.show,
.hw-overlay.active { opacity: 1; pointer-events: auto; }

.hw-modal {
  width: 100%; max-width: 580px;
  margin: 0 auto;                     /* waagerecht mittig */
  display: flex; flex-direction: column;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.6);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
/* Im geöffneten Zustand `none`, nicht `translateY(0)`: eine bleibende
   Transformation macht den Dialog zum Bezugsrahmen und kostet auf
   schwachen Geräten unnötig Compositing. */
.hw-overlay.show .hw-modal,
.hw-overlay.active .hw-modal { transform: none; }

.hw-modal-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 26px 22px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-radius: 28px 28px 0 0;
}
.hw-modal-head::before {
  content: ''; position: absolute; top: 11px; left: 50%; transform: translateX(-50%);
  width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.2);
}
.hw-modal-body { padding: 20px 22px 26px; flex: 0 0 auto; }

/* Mobil bleibt die Anmutung des von unten hereinfahrenden Blatts:
   etwas Luft darüber, Rest füllt der Dialog. */
.hw-overlay::before { content: ''; display: block; height: 10vh; }

@media (min-width: 600px) {
  .hw-overlay { padding: 40px 20px; }
  .hw-overlay::before { display: none; }
  .hw-modal {
    border-radius: 24px; border-bottom: 1px solid var(--border);
    transform: scale(0.95); opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
  }
  .hw-overlay.show .hw-modal,
  .hw-overlay.active .hw-modal { transform: none; opacity: 1; }
  .hw-modal-head { border-radius: 24px 24px 0 0; }
  .hw-modal-head::before { display: none; }
}

/* ── Leere Zustände ─────────────────────────────────────── */
.hw-empty {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 56px 24px; text-align: center; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.hw-empty .hwi { width: 34px; height: 34px; opacity: .6; }
.hw-empty b { color: var(--text); font-size: 16px; }

/* ── Meldungen ──────────────────────────────────────────── */
.hw-note {
  padding: 13px 16px; border-radius: 14px; font-size: 14px; font-weight: 600;
  border: 1px solid var(--border); background: rgba(255,255,255,.04);
}
.hw-note.ok   { background: var(--ok-soft);   border-color: var(--ok-line);   color: var(--ok); }
.hw-note.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.hw-note.bad  { background: var(--bad-soft);  border-color: var(--bad-line);  color: var(--bad); }

/* ── Animationen (eine Sprache, wie die Landing) ────────── */
@keyframes hw-in { from { opacity: 0; transform: translateY(14px); } }
.hw-in { animation: hw-in .45s cubic-bezier(.22,1,.36,1) both; }
@keyframes hw-pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
.hw-pop { animation: hw-pop .45s cubic-bezier(.34,1.56,.64,1) both; }

@media (prefers-reduced-motion: reduce) {
  .hw-in, .hw-pop { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
