/* ============================================================
   TitanFleet TMS — Main Stylesheet
   ============================================================ */

:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1a1a2e;
  --sidebar-hover-bg: rgba(255,255,255,.07);
  --sidebar-active-bg: rgba(99,102,241,.25);
  --sidebar-text: rgba(255,255,255,.8);
  --topbar-height: 56px;
  --primary: #6366f1;
  --body-bg: #f4f6fa;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  background: var(--body-bg);
  font-size: .875rem;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ════════════════════════════════════════════════
   APP WRAPPER — full-width flex container
   ════════════════════════════════════════════════ */
#app-wrapper {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 1040;
}

.sidebar-brand {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
}
.sidebar-brand .brand-text {
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
}
.sidebar-brand:hover .brand-text { color: #e0e7ff; }

.sidebar-hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,.08);
  margin: 0;
}

/* Nav pills inside sidebar */
#sidebar .nav-pills {
  padding: .5rem .5rem 0;
}

#sidebar .nav-link {
  color: var(--sidebar-text);
  padding: .5rem .85rem;
  border-radius: .4rem;
  font-size: .82rem;
  display: flex;
  align-items: center;
  gap: .55rem;
  transition: background .15s, color .15s;
  margin-bottom: 1px;
}
#sidebar .nav-link i { font-size: .95rem; opacity: .75; flex-shrink: 0; }
#sidebar .nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}
#sidebar .nav-link:hover i { opacity: 1; }
#sidebar .nav-link.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  font-weight: 600;
}
#sidebar .nav-link.active i { opacity: 1; }

.sidebar-section-label,
.nav-section-label {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.3);
  padding: .9rem 1rem .3rem;
  list-style: none;
}

.sidebar-user-area {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.08);
  padding: .85rem 1rem;
  flex-shrink: 0;
}
.sidebar-user-area a:hover { color: rgba(255,255,255,.85) !important; }

.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-circle-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: .7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ════════════════════════════════════════════════
   MAIN CONTENT AREA
   ════════════════════════════════════════════════ */
#main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

/* ── Top bar ── */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* ── Flash container + page content ── */
#flash-container { padding: .75rem 1.5rem 0; }
#flash-container:empty { padding: 0; }

main.flex-grow-1 {
  padding: 1.5rem;
  flex: 1;
}

/* ════════════════════════════════════════════════
   PAGE HEADER
   ════════════════════════════════════════════════ */
.page-header {
  margin-bottom: 1.5rem;
  padding-top: .25rem;
}
.page-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
  color: #111827;
}
.page-header .text-muted { font-size: .82rem; margin: .15rem 0 0; }

/* ════════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════════ */
.card {
  border: 1px solid #e5e7eb;
  border-radius: .6rem;
  background: #fff;
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #f3f4f6;
  padding: .75rem 1.1rem;
  font-weight: 600;
  border-radius: .6rem .6rem 0 0 !important;
}
.card.shadow-sm { box-shadow: 0 1px 3px rgba(0,0,0,.07) !important; }

/* ════════════════════════════════════════════════
   KPI / STAT CARDS
   ════════════════════════════════════════════════ */
.kpi-card {
  border: none;
  border-radius: .75rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.07);
}
.kpi-icon {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════════
   TABLES
   ════════════════════════════════════════════════ */
.table { font-size: .82rem; }
.table td, .table th { vertical-align: middle; padding: .6rem .85rem; }
.table thead th {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}
.table-hover tbody tr:hover { background: rgba(99,102,241,.04); }

/* ════════════════════════════════════════════════
   AVATAR (generic)
   ════════════════════════════════════════════════ */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary);
  color: #fff; font-weight: 700; font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-sm { width: 28px; height: 28px; font-size: .68rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }

/* ════════════════════════════════════════════════
   STATUS BADGES
   ════════════════════════════════════════════════ */
.badge { font-size: .72rem; font-weight: 600; letter-spacing: .02em; }
.badge-pending    { background: #6c757d; }
.badge-confirmed  { background: #0d6efd; }
.badge-in_transit { background: #0dcaf0; color: #000; }
.badge-delivered  { background: #198754; }
.badge-complete   { background: #20c997; }
.badge-cancelled  { background: #343a40; }

/* ════════════════════════════════════════════════
   PAGINATION
   ════════════════════════════════════════════════ */
.pagination { margin-top: 1.25rem; margin-bottom: .25rem; }
.page-link { font-size: .8rem; padding: .35rem .65rem; color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ════════════════════════════════════════════════
   TIMELINE
   ════════════════════════════════════════════════ */
.timeline-dot {
  width: 14px; height: 14px; border-radius: 50%;
  flex-shrink: 0; margin-top: 4px;
}

/* ════════════════════════════════════════════════
   FORMS
   ════════════════════════════════════════════════ */
.form-label { font-weight: 600; font-size: .8rem; color: #374151; margin-bottom: .3rem; }
.form-control, .form-select {
  font-size: .85rem;
  border-color: #d1d5db;
  border-radius: .4rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* ════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════ */
.btn { font-size: .82rem; font-weight: 500; border-radius: .4rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #4f46e5; border-color: #4f46e5; }

/* ════════════════════════════════════════════════
   ALERTS
   ════════════════════════════════════════════════ */
.alert { font-size: .85rem; border-radius: .5rem; }

/* ════════════════════════════════════════════════
   FLEET REGISTER
   The fleet list carries a lot of numbers per row —
   spec, statutory dates, service, fuel, cost. These
   rules keep it dense and scannable rather than
   letting Bootstrap defaults stretch it out.
   ════════════════════════════════════════════════ */

/* ── KPI tiles ── */
.fl-kpi {
  display: block;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-left: 3px solid #9ca3af;
  border-radius: .6rem;
  padding: .7rem .9rem;
  height: 100%;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  transition: box-shadow .15s, transform .15s;
}
a.fl-kpi:hover { box-shadow: 0 4px 12px rgba(0,0,0,.10); transform: translateY(-1px); }
.fl-kpi-label {
  font-size: .66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #6b7280; white-space: nowrap;
}
.fl-kpi-value { font-size: 1.5rem; font-weight: 700; color: #111827; line-height: 1.15; }
.fl-kpi-foot { font-size: .7rem; color: #6b7280; }
.fl-kpi-primary { border-left-color: #6366f1; }
.fl-kpi-primary .fl-kpi-value { color: #4f46e5; }
.fl-kpi-warning { border-left-color: #f59e0b; }
.fl-kpi-warning .fl-kpi-value { color: #b45309; }
.fl-kpi-danger  { border-left-color: #ef4444; }
.fl-kpi-danger  .fl-kpi-value { color: #b91c1c; }
.fl-kpi-info    { border-left-color: #0ea5e9; }
.fl-kpi-info    .fl-kpi-value { color: #0369a1; }

/* ── Register table ── */
.fl-table-wrap { max-height: calc(100vh - 380px); overflow: auto; }
.fl-table { font-size: .78rem; }
.fl-table thead th {
  position: sticky; top: 0; z-index: 3;
  white-space: nowrap;
}
.fl-table td { padding: .55rem .7rem; }
/* The plate stays on screen while the numbers scroll under it — without it a
   wide register loses track of which unit a row belongs to. */
.fl-table .fl-sticky {
  position: sticky; left: 0; z-index: 2;
  background: #fff;
  border-right: 1px solid #eef0f4;
  min-width: 190px;
}
.fl-table thead .fl-sticky { z-index: 4; background: #f9fafb; }
.fl-table tbody tr:hover .fl-sticky { background: #fafaff; }
.fl-row-alert { background: rgba(239,68,68,.045); }
.fl-row-alert:hover .fl-sticky,
.fl-row-alert .fl-sticky { background: #fef6f6; }

.fl-type-icon {
  width: 30px; height: 30px; border-radius: .45rem;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; flex-shrink: 0;
}
.fl-fleetno {
  font-size: .64rem; font-weight: 700; letter-spacing: .04em;
  background: #eef2ff; color: #4338ca;
  padding: .05rem .3rem; border-radius: .25rem;
  vertical-align: middle;
}

/* ── Expiry chips: three statutory dates in the width of one ── */
.fl-chip {
  display: inline-block;
  font-size: .64rem; font-weight: 600; line-height: 1.5;
  padding: .05rem .35rem; margin: 0 .15rem .15rem 0;
  border-radius: .25rem; white-space: nowrap;
  border: 1px solid transparent;
}
.fl-chip b { font-weight: 800; }
.fl-chip-success   { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.fl-chip-info      { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.fl-chip-warning   { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.fl-chip-danger    { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.fl-chip-secondary,
.fl-chip-blank     { background: #f3f4f6; color: #9ca3af; border-color: #e5e7eb; }

.fl-bar { height: 5px; border-radius: 3px; background: #eef0f4; }

/* ── Card view ── */
.fl-card { border-left: 3px solid #d1d5db; }
.fl-card-available      { border-left-color: #10b981; }
.fl-card-on_route       { border-left-color: #6366f1; }
.fl-card-in_maintenance { border-left-color: #f59e0b; }
.fl-card-offline        { border-left-color: #ef4444; }
.fl-card-metrics { background: #f9fafb; border-radius: .4rem; padding: .5rem 0; }
.fl-metric-value { font-size: .95rem; font-weight: 700; color: #111827; line-height: 1.2; }
.fl-metric-label {
  font-size: .6rem; text-transform: uppercase; letter-spacing: .05em; color: #9ca3af;
}

/* ── Vehicle detail ── */
.fl-spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .75rem 1.25rem;
}
.fl-spec-label {
  font-size: .64rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: #9ca3af;
}
.fl-spec-value { font-size: .85rem; font-weight: 600; color: #1f2937; }
.fl-hero {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d2d5a 100%);
  color: #fff; border-radius: .7rem; padding: 1.1rem 1.3rem;
}
.fl-hero .fl-hero-reg { font-size: 1.5rem; font-weight: 800; letter-spacing: .04em; }
.fl-hero .fl-hero-sub { color: rgba(255,255,255,.65); font-size: .8rem; }
.fl-hero-stat { border-left: 1px solid rgba(255,255,255,.15); padding-left: 1rem; }
.fl-hero-stat .v { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.fl-hero-stat .l {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .06em;
  color: rgba(255,255,255,.55);
}

@media (max-width: 991.98px) {
  .fl-table-wrap { max-height: none; }
  .fl-table .fl-sticky { position: static; }
}

/* ════════════════════════════════════════════════
   MOBILE SIDEBAR TOGGLE
   ════════════════════════════════════════════════ */
#sidebarToggle {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: #374151;
  padding: 0;
  line-height: 1;
  display: none;
  cursor: pointer;
}

/* ════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    height: 100vh;
    box-shadow: none;
  }
  #sidebar.show {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  #main-content {
    margin-left: 0;
    width: 100%;
  }
  #sidebarToggle { display: block; }
  main.flex-grow-1 { padding: 1rem; }
}
