/* ═══════════════════════════════════════════════
   BeKu Portal · Feuerwehr Design System
   ═══════════════════════════════════════════════ */

:root {
  --red:        #c1121f;
  --red-dark:   #8f0d16;
  --red-light:  #fee2e2;
  --orange:     #ea580c;
  --bg:         #f1f5f9;
  --panel:      #ffffff;
  --text:       #0f172a;
  --muted:      #64748b;
  --border:     #e2e8f0;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg:  0 20px 48px rgba(0,0,0,.12), 0 8px 16px rgba(0,0,0,.06);
  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --sidebar-w:  268px;
  --header-h:   56px;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ─── Utilities ──────────────────────────────── */
.hidden { display: none !important; }

/* ─── Buttons ────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--red); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: .6rem 1.25rem; font-size: .925rem; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn-primary:hover  { background: var(--red-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-primary.btn-full { width: 100%; justify-content: center; padding: .75rem; font-size: 1rem; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: .4rem;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .6rem 1.1rem; font-size: .925rem; font-weight: 500;
  cursor: pointer; transition: background .15s;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--panel);
  font-size: .85rem; cursor: pointer; transition: background .15s;
  color: var(--muted);
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.danger { border-color: #fca5a5; background: var(--red-light); color: var(--red); }
.btn-icon.danger:hover { background: #fecaca; }

/* ─── LOGIN ──────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 1.5rem;
  background: url('/img/hintergrund.png') center center / cover no-repeat;
  position: relative;
  overflow: hidden;
}
.login-shell::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(0,0,0,.45);
}
.login-card {
  position: relative; z-index: 1;
  width: min(420px, 100%);
  background: rgba(255,255,255,.97);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 2rem;
}
.logo-badge {
  width: 52px; height: 52px; border-radius: var(--radius-md);
  background: var(--red); display: grid; place-items: center;
  font-size: 1.6rem; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(193,18,31,.35);
}
.login-brand h1 { font-size: 1.35rem; font-weight: 800; line-height: 1.1; }
.login-brand p  { font-size: .875rem; color: var(--muted); margin-top: .1rem; }

.field { margin-bottom: 1rem; }
.field-label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .35rem; }
.field-input {
  width: 100%; padding: .7rem .9rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .95rem; background: var(--panel); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.field-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(193,18,31,.12); }
.login-error {
  margin-top: .9rem; min-height: 1.2rem;
  font-size: .875rem; color: var(--red); text-align: center;
}

/* ─── APP SHELL ──────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────── */
.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #1a0a0a 100%);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; overflow-x: hidden;
}
.sidebar-logo {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--red); display: grid; place-items: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.sidebar-logo-img {
  width: 44px; height: 44px; flex-shrink: 0;
  object-fit: contain; border-radius: var(--radius-sm);
}
.sidebar-logo-text strong { display: block; color: #fff; font-size: .95rem; font-weight: 700; }
.sidebar-logo-text small  { color: #94a3b8; font-size: .78rem; }

.sidebar-nav {
  flex: 1; padding: .75rem .6rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.nav-section-label {
  display: block;
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  color: #475569; text-transform: uppercase;
  padding: .6rem .55rem .25rem;
  margin-top: .4rem;
}
.nav-btn {
  display: flex; align-items: center; gap: .65rem;
  width: 100%; padding: .6rem .75rem;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: #94a3b8;
  font-size: .9rem; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: rgba(255,255,255,.07); color: #e2e8f0; }
.nav-btn.active {
  background: rgba(193,18,31,.25); color: #fff;
  font-weight: 600;
}
.nav-btn.active .nav-icon { filter: none; }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

/* Nav-Buttons mit Vorschaubild */
.nav-btn-img { padding: .35rem .75rem; }
.nav-img-thumb {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.1);
  transition: transform .15s;
  display: block;
}
.nav-btn-img:hover .nav-img-thumb { transform: scale(1.06); }
.nav-btn-img.active .nav-img-thumb { border-color: rgba(193,18,31,.6); box-shadow: 0 0 0 2px rgba(193,18,31,.35); }

.page-title-img {
  width: 40px; height: 40px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: .35rem;
  border-radius: var(--radius-sm);
}

/* Dashboard Bildkacheln */
.dash-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.dash-tile {
  position: relative; border-radius: var(--radius-md); overflow: hidden;
  cursor: pointer; box-shadow: var(--shadow-sm);
  aspect-ratio: 4/3;
  transition: transform .15s, box-shadow .15s;
}
.dash-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.dash-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dash-tile-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.65) 0%, transparent 60%);
  display: flex; align-items: flex-end; padding: .6rem .75rem;
}
.dash-tile-label { color: #fff; font-weight: 700; font-size: .95rem; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.dash-tile-count {
  position: absolute; top: .5rem; right: .6rem;
  background: rgba(193,18,31,.85); color: #fff;
  border-radius: 999px; font-size: .75rem; font-weight: 700;
  padding: .1rem .55rem; min-width: 24px; text-align: center;
}

.sidebar-user {
  display: flex; align-items: center; gap: .6rem;
  padding: .9rem 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
  margin-top: auto;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: grid; place-items: center;
  font-size: .85rem; font-weight: 700; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; color: #e2e8f0; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info small  { color: #64748b; font-size: .75rem; }
.logout-btn {
  border: none; background: rgba(255,255,255,.07); color: #94a3b8;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 1rem;
  display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.logout-btn:hover { background: rgba(193,18,31,.3); color: #fca5a5; }

/* ─── MAIN ───────────────────────────────────── */
.main-wrap { display: flex; flex-direction: column; min-height: 100vh; overflow: hidden; }

.mobile-header {
  display: none; align-items: center; gap: 1rem;
  padding: .75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.menu-toggle { border: none; background: none; font-size: 1.3rem; cursor: pointer; }
.mobile-title { font-weight: 700; }

.content { flex: 1; padding: 2rem; overflow: auto; }

/* ─── PAGES ──────────────────────────────────── */
.page { display: none; }
.active-page { display: block; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; margin-bottom: 1.5rem;
}
.page-header-text h1 { font-size: 1.75rem; font-weight: 800; line-height: 1.1; }
.page-header-text p  { color: var(--muted); font-size: .9rem; margin-top: .3rem; }

/* ─── DASHBOARD CARDS ────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
  background: var(--panel); border-radius: var(--radius-md);
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: .35rem;
}
.stat-card-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: grid; place-items: center; font-size: 1.2rem;
  margin-bottom: .25rem;
}
.stat-card-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-card-label { font-size: .8rem; color: var(--muted); font-weight: 500; }

.panel-toolbar {
  display: flex; justify-content: flex-end;
  margin-bottom: .75rem;
}

.dashboard-section-title {
  display: flex; align-items: center; gap: .5rem;
}
.dashboard-section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ─── TABLE CARD ─────────────────────────────── */
.table-card {
  background: var(--panel); border-radius: var(--radius-md);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-toolbar {
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex; gap: .6rem; align-items: center;
}
.search-input {
  flex: 1; max-width: 280px;
  padding: .45rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .875rem; outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--red); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #f8fafc; font-size: .78rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafafa; }
td.td-actions { text-align: right; white-space: nowrap; }
.td-actions { display: flex; gap: .3rem; justify-content: flex-end; }
.empty-row td { text-align: center; color: var(--muted); padding: 2.5rem; font-size: .9rem; }

/* ─── PILLS / BADGES ─────────────────────────── */
.pill {
  display: inline-flex; align-items: center;
  border-radius: 999px; padding: .2rem .65rem;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.pill-blue   { background: #eff6ff; color: #1d4ed8; }
.pill-green  { background: #f0fdf4; color: #16a34a; }
.pill-red    { background: var(--red-light); color: var(--red-dark); }
.pill-orange { background: #fff7ed; color: var(--orange); }
.pill-gray   { background: #f1f5f9; color: #475569; }
.pill-purple { background: #f5f3ff; color: #7c3aed; }

/* ─── DIALOG ─────────────────────────────────── */
dialog {
  border: none; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(860px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  overflow: hidden;
}
dialog::backdrop { background: rgba(15,23,42,.6); backdrop-filter: blur(2px); }
.dialog-inner { display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }
.dialog-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.dialog-head h2 { font-size: 1.1rem; font-weight: 700; }
.dialog-close {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: none; background: var(--bg); cursor: pointer;
  font-size: 1rem; display: grid; place-items: center;
  color: var(--muted); transition: background .15s;
}
.dialog-close:hover { background: var(--red-light); color: var(--red); }
#editForm { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.form-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: .9rem; padding: 1.25rem 1.5rem;
  overflow-y: auto; flex: 1;
}
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.form-control {
  padding: .65rem .85rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .9rem; background: var(--panel); color: var(--text);
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.form-control:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(193,18,31,.1); }
textarea.form-control { min-height: 80px; resize: vertical; font-family: inherit; }
.dialog-actions {
  display: flex; justify-content: flex-end; gap: .6rem;
  padding: .9rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─── TOAST ──────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 9999; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: .6rem;
  padding: .75rem 1.1rem;
  background: var(--text); color: #fff;
  border-radius: var(--radius-md); font-size: .875rem;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
  pointer-events: all;
}
.toast.success { background: #166534; }
.toast.error   { background: var(--red-dark); }
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOut { to { transform: translateX(110%); opacity: 0; } }

/* ─── MOBILE ─────────────────────────────────── */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
    transform: translateX(-100%); transition: transform .25s ease;
    width: var(--sidebar-w);
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 99;
    background: rgba(0,0,0,.4);
  }
  .sidebar-overlay.visible { display: block; }
  .mobile-header { display: flex; }
  .content { padding: 1rem; }
  .page-header { flex-direction: column; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

/* ─── Mitgliederkartei / Personaldetails ─────── */
.detail-actions {
  display: flex;
  gap: .6rem;
  align-items: center;
  flex-wrap: wrap;
}

.kartei-header {
  align-items: center;
}

.kartei-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.kartei-summary > div {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: .95rem 1rem;
}

.kartei-summary span,
.detail-item span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .25rem;
}

.kartei-summary strong {
  font-size: 1.25rem;
}

.detail-tabs {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.detail-tab {
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: .7rem 1rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: .9rem;
  font-weight: 700;
}

.detail-tab:hover {
  background: #f8fafc;
  color: var(--text);
}

.detail-tab.active {
  background: var(--panel);
  border-color: var(--border);
  color: var(--red);
  box-shadow: 0 -1px 0 var(--panel) inset;
}

.detail-tab span {
  display: inline-flex;
  min-width: 1.35rem;
  height: 1.35rem;
  align-items: center;
  justify-content: center;
  margin-left: .3rem;
  padding: 0 .35rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: .75rem;
}

.detail-panel {
  display: none;
}

.detail-panel.active {
  display: block;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}

.detail-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: .95rem 1rem;
  min-width: 0;
}

.detail-item.full {
  grid-column: 1 / -1;
}

.detail-item strong {
  display: block;
  word-break: break-word;
}

.hint-box {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: var(--radius-md);
  padding: .8rem 1rem;
  margin-bottom: .75rem;
  font-size: .9rem;
}

.empty-detail {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}

.stats-year-card {
  margin-bottom: 1rem;
}

.stats-year-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: .6rem;
}

.stats-year-head h3 {
  font-size: 1.2rem;
}

.stats-year-head div {
  display: flex;
  gap: .75rem;
  align-items: baseline;
  color: var(--muted);
}

.stats-year-head strong {
  color: var(--text);
  font-size: 1.1rem;
}

@media (max-width: 860px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .detail-tab { white-space: nowrap; }
  .stats-year-head { flex-direction: column; align-items: flex-start; }
}

/* --- Checkbox-Grid (Fahrzeugfunktionen) -------- */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  cursor: pointer;
  padding: .25rem .4rem;
  border-radius: 6px;
}

.checkbox-item:hover { background: var(--border); }
.checkbox-item input[type=checkbox] { accent-color: var(--red); width: 1rem; height: 1rem; flex-shrink: 0; }
.hint-text { font-size: .875rem; color: var(--muted); font-style: italic; }

/* --- Einsatz-Fahrzeuge-Grid -------------------- */
.einsatz-fahrzeuge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  padding: 1rem 0;
}

.efp-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.efp-card-header {
  background: var(--red);
  color: #fff;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.efp-fahrzeug-name {
  font-weight: 700;
  font-size: 1rem;
  flex: 1;
}

.efp-rows {
  padding: .5rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.efp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .3rem .25rem;
  border-bottom: 1px solid var(--border);
}

.efp-row:last-child { border-bottom: none; }
.efp-person { font-size: .9rem; }
