/* base.css — Design-System (CSS-Variablen, Reset, Typo, Buttons, Formulare).
   Kein Framework, keine Drittanbieter-CDN. Selbst gehostet (DSGVO-freundlich).
   Phase 10, docs/15 §1, §7. */

/* --- Design-Tokens (Dark = Default) --- */
:root {
  /* Farbpalette — dunkel, kontrastreich (WCAG AA+). */
  --c-bg:           #0b0f14;
  --c-bg-elev:      #131922;
  --c-bg-elev-2:    #1b2330;
  --c-border:       #2a3340;
  --c-border-soft:  #1f2733;
  --c-text:         #e6edf3;
  --c-text-muted:   #9aa6b2;
  --c-text-dim:     #6b7785;

  --c-primary:      #4ea1ff;
  --c-primary-hi:   #6fb4ff;
  --c-primary-lo:   #2a6fb0;
  --c-accent:       #8b9eff;

  --c-ok:           #3fb950;
  --c-ok-bg:        rgba(63,185,80,.12);
  --c-warn:         #d29922;
  --c-warn-bg:      rgba(210,153,34,.14);
  --c-danger:       #f85149;
  --c-danger-bg:    rgba(248,81,73,.14);
  --c-info:         #4ea1ff;
  --c-info-bg:      rgba(78,161,255,.12);
  --c-neutral:      #6b7785;
  --c-neutral-bg:   rgba(107,119,133,.12);

  /* Status-Farben (Aliase). */
  --c-status-active:    #3fb950;
  --c-status-disabled:  #d29922;
  --c-status-burned:     #f85149;
  --c-status-deleted:   #6b7785;

  /* Geometrie. */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow:    0 4px 12px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.45);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --maxw:      1100px;
  --maxw-narrow: 720px;

  --transition: 160ms cubic-bezier(.4,0,.2,1);
}

/* Light-Theme (optional, via [data-theme="light"]). */
[data-theme="light"] {
  --c-bg:           #f6f8fa;
  --c-bg-elev:      #ffffff;
  --c-bg-elev-2:    #f0f3f6;
  --c-border:       #d0d7de;
  --c-border-soft:  #e3e8ec;
  --c-text:         #1f2328;
  --c-text-muted:   #59636e;
  --c-text-dim:     #818b98;

  --c-primary:      #1f6feb;
  --c-primary-hi:   #2f81f7;
  --c-primary-lo:   #1552a3;

  --c-ok:           #1a7f37;
  --c-ok-bg:        rgba(26,127,55,.10);
  --c-warn:         #9a6700;
  --c-warn-bg:      rgba(154,103,0,.12);
  --c-danger:       #cf222e;
  --c-danger-bg:    rgba(207,34,46,.10);
  --c-info-bg:      rgba(31,111,235,.10);
  --c-neutral:      #636c76;
  --c-neutral-bg:   rgba(99,108,118,.10);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow:    0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.12);
}

/* --- Reset (minimal, kein normalize.css) --- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--c-primary-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
hr { border: 0; border-top: 1px solid var(--c-border-soft); margin: var(--space-5) 0; }
code, kbd, samp { font-family: var(--font-mono); font-size: .92em; }
small { color: var(--c-text-muted); }

/* --- Skip-Link (Barrierefreiheit) --- */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 1000;
  background: var(--c-primary); color: #fff; padding: var(--space-2) var(--space-3);
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* --- Typo --- */
h1, h2, h3, h4, h5 { margin: 0 0 var(--space-3); font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 var(--space-3); }
ul, ol { margin: 0 0 var(--space-3); padding-left: 1.25rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-bg-elev);
  color: var(--c-text);
  cursor: pointer;
  font-size: .95rem; font-weight: 500;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  user-select: none;
  white-space: nowrap;
}
.btn:hover { background: var(--c-bg-elev-2); border-color: var(--c-primary); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn--primary:hover { background: var(--c-primary-hi); border-color: var(--c-primary-hi); }
.btn--danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn--danger:hover { background: #ff6157; border-color: #ff6157; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--c-bg-elev-2); border-color: var(--c-border); }
.btn--sm { padding: var(--space-1) var(--space-3); font-size: .85rem; }
.btn--block { width: 100%; justify-content: center; }
.btn--icon { padding: var(--space-2); }

/* --- Formulare --- */
.field { margin-bottom: var(--space-4); }
.field__label { display: block; margin-bottom: var(--space-2); font-weight: 500; font-size: .9rem; color: var(--c-text-muted); }
.field__hint  { margin-top: var(--space-1); font-size: .82rem; color: var(--c-text-dim); }
.field__error { margin-top: var(--space-1); font-size: .82rem; color: var(--c-danger); }
.input, .select, .textarea {
  width: 100%; padding: var(--space-2) var(--space-3);
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  color: var(--c-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-info-bg);
}
.input--mono { font-family: var(--font-mono); font-size: .92rem; }
.textarea { min-height: 6rem; resize: vertical; }
.input-group { display: flex; gap: var(--space-2); }
.input-group .input { flex: 1 1 auto; }

/* --- Badges / Status-Pills --- */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: .78rem; font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--active   { background: var(--c-ok-bg);     color: var(--c-status-active);   border-color: var(--c-status-active); }
.badge--disabled { background: var(--c-warn-bg);   color: var(--c-status-disabled); border-color: var(--c-status-disabled); }
.badge--burned   { background: var(--c-danger-bg); color: var(--c-status-burned);   border-color: var(--c-status-burned); }
.badge--deleted  { background: var(--c-neutral-bg);color: var(--c-status-deleted);  border-color: var(--c-status-deleted); }
.badge--info     { background: var(--c-info-bg);   color: var(--c-info); }
.badge--neutral  { background: var(--c-neutral-bg);color: var(--c-neutral); }
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

/* --- Karten / Panels --- */
.card {
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); gap: var(--space-3); }
.card__title { margin: 0; font-size: 1.1rem; }
.card__actions { display: flex; gap: var(--space-2); flex-shrink: 0; }

/* --- Lade-/Leer-/Fehler-Zustände --- */
.state {
  padding: var(--space-6); text-align: center; color: var(--c-text-muted);
}
.state__icon { font-size: 2rem; margin-bottom: var(--space-3); opacity: .6; }
.state--error { color: var(--c-danger); }

/* --- Spinner --- */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--c-border); border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Hilfsklassen --- */
.row { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.row--between { justify-content: space-between; align-items: center; }
.row--end { justify-content: flex-end; }
.row--center { align-items: center; }
.col { flex: 1 1 0; min-width: 0; }
.muted { color: var(--c-text-muted); }
.dim { color: var(--c-text-dim); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.hidden, [hidden] { display: none !important; }

/* --- Boot-Fehler (noscript / JS-aus) --- */
.boot-error {
  max-width: 30rem; margin: var(--space-8) auto; padding: var(--space-5);
  text-align: center; color: var(--c-danger);
  background: var(--c-bg-elev); border: 1px solid var(--c-danger); border-radius: var(--radius);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
