/* Trafeek Dashboard — Dark Theme */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #22263a;
  --border: #2a2e3e;
  --text: #e1e4ed;
  --text-muted: #8b90a0;
  --accent: #4f8cff;
  --accent-dim: #2d5ab8;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header / Nav */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.dot { color: var(--accent); }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge.ok { background: #1a3a2a; color: var(--green); }
.badge.err { background: #3a1a1a; color: var(--red); }

nav { display: flex; gap: 4px; }

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: var(--surface-hover); color: var(--text); }
.nav-btn.active { background: var(--accent-dim); color: #fff; }

/* Main */
main { max-width: 1280px; margin: 0 auto; padding: 20px; }

.tab { display: none; }
.tab.active { display: block; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar h2 { font-size: 18px; font-weight: 600; margin-right: auto; }
.filter-inline { display: flex; gap: 8px; align-items: center; }

/* Buttons */
.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-dim); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-outline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #dc2626; }

/* Inputs */
.input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius);
  outline: none;
  transition: border 0.15s;
}
.input:focus { border-color: var(--accent); }
.input-sm { max-width: 150px; }

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

/* Stats row */
.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-width: 140px;
  flex: 1;
}
.stat-card .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat-card .value.green { color: var(--green); }
.stat-card .value.yellow { color: var(--yellow); }
.stat-card .value.red { color: var(--red); }

/* Tables */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover { background: var(--surface-hover); }

.plate-tag {
  display: inline-block;
  background: #1a2a4f;
  color: var(--accent);
  font-weight: 600;
  font-family: 'Courier New', monospace;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
.plate-tag:hover { background: var(--accent-dim); color: #fff; }

.plate-tag.watchlist {
  background: #4f1a1a;
  color: var(--red);
  border: 1px solid var(--red);
}

.thumb {
  width: 60px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s;
}
.thumb:hover { transform: scale(1.5); z-index: 10; position: relative; }

.text-muted { color: var(--text-muted); font-size: 12px; }

/* Pagination */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.page-btn {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.page-btn:hover, .page-btn.active { background: var(--accent-dim); color: #fff; border-color: var(--accent-dim); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* Cards / Grid */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 { font-size: 14px; margin-bottom: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  justify-content: center;
  align-items: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 640px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 13px; }
.detail-grid dt { color: var(--text-muted); }
.detail-grid dd { font-weight: 500; }
.detail-img { width: 100%; border-radius: var(--radius); margin: 12px 0; }

/* Footer */
footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 11px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* Speed indicators */
.speed-ok { color: var(--green); }
.speed-warn { color: var(--yellow); }
.speed-over { color: var(--red); font-weight: 600; }

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  header { flex-direction: column; gap: 8px; }
  nav { overflow-x: auto; width: 100%; }
  .grid-2 { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .input-sm { max-width: none; }
  main { padding: 12px; }
}
