/* =====================================================
   G2 LOGISTICS - LIVE TRACKING PAGE STYLES
   Premium Split-View Tracking Interface
   ===================================================== */

/* ===========================================
   G2 DESIGN SYSTEM - CSS VARIABLES
   =========================================== */
:root {
  /* Primary Brand Colors - G2 Orange (matches dashboard #0A84DD) */
  --g2-orange-50: #FFF5F2;
  --g2-orange-100: #FFE6E0;
  --g2-orange-200: #FFCABD;
  --g2-orange-300: #9BD0F7;
  --g2-orange-400: #3DA0EE;
  --g2-orange-500: #0A84DD;
  --g2-orange-600: #0070C2;
  --g2-orange-700: #005A9C;

  /* Warm Stone Neutrals */
  --g2-stone-50: #FAFAF9;
  --g2-stone-100: #F5F5F4;
  --g2-stone-200: #E7E5E4;
  --g2-stone-300: #D6D3D1;
  --g2-stone-400: #A8A29E;
  --g2-stone-500: #78716C;
  --g2-stone-600: #57534E;
  --g2-stone-700: #44403C;
  --g2-stone-800: #292524;
  --g2-stone-900: #1C1917;

  /* Semantic Colors */
  --g2-success-500: #10B981;
  --g2-success-100: #D1FAE5;
  --g2-warning-500: #F59E0B;
  --g2-warning-100: #FEF3C7;
  --g2-error-500: #EF4444;
  --g2-error-100: #FEE2E2;
  --g2-info-500: #3B82F6;
  --g2-info-100: #DBEAFE;

  /* Typography - Inter (matches dashboard) */
  --font-display: 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 25px -5px rgba(28, 25, 23, 0.1), 0 8px 10px -6px rgba(28, 25, 23, 0.05);

  /* Border Radius (matches dashboard) */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================================
   RESET & BASE STYLES
   =========================================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--g2-stone-100);
  height: 100%;
  color: var(--g2-stone-900);
  line-height: 1.6;
  overflow: hidden;
}

/* ===========================================
   LAYOUT - App Structure
   =========================================== */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport for mobile */
  overflow: hidden;
}

/* Make main-content fill height and stack children vertically */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--g2-orange-500);
  color: white;
  padding: 8px 16px;
  z-index: 1000;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 0;
}

/* Live Indicator - styles in sidebar.css (single source of truth) */

/* ===========================================
   TRACKING CONTENT - Split View
   =========================================== */
.tracking-content {
  flex: 1;
  display: flex;
  gap: 0;
  min-height: 0; /* Important for flex children to shrink */
  overflow: hidden;
}

/* Left Panel - Jobs Sidebar */
.tracking-sidebar {
  width: 380px;
  background: #FFFFFF;
  border-right: 1px solid var(--g2-stone-200);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0; /* Allow flex shrinking */
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--g2-stone-100);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #0B0B0B;
  margin: 0;
}

.job-count {
  font-size: 12px;
  font-weight: 600;
  color: #0A84DD;
  background: rgba(10, 132, 221, 0.08);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.jobs-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--g2-stone-200);
  border-top-color: var(--g2-orange-500);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state p {
  margin-top: 16px;
  color: var(--g2-stone-500);
  font-size: 14px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--g2-stone-300);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--g2-stone-700);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--g2-stone-500);
  max-width: 240px;
}

/* Job Cards */
.job-card {
  background: #FFFFFF;
  border: 1px solid var(--g2-stone-200);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.job-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(180deg, var(--g2-orange-500) 0%, var(--g2-orange-600) 100%);
  transition: width var(--transition-smooth);
}

.job-card:hover {
  border-color: var(--g2-orange-200);
  box-shadow: var(--shadow-md);
}

.job-card:hover::before {
  width: 4px;
}

.job-card.selected {
  border-color: var(--g2-orange-500);
  background: var(--g2-orange-50);
  box-shadow: var(--shadow-lg), 0 0 0 2px var(--g2-orange-200);
}

.job-card.selected::before {
  width: 4px;
}

.job-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.job-vehicle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vehicle-icon {
  width: 36px;
  height: 36px;
  background: var(--g2-stone-100);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.vehicle-details h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--g2-stone-900);
  margin: 0;
}

.vehicle-reg {
  font-size: 12px;
  font-weight: 600;
  color: var(--g2-orange-600);
  background: var(--g2-orange-100);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-top: 4px;
  display: inline-block;
  font-family: monospace;
}

.job-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.job-status-badge.assigned {
  background: var(--g2-stone-200);
  color: var(--g2-stone-600);
}

.job-status-badge.in-progress {
  background: var(--g2-info-100);
  color: var(--g2-info-500);
}

.job-status-badge.collecting {
  background: var(--g2-warning-100);
  color: var(--g2-warning-500);
}

.job-status-badge.delivering {
  background: var(--g2-success-100);
  color: var(--g2-success-500);
}

.job-status-badge .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}

.job-card-route {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--g2-stone-100);
}

.route-points {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.route-point {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--g2-stone-600);
}

.route-point .point-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.route-point.collection .point-icon {
  background: var(--g2-success-500);
}

.route-point.delivery .point-icon {
  background: var(--g2-info-500);
}

.route-point .point-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--g2-stone-100);
}

.driver-preview {
  display: flex;
  align-items: center;
  gap: 8px;
}

.driver-preview-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--g2-orange-500);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.driver-preview-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--g2-stone-700);
}

.job-eta {
  font-size: 13px;
  font-weight: 600;
  color: var(--g2-stone-900);
  background: var(--g2-stone-100);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

/* ===========================================
   RIGHT PANEL - Map & Details
   =========================================== */
.tracking-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--g2-stone-50);
  min-width: 0;
  min-height: 0; /* Allow flex shrinking */
  overflow: hidden;
}

/* ===========================================
   MAP SECTION HEADER (Toggle Bar)
   =========================================== */
.map-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(135deg, #0A84DD 0%, #0070C2 100%);
  color: white;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.map-section-header:hover {
  background: linear-gradient(135deg, #0070C2 0%, #cc4429 100%);
}

.map-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.map-header-left .map-icon {
  width: 20px;
  height: 20px;
  opacity: 0.8;
}

.map-header-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
}

.map-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  border-radius: var(--radius-full);
}

.map-header-status .status-dot {
  width: 6px;
  height: 6px;
  background: #FFFFFF;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.map-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  transition: color 0.2s ease;
}

.map-section-header:hover .toggle-hint {
  color: #FFFFFF;
}

.map-section-header .chevron-icon {
  width: 20px;
  height: 20px;
  color: rgba(255, 255, 255, 0.7);
  transition: transform 0.3s ease, color 0.2s ease;
}

.map-section-header:hover .chevron-icon {
  color: #FFFFFF;
}

/* Collapsed state for header */
.map-section-header.collapsed .chevron-icon {
  transform: rotate(180deg);
}

.map-section-header.collapsed .toggle-hint {
  display: none;
}

.map-section-header.collapsed::after {
  content: 'Click to expand';
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.map-section-header.collapsed:hover::after {
  color: #FFFFFF;
}

/* Map Container */
.map-container {
  flex: 1;
  position: relative;
  min-height: 200px;
  transition: all 0.3s ease;
}

/* Collapsed Map State */
.map-container.collapsed {
  flex: 0;
  min-height: 0;
  height: 0;
  overflow: hidden;
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--g2-stone-200);
}

/* Map Controls (Follow + Fullscreen buttons) */
.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  gap: 8px;
}

.map-control-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid var(--g2-stone-200);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  color: var(--g2-stone-700);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  font-family: var(--font-body);
}

.map-control-btn:hover {
  background: var(--g2-stone-50);
  border-color: var(--g2-stone-300);
}

.map-control-btn.active {
  background: var(--g2-orange-500);
  color: #fff;
  border-color: var(--g2-orange-500);
}

.map-control-btn.active:hover {
  background: var(--g2-orange-600);
}

.map-control-btn svg { flex-shrink: 0; }

/* Fullscreen Map State */
.map-container.fullscreen {
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  flex: none;
  min-height: auto;
}

.map-container.fullscreen #map {
  width: 100%;
  height: 100%;
}

.map-container.fullscreen .map-controls {
  top: 20px;
  right: 20px;
}

/* Hide everything else in fullscreen */
.app-layout.map-fullscreen .sidebar,
.app-layout.map-fullscreen .header-bar,
.app-layout.map-fullscreen .tracking-sidebar,
.app-layout.map-fullscreen .map-section-header,
.app-layout.map-fullscreen .details-panel {
  display: none !important;
}

[data-theme="dark"] .map-control-btn {
  background: #2D2D2B;
  border-color: #454543;
  color: #E5E5E5;
}

[data-theme="dark"] .map-control-btn:hover {
  background: #3D3D3B;
}

[data-theme="dark"] .map-control-btn.active {
  background: var(--g2-orange-500);
  color: #fff;
  border-color: var(--g2-orange-500);
}

@media (max-width: 768px) {
  .map-control-btn span { display: none; }
  .map-control-btn { padding: 10px; }
}

/* Map Overlay - No Selection */
.map-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(250, 250, 249, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.overlay-content {
  text-align: center;
  padding: 40px;
}

.overlay-content svg {
  width: 80px;
  height: 80px;
  color: #0A84DD;
  opacity: 0.5;
  margin-bottom: 24px;
}

.overlay-content h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: #0B0B0B;
  margin-bottom: 8px;
}

.overlay-content p {
  font-size: 14px;
  color: #6B7280;
  max-width: 300px;
}

/* Details Panel */
.details-panel {
  background: #FFFFFF;
  border-top: 1px solid var(--g2-stone-200);
  padding: 20px 24px;
  flex-shrink: 0;
  max-height: 55%;
  overflow-y: auto;
  overflow-x: hidden;
  transition: max-height 0.3s ease, flex 0.3s ease;
}

/* Details Panel expanded when map collapsed */
.tracking-main.map-collapsed .details-panel {
  flex: 1;
  max-height: none;
  overflow-y: auto;
}

/* ===========================================
   STORY HEADER - Vehicle & Driver
   =========================================== */
.story-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: linear-gradient(135deg, var(--g2-stone-50) 0%, var(--g2-orange-50) 100%);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  border: 1px solid var(--g2-stone-100);
}

.story-vehicle {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vehicle-badge {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--g2-orange-500) 0%, var(--g2-orange-600) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(10, 132, 221, 0.25);
}

.vehicle-badge svg {
  width: 24px;
  height: 24px;
}

.vehicle-text h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--g2-stone-900);
  margin: 0 0 4px 0;
}

.reg-badge {
  font-size: 12px;
  font-weight: 700;
  font-family: monospace;
  color: var(--g2-orange-600);
  background: var(--g2-orange-100);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.driver-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 8px;
  background: white;
  border-radius: var(--radius-full);
  border: 1px solid var(--g2-stone-200);
}

.driver-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g2-orange-500) 0%, var(--g2-orange-600) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.driver-text {
  display: flex;
  flex-direction: column;
}

.driver-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--g2-stone-400);
}

.driver-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--g2-stone-800);
}

/* ===========================================
   LIVE ETA BANNER
   =========================================== */
.live-eta-banner {
  background: linear-gradient(135deg, var(--g2-info-100) 0%, #E0F2FE 100%);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.eta-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.eta-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--g2-info-500) 0%, #2563EB 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
  flex-shrink: 0;
}

.eta-icon svg {
  width: 24px;
  height: 24px;
}

.eta-details {
  flex: 1;
}

.eta-details .eta-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--g2-info-500);
  display: block;
  margin-bottom: 4px;
}

.eta-times {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.eta-duration {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--g2-stone-900);
}

.eta-separator {
  color: var(--g2-stone-400);
}

.eta-arrival {
  font-size: 15px;
  font-weight: 600;
  color: var(--g2-stone-600);
}

.eta-distance {
  font-size: 14px;
  font-weight: 600;
  color: var(--g2-stone-500);
  padding: 6px 14px;
  background: white;
  border-radius: var(--radius-full);
  border: 1px solid var(--g2-stone-200);
}

/* Current Road Display */
.current-road {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--g2-stone-200);
}

.current-road .road-icon {
  width: 18px;
  height: 18px;
  color: var(--g2-orange-500);
  flex-shrink: 0;
}

.current-road .road-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--g2-stone-500);
  flex-shrink: 0;
}

.current-road .road-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--g2-stone-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.traffic-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(59, 130, 246, 0.15);
}

.traffic-dot {
  width: 6px;
  height: 6px;
  background: var(--g2-success-500);
  border-radius: 50%;
  animation: trafficPulse 2s infinite;
}

@keyframes trafficPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.traffic-text {
  font-size: 11px;
  font-weight: 500;
  color: var(--g2-stone-500);
}

/* Traffic conditions colors */
.traffic-indicator.heavy .traffic-dot {
  background: var(--g2-error-500);
}

.traffic-indicator.moderate .traffic-dot {
  background: var(--g2-warning-500);
}

.traffic-indicator.light .traffic-dot {
  background: var(--g2-success-500);
}

/* ===========================================
   JOURNEY STORY TIMELINE
   =========================================== */
.journey-story {
  background: var(--g2-stone-50);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--g2-stone-100);
}

.story-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--g2-stone-200);
}

.story-icon {
  font-size: 18px;
}

.story-title h4 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--g2-stone-800);
  margin: 0;
  flex: 1;
}

.story-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--g2-info-100);
  color: var(--g2-info-500);
}

.story-status.complete {
  background: var(--g2-success-100);
  color: var(--g2-success-500);
}

/* Timeline Stages */
.journey-timeline {
  position: relative;
}

.timeline-stage {
  display: flex;
  gap: 16px;
  position: relative;
  padding-bottom: 20px;
  opacity: 0.5;
  transition: all var(--transition-smooth);
}

.timeline-stage:last-child {
  padding-bottom: 0;
}

.timeline-stage.completed {
  opacity: 1;
}

.timeline-stage.active {
  opacity: 1;
}

/* Stage Indicator (dot + line) */
.stage-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 32px;
}

.stage-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--g2-stone-200);
  border: 3px solid var(--g2-stone-100);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  transition: all var(--transition-smooth);
}

.stage-dot svg {
  width: 14px;
  height: 14px;
  color: var(--g2-stone-400);
  opacity: 0;
  transition: all var(--transition-smooth);
}

.stage-line {
  width: 3px;
  flex: 1;
  background: var(--g2-stone-200);
  margin-top: 4px;
  border-radius: 2px;
  transition: background var(--transition-smooth);
}

/* Completed Stage */
.timeline-stage.completed .stage-dot {
  background: var(--g2-success-500);
  border-color: var(--g2-success-100);
}

.timeline-stage.completed .stage-dot svg {
  opacity: 1;
  color: white;
}

.timeline-stage.completed .stage-line {
  background: var(--g2-success-500);
}

/* Active Stage */
.timeline-stage.active .stage-dot {
  background: var(--g2-orange-500);
  border-color: var(--g2-orange-200);
  box-shadow: 0 0 0 6px rgba(10, 132, 221, 0.15);
  animation: stagePulse 2s infinite;
}

.timeline-stage.active .stage-dot svg {
  opacity: 1;
  color: white;
}

@keyframes stagePulse {
  0%, 100% {
    box-shadow: 0 0 0 6px rgba(10, 132, 221, 0.15);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(10, 132, 221, 0.08);
  }
}

/* Location Dots (Collection/Delivery Points) */
.stage-dot.location-dot {
  background: var(--g2-success-500);
  font-size: 12px;
  font-weight: 800;
  color: white;
}

.stage-dot.location-dot.delivery {
  background: var(--g2-info-500);
}

.location-letter {
  font-family: var(--font-display);
}

.timeline-stage.completed .stage-dot.location-dot {
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.timeline-stage.completed .stage-dot.location-dot.delivery {
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Stage Content */
.stage-content {
  flex: 1;
  padding-top: 4px;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.stage-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--g2-stone-700);
}

.timeline-stage.active .stage-title {
  color: var(--g2-stone-900);
}

.stage-time {
  font-size: 11px;
  font-weight: 500;
  color: var(--g2-stone-400);
}

.stage-description {
  font-size: 12px;
  color: var(--g2-stone-500);
  margin: 0;
}

.stage-address {
  font-size: 12px;
  color: var(--g2-stone-600);
  margin: 0 0 8px 0;
  font-weight: 500;
}

.stage-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--g2-stone-200);
  color: var(--g2-stone-600);
}

.stage-badge.complete {
  background: var(--g2-success-100);
  color: var(--g2-success-500);
}

/* Live Badge */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--g2-success-100);
  color: var(--g2-success-500);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--g2-success-500);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

/* ETA Inline */
.eta-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 12px;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--g2-stone-200);
}

.eta-inline .eta-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--g2-stone-500);
}

.eta-inline .eta-value {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--g2-orange-600);
}

/* Live Tracking Stage Highlight */
.timeline-stage.live-tracking-stage.active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.05) 0%, transparent 100%);
  margin: -8px -12px;
  padding: 8px 12px 28px 12px;
  border-radius: var(--radius-md);
}

/* Reference Bar */
.reference-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #EFF6FF 0%, #FFF1EC 100%);
  border: 1px solid rgba(10, 132, 221, 0.15);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.ref-label {
  font-size: 12px;
  font-weight: 600;
  color: #0A84DD;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ref-value {
  font-size: 14px;
  font-weight: 700;
  color: #0B0B0B;
  font-family: 'Inter', monospace;
  letter-spacing: 0.03em;
}

/* Legacy styles for backwards compatibility */
.point-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--g2-stone-200);
  color: var(--g2-stone-600);
}

.point-status.complete {
  background: var(--g2-success-100);
  color: var(--g2-success-500);
}

/* Detail Actions */
.detail-actions {
  display: flex;
  gap: 12px;
}

.btn-secondary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: #FFFFFF;
  border: 1px solid var(--g2-stone-200);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--g2-stone-700);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--g2-stone-50);
  border-color: var(--g2-stone-300);
}

.btn-secondary svg {
  width: 18px;
  height: 18px;
}

/* ===========================================
   TOAST NOTIFICATION
   =========================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  background: var(--g2-stone-900);
  color: white;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-smooth);
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ===========================================
   RESPONSIVE STYLES
   =========================================== */

/* Large Desktop - Narrow sidebar */
@media (max-width: 1400px) {
  .tracking-sidebar {
    width: 340px;
  }
}

/* Medium Desktop */
@media (max-width: 1200px) {
  .tracking-sidebar {
    width: 300px;
  }

  .vehicle-info {
    grid-template-columns: 1fr 1fr;
  }

  .story-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .driver-chip {
    align-self: flex-end;
  }

  .eta-content {
    flex-wrap: wrap;
  }

  .eta-distance {
    margin-top: 8px;
    width: 100%;
    text-align: center;
  }
}

/* Tablet/Small Desktop */
@media (max-width: 1024px) {
  .tracking-content {
    flex-direction: column;
  }

  .tracking-sidebar {
    width: 100%;
    height: auto;
    max-height: 35vh;
    min-height: 180px;
    border-right: none;
    border-bottom: 1px solid var(--g2-stone-200);
    flex-shrink: 0;
  }

  .jobs-list {
    padding: 12px;
  }

  .job-card {
    padding: 14px;
  }

  .tracking-main {
    flex: 1;
    min-height: 0;
  }

  .map-container {
    flex: 1;
    min-height: 200px;
  }

  .details-panel {
    flex-shrink: 0;
    padding: 16px;
    overflow-y: auto;
    max-height: 40vh;
  }

  /* When map collapsed on tablet, details fills space */
  .tracking-main.map-collapsed .details-panel {
    flex: 1;
    max-height: none;
  }

  .map-section-header {
    padding: 10px 16px;
  }

  .toggle-hint {
    font-size: 11px;
  }

  .journey-timeline {
    padding-left: 0;
  }

  .timeline-stage {
    padding-left: 40px;
  }

  .stage-indicator {
    left: 0;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .tracking-sidebar {
    max-height: 30vh;
    min-height: 150px;
  }

  /* Map section header on mobile */
  .map-section-header {
    padding: 10px 16px;
  }

  .map-header-title {
    font-size: 13px;
  }

  .map-header-status {
    font-size: 10px;
    padding: 3px 8px;
  }

  .toggle-hint {
    display: none;
  }

  .map-section-header::after {
    content: none;
  }

  .panel-header {
    padding: 12px 16px;
  }

  .panel-header h2 {
    font-size: 14px;
  }

  .job-card {
    padding: 12px;
  }

  .job-card-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .job-status-badge {
    font-size: 10px;
    padding: 3px 8px;
  }

  .details-panel {
    padding: 14px;
    max-height: 45vh;
  }

  .story-header {
    padding: 12px;
    flex-direction: column;
    gap: 10px;
  }

  .vehicle-badge {
    width: 40px;
    height: 40px;
  }

  .vehicle-badge svg {
    width: 20px;
    height: 20px;
  }

  .vehicle-text h3 {
    font-size: 14px;
  }

  .driver-chip {
    padding: 6px 12px 6px 6px;
    align-self: flex-start;
  }

  .driver-avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .live-eta-banner {
    padding: 12px;
  }

  .eta-content {
    flex-wrap: wrap;
    gap: 10px;
  }

  .eta-icon {
    width: 40px;
    height: 40px;
  }

  .eta-icon svg {
    width: 20px;
    height: 20px;
  }

  .eta-duration {
    font-size: 18px;
  }

  .eta-arrival {
    font-size: 13px;
  }

  .eta-distance {
    font-size: 12px;
    padding: 4px 10px;
  }

  .current-road {
    padding: 8px 10px;
    margin-top: 10px;
  }

  .current-road .road-name {
    font-size: 12px;
  }

  .journey-story {
    padding: 14px;
  }

  .story-title h4 {
    font-size: 13px;
  }

  .stage-title {
    font-size: 12px;
  }

  .stage-description,
  .stage-address {
    font-size: 11px;
  }

  .vehicle-info {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .detail-actions {
    flex-direction: column;
    gap: 8px;
  }

  .detail-actions button {
    width: 100%;
    justify-content: center;
  }
}

/* Extra Small Mobile */
@media (max-width: 480px) {
  .tracking-sidebar {
    max-height: 25vh;
    min-height: 120px;
  }

  .job-card-route {
    display: none;
  }

  .eta-times {
    flex-direction: column;
    gap: 2px;
  }

  .eta-separator {
    display: none;
  }

  .journey-timeline {
    font-size: 11px;
  }

  .timeline-stage {
    padding-left: 35px;
    margin-bottom: 16px;
  }

  .stage-dot {
    width: 24px;
    height: 24px;
  }

  .location-letter {
    font-size: 10px;
  }
}

/* ===========================================
   DARK MODE STYLES
   =========================================== */
[data-theme="dark"] {
  --g2-stone-50: #353533;
  --g2-stone-100: #3D3D3B;
  --g2-stone-200: #454543;
  --g2-stone-300: #525250;
  --g2-stone-400: #666666;
  --g2-stone-500: #808080;
  --g2-stone-600: #B0B0B0;
  --g2-stone-700: #CCCCCC;
  --g2-stone-800: #E0E0E0;
  --g2-stone-900: #FFFFFF;
}

[data-theme="dark"] body {
  background: #2D2D2B;
  color: #FFFFFF;
}

[data-theme="dark"] .tracking-sidebar {
  background: #353533;
  border-right-color: #454543;
}

[data-theme="dark"] .panel-header {
  border-bottom-color: #454543;
}

[data-theme="dark"] .panel-header h2 {
  color: #FFFFFF;
}

[data-theme="dark"] .job-count {
  background: rgba(10, 132, 221, 0.12);
  color: #0A84DD;
}

[data-theme="dark"] .job-card {
  background: #353533;
  border-color: #454543;
}

[data-theme="dark"] .job-card:hover {
  border-color: rgba(10, 132, 221, 0.3);
}

[data-theme="dark"] .job-card.selected {
  background: rgba(10, 132, 221, 0.1);
  border-color: #0A84DD;
}

[data-theme="dark"] .vehicle-icon {
  background: #3D3D3B;
}

[data-theme="dark"] .vehicle-details h4 {
  color: #FFFFFF;
}

[data-theme="dark"] .job-card-route {
  border-top-color: #454543;
}

[data-theme="dark"] .route-point {
  color: #B0B0B0;
}

[data-theme="dark"] .job-card-footer {
  border-top-color: #454543;
}

[data-theme="dark"] .driver-preview-name {
  color: #FFFFFF;
}

[data-theme="dark"] .job-eta {
  background: #454543;
  color: #FFFFFF;
}

[data-theme="dark"] .tracking-main {
  background: #292927;
}

[data-theme="dark"] .map-overlay {
  background: rgba(18, 18, 18, 0.95);
}

[data-theme="dark"] .overlay-content svg {
  color: #0A84DD;
  opacity: 0.4;
}

[data-theme="dark"] .overlay-content h3 {
  color: #FFFFFF;
}

[data-theme="dark"] .overlay-content p {
  color: #808080;
}

[data-theme="dark"] .details-panel {
  background: #353533;
  border-top-color: #454543;
}

[data-theme="dark"] .story-header {
  background: linear-gradient(135deg, #3D3D3B 0%, rgba(10, 132, 221, 0.1) 100%);
  border-color: #454543;
}

[data-theme="dark"] .vehicle-text h3 {
  color: #FFFFFF;
}

[data-theme="dark"] .driver-chip {
  background: #3D3D3B;
  border-color: #454543;
}

[data-theme="dark"] .driver-label {
  color: #666666;
}

[data-theme="dark"] .driver-name {
  color: #FFFFFF;
}

[data-theme="dark"] .live-eta-banner {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.1) 100%);
  border-color: rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .eta-duration {
  color: #FFFFFF;
}

[data-theme="dark"] .eta-arrival {
  color: #B0B0B0;
}

[data-theme="dark"] .eta-distance {
  background: #3D3D3B;
  border-color: #454543;
  color: #B0B0B0;
}

[data-theme="dark"] .current-road {
  background: #3D3D3B;
  border-color: #454543;
}

[data-theme="dark"] .current-road .road-name {
  color: #FFFFFF;
}

[data-theme="dark"] .journey-story {
  background: #2D2D2B;
  border-color: #454543;
}

[data-theme="dark"] .story-title {
  border-bottom-color: #454543;
}

[data-theme="dark"] .story-title h4 {
  color: #FFFFFF;
}

[data-theme="dark"] .stage-title {
  color: #B0B0B0;
}

[data-theme="dark"] .timeline-stage.active .stage-title {
  color: #FFFFFF;
}

[data-theme="dark"] .stage-description,
[data-theme="dark"] .stage-address {
  color: #808080;
}

[data-theme="dark"] .stage-badge {
  background: #454543;
  color: #B0B0B0;
}

[data-theme="dark"] .eta-inline {
  background: #3D3D3B;
  border-color: #454543;
}

[data-theme="dark"] .eta-inline .eta-label {
  color: #808080;
}

[data-theme="dark"] .reference-bar {
  background: linear-gradient(135deg, rgba(10, 132, 221, 0.08) 0%, rgba(10, 132, 221, 0.03) 100%);
  border-color: rgba(10, 132, 221, 0.2);
}

[data-theme="dark"] .ref-label {
  color: #0A84DD;
}

[data-theme="dark"] .ref-value {
  color: #FFFFFF;
}

[data-theme="dark"] .btn-secondary {
  background: #3D3D3B;
  border-color: #454543;
  color: #B0B0B0;
}

[data-theme="dark"] .btn-secondary:hover {
  background: #454543;
  border-color: #525250;
  color: #FFFFFF;
}

[data-theme="dark"] .toast {
  background: #3D3D3B;
  color: #FFFFFF;
}

[data-theme="dark"] .loading-state p {
  color: #808080;
}

[data-theme="dark"] .empty-state svg {
  color: #525250;
}

[data-theme="dark"] .empty-state h3 {
  color: #FFFFFF;
}

[data-theme="dark"] .empty-state p {
  color: #808080;
}

/* ===========================================
   UPGRADE PROMPT (PAYG tracking gate)
   =========================================== */
.upgrade-prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 32px;
}

.upgrade-prompt__card {
  text-align: center;
  max-width: 440px;
}

.upgrade-prompt__icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--g2-info-500, #3B82F6), #1D4ED8);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.upgrade-prompt__title {
  font-family: var(--font-display, 'Inter', sans-serif);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--g2-stone-900, #111827);
}

.upgrade-prompt__text {
  color: var(--g2-stone-500, #6B7280);
  margin: 0 0 24px;
  line-height: 1.6;
}

.upgrade-prompt__text--small {
  font-size: 0.875rem;
}

.upgrade-prompt__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  background: var(--g2-info-500, #3B82F6);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  transition: background 0.2s;
}

.upgrade-prompt__btn:hover {
  background: #2563EB;
}

/* Dark mode */
[data-theme="dark"] .upgrade-prompt__title {
  color: #FFFFFF;
}

[data-theme="dark"] .upgrade-prompt__text {
  color: #A8A29E;
}
