/* ============================================================
   DELIVR — Global Design System
   Aesthetic: Industrial-luxury. Dark chrome meets warm saffron.
   Typography: Barlow Condensed (headings) + DM Sans (body)
   ============================================================ */

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

/* ── CSS Custom Properties ──────────────────────────────────── */
:root {
  /* Core palette */
  --clr-bg:         #0d0d0f;
  --clr-surface:    #16161b;
  --clr-surface2:   #1e1e26;
  --clr-border:     #2a2a36;
  --clr-border2:    #363648;

  /* Brand */
  --clr-saffron:    #f5a623;
  --clr-saffron-lt: #f7ba50;
  --clr-saffron-dk: #c27d0e;

  /* Status colours */
  --clr-success:    #2ecc71;
  --clr-warning:    #f39c12;
  --clr-danger:     #e74c3c;
  --clr-info:       #3498db;

  /* Text */
  --clr-text:       #e8e8f0;
  --clr-text-muted: #888899;
  --clr-text-dim:   #555566;

  /* Typography */
  --font-display:   'Barlow Condensed', sans-serif;
  --font-body:      'DM Sans', sans-serif;

  /* Spacing scale */
  --sp-1: 0.25rem;  /* 4px  */
  --sp-2: 0.5rem;   /* 8px  */
  --sp-3: 0.75rem;  /* 12px */
  --sp-4: 1rem;     /* 16px */
  --sp-5: 1.25rem;  /* 20px */
  --sp-6: 1.5rem;   /* 24px */
  --sp-8: 2rem;     /* 32px */
  --sp-10: 2.5rem;  /* 40px */
  --sp-12: 3rem;    /* 48px */

  /* Border radius */
  --radius-sm:  4px;
  --radius:     8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.6);
  --shadow-glow: 0 0 24px rgba(245,166,35,.15);

  /* Transitions */
  --ease:       cubic-bezier(.4,0,.2,1);
  --dur-fast:   150ms;
  --dur:        250ms;
  --dur-slow:   400ms;

  /* Map height */
  --map-h:      380px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--clr-saffron); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--clr-saffron-lt); }

img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font-body); }
input, select, textarea { font-family: var(--font-body); }

/* ── Layout ─────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.app-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-8);
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.app-logo {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: .05em;
  color: var(--clr-saffron);
  text-transform: uppercase;
}
.app-logo span { color: var(--clr-text); }

.app-sidebar {
  background: var(--clr-surface);
  border-right: 1px solid var(--clr-border);
  padding: var(--sp-6) 0;
  position: sticky;
  top: 61px;
  height: calc(100vh - 61px);
  overflow-y: auto;
}

.sidebar-nav { list-style: none; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-6);
  color: var(--clr-text-muted);
  font-size: .9rem;
  font-weight: 500;
  transition: all var(--dur-fast) var(--ease);
  border-left: 3px solid transparent;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  color: var(--clr-text);
  background: var(--clr-surface2);
  border-left-color: var(--clr-saffron);
}
.sidebar-nav .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-role-badge {
  margin: 0 var(--sp-6) var(--sp-6);
  padding: var(--sp-2) var(--sp-4);
  background: rgba(245,166,35,.08);
  border: 1px solid rgba(245,166,35,.2);
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: .85rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--clr-saffron);
}

.app-main {
  padding: var(--sp-8);
  overflow-y: auto;
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  margin-bottom: var(--sp-8);
}
.page-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1.1;
}
.page-title em {
  color: var(--clr-saffron);
  font-style: normal;
}
.page-subtitle {
  color: var(--clr-text-muted);
  margin-top: var(--sp-1);
  font-size: .95rem;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  transition: border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.card:hover {
  border-color: var(--clr-border2);
  box-shadow: var(--shadow-md);
}
.card-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: var(--sp-4);
  color: var(--clr-text);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

/* ── Stats Row ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
}
.stat-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent, var(--clr-saffron));
}
.stat-label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--clr-text-muted);
  font-weight: 600;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.1;
  margin-top: var(--sp-1);
  color: var(--clr-text);
}
.stat-value.accent { color: var(--clr-saffron); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .02em;
  transition: all var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn-primary {
  background: var(--clr-saffron);
  color: #0d0d0f;
}
.btn-primary:hover {
  background: var(--clr-saffron-lt);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245,166,35,.3);
}
.btn-secondary {
  background: var(--clr-surface2);
  color: var(--clr-text);
  border: 1px solid var(--clr-border2);
}
.btn-secondary:hover {
  background: var(--clr-border);
  border-color: var(--clr-text-muted);
}
.btn-success {
  background: var(--clr-success);
  color: #fff;
}
.btn-success:hover { filter: brightness(1.1); }
.btn-danger {
  background: var(--clr-danger);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: var(--sp-2) var(--sp-3); font-size: .8rem; }
.btn-lg { padding: var(--sp-4) var(--sp-8); font-size: 1rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--sp-5); }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--clr-text-muted);
  margin-bottom: var(--sp-2);
}
.form-control {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--clr-surface2);
  border: 1px solid var(--clr-border2);
  border-radius: var(--radius);
  color: var(--clr-text);
  font-size: .95rem;
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.form-control:focus {
  outline: none;
  border-color: var(--clr-saffron);
  box-shadow: 0 0 0 3px rgba(245,166,35,.15);
}
.form-control::placeholder { color: var(--clr-text-dim); }
select.form-control { cursor: pointer; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
thead th {
  font-family: var(--font-display);
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--clr-text-muted);
  font-weight: 700;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--clr-border);
  text-align: left;
}
tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--clr-border);
  color: var(--clr-text);
}
tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ── Status Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px var(--sp-3);
  border-radius: var(--radius-full);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-pending       { background: rgba(243,156,18,.12);  color: #f39c12; }
.badge-confirmed     { background: rgba(52,152,219,.12);  color: #3498db; }
.badge-driver_assigned { background: rgba(155,89,182,.12); color: #9b59b6; }
.badge-picked_up     { background: rgba(46,204,113,.12);  color: #2ecc71; }
.badge-in_transit    { background: rgba(245,166,35,.12);  color: #f5a623; }
.badge-arrived       { background: rgba(52,152,219,.15);  color: #3498db; }
.badge-delivered     { background: rgba(46,204,113,.2);   color: #2ecc71; }
.badge-cancelled     { background: rgba(231,76,60,.12);   color: #e74c3c; }
.badge-available     { background: rgba(46,204,113,.12);  color: #2ecc71; }
.badge-offline       { background: rgba(100,100,120,.15); color: #888; }
.badge-on_delivery   { background: rgba(245,166,35,.12);  color: #f5a623; }

/* ── Map Container ──────────────────────────────────────────── */
.map-container {
  height: var(--map-h);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--clr-border);
  position: relative;
  background: var(--clr-surface2);
}
.map-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--clr-text-muted);
  font-size: .9rem;
  flex-direction: column;
  gap: var(--sp-3);
}

/* ── Toast notifications ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.toast {
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  min-width: 260px;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: slideIn var(--dur) var(--ease);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.toast-success { background: #1a3a27; border: 1px solid var(--clr-success); color: var(--clr-success); }
.toast-error   { background: #3a1a1a; border: 1px solid var(--clr-danger);  color: var(--clr-danger); }
.toast-info    { background: #1a2d3a; border: 1px solid var(--clr-info);    color: var(--clr-info); }

@keyframes slideIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Order timeline ─────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: var(--sp-8);
}
.timeline::before {
  content: '';
  position: absolute;
  left: 12px; top: 0; bottom: 0;
  width: 2px;
  background: var(--clr-border);
}
.timeline-item {
  position: relative;
  padding-bottom: var(--sp-6);
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--sp-8) + 8px);
  top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--clr-border2);
  border: 2px solid var(--clr-bg);
}
.timeline-item.done::before { background: var(--clr-success); }
.timeline-item.active::before {
  background: var(--clr-saffron);
  box-shadow: 0 0 0 4px rgba(245,166,35,.2);
}
.timeline-label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  color: var(--clr-text-muted);
}
.timeline-item.done .timeline-label { color: var(--clr-success); }
.timeline-item.active .timeline-label { color: var(--clr-saffron); }

/* ── Driver info strip ─────────────────────────────────────── */
.driver-strip {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  background: var(--clr-surface2);
  border-radius: var(--radius);
  border: 1px solid var(--clr-border2);
}
.driver-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--clr-saffron-dk), var(--clr-saffron));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  color: #0d0d0f;
  flex-shrink: 0;
}
.driver-info { flex: 1; }
.driver-name { font-weight: 600; font-size: .95rem; }
.driver-sub  { font-size: .8rem; color: var(--clr-text-muted); }

/* ── Utility ─────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-6); }
.mt-4  { margin-top: var(--sp-4); }
.mt-6  { margin-top: var(--sp-6); }
.mb-4  { margin-bottom: var(--sp-4); }
.mb-6  { margin-bottom: var(--sp-6); }
.text-muted { color: var(--clr-text-muted); font-size: .9rem; }
.text-sm    { font-size: .85rem; }
.text-right { text-align: right; }
.w-full     { width: 100%; }
.divider    { height: 1px; background: var(--clr-border); margin: var(--sp-6) 0; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
  .app-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--clr-border);
  }
  .sidebar-nav { display: flex; padding: 0 var(--sp-4); overflow-x: auto; }
  .sidebar-nav li a { border-left: none; border-bottom: 3px solid transparent; flex-direction: column; gap: var(--sp-1); font-size: .75rem; padding: var(--sp-3) var(--sp-4); }
  .sidebar-nav li a.active, .sidebar-nav li a:hover { border-left-color: transparent; border-bottom-color: var(--clr-saffron); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .app-main { padding: var(--sp-5); }
}
