/* ============================================================
   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; }

/* ════════════════════════════════════════════════
   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; }
}
