/* =========================================================
   Fahrzeugverwaltung OFSI — Haupt-Stylesheet
   THW Ultramarinblau RAL 5002 = #00338D
   ========================================================= */

:root {
  --thw-blau: #00338D;
  --thw-blau-dunkel: #002470;
  --thw-blau-hell: #E6EEF8;
  --thw-blau-mittel: #B8CCE8;
  --rot: #C0392B;
  --rot-hell: #FDECEA;
  --gelb: #E67E22;
  --gelb-hell: #FEF3E2;
  --gruen: #27AE60;
  --gruen-hell: #E8F8EF;
  --grau: #6C757D;
  --grau-hell: #F8F9FA;
  --rand: #DEE2E6;
  --text: #212529;
  --text-muted: #6C757D;
  --weiss: #FFFFFF;
  --sidebar-breite: 220px;
  --topbar-hoehe: 52px;
  --border-radius: 8px;
  --border-radius-lg: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--grau-hell);
  line-height: 1.5;
}

a { color: var(--thw-blau); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =========================================================
   Layout Shell
   ========================================================= */

.shell { display: flex; min-height: 100vh; }

/* =========================================================
   Sidebar
   ========================================================= */

.sidebar {
  width: var(--sidebar-breite);
  background: var(--thw-blau);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-logo {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-logo-title {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}
.sidebar-logo-sub {
  color: rgba(255,255,255,.55);
  font-size: 11px;
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-section {
  font-size: 10px;
  color: rgba(255,255,255,.35);
  padding: 12px 16px 4px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 13px;
  color: rgba(255,255,255,.72);
  cursor: pointer;
  border-left: 3px solid transparent;
  text-decoration: none;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,.13); color: #fff; border-left-color: #fff; }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--rot);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.user-name { color: #fff; font-size: 12px; font-weight: 500; }
.user-role { color: rgba(255,255,255,.5); font-size: 10px; }

/* =========================================================
   Main Content
   ========================================================= */

.main {
  margin-left: var(--sidebar-breite);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  height: var(--topbar-hoehe);
  background: var(--weiss);
  border-bottom: 1px solid var(--rand);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: 6px;
  background: none;
  border: none;
}
.hamburger span {
  width: 20px; height: 2px;
  background: var(--text);
  display: block;
  border-radius: 2px;
}

.topbar-title { font-size: 16px; font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-date { font-size: 12px; color: var(--text-muted); }

.content { padding: 20px; flex: 1; }

/* =========================================================
   Karten & Panels
   ========================================================= */

.card {
  background: var(--weiss);
  border: 1px solid var(--rand);
  border-radius: var(--border-radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.card-link {
  font-size: 12px;
  color: var(--thw-blau);
  font-weight: 400;
}

/* =========================================================
   KPI / Metrik-Karten
   ========================================================= */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--weiss);
  border: 1px solid var(--rand);
  border-radius: var(--border-radius-lg);
  padding: 16px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1; }
.kpi-sub { font-size: 11px; margin-top: 4px; }

.kpi-rot .kpi-value, .kpi-rot .kpi-sub { color: var(--rot); }
.kpi-gelb .kpi-value, .kpi-gelb .kpi-sub { color: var(--gelb); }
.kpi-gruen .kpi-value, .kpi-gruen .kpi-sub { color: var(--gruen); }

/* =========================================================
   Ampel-Status
   ========================================================= */

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.dot-rot { background: var(--rot); }
.dot-gelb { background: var(--gelb); }
.dot-gruen { background: var(--gruen); }
.dot-grau { background: var(--grau); }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
}
.badge-rot { background: var(--rot-hell); color: var(--rot); }
.badge-gelb { background: var(--gelb-hell); color: var(--gelb); }
.badge-gruen { background: var(--gruen-hell); color: var(--gruen); }
.badge-blau { background: var(--thw-blau-hell); color: var(--thw-blau); }
.badge-grau { background: var(--grau-hell); color: var(--grau); }

/* =========================================================
   Tabellen & Listen
   ========================================================= */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--rand);
  background: var(--grau-hell);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rand);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--grau-hell); }

.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rand);
}
.list-row.klickbar {
  cursor: pointer;
  transition: background .12s;
  border-radius: var(--border-radius);
  padding-left: 6px;
  padding-right: 6px;
  margin-left: -6px;
  margin-right: -6px;
}
.list-row.klickbar:hover { background: var(--grau-hell); }
.list-row:last-child { border-bottom: none; }

.dl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.dl-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--rand);
  gap: 8px;
}
.dl-row:last-child { border-bottom: none; }
.dl-label { font-size: 12px; color: var(--text-muted); }
.dl-value { font-size: 13px; font-weight: 500; text-align: right; }

/* =========================================================
   Formulare
   ========================================================= */

.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.form-label .required { color: var(--rot); }

.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--rand);
  border-radius: var(--border-radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--weiss);
  transition: border-color .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--thw-blau);
  box-shadow: 0 0 0 3px rgba(0,51,141,.1);
}
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.5; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.form-section {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 16px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rand);
}

/* =========================================================
   Buttons
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--border-radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  transition: background .12s, border-color .12s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--thw-blau); color: #fff; border-color: var(--thw-blau); }
.btn-primary:hover { background: var(--thw-blau-dunkel); border-color: var(--thw-blau-dunkel); color: #fff; }

.btn-secondary { background: var(--weiss); color: var(--text); border-color: var(--rand); }
.btn-secondary:hover { background: var(--grau-hell); }

.btn-danger { background: var(--rot); color: #fff; border-color: var(--rot); }
.btn-success { background: var(--gruen); color: #fff; border-color: var(--gruen); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 14px; }
.btn-block { width: 100%; }
.btn svg { width: 14px; height: 14px; }

/* =========================================================
   Flash-Meldungen
   ========================================================= */

.flash-container { padding: 0 20px; margin-top: 12px; }
.alert {
  padding: 10px 14px;
  border-radius: var(--border-radius);
  margin-bottom: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: var(--gruen-hell); color: #145a32; border: 1px solid #a9dfbf; }
.alert-danger { background: var(--rot-hell); color: #922b21; border: 1px solid #f5b7b1; }
.alert-warning { background: var(--gelb-hell); color: #784212; border: 1px solid #fad7a0; }
.alert-info { background: var(--thw-blau-hell); color: #1a5276; border: 1px solid var(--thw-blau-mittel); }

/* =========================================================
   Fahrzeugkarten
   ========================================================= */

.fz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.fz-card {
  position: relative;
  background: var(--weiss);
  border: 1px solid var(--rand);
  border-radius: var(--border-radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fz-card:hover { border-color: var(--thw-blau); transform: translateY(-1px); text-decoration: none; }
.fz-card.status-rot { border-left: 3px solid var(--rot); border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0; }
.fz-card.status-gelb { border-left: 3px solid var(--gelb); border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0; }

.fz-pikt {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grau-hell);
  border-radius: var(--border-radius);
  overflow: hidden;
}
.fz-pikt img { max-height: 44px; max-width: 100%; object-fit: contain; }
.fz-pikt-placeholder { font-size: 24px; opacity: .3; }

.fz-name { font-size: 13px; font-weight: 600; }
.fz-kz { font-size: 11px; color: var(--text-muted); }
.fz-badges { display: flex; flex-wrap: wrap; gap: 4px; }

/* =========================================================
   Timeline / Verlauf
   ========================================================= */

.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 12px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot-col { display: flex; flex-direction: column; align-items: center; }
.timeline-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--thw-blau);
  flex-shrink: 0;
  margin-top: 3px;
}
.timeline-line {
  width: 1px;
  flex: 1;
  background: var(--rand);
  margin-top: 3px;
}
.timeline-date { font-size: 11px; color: var(--text-muted); min-width: 78px; padding-top: 2px; }
.timeline-content { flex: 1; }
.timeline-title { font-size: 13px; font-weight: 500; }
.timeline-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* =========================================================
   Foto-Upload (Schadensmeldung)
   ========================================================= */

.foto-upload-bereich {
  border: 2px dashed var(--rand);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s;
  position: relative;
}
.foto-upload-bereich:hover { border-color: var(--thw-blau); }
.foto-upload-bereich input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.kamera-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: var(--thw-blau-hell);
  color: var(--thw-blau);
  border: 1px solid var(--thw-blau-mittel);
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  font-family: inherit;
}
.kamera-btn input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.foto-vorschau-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.foto-thumb {
  aspect-ratio: 1;
  border-radius: var(--border-radius);
  overflow: hidden;
  position: relative;
  background: var(--grau-hell);
  border: 1px solid var(--rand);
}
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; }
.foto-thumb .foto-remove {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px;
  background: rgba(0,0,0,.6); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 10px; border: none;
}

/* =========================================================
   Bestätigungsbox
   ========================================================= */

.bestaetigung-box {
  background: var(--weiss);
  border: 2px solid var(--thw-blau);
  border-radius: var(--border-radius-lg);
  padding: 20px;
}
.bestaetigung-preview {
  background: var(--thw-blau-hell);
  border-radius: var(--border-radius);
  padding: 12px 14px;
  margin: 12px 0;
}
.bestaetigung-preview-label { font-size: 11px; color: var(--thw-blau); margin-bottom: 4px; }
.bestaetigung-preview-wert { font-size: 14px; font-weight: 600; color: var(--thw-blau-dunkel); }

/* =========================================================
   Login-Seite
   ========================================================= */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--thw-blau);
  padding: 20px;
}
.login-card {
  background: var(--weiss);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo-title { font-size: 20px; font-weight: 700; color: var(--thw-blau); }
.login-logo-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* =========================================================
   Breadcrumb
   ========================================================= */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--thw-blau); }
.breadcrumb-sep { color: var(--rand); }
.breadcrumb-current { color: var(--text); font-weight: 500; }

/* =========================================================
   Zwei-Spalten Layout
   ========================================================= */

.two-col { display: grid; grid-template-columns: 360px 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* =========================================================
   Responsive — Tablet (max 900px)
   ========================================================= */

@media (max-width: 900px) {
  :root { --sidebar-breite: 0px; }

  .sidebar {
    transform: translateX(-220px);
    width: 220px;
  }
  .sidebar.open { transform: translateX(0); }

  .main { margin-left: 0; }

  .hamburger { display: flex; }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr 1fr; }
  .fz-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .topbar-date { display: none; }
}

/* =========================================================
   Responsive — Smartphone (max 560px)
   ========================================================= */

@media (max-width: 560px) {
  .content { padding: 12px; }
  .card { overflow-x: auto; }
  .card[style*="overflow:hidden"] { overflow-x: auto !important; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 22px; }
  .fz-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .three-col { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .dl-grid { grid-template-columns: 1fr; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px; }
  .card { padding: 12px; }
}

/* =========================================================
   Overlay bei offener Sidebar (Mobile)
   ========================================================= */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* =========================================================
   Sonstige Utilities
   ========================================================= */

.text-muted { color: var(--text-muted); }
.text-rot { color: var(--rot); }
.text-gelb { color: var(--gelb); }
.text-gruen { color: var(--gruen); }
.text-blau { color: var(--thw-blau); }
.fw-600 { font-weight: 600; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.justify-between { justify-content: space-between; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }
