/* ============================================================
   FleetOS — Premium Dark UI Stylesheet
   Font: Syne (display) + DM Mono (data)
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --bg:          #0f0f12;
  --surface:     #1a1a21;
  --surface2:    #22222c;
  --surface3:    #2a2a36;
  --border:      #2e2e3e;
  --border2:     #3a3a4e;

  --blue:        #3b8bff;
  --blue-dim:    #1a3a6e;
  --blue-glow:   rgba(59,139,255,0.18);
  --green:       #22c98e;
  --green-dim:   #0d3d29;
  --amber:       #f5a623;
  --amber-dim:   #3d2a08;
  --red:         #ff4d6a;
  --red-dim:     #3d0d18;
  --purple:      #9b72ff;

  --text:        #e8e8f0;
  --text-muted:  #7a7a96;
  --text-dim:    #50505e;

  --font-display: 'Syne', sans-serif;
  --font-mono:    'DM Mono', monospace;

  --radius:      10px;
  --radius-lg:   16px;
  --sidebar-w:   240px;
  --topbar-h:    62px;
  --shadow:      0 4px 24px rgba(0,0,0,0.45);
  --shadow-lg:   0 8px 48px rgba(0,0,0,0.6);
  --transition:  0.2s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: #6ba8ff; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: var(--font-display); }

/* ── App Shell ────────────────────────────────────────────── */
#app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 38px; height: 38px;
  background: var(--blue-dim);
  border: 1px solid var(--blue);
  border-radius: 9px;
  display: grid; place-items: center;
  color: var(--blue);
  font-size: 16px;
}
.brand-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}
.brand-name em { color: var(--blue); font-style: normal; }

.nav-links {
  list-style: none;
  padding: 18px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-links li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}
.nav-links li a i { width: 18px; text-align: center; font-size: 15px; }
.nav-links li a:hover {
  background: var(--surface2);
  color: var(--text);
}
.nav-links li.active a {
  background: var(--blue-glow);
  color: var(--blue);
  border: 1px solid rgba(59,139,255,0.25);
}
.nav-links li.active a i { color: var(--blue); }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}
.logout-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}
.logout-btn:hover { background: var(--red-dim); color: var(--red); }

/* ── Main Content ─────────────────────────────────────────── */
#main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ───────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky; top: 0;
  z-index: 50;
}
#sidebar-toggle {
  display: none;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 18px;
  padding: 6px;
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted);
  font-family: var(--font-mono);
}
.topbar-user i { color: var(--blue); font-size: 20px; }

/* ── Page Body ────────────────────────────────────────────── */
#page-body {
  padding: 28px;
  flex: 1;
}

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border2); }
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
}
.stat-card.blue::before  { background: var(--blue); }
.stat-card.green::before { background: var(--green); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.red::before   { background: var(--red); }
.stat-card.purple::before { background: var(--purple); }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 17px;
}
.blue .stat-icon  { background: var(--blue-dim);  color: var(--blue); }
.green .stat-icon { background: var(--green-dim); color: var(--green); }
.amber .stat-icon { background: var(--amber-dim); color: var(--amber); }
.red .stat-icon   { background: var(--red-dim);   color: var(--red); }
.purple .stat-icon { background: rgba(155,114,255,.15); color: var(--purple); }

.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  font-family: var(--font-mono);
}
.stat-sub { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

/* ── Alert Banner ─────────────────────────────────────────── */
.alert-section { margin-bottom: 28px; }
.alert-banner {
  background: linear-gradient(135deg, rgba(245,166,35,.12), rgba(255,77,106,.1));
  border: 1px solid rgba(245,166,35,.35);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
}
.alert-banner-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--amber);
  margin-bottom: 14px;
}
.alert-banner-title i { font-size: 16px; }
.alert-items { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  font-size: 13px;
}
.alert-item .car-name { font-weight: 600; color: var(--text); flex: 1; }
.alert-item .doc-name { color: var(--text-muted); min-width: 140px; }
.badge-expired { background: var(--red-dim); color: var(--red); padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; font-family: var(--font-mono); }
.badge-soon    { background: var(--amber-dim); color: var(--amber); padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; font-family: var(--font-mono); }

/* ── Section Headers ──────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.section-title {
  font-size: 17px; font-weight: 700; color: var(--text);
}
.section-title span { color: var(--blue); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  border: none;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary   { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #5a9fff; color: #fff; }
.btn-success   { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,201,142,.3); }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-danger    { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255,77,106,.3); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-ghost     { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border2); color: var(--text); background: var(--surface2); }
.btn-icon      { padding: 7px 10px; }
.btn-sm        { padding: 6px 12px; font-size: 12px; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

/* ── Fleet Grid ───────────────────────────────────────────── */
.fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.car-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
  display: flex; flex-direction: column;
}
.car-card:hover {
  border-color: rgba(59,139,255,.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(59,139,255,.1);
}
.car-card-img {
  width: 100%; height: 165px;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}
.car-card-img-placeholder {
  width: 100%; height: 165px;
  background: linear-gradient(135deg, var(--surface2), var(--surface3));
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  font-size: 48px;
}
.car-card-body { padding: 18px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.car-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.car-model { font-size: 16px; font-weight: 700; color: var(--text); }
.car-plate {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 5px;
}
.car-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.car-meta-item { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.car-meta-item i { color: var(--blue); }
.car-card-actions {
  display: flex; gap: 8px; padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.car-card-actions a {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px;
  border-radius: 7px;
  font-size: 12px; font-weight: 600;
  transition: all var(--transition);
}
.action-view  { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(59,139,255,.25); }
.action-view:hover  { background: var(--blue); color: #fff; }
.action-fuel  { background: rgba(34,201,142,.1); color: var(--green); border: 1px solid rgba(34,201,142,.2); }
.action-fuel:hover  { background: var(--green); color: #fff; }
.action-maint { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,166,35,.2); }
.action-maint:hover { background: var(--amber); color: #0f0f12; }

/* ── Status Badges ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge-active      { background: rgba(34,201,142,.12); color: var(--green); border: 1px solid rgba(34,201,142,.3); }
.badge-active::before { background: var(--green); }
.badge-available   { background: var(--blue-glow); color: var(--blue); border: 1px solid rgba(59,139,255,.3); }
.badge-available::before { background: var(--blue); }
.badge-maintenance { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,166,35,.3); }
.badge-maintenance::before { background: var(--amber); }
.badge-inactive    { background: rgba(122,122,150,.12); color: var(--text-muted); border: 1px solid var(--border); }
.badge-inactive::before { background: var(--text-muted); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface2);
  padding: 13px 16px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td {
  padding: 13px 16px;
  font-size: 13px; color: var(--text);
  font-family: var(--font-mono);
}
tbody td.text-body { font-family: var(--font-display); }
.td-money { color: var(--green); font-weight: 600; }
.td-muted { color: var(--text-muted); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  transition: border-color var(--transition);
  width: 100%;
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }
.form-control::placeholder { color: var(--text-dim); }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); font-size: 20px;
  padding: 4px; transition: color var(--transition);
}
.modal-close:hover { color: var(--red); }
.modal-body { padding: 24px 26px; display: flex; flex-direction: column; gap: 18px; }
.modal-footer {
  padding: 18px 26px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Car Detail Page ──────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
.car-profile-img {
  width: 100%; aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.car-profile-placeholder {
  width: 100%; aspect-ratio: 4/3;
  background: linear-gradient(135deg, var(--surface2), var(--surface3));
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 72px; color: var(--text-dim);
}
.specs-list { display: flex; flex-direction: column; gap: 0; }
.spec-row {
  display: flex; align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.spec-row:last-child { border-bottom: none; }
.spec-key { font-size: 12px; color: var(--text-muted); width: 160px; flex-shrink: 0; }
.spec-val { font-size: 13px; color: var(--text); font-family: var(--font-mono); font-weight: 500; }
.spec-val.highlight { color: var(--green); }

.detail-section { margin-bottom: 28px; }
.detail-section-title {
  font-size: 14px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-muted);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.detail-section-title i { color: var(--blue); }

/* Expiry indicator dots */
.doc-expiry { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-ok      { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-warning { background: var(--amber); box-shadow: 0 0 6px var(--amber); animation: pulse 2s infinite; }
.dot-expired { background: var(--red);   box-shadow: 0 0 6px var(--red);   animation: pulse 1.5s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* Inline table row editing */
.inline-add-row td { background: rgba(59,139,255,.05); }
.inline-add-row input, .inline-add-row select {
  background: var(--surface3);
  border: 1px solid var(--blue);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  width: 100%;
  min-width: 80px;
}
.inline-add-row input:focus, .inline-add-row select:focus {
  outline: none; box-shadow: 0 0 0 2px var(--blue-glow);
}

/* KM/L Badge */
.kpl-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--green-dim);
  color: var(--green);
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px; font-weight: 700;
  font-family: var(--font-mono);
}

/* ── Login Page ───────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.login-bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 60% 50% at 10% 80%, rgba(59,139,255,.08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 90% 20%, rgba(155,114,255,.07) 0%, transparent 70%);
}
.login-card {
  position: relative; z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 44px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 36px;
  justify-content: center;
}
.login-logo-icon {
  width: 52px; height: 52px;
  background: var(--blue-dim);
  border: 1px solid var(--blue);
  border-radius: 13px;
  display: grid; place-items: center;
  color: var(--blue); font-size: 22px;
}
.login-logo-text { font-size: 28px; font-weight: 800; }
.login-logo-text em { color: var(--blue); font-style: normal; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 32px; }
.login-form { display: flex; flex-direction: column; gap: 18px; }
.login-error {
  background: var(--red-dim); color: var(--red);
  border: 1px solid rgba(255,77,106,.3);
  padding: 11px 16px; border-radius: 8px;
  font-size: 13px;
}
.btn-login {
  background: var(--blue); color: #fff;
  padding: 13px; border-radius: 9px;
  font-size: 15px; font-weight: 700;
  border: none; width: 100%;
  letter-spacing: 0.3px;
  transition: all var(--transition);
  margin-top: 6px;
}
.btn-login:hover { background: #5a9fff; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(59,139,255,.35); }

/* ── Misc Utilities ───────────────────────────────────────── */
.text-green  { color: var(--green); }
.text-amber  { color: var(--amber); }
.text-red    { color: var(--red); }
.text-blue   { color: var(--blue); }
.text-muted  { color: var(--text-muted); }
.text-mono   { font-family: var(--font-mono); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mt-4   { margin-top: 4px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.gap-12 { gap: 12px; }
.flex   { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.d-none { display: none !important; }
.w100   { width: 100%; }

/* Toast notifications */
#toast-container {
  position: fixed; bottom: 28px; right: 28px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13px; color: var(--text);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .3s ease;
  min-width: 260px;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--blue); }
.toast i.success { color: var(--green); }
.toast i.error   { color: var(--red); }
.toast i.info    { color: var(--blue); }

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

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: none; }
  #main-content { margin-left: 0; }
  #sidebar-toggle { display: block; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  #page-body { padding: 18px; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .fleet-grid { grid-template-columns: 1fr; }
}
