/* FaceInsight PWA — dark mobile-first theme */

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

:root {
  --bg:        #1a1a1e;
  --bg2:       #26262c;
  --bg3:       #32323a;
  --border:    #3a3a44;
  --text:      #dde;
  --muted:     #888;
  --accent:    #44aaff;
  --green:     #2aaa66;
  --red:       #ee4444;
  --orange:    #cc8800;
  --safe-top:  env(safe-area-inset-top, 0px);
  --safe-bot:  env(safe-area-inset-bottom, 0px);
  --nav-h:     64px;
  --header-h:  52px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  overflow: hidden;
}

/* ── Screens ─────────────────────────────────────────────────────────────── */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ── Login ───────────────────────────────────────────────────────────────── */
#login-screen {
  align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-box {
  width: 100%; max-width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
}
.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.logo-icon { font-size: 32px; color: var(--accent); }
.logo-text  { font-size: 26px; font-weight: 700; color: var(--text); }
.login-sub  { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  padding: 0 16px;
  padding-top: var(--safe-top);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.header-title { font-weight: 700; font-size: 17px; color: var(--accent); }
.header-right { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }

.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-online  { background: var(--green); }
.dot-offline { background: var(--red); }

/* ── Bottom nav ──────────────────────────────────────────────────────────── */
.bottom-nav {
  height: calc(var(--nav-h) + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; padding: 8px 0;
  transition: color 0.15s;
}
.nav-btn.active { color: var(--accent); }
.nav-icon  { font-size: 20px; }
.nav-label { font-size: 11px; font-weight: 500; }

/* ── Tab content ─────────────────────────────────────────────────────────── */
.tab-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.tab-panel { padding: 12px; min-height: 100%; }
.tab-panel.active { display: block; }

/* ── Forms / fields ──────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  padding: 10px 12px; font-size: 15px; width: 100%;
  -webkit-appearance: none;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--accent);
}
.field-row { display: flex; gap: 10px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  padding: 11px 20px; border-radius: 9px; border: none;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { opacity: 0.8; transform: scale(0.98); }
.btn:disabled { opacity: 0.35; pointer-events: none; }
.btn-primary  { background: var(--accent); color: #000; }
.btn-secondary{ background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-save     { background: var(--green); color: #fff; }
.btn-danger   { background: var(--red); color: #fff; }
.btn-ghost    { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-full     { width: 100%; }
.btn-sm       { padding: 7px 14px; font-size: 13px; }

/* ── Camera views ────────────────────────────────────────────────────────── */
.camera-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
}
.camera-wrap video {
  width: 100%; height: 100%; object-fit: contain;
}
.camera-wrap canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* ── Inline camera picker ────────────────────────────────────────────────── */
.cam-picker-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px;
}
.cam-picker-label { font-size: 16px; flex-shrink: 0; }
.cam-picker-select {
  flex: 1; padding: 7px 10px; font-size: 13px;
  background: var(--bg2); color: var(--fg);
  border: 1px solid var(--bg3); border-radius: 8px;
}

/* ── Scan ────────────────────────────────────────────────────────────────── */
.scan-controls {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; margin-bottom: 12px;
}
.toggle-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.result-banner {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 14px 16px; font-size: 17px; font-weight: 700;
  text-align: center; z-index: 10;
}
.result-banner.alert   { background: rgba(238,68,68,0.92); color: #fff; }
.result-banner.match   { background: rgba(42,170,102,0.92); color: #fff; }
.result-banner.unknown { background: rgba(30,30,40,0.85);  color: var(--muted); }
.scan-log {
  font-size: 13px; color: var(--muted);
  max-height: 200px; overflow-y: auto;
  background: var(--bg2); border-radius: 8px; padding: 10px;
}
.scan-log-entry { padding: 3px 0; border-bottom: 1px solid var(--border); }
.scan-log-entry:last-child { border: none; }
.scan-log-entry.alert   { color: var(--red); }
.scan-log-entry.match   { color: var(--green); }

/* ── Enroll ──────────────────────────────────────────────────────────────── */
.enroll-form { margin-bottom: 10px; }
.pose-label {
  position: absolute; top: 10px; left: 0; right: 0;
  text-align: center; font-size: 16px; font-weight: 700;
  color: var(--accent); text-shadow: 0 1px 4px #000;
  z-index: 5;
}
.align-bar-wrap {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); margin-bottom: 10px;
}
.align-bar-outer {
  flex: 1; height: 8px; background: var(--bg3);
  border-radius: 4px; overflow: hidden;
}
.align-bar-inner { height: 100%; background: var(--red); border-radius: 4px; transition: width 0.2s, background 0.3s; }
.enroll-controls { display: flex; gap: 10px; margin-bottom: 12px; }

.pose-checklist {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 14px;
}
.pose-item {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 10px;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; transition: border-color 0.15s;
  font-size: 13px;
}
.pose-item.active    { border-color: var(--accent); background: #1a2a3a; }
.pose-item.captured  { border-color: var(--green);  background: #0a1e14; }
.pose-item.required::after { content: '*'; color: var(--red); margin-left: 2px; }
.pose-item .pose-status { margin-left: auto; font-size: 16px; }

.enroll-actions { display: flex; gap: 10px; margin-bottom: 10px; }
.status-msg { font-size: 13px; color: var(--muted); min-height: 18px; }

/* ── Wanted list ─────────────────────────────────────────────────────────── */
.wanted-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.wanted-header h2 { font-size: 17px; }
.wanted-list { display: flex; flex-direction: column; gap: 8px; }
.wanted-photo {
  width: 48px; height: 48px; object-fit: cover;
  border-radius: 8px;
}
.wanted-photo-placeholder {
  width: 48px; height: 48px; background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 24px; color: var(--muted);
}
.wanted-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.wanted-card.watchlist { border-left: 3px solid var(--red); }
.wanted-card.known     { border-left: 3px solid var(--green); }
.wanted-name   { font-weight: 600; font-size: 15px; }
.wanted-meta   { font-size: 12px; color: var(--muted); }
.wanted-badge  {
  font-size: 11px; font-weight: 700; padding: 3px 7px;
  border-radius: 5px; text-transform: uppercase;
}
.badge-watchlist { background: rgba(238,68,68,0.2); color: var(--red); }
.badge-known     { background: rgba(42,170,102,0.2); color: var(--green); }

/* ── Settings ────────────────────────────────────────────────────────────── */
.settings-section {
  background: var(--bg2); border-radius: 12px;
  padding: 16px; margin-bottom: 14px;
}
.settings-section h3 { font-size: 14px; color: var(--muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.admin-section {
  border: 1px solid var(--accent);
  background: rgba(68,170,255,0.06);
}
.admin-section h3 { color: var(--accent); }

/* ── Sync banner ─────────────────────────────────────────────────────────── */
.sync-banner {
  background: var(--bg2); border-bottom: 1px solid var(--accent);
  padding: 8px 14px; display: flex; align-items: center; gap: 10px;
  flex-shrink: 0; font-size: 13px; color: var(--accent);
}
.sync-banner span { flex: 1; }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.error-msg  { color: var(--red); font-size: 13px; margin-top: 8px; }
.muted-text { color: var(--muted); font-size: 13px; }

/* ── Alert bell button ───────────────────────────────────────────────────── */
.alert-bell {
  position: fixed; top: 52px; right: 12px; z-index: 900;
  background: var(--bg2); border: 1px solid var(--red);
  border-radius: 50%; width: 42px; height: 42px;
  font-size: 18px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.alert-bell-count {
  position: absolute; top: -4px; right: -4px;
  background: var(--red); color: white;
  border-radius: 50%; width: 18px; height: 18px;
  font-size: 10px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
}

/* ── Alert overlay panel ─────────────────────────────────────────────────── */
.alert-overlay {
  position: fixed; inset: 0; z-index: 950;
  background: var(--bg); display: flex; flex-direction: column;
}
.alert-overlay-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--bg2);
  border-bottom: 1px solid var(--red); font-weight: bold; color: var(--red);
  flex-shrink: 0;
}
.alert-overlay-header span:first-child { flex: 1; font-size: 15px; }
.alert-badge {
  background: var(--red); color: white; border-radius: 50%;
  width: 22px; height: 22px; font-size: 11px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
}
.alert-feed {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 12px;
}

/* ── Alert card ──────────────────────────────────────────────────────────── */
.alert-card {
  background: var(--bg2); border-radius: 12px;
  border-left: 4px solid var(--red); overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  animation: alertSlideIn 0.3s ease-out;
}
.alert-card.acked { opacity: 0.5; border-left-color: var(--muted); }
@keyframes alertSlideIn {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
.alert-card-banner {
  padding: 8px 14px; font-size: 13px; font-weight: bold;
  display: flex; align-items: center; gap: 8px; color: white;
}
.alert-card-banner.face  { background: rgba(200,50,50,0.85); }
.alert-card-banner.plate { background: rgba(200,100,20,0.85); }
.alert-card-photo {
  width: 100%; max-height: 200px; object-fit: cover; display: block;
}
.alert-card-body {
  padding: 12px 14px; display: flex; flex-direction: column; gap: 5px;
}
.alert-subject  { font-size: 18px; font-weight: bold; color: var(--text); }
.alert-conf     { font-size: 13px; color: var(--muted); }
.alert-reason   { font-size: 13px; color: var(--accent); }
.alert-time     { font-size: 12px; color: var(--muted); }
.alert-location {
  font-size: 13px; color: var(--green); text-decoration: none;
  display: flex; align-items: center; gap: 4px;
}
.alert-officer  { font-size: 12px; color: var(--muted); margin-top: 4px; }
.alert-ack-btn  {
  margin: 0 14px 14px; padding: 10px;
  background: var(--accent); color: white;
  border: none; border-radius: 8px; font-weight: bold;
  font-size: 14px; cursor: pointer; width: calc(100% - 28px);
}
.error-msg.hidden, .muted-text.hidden { display: none; }
