/* ==========================================================
   NPF Tracksurance — Admin Panel
   Dark theme matching the mobile app
   ========================================================== */

:root {
  --bg-dark: #060e17;
  --bg-card: #0b1a28;
  --bg-card-2: #102a3d;
  --bg-elev: #14304a;
  --border: #1f4060;
  --text: #e6f0fa;
  --text-dim: #8aa4bd;
  --teal-primary: #00d2ff;
  --teal-dim: #0095b8;
  --green: #2ecc71;
  --red: #ff4757;
  --orange: #ffa502;
  --yellow: #f1c40f;
  --blue: #3498db;
  --gray: #6c7a89;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--teal-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.admin-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
}

.brand {
  padding: 22px 20px;
  font-size: 18px;
  font-weight: 700;
  color: var(--teal-primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--text-dim);
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-item:hover {
  background: var(--bg-card-2);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--bg-card-2);
  color: var(--teal-primary);
  border-left-color: var(--teal-primary);
}
.nav-item i { width: 18px; text-align: center; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 10px;
}
.logout-btn {
  display: flex; align-items: center; gap: 8px;
  color: var(--red);
  font-size: 13px;
}

.main {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg-card);
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { font-size: 20px; font-weight: 600; }

.btn-link {
  color: var(--text-dim);
  font-size: 13px;
}
.btn-link:hover { color: var(--teal-primary); text-decoration: none; }

.content {
  padding: 24px;
  flex: 1;
}

/* ===== Cards & stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stat-label { color: var(--text-dim); font-size: 13px; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--teal-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.stat-icon.green { color: var(--green); }
.stat-icon.red { color: var(--red); }
.stat-icon.orange { color: var(--orange); }
.stat-icon.blue { color: var(--blue); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-header h2 { font-size: 16px; font-weight: 600; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--bg-card-2);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
tr:hover td { background: rgba(0, 210, 255, 0.04); }
td { color: var(--text); vertical-align: middle; }

.imei-cell { font-family: "Courier New", monospace; color: var(--teal-primary); }
.muted { color: var(--text-dim); font-size: 12px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.badge-green   { background: rgba(46, 204, 113, .15); color: var(--green); }
.badge-red     { background: rgba(255, 71, 87, .15); color: var(--red); }
.badge-orange  { background: rgba(255, 165, 2, .15); color: var(--orange); }
.badge-yellow  { background: rgba(241, 196, 15, .15); color: var(--yellow); }
.badge-blue    { background: rgba(52, 152, 219, .15); color: var(--blue); }
.badge-gray    { background: rgba(108, 122, 137, .15); color: var(--gray); }

/* ===== Toolbar / search ===== */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.search-box {
  flex: 1;
  min-width: 220px;
  position: relative;
}
.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}
.search-box input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}
.search-box input:focus {
  outline: none;
  border-color: var(--teal-primary);
}

.filter-select, .btn {
  padding: 9px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.filter-select:focus, .btn:focus { outline: none; border-color: var(--teal-primary); }

.btn-primary {
  background: var(--teal-primary);
  color: var(--bg-dark);
  border-color: var(--teal-primary);
  font-weight: 600;
}
.btn-primary:hover { background: var(--teal-dim); }

.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-card) 100%);
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.login-box .brand {
  border: none;
  justify-content: center;
  font-size: 22px;
  padding: 0 0 24px 0;
}
.login-box label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.login-box input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 16px;
}
.login-box input:focus {
  outline: none;
  border-color: var(--teal-primary);
}
.login-box .btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}
.login-error {
  background: rgba(255, 71, 87, .12);
  color: var(--red);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 71, 87, .3);
}
.login-hint {
  text-align: center;
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ===== Empty state ===== */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty i { font-size: 48px; margin-bottom: 14px; opacity: .4; }
.empty p { font-size: 14px; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 18px;
}
.pagination a, .pagination span {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 13px;
}
.pagination a:hover { background: var(--bg-card-2); text-decoration: none; }
.pagination .current {
  background: var(--teal-primary);
  color: var(--bg-dark);
  border-color: var(--teal-primary);
  font-weight: 600;
}
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 100; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block !important; }
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}
