/* ============================================================
   VeloTrack GPS – assets/css/style.css
   ============================================================ */

:root {
  --sidebar-w: 230px;
  --topbar-h: 56px;
  --color-primary: #1a56db;
  --color-primary-dark: #1042b5;
  --color-success: #0e7a45;
  --color-danger: #c81e1e;
  --color-warn: #92400e;
  --color-info: #1a56db;
  --color-muted: #4b5563;
  --color-bg: #f3f4f6;
  --color-white: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-sidebar-bg: #0f172a;
  --color-sidebar-text: #cbd5e1;
  --color-sidebar-active: #1a56db;
  --color-sidebar-hover: #1e293b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,.12);
}

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

html { height: 100%; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  width: 100%;
}

/* Dashboard/admin layout uses flex */
body.app-body {
  display: flex;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform .25s;
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar-brand {
  padding: 18px 16px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand i { color: var(--color-primary); font-size: 20px; }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-group-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--color-sidebar-text);
  text-decoration: none;
  border-radius: 6px;
  margin: 1px 8px;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-link i { width: 18px; text-align: center; font-size: 14px; }
.nav-link:hover { background: var(--color-sidebar-hover); color: #fff; }
.nav-link.active { background: var(--color-primary); color: #fff; font-weight: 500; }

.sidebar-footer {
  border-top: 1px solid #1e293b;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-user { flex: 1; display: flex; align-items: center; gap: 8px; }
.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar-user-name { font-size: 12.5px; font-weight: 500; color: #e2e8f0; line-height: 1.3; }
.sidebar-user-role { font-size: 11px; color: #64748b; }
.sidebar-user-info { overflow: hidden; }

.btn-logout {
  color: #64748b;
  font-size: 16px;
  text-decoration: none;
  padding: 4px;
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--color-danger); }

/* ── Main wrapper ─────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-w));
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow);
}
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); font-size: 18px;
  padding: 4px 8px; border-radius: 4px;
}
.sidebar-toggle:hover { background: var(--color-bg); }
.topbar-title { font-size: 17px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-badge { position: relative; color: var(--color-text-muted); font-size: 18px; text-decoration: none; }
.badge-count {
  position: absolute; top: -5px; right: -7px;
  background: var(--color-danger); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 10px; min-width: 17px; height: 17px;
  display: flex; align-items: center; justify-content: center;
}
.topbar-user { font-size: 13px; color: var(--color-text-muted); }

/* ── Page content ─────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--color-border); }

/* ── Stat cards ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.blue    { background: #eff6ff; color: #1a56db; }
.stat-icon.green   { background: #f0fdf4; color: #0e7a45; }
.stat-icon.red     { background: #fef2f2; color: #c81e1e; }
.stat-icon.orange  { background: #fff7ed; color: #b45309; }
.stat-icon.purple  { background: #f5f3ff; color: #7c3aed; }
.stat-label { font-size: 12px; color: var(--color-text-muted); margin-bottom: 2px; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1; }
.stat-sub { font-size: 11px; color: var(--color-text-muted); margin-top: 3px; }

/* ── Table ───────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
table.vtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.vtable th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
table.vtable td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
table.vtable tr:hover td { background: #f8fafc; }
table.vtable tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
}
.badge-success  { background: #dcfce7; color: #166534; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-warn     { background: #fef3c7; color: #92400e; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-muted    { background: #f1f5f9; color: #475569; }
.badge-expired  { background: #fee2e2; color: #991b1b; }
.badge-purple   { background: #ede9fe; color: #5b21b6; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-success   { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover { background: #15803d; }
.btn-danger    { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-outline   { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-outline:hover { background: var(--color-bg); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; }
.btn-icon { padding: 6px 8px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 13px; font-weight: 500;
  margin-bottom: 5px; color: var(--color-text);
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13.5px;
  background: #fff;
  color: var(--color-text);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
.form-control.is-invalid { border-color: var(--color-danger); }
.form-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 16px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-section-title {
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px; margin: 20px 0 14px;
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13.5px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.filter-bar .form-control { max-width: 220px; }
.filter-bar select.form-control { max-width: 160px; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.pagination a {
  padding: 6px 12px; border-radius: 5px;
  border: 1px solid var(--color-border);
  color: var(--color-text); text-decoration: none; font-size: 13px;
}
.pagination a:hover { background: var(--color-bg); }
.pagination a.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ── Tabs ────────────────────────────────────────────────── */
.tab-bar { display: flex; border-bottom: 1px solid var(--color-border); margin-bottom: 20px; gap: 4px; }
.tab-btn {
  padding: 10px 18px; border: none; background: none;
  cursor: pointer; font-size: 13.5px; color: var(--color-text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 500; }

/* ── LOGIN PAGE ──────────────────────────────────────────── */
body.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: linear-gradient(135deg, #0f172a 0%, #1a2744 100%);
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo i { font-size: 36px; color: var(--color-primary); }
.login-logo h2 { font-size: 22px; font-weight: 700; margin-top: 8px; }
.login-logo p { color: var(--color-text-muted); font-size: 13px; }

/* ── Expiry progress bar ─────────────────────────────────── */
.expiry-bar { display: flex; align-items: center; gap: 8px; }
.expiry-bar-track {
  flex: 1; height: 6px; background: #e5e7eb;
  border-radius: 3px; overflow: hidden; min-width: 60px;
}
.expiry-bar-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.fill-green  { background: #16a34a; }
.fill-amber  { background: #d97706; }
.fill-red    { background: #dc2626; }
.expiry-days { font-size: 11.5px; font-weight: 500; white-space: nowrap; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.modal {
  background: #fff; border-radius: 10px;
  width: 100%; max-width: 580px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--color-text-muted); }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--color-border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Section header ─────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.section-header h2 { font-size: 18px; font-weight: 700; }

/* ── Online dot ──────────────────────────────────────────── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot-online  { background: #16a34a; }
.dot-offline { background: #9ca3af; }
.dot-unknown { background: #d97706; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .form-row-2 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}
