/*
 * TIU Platform — Design Tokens
 * Single source of truth for all UI styling.
 * All HTML pages must reference this file.
 */

:root {
  /* ── Colors (dark slate) ────────────────── */
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --primary-light: rgba(59,130,246,0.10);

  --bg: #111827;
  --surface: #1F2937;
  --border: #374151;
  --border-strong: #4B5563;

  --text: #F3F4F6;
  --text-muted: #9CA3AF;
  --text-inverse: #111827;

  --success: #22C55E;
  --success-light: rgba(34,197,94,0.12);
  --warning: #F59E0B;
  --warning-light: rgba(245,158,11,0.12);
  --danger: #EF4444;
  --danger-light: rgba(239,68,68,0.12);

  --header-bg: #1F2937;
  --sidebar-bg: #1F2937;
  --sidebar-active: var(--primary-light);

  /* ── Typography ──────────────────────────── */
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', Consolas, 'Courier New', monospace;

  --text-h1: 24px;
  --text-h2: 20px;
  --text-h3: 18px;
  --text-body: 14px;
  --text-small: 12px;
  --text-xs: 11px;

  --leading: 1.5;
  --leading-tight: 1.3;

  /* ── Spacing (4px grid) ──────────────────── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-8: 48px;

  /* ── Radius ──────────────────────────────── */
  --radius: 6px;
  --radius-sm: 4px;

  /* ── Shadows ─────────────────────────────── */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 1px 3px rgba(0,0,0,0.4);

  /* ── Modal overlay ─────────────────────── */
  --modal-overlay: rgba(0,0,0,0.6);

  /* ── Status colors (truck workflow) ────── */
  --status-warten: #2563EB;
  --status-einfahren: #F59E0B;
  --status-stop: #DC2626;
  --status-fertig: #16A34A;

  /* ── Z-index scale ─────────────────────── */
  --z-banner: 50;
  --z-dropdown: 80;
  --z-modal: 100;
  --z-overlay: 120;
}

/* ── Base reset ────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font);
  font-size: var(--text-body);
  line-height: var(--leading);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Buttons ───────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  font-size: var(--text-small);
  font-weight: 600;
  font-family: var(--font);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: var(--border-strong); }

.btn-danger {
  background: var(--danger);
  color: var(--text-inverse);
  border-color: var(--danger);
}
.btn-danger:hover { background: #B91C1C; }

.btn-sm { height: 28px; padding: 0 var(--space-3); font-size: var(--text-xs); }

/* ── Inputs ────────────────────────────────── */
.input, input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"], select, textarea {
  height: 36px;
  padding: 0 var(--space-3);
  font-size: var(--text-body);
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
textarea { height: auto; padding: var(--space-3); }

/* ── Tables ────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body);
}
.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:hover td { background: var(--primary-light); }

/* ── Cards ─────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
}

/* ── Badges ────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
  line-height: 1.4;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-muted { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Section headers ───────────────────────── */
.section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-4);
}

/* ── Status banner ─────────────────────────── */
#tiu-status-banner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9999;
  text-align: center;
  font-size: var(--text-body);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  display: none;
}

/* ── Modal ─────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  min-width: 400px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-size: var(--text-h3);
  font-weight: 700;
  margin-bottom: var(--space-4);
}

/* ── Stat cards ────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  text-align: center;
}
.stat-value {
  font-size: var(--text-h1);
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text);
  line-height: 1;
}
.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: var(--space-1);
}

/* ── Scrollbar (dark) ─────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #6B7280; }
