/* FleetMaster · app.css
   Design: Industrial / utilitarian dark — amber gauges
   Font: Barlow Condensed (display) + Inter (body)
*/

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700&family=Barlow:wght@300;400;500;600&display=swap');

/* ── RESET & VARIABLES ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0b0f1a;
  --surface:   #141928;
  --surface2:  #1c2337;
  --border:    #252e44;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --amber:     #f59e0b;
  --amber-dim: #92600a;
  --green:     #22c55e;
  --red:       #ef4444;
  --blue:      #3b82f6;
  --radius:    8px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
  --font-body: 'Barlow', sans-serif;
  --font-head: 'Barlow Condensed', sans-serif;
  --sidebar-w: 240px;
  --header-h:  56px;
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--amber); text-decoration: none; }
a:hover { color: #fbbf24; }

input, select, textarea {
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .85rem;
  width: 100%;
  transition: border-color .2s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--amber); }
select option { background: var(--surface); }
label { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: .3rem; }

button { font-family: var(--font-body); cursor: pointer; border: none; border-radius: var(--radius); padding: .55rem 1.2rem; font-size: .9rem; font-weight: 600; transition: all .2s; }

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

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  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;
  transform: translateX(0);
  transition: transform .3s ease;
}
#sidebar.hidden { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: var(--amber);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.sidebar-logo .logo-text {
  font-family: var(--font-head);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
}

.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-section { padding: .4rem 1rem .2rem; font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem 1rem;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
  transition: all .15s;
  cursor: pointer;
  border-left: 3px solid transparent;
  margin: 1px 0;
}
.nav-item:hover  { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--amber); border-left-color: var(--amber); background: rgba(245,158,11,.08); }
.nav-item .icon  { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-user {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: .6rem;
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--amber-dim);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: var(--amber); flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name  { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* Main content */
#main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin .3s ease;
}
#main.full { margin-left: 0; }

/* Top header */
#header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 50;
}
#menu-toggle { background: none; padding: .4rem; color: var(--muted); font-size: 1.2rem; display: none; }
#menu-toggle:hover { color: var(--text); }
#page-title { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; letter-spacing: .5px; flex: 1; }

/* Page content */
#content { padding: 1.5rem; flex: 1; }

/* ── OVERLAY (mobile sidebar) ────────────────────────────────────────────── */
#overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 90; }
#overlay.show { display: block; }

/* ── CARDS ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; letter-spacing: .5px; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--amber);
}
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: .3rem; }
.stat-value { font-family: var(--font-head); font-size: 2rem; font-weight: 700; line-height: 1; color: var(--amber); }
.stat-icon  { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); font-size: 2rem; opacity: .1; }

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn         { display: inline-flex; align-items: center; gap: .4rem; }
.btn-primary { background: var(--amber); color: #000; }
.btn-primary:hover { background: #fbbf24; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--amber); color: var(--amber); }
.btn-danger  { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover  { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #000; }
.btn-sm  { padding: .35rem .7rem; font-size: .8rem; }
.btn-icon { padding: .4rem .5rem; }

/* ── TABLE ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); padding: .6rem .85rem; border-bottom: 2px solid var(--border); font-weight: 600; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: .7rem .85rem; }

/* ── BADGES ─────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 20px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.badge-amber  { background: rgba(245,158,11,.15); color: var(--amber); }
.badge-green  { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-red    { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-blue   { background: rgba(59,130,246,.15);  color: var(--blue); }
.badge-muted  { background: var(--surface2); color: var(--muted); }

/* ── MODAL ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modal-in .2s ease;
}
@keyframes modal-in { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.25rem .9rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; letter-spacing: .5px; }
.modal-close { background: none; color: var(--muted); font-size: 1.3rem; padding: .2rem .4rem; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 1.25rem; }
.modal-footer { padding: .9rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .6rem; }

/* ── FORM GROUPS ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-error { color: var(--red); font-size: .8rem; margin-top: .3rem; }

/* ── LOGIN PAGE ─────────────────────────────────────────────────────────── */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 50%, rgba(245,158,11,.06) 0%, transparent 60%),
    radial-gradient(circle at 80% 20%, rgba(59,130,246,.04) 0%, transparent 50%);
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .big-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: .5rem;
}
.login-logo h1 {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
}
.login-logo p { color: var(--muted); font-size: .85rem; }
.login-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: var(--red);
  border-radius: var(--radius);
  padding: .65rem .85rem;
  font-size: .85rem;
  margin-bottom: 1rem;
  display: none;
}
.login-error.show { display: block; }

/* ── ALERTS ─────────────────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .88rem; }
.alert-success { background: rgba(34,197,94,.1);  border: 1px solid rgba(34,197,94,.3);  color: var(--green); }
.alert-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: var(--red); }
.alert-info    { background: rgba(59,130,246,.1);  border: 1px solid rgba(59,130,246,.3); color: var(--blue); }
.alert-warning { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: var(--amber); }

/* ── TOAST ──────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.1rem;
  font-size: .88rem;
  min-width: 240px;
  max-width: 340px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: .6rem;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }

/* ── CALENDAR ───────────────────────────────────────────────────────────── */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.cal-nav { display: flex; gap: .4rem; }
.cal-month { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; letter-spacing: .5px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day-name { text-align: center; font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: .4rem 0; font-weight: 600; }
.cal-day {
  min-height: 72px;
  background: var(--surface2);
  border-radius: 4px;
  padding: .35rem .4rem;
  font-size: .8rem;
  position: relative;
  cursor: pointer;
  transition: background .15s;
}
.cal-day:hover { background: var(--border); }
.cal-day.today { outline: 1px solid var(--amber); }
.cal-day.other-month { opacity: .3; }
.cal-day .day-num { font-weight: 600; color: var(--muted); font-size: .78rem; }
.cal-day.today .day-num { color: var(--amber); }
.cal-event { background: rgba(245,158,11,.2); color: var(--amber); border-radius: 3px; padding: 1px 4px; font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.cal-event.itv { background: rgba(239,68,68,.2); color: var(--red); }
.cal-event.maint { background: rgba(59,130,246,.2); color: var(--blue); }

/* ── VEHICLE CARD ────────────────────────────────────────────────────────── */
.vehicle-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.vehicle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s, transform .2s;
  cursor: pointer;
}
.vehicle-card:hover { border-color: var(--amber); transform: translateY(-2px); }
.vehicle-card-header {
  background: var(--surface2);
  padding: .85rem 1rem;
  display: flex; align-items: center; justify-content: space-between;
}
.vehicle-plate {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--amber);
}
.vehicle-card-body { padding: .85rem 1rem; }
.vehicle-name { font-weight: 600; font-size: 1rem; margin-bottom: .25rem; }
.vehicle-meta { font-size: .82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .5rem; }
.vehicle-card-footer {
  padding: .6rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-size: .78rem;
}
.km-badge { display: flex; align-items: center; gap: .3rem; color: var(--muted); }
.km-badge .val { font-family: monospace; color: var(--text); font-weight: 600; }

/* ── EMPTY STATE ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; display: block; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: .4rem; color: var(--text); }

/* ── LOADING ────────────────────────────────────────────────────────────── */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--amber); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; justify-content: center; padding: 2rem; }

/* ── SEARCH BAR ─────────────────────────────────────────────────────────── */
.search-bar { display: flex; gap: .6rem; margin-bottom: 1rem; }
.search-bar input { max-width: 280px; }

/* ── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  #sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; }
  #menu-toggle { display: block; }
  #content { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .vehicle-list { grid-template-columns: 1fr; }
  .modal { max-width: 100%; }
  .cal-day { min-height: 48px; }
  .cal-event { display: none; }
  .cal-day.has-event::after {
    content: '•'; position: absolute; bottom: 2px; right: 4px;
    color: var(--amber); font-size: .8rem;
  }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-box { padding: 1.75rem 1.25rem; }
}

/* ── UTILS ──────────────────────────────────────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: .5rem; }
.gap-md { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--muted); font-size: .85rem; }
.text-amber  { color: var(--amber); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.font-mono   { font-family: monospace; }
.w-full      { width: 100%; }
.hidden      { display: none !important; }
