/* TruckSOS Admin — mobile-first, Design-Anlehnung an „The Kinetic Guardian":
   Inter, keine 1px-Solid-Borders (Flächenabstufungen statt Linien), Buttons
   min. 56px, Schatten blau getönt bei 4–6 %. Farb-Tokens spiegeln
   trucksos/lib/shared/ui/theme/app_colors.dart. */

:root {
  --brand-deep: #06619c;
  --brand-accent: #fdc003;
  --brand-tertiary: #1d4e89;
  --accent-ok: #2f9e6b;
  --accent-warn: #e8a33d;
  --accent-danger: #d64545;
  --surface-0: #ffffff;
  --surface-1: #f4f6f8;
  --surface-2: #e7ecf0;
  --baby-blue: #eef4fb;
  --text-strong: #0d1b2a;
  --text-muted: #75777c;
  --shadow: 0 4px 16px rgba(6, 97, 156, 0.06);
  --radius: 16px;
  --radius-small: 12px;
}

* { box-sizing: border-box; }

/* Das eingebaute [hidden]{display:none} des Browsers hat dieselbe Spezifität
   wie jede Klasse, die display setzt (.btn, .loading, .bulkbar …) — und
   Autoren-Regeln stechen die des Browsers. Ohne dieses !important blieben per
   hidden-Attribut versteckte Elemente (Spinner, „Mehr laden") sichtbar. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-1);
  color: var(--text-strong);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ── Kopfzeile ─────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--brand-deep);
  color: #fff;
  box-shadow: 0 2px 12px rgba(6, 97, 156, 0.25);
}
.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  letter-spacing: 0.2px;
}
.brand img { width: 34px; height: 34px; display: block; }
.brand b { color: var(--brand-accent); font-weight: 700; }
.topnav { display: flex; gap: 6px; }
.navbtn {
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
}
.navbtn.active { background: var(--brand-accent); color: var(--text-strong); font-weight: 600; }
.navbtn.muted { background: transparent; color: rgba(255, 255, 255, 0.7); }

/* ── Seitenraster ──────────────────────────────────────────────────────── */

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}
.page-title { font-size: 20px; margin: 4px 0 12px; }
.view[hidden] { display: none; }

.card {
  background: var(--surface-0);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { font-size: 16px; margin: 0 0 12px; }

.hint { color: var(--text-muted); font-size: 14px; margin: 6px 0; }
.hint.center { text-align: center; }
.error {
  color: var(--accent-danger);
  background: rgba(214, 69, 69, 0.08);
  border-radius: var(--radius-small);
  padding: 10px 12px;
  font-size: 14px;
  margin: 8px 0;
}
.error.banner { margin: 0 0 12px; }

/* ── Login ─────────────────────────────────────────────────────────────── */

.login-card { max-width: 420px; margin: 10vh auto 0; }
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 24px;
  margin: 8px 0 8px;
}
.login-logo img { width: 64px; height: 64px; display: block; }
.login-logo b { color: var(--brand-accent); font-weight: 700; }
.login-card .hint { text-align: center; margin-bottom: 16px; }

.field { display: block; margin-bottom: 12px; }
.field span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input, .search, select {
  width: 100%;
  border: 0;
  background: var(--surface-1);
  border-radius: var(--radius-small);
  padding: 0 14px;
  min-height: 52px;
  font: inherit;
  color: var(--text-strong);
  outline: 2px solid transparent;
}
.field input:focus, .search:focus, select:focus {
  outline-color: var(--brand-deep);
  background: var(--surface-0);
}

/* Passwortfeld mit Auge zum Ein-/Ausblenden. Der Knopf liegt IM Feld; das
   Eingabefeld bekommt rechts Platz, damit Text und Auge sich nicht kreuzen. */
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 56px; }
.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-small);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.pw-toggle:hover { color: var(--brand-deep); }

/* ── Buttons: min. 56px für Handschuh-Hände ────────────────────────────── */

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: var(--radius-small);
  min-height: 56px;
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text-strong);
}
.btn.primary { background: var(--brand-deep); color: #fff; }
.btn.danger { background: var(--accent-danger); color: #fff; }
.btn.warn { background: var(--accent-warn); color: var(--text-strong); }
.btn.ghost { background: transparent; color: var(--brand-deep); box-shadow: inset 0 0 0 2px var(--surface-2); }
.btn.small { min-height: 44px; width: auto; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: default; }

.backlink {
  border: 0;
  background: none;
  color: var(--brand-deep);
  font: inherit;
  font-weight: 600;
  padding: 8px 0;
  margin-bottom: 6px;
  cursor: pointer;
}

/* ── Filter + Liste ────────────────────────────────────────────────────── */

.filters { display: grid; gap: 10px; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.list { display: grid; gap: 10px; }

.user-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--surface-0);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  cursor: pointer;
}
.user-row.selected { background: var(--baby-blue); }
.user-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--brand-deep);
}
.user-main { min-width: 0; }
.user-email {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-sub {
  color: var(--text-muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-side { text-align: right; }

.chip {
  display: inline-block;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--surface-2);
  color: var(--text-strong);
  white-space: nowrap;
}
.chip.role { background: var(--baby-blue); color: var(--brand-tertiary); }
.chip.ok { background: rgba(47, 158, 107, 0.14); color: var(--accent-ok); }
.chip.warn { background: rgba(232, 163, 61, 0.16); color: #9a6a1e; }
.chip.danger { background: rgba(214, 69, 69, 0.12); color: var(--accent-danger); }
.chip.premium { background: rgba(253, 192, 3, 0.22); color: #8a6a00; }
.user-until { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Sammel-Aktionsleiste ──────────────────────────────────────────────── */

.bulkbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: var(--surface-0);
  box-shadow: 0 -4px 20px rgba(6, 97, 156, 0.14);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.bulkbar[hidden] { display: none; }
.bulk-count { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Detail ────────────────────────────────────────────────────────────── */

.detail-head { margin-bottom: 10px; }
.detail-email { font-size: 18px; font-weight: 700; word-break: break-all; }
.detail-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.kv > div {
  display: contents;
  font-size: 14px;
}
.kv dt { color: var(--text-muted); margin: 0; padding: 6px 0; }
.kv dd { margin: 0; padding: 6px 0; text-align: right; font-weight: 500; }

.action-grid { display: grid; gap: 8px; }
@media (min-width: 560px) {
  .action-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Protokoll ─────────────────────────────────────────────────────────── */

.log-list { display: grid; gap: 4px; }
.log-entry { padding: 10px 0; }
.log-entry + .log-entry { box-shadow: inset 0 2px 0 var(--surface-1); }
.log-line { font-size: 14px; }
.log-line b { font-weight: 600; }
.log-meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.log-diff { font-size: 12px; color: var(--brand-tertiary); margin-top: 4px; }

/* ── Dialog, Toast, Spinner ────────────────────────────────────────────── */

dialog {
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(6, 97, 156, 0.25);
  padding: 0;
  width: min(92vw, 440px);
}
dialog::backdrop { background: rgba(13, 27, 42, 0.45); }
.dialog-body { padding: 20px; }
.dialog-body h2 { margin: 0 0 8px; font-size: 17px; }
.dialog-body p { margin: 0 0 12px; font-size: 14px; color: var(--text-muted); }
.dialog-buttons { display: grid; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--text-strong);
  color: #fff;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px;
  box-shadow: var(--shadow);
  max-width: 92vw;
}
.toast[hidden] { display: none; }

.loading { display: flex; justify-content: center; padding: 24px; }
.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 4px solid var(--surface-2);
  border-top-color: var(--brand-accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
