/* ============================================================
   TruckPortal v2 — Main Stylesheet
   Theme: Industrial Utilitarian — dark steel + amber
   ============================================================ */

:root {
  --brand:        #F59E0B;
  --brand-dark:   #B45309;
  --brand-light:  #FDE68A;
  --dark:         #0F1117;
  --dark-2:       #1A1D27;
  --dark-3:       #252836;
  --dark-4:       #2E3248;
  --border:       #353849;
  --text:         #E2E8F0;
  --text-muted:   #8892A4;
  --success:      #10B981;
  --danger:       #EF4444;
  --warning:      #F59E0B;
  --info:         #3B82F6;
  --sidebar-w:    260px;
  --topbar-h:     64px;
  --radius:       10px;
  --shadow:       0 4px 24px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: 'DM Sans', system-ui, sans-serif; background: var(--dark); color: var(--text); min-height: 100vh; line-height: 1.6; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-light); }
h1,h2,h3,h4,h5,h6 { font-family: 'Syne', sans-serif; font-weight: 700; color: var(--text); }

/* ── Layout ─────────────────────────────────────────────────── */
.tp-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.tp-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--dark-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  transition: transform .25s ease;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-family: 'Syne', sans-serif;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--brand);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--dark);
  font-size: 1.05rem;
  flex-shrink: 0;
}
.brand-name strong { color: var(--brand); }
.brand-tag { font-size: .65rem; color: var(--text-muted); font-family: 'DM Sans', sans-serif; font-weight: 400; line-height: 1; margin-top: 2px; }

.sidebar-sub-badge { padding: .4rem 1.5rem; border-bottom: 1px solid var(--border); }

.sidebar-nav { flex: 1; padding: .75rem 0; }
.nav-section {
  font-size: .6rem; font-weight: 700;
  letter-spacing: .12em; color: var(--text-muted);
  padding: .9rem 1.5rem .25rem;
  text-transform: uppercase;
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem 1.5rem;
  color: var(--text-muted);
  font-size: .86rem; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
  position: relative;
}
.sidebar-nav .nav-link i { font-size: .95rem; width: 17px; flex-shrink: 0; }
.sidebar-nav .nav-link:hover { color: var(--text); background: rgba(245,158,11,.06); border-left-color: rgba(245,158,11,.4); }
.sidebar-nav .nav-link.active { color: var(--brand); background: rgba(245,158,11,.10); border-left-color: var(--brand); }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.nav-badge.amber { background: var(--brand); color: var(--dark); }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
  flex-shrink: 0;
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .78rem;
  color: var(--dark); flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: .8rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; color: var(--text-muted); text-transform: capitalize; }
.btn-logout { color: var(--text-muted); font-size: 1.05rem; padding: .25rem; transition: color .15s; }
.btn-logout:hover { color: var(--danger); }

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

/* ── Topbar ───────────────────────────────────────────────────── */
.tp-topbar {
  height: var(--topbar-h);
  background: var(--dark-2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 100;
}
.sidebar-toggle { background: none; border: none; color: var(--text-muted); font-size: 1.3rem; cursor: pointer; display: none; padding: .25rem; }
.topbar-info { flex: 1; }
.topbar-eyebrow { font-size: .67rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.topbar-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1rem; }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }

/* ── Content Area ─────────────────────────────────────────────── */
.tp-content { flex: 1; padding: 1.5rem; }

/* ── Cards ────────────────────────────────────────────────────── */
.tp-card {
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.tp-card + .tp-card { margin-top: 1rem; }

/* ── Stat Cards ───────────────────────────────────────────────── */
.stat-card {
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-icon.amber { background: rgba(245,158,11,.15); color: var(--brand); }
.stat-icon.blue  { background: rgba(59,130,246,.15);  color: var(--info); }
.stat-icon.green { background: rgba(16,185,129,.15);  color: var(--success); }
.stat-icon.red   { background: rgba(239,68,68,.15);   color: var(--danger); }
.stat-icon.purple{ background: rgba(139,92,246,.15);  color: #8b5cf6; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .77rem; color: var(--text-muted); margin-top: .2rem; }
.stat-sub   { font-size: .72rem; color: var(--text-muted); margin-top: .15rem; }

/* ── Tables ───────────────────────────────────────────────────── */
.tp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.tp-table thead th {
  background: var(--dark-3);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tp-table tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(53,56,73,.6);
  vertical-align: middle;
}
.tp-table tbody tr:hover { background: rgba(245,158,11,.04); }
.tp-table tbody tr:last-child td { border-bottom: none; }
.tp-table .row-pickup-today { border-left: 3px solid var(--brand) !important; }
.tp-table .row-pickup-late  { border-left: 3px solid var(--danger) !important; }
.tp-table .row-just-delivered { background: rgba(16,185,129,.05); }

/* ── Status Badges ────────────────────────────────────────────── */
.tp-badge {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .02em;
}
.badge-draft     { background: rgba(136,146,164,.18); color: var(--text-muted); }
.badge-booked    { background: rgba(139,92,246,.18);  color: #a78bfa; }
.badge-dispatched{ background: rgba(59,130,246,.18);  color: #60a5fa; }
.badge-transit   { background: rgba(245,158,11,.18);  color: var(--brand); }
.badge-delivered { background: rgba(16,185,129,.18);  color: #34d399; }
.badge-invoiced  { background: rgba(6,182,212,.18);   color: #22d3ee; }
.badge-paid      { background: rgba(16,185,129,.25);  color: #10b981; }
.badge-cancelled { background: rgba(239,68,68,.18);   color: #f87171; }
.badge-secondary { background: rgba(136,146,164,.18); color: var(--text-muted); }

/* ── Filter Bar ───────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
}
.filter-bar .form-control,
.filter-bar .form-select { background: var(--dark-3); border-color: var(--border); color: var(--text); font-size: .85rem; }
.filter-bar .form-control:focus,
.filter-bar .form-select:focus { background: var(--dark-3); border-color: var(--brand); color: var(--text); box-shadow: 0 0 0 2px rgba(245,158,11,.2); }
.filter-bar .form-control::placeholder { color: var(--text-muted); }

/* ── Status Pill Tabs ─────────────────────────────────────────── */
.status-pills { display: flex; gap: .4rem; flex-wrap: wrap; }
.status-pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .8rem;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--dark-3);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.status-pill:hover { color: var(--text); border-color: rgba(245,158,11,.4); }
.status-pill.active { color: var(--brand); background: rgba(245,158,11,.12); border-color: var(--brand); }
.status-pill .count { background: var(--dark-4); border-radius: 10px; padding: .05rem .4rem; font-size: .68rem; }

/* ── Row Actions ──────────────────────────────────────────────── */
.row-actions { display: flex; gap: .3rem; }
.row-actions a, .row-actions button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--dark-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .8rem;
  transition: all .15s;
  cursor: pointer;
  text-decoration: none;
}
.row-actions a:hover, .row-actions button:hover { background: rgba(245,158,11,.15); color: var(--brand); border-color: var(--brand); }
.row-actions a.danger:hover { background: rgba(239,68,68,.15); color: var(--danger); border-color: var(--danger); }

/* ── Forms ────────────────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--dark-3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
}
.form-control:focus, .form-select:focus {
  background: var(--dark-3);
  border-color: var(--brand);
  color: var(--text);
  box-shadow: 0 0 0 2px rgba(245,158,11,.2);
}
.form-control::placeholder { color: var(--text-muted); }
.form-label { font-size: .83rem; font-weight: 500; color: var(--text-muted); margin-bottom: .35rem; }
.input-group-text { background: var(--dark-4); border-color: var(--border); color: var(--text-muted); }
.form-select option { background: var(--dark-3); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--dark); font-weight: 600; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: var(--dark); }
.btn-outline-primary { border-color: var(--border); color: var(--text-muted); }
.btn-outline-primary:hover { background: rgba(245,158,11,.1); border-color: var(--brand); color: var(--brand); }
.btn-secondary { background: var(--dark-3); border-color: var(--border); color: var(--text-muted); }
.btn-secondary:hover { background: var(--dark-4); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-success { background: var(--success); border-color: var(--success); }

/* ── Offcanvas (Detail Panel) ─────────────────────────────────── */
.offcanvas { background: var(--dark-2) !important; border-left: 1px solid var(--border) !important; }
.offcanvas-header { border-bottom: 1px solid var(--border) !important; }
.offcanvas-title { font-family: 'Syne', sans-serif; font-weight: 700; color: var(--text); }
.btn-close { filter: invert(1) brightness(.7); }

/* ── Timeline ─────────────────────────────────────────────────── */
.load-timeline { position: relative; padding-left: 1.75rem; }
.load-timeline::before { content: ''; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 1.1rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute; left: -1.75rem;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--dark-2);
  top: 3px;
}
.timeline-dot.done  { background: var(--success); border-color: var(--success); }
.timeline-dot.active{ background: var(--brand);   border-color: var(--brand); }
.timeline-label { font-size: .82rem; font-weight: 600; color: var(--text); }
.timeline-time  { font-size: .73rem; color: var(--text-muted); margin-top: .1rem; }

/* ── Document Upload ──────────────────────────────────────────── */
.doc-upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .2s;
}
.doc-upload-zone:hover { border-color: var(--brand); color: var(--brand); }
.doc-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .9rem;
  background: var(--dark-3);
  border-radius: 8px;
  margin-bottom: .4rem;
}
.doc-icon { font-size: 1.2rem; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: .83rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: .71rem; color: var(--text-muted); }

/* ── Chart Container ──────────────────────────────────────────── */
.chart-container { position: relative; height: 200px; }

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: .75rem; display: block; opacity: .4; }
.empty-state h5 { color: var(--text-muted); font-size: 1rem; margin-bottom: .4rem; }
.empty-state p  { font-size: .85rem; }

/* ── Modals ───────────────────────────────────────────────────── */
.modal-content  { background: var(--dark-2); border: 1px solid var(--border); }
.modal-header   { border-bottom-color: var(--border); }
.modal-footer   { border-top-color: var(--border); }
.modal-title    { font-family: 'Syne', sans-serif; font-weight: 700; }

/* ── Alerts ───────────────────────────────────────────────────── */
.alert-success { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.3); color: #34d399; }
.alert-danger  { background: rgba(239,68,68,.12);  border-color: rgba(239,68,68,.3);  color: #f87171; }
.alert-warning { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: var(--brand); }
.alert-info    { background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.3); color: #60a5fa; }

/* ── Auth Layout ──────────────────────────────────────────────── */
.auth-layout { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--dark); padding: 1rem; }
.auth-card { background: var(--dark-2); border: 1px solid var(--border); border-radius: 14px; padding: 2rem; width: 100%; max-width: 420px; }
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo .brand-icon { margin: 0 auto 0.6rem; width: 48px; height: 48px; font-size: 1.4rem; }

/* ── Invoice PDF ──────────────────────────────────────────────── */
@media print {
  .tp-sidebar, .tp-topbar, .no-print { display: none !important; }
  .tp-main { margin-left: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
}

/* ── Overdue stripe row ───────────────────────────────────────── */
.overdue-row td { background: rgba(239,68,68,.04) !important; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 991px) {
  .tp-sidebar { transform: translateX(-100%); }
  .tp-sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .tp-main { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 199; }
  .sidebar-overlay.show { display: block; }
}
@media (max-width: 575px) {
  .tp-content { padding: 1rem; }
  .stat-value { font-size: 1.3rem; }
  .filter-bar { padding: .6rem; gap: .4rem; }
}
