/* ================================================================
   BASE.CSS — Parking System Design System
   Global tokens, reset, typography, utilities, shared components
   ================================================================ */

/* ── Google Fonts ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
  /* Core Palette — 60/30/10 */
  --bg:           #F8FAFC;   /* 60% — Light slate background (Safe & Calm) */
  --bg-2:         #F1F5F9;   /* background variant */
  --surface:      #FFFFFF;   /* 30% — White surfaces & panels */
  --surface-2:    #EEF2FF;   /* surface tint */
  --accent:       #2563EB;   /* 10% — Royal blue accent (Professional) */
  --accent-hover: #1D4ED8;
  --accent-light: #EFF6FF;
  --accent-pale:  #DBEAFE;

  /* Text */
  --text:         #0F172A;   /* Deep slate for better readability */
  --text-2:       #334155;
  --text-muted:   #64748B;
  --text-on-accent: #FFFFFF;

  /* Semantic Colors */
  --success:      #10B981;
  --success-bg:   #ECFDF5;
  --warning:      #F59E0B;
  --warning-bg:   #FFFBEB;
  --danger:       #EF4444;
  --danger-bg:    #FEF2F2;
  --info:         #0EA5E9;
  --info-bg:      #F0F9FF;

  /* Border */
  --border:       #E2E8F0;
  --border-light: #F1F5F9;

  /* Shadows */
  --shadow-xs:    0 1px 2px rgba(15,23,42,0.06);
  --shadow-sm:    0 2px 8px rgba(15,23,42,0.08);
  --shadow-md:    0 4px 16px rgba(37,99,235,0.10);
  --shadow-lg:    0 8px 32px rgba(37,99,235,0.12);
  --shadow-xl:    0 16px 48px rgba(37,99,235,0.16);

  /* Radius */
  --r-sm:   6px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-full: 999px;

  /* Spacing scale (base 4px) */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Typography */
  --font:      'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-size-xs:   11px;
  --font-size-sm:   13px;
  --font-size-base: 15px;
  --font-size-lg:   17px;
  --font-size-xl:   20px;
  --font-size-2xl:  24px;
  --font-size-3xl:  30px;
  --font-size-4xl:  36px;
  --line-height:    1.6;

  /* Transitions */
  --ease:      cubic-bezier(0.4, 0, 0.2, 1);
  --duration:  180ms;

  /* Bottom Nav Height (mobile) */
  --bottom-nav-h: 68px;
  --header-h:     60px;
}

/* ── CSS Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Typography Utilities ─────────────────────────────────────── */
.text-xs     { font-size: var(--font-size-xs); }
.text-sm     { font-size: var(--font-size-sm); }
.text-base   { font-size: var(--font-size-base); }
.text-lg     { font-size: var(--font-size-lg); }
.text-xl     { font-size: var(--font-size-xl); }
.text-2xl    { font-size: var(--font-size-2xl); }
.text-3xl    { font-size: var(--font-size-3xl); }

.font-light  { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semi   { font-weight: 600; }
.font-bold   { font-weight: 700; }
.font-black  { font-weight: 800; }

.text-center { text-align: center; }
.text-right  { text-align: right; }

.text-primary { color: var(--text); }
.text-2       { color: var(--text-2); }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }

/* ── Shared Card Component ────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-body { padding: var(--sp-5); }
.card-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.card-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-5);
  border-radius: var(--r-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  border: none;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--duration) var(--ease);
}

.btn:hover::after { background: rgba(255,255,255,0.12); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(37,99,235,0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}
.btn-success:hover { background: #059669; transform: translateY(-1px); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}
.btn-danger:hover { background: #DC2626; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--bg); border-color: var(--border); }

.btn-warning {
  background: var(--warning);
  color: #fff;
  box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}
.btn-warning:hover { background: #D97706; transform: translateY(-1px); }

.btn-xs { padding: 5px 10px; font-size: var(--font-size-xs); border-radius: var(--r-sm); }
.btn-sm { padding: 7px 14px; font-size: var(--font-size-xs); border-radius: var(--r-sm); }
.btn-lg { padding: 14px var(--sp-8); font-size: var(--font-size-base); }
.btn-full { width: 100%; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.btn-icon {
  width: 40px; height: 40px;
  padding: 0;
  border-radius: var(--r-md);
}

/* ── Form Elements ────────────────────────────────────────────── */
.form-group { margin-bottom: var(--sp-4); }

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: var(--sp-2);
}

.form-input {
  width: 100%;
  padding: 11px var(--sp-4);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--font-size-base);
  color: var(--text);
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-input::placeholder { color: var(--text-muted); }
.form-input:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }

.form-select {
  width: 100%;
  padding: 11px var(--sp-4);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--font-size-base);
  color: var(--text);
  appearance: none;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease);
}
.form-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }

.input-group { position: relative; }
.input-group .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}
.input-group .form-input { padding-left: 42px; }

/* ── Badge ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-blue    { background: var(--accent-pale); color: var(--accent); }
.badge-green   { background: var(--success-bg);  color: var(--success); }
.badge-yellow  { background: var(--warning-bg);  color: #92400E; }
.badge-red     { background: var(--danger-bg);   color: var(--danger); }
.badge-gray    { background: var(--border-light); color: var(--text-muted); }

/* Badge dot */
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ── Status Indicators ────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.active   { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,0.2); animation: pulse-dot 2s ease infinite; }
.status-dot.inactive { background: var(--text-muted); }
.status-dot.warning  { background: var(--warning); }
.status-dot.error    { background: var(--danger); }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
  50%       { box-shadow: 0 0 0 6px rgba(16,185,129,0.08); }
}

/* ── Stat Card ────────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  transition: all var(--duration) var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-icon-wrap.blue   { background: var(--accent-pale); }
.stat-icon-wrap.green  { background: var(--success-bg); }
.stat-icon-wrap.yellow { background: var(--warning-bg); }
.stat-icon-wrap.red    { background: var(--danger-bg); }

.stat-label { font-size: var(--font-size-xs); color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: var(--font-size-2xl); font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub   { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 4px; }

/* ── Table ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}
.table th {
  text-align: left;
  padding: 10px var(--sp-4);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 13px var(--sp-4);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-2);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg); }
.table .plate {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
}

/* ── Toast Notification ───────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 14px var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text);
  min-width: 260px;
  max-width: 360px;
  pointer-events: all;
  animation: toastIn 0.3s var(--ease) forwards;
}

.toast.leaving { animation: toastOut 0.25s var(--ease) forwards; }

.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-success { border-left: 3px solid var(--success); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--accent); }

@keyframes toastIn  { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); } to { opacity:0; transform:translateX(20px); } }

/* ── Modal Backdrop ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: backdropIn 0.2s var(--ease);
}

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: var(--sp-4); }
  .modal-sheet    { border-radius: var(--r-xl) !important; max-width: 480px; }
}

@keyframes backdropIn { from { opacity:0; } to { opacity:1; } }

.modal-sheet {
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: sheetUp 0.3s var(--ease);
  box-shadow: var(--shadow-xl);
}

@keyframes sheetUp { from { transform:translateY(40px); opacity:0; } to { transform:translateY(0); opacity:1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-light);
}
.modal-title { font-size: var(--font-size-lg); font-weight: 700; color: var(--text); }
.modal-body  { padding: var(--sp-5) var(--sp-6); }
.modal-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: var(--sp-3);
  justify-content: flex-end;
}

.btn-close {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-muted);
  transition: all var(--duration) var(--ease);
}
.btn-close:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

/* ── Loader / Spinner ─────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  border-radius: inherit;
  z-index: 10;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* ── Camera Preview ───────────────────────────────────────────── */
.camera-wrap {
  position: relative;
  background: #0f172a;
  border-radius: var(--r-lg);
  overflow: hidden;
  aspect-ratio: 4/3;
}

.camera-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-frame {
  width: 75%;
  aspect-ratio: 3/1;
  border: 2.5px solid var(--accent);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
  position: relative;
}

.scan-line {
  position: absolute;
  left: 8px; right: 8px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scanLine 2s ease-in-out infinite;
  border-radius: 1px;
}

@keyframes scanLine {
  0%   { top: 8px; opacity: 1; }
  100% { top: calc(100% - 10px); opacity: 0.4; }
}

/* scan corners */
.scan-frame::before,
.scan-frame::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--accent);
  border-style: solid;
  border-width: 0;
}
.scan-frame::before {
  top: -2px; left: -2px;
  border-top-width: 3px;
  border-left-width: 3px;
  border-radius: var(--r-sm) 0 0 0;
}
.scan-frame::after {
  bottom: -2px; right: -2px;
  border-bottom-width: 3px;
  border-right-width: 3px;
  border-radius: 0 0 var(--r-sm) 0;
}

/* ── Plate Display ────────────────────────────────────────────── */
.plate-display {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  background: var(--accent-pale);
  color: var(--accent);
  border: 2px dashed var(--accent);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-6);
  text-align: center;
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* ── Receipt Preview ──────────────────────────────────────────── */
.receipt-preview {
  font-family: var(--font-mono);
  font-size: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 16px;
  max-width: 300px;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
  line-height: 1.7;
}
.receipt-preview .r-center { text-align: center; }
.receipt-preview .r-bold   { font-weight: 700; }
.receipt-preview .r-div    { border-top: 1px dashed #ccc; margin: 8px 0; }
.receipt-preview .r-row    { display: flex; justify-content: space-between; }

/* ── Scan Result ──────────────────────────────────────────────── */
.scan-result-card {
  background: var(--success-bg);
  border: 1.5px solid var(--success);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  animation: resultIn 0.3s var(--ease);
}
@keyframes resultIn { from { opacity:0; transform:scale(0.96); } to { opacity:1; transform:scale(1); } }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: var(--sp-4); opacity: 0.6; }
.empty-state h3 { font-size: var(--font-size-lg); font-weight: 600; color: var(--text-2); margin-bottom: var(--sp-2); }
.empty-state p  { font-size: var(--font-size-sm); }

/* ── Section Header ───────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.section-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text);
}
.section-sub {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Layout Utilities ─────────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }

.p-4 { padding: var(--sp-4); }
.p-5 { padding: var(--sp-5); }
.p-6 { padding: var(--sp-6); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }

.w-full  { width: 100%; }
.hidden  { display: none !important; }
.visible { display: block !important; }

.app-section:not(.hidden) {
  animation: sectionFadeIn 0.25s var(--ease) forwards;
}

@keyframes sectionFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 5px; height: 5px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Divider ──────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-4) 0;
}
