/* ==========================================================================
   TraceTrack - Driver Portal Mobile-First Stylesheet (Phase 6 Driver Frontend)
   Clean, Glassmorphism-aligned, High-contrast, Touch-friendly (>=48px targets)
   ========================================================================== */

.driver-portal-wrapper {
  max-width: 768px;
  margin: 0 auto;
  padding: 12px 12px 90px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   1. Driver Header Card
   ========================================================================== */
.driver-header-card {
  background: var(--glass-surface, rgba(255, 255, 255, 0.85));
  backdrop-filter: var(--glass-blur, blur(16px));
  -webkit-backdrop-filter: var(--glass-blur, blur(16px));
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: var(--radius-lg, 18px);
  padding: 16px;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.driver-profile-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.driver-avatar-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ea580c, #c2410c);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.35);
  flex-shrink: 0;
}

.driver-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.driver-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--navy-900, #0f172a);
  line-height: 1.2;
}

.driver-meta {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--navy-500, #64748b);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.driver-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.driver-status-pill.available {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.driver-status-pill.busy {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.driver-sync-btn {
  min-height: 48px;
  min-width: 48px;
  padding: 8px 14px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  color: #2563eb;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.driver-sync-btn:hover, .driver-sync-btn:active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

/* ==========================================================================
   2. Metric Summary Cards Grid
   ========================================================================== */
.driver-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 480px) {
  .driver-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.driver-metric-card {
  background: var(--glass-surface, rgba(255, 255, 255, 0.85));
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: var(--radius-md, 14px);
  padding: 12px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
}

.driver-metric-card:active {
  transform: scale(0.97);
}

.driver-metric-val {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
}

.driver-metric-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--navy-500, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.driver-metric-card.assigned { border-left: 4px solid #f59e0b; }
.driver-metric-card.assigned .driver-metric-val { color: #d97706; }

.driver-metric-card.in-progress { border-left: 4px solid #2563eb; }
.driver-metric-card.in-progress .driver-metric-val { color: #2563eb; }

.driver-metric-card.completed { border-left: 4px solid #10b981; }
.driver-metric-card.completed .driver-metric-val { color: #059669; }

.driver-metric-card.failed { border-left: 4px solid #ef4444; }
.driver-metric-card.failed .driver-metric-val { color: #dc2626; }

/* ==========================================================================
   3. Segmented Navigation Tabs (Pills)
   ========================================================================== */
.driver-tab-nav {
  display: flex;
  background: rgba(226, 232, 240, 0.65);
  padding: 4px;
  border-radius: 14px;
  gap: 4px;
}

.driver-tab-btn {
  flex: 1;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--navy-600, #475569);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.driver-tab-btn.active {
  background: #ffffff;
  color: #1e40af;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

/* ==========================================================================
   4. Search & Filter Bar
   ========================================================================== */
.driver-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.driver-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.driver-search-wrap svg {
  position: absolute;
  left: 14px;
  color: var(--navy-400, #94a3b8);
  pointer-events: none;
}

.driver-search-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px 10px 42px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  color: var(--navy-900, #0f172a);
  outline: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.driver-search-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.driver-chips-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.driver-chips-row::-webkit-scrollbar {
  display: none;
}

.driver-filter-chip {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--navy-600, #475569);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  touch-action: manipulation;
  transition: all 0.15s ease;
}

.driver-filter-chip.active {
  background: #1e40af;
  color: #ffffff;
  border-color: #1e40af;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.25);
}

/* ==========================================================================
   5. Hero Active Task Card (Dashboard)
   ========================================================================== */
.driver-hero-task {
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
  border-radius: var(--radius-lg, 18px);
  padding: 20px;
  color: #ffffff;
  box-shadow: 0 8px 30px -4px rgba(30, 58, 138, 0.35);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.driver-hero-task::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.driver-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.driver-hero-title {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.25;
  margin: 0;
}

.driver-hero-locations {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.driver-hero-loc-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.85rem;
}

.driver-hero-loc-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.driver-hero-loc-dot.pickup { background: #38bdf8; box-shadow: 0 0 8px #38bdf8; }
.driver-hero-loc-dot.delivery { background: #4ade80; box-shadow: 0 0 8px #4ade80; }

.driver-hero-btn {
  min-height: 52px;
  border-radius: 14px;
  border: none;
  background: #ffffff;
  color: #1e3a8a;
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  touch-action: manipulation;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.driver-hero-btn:active {
  transform: scale(0.98);
}

/* ==========================================================================
   6. Task Cards List & Items
   ========================================================================== */
.driver-task-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.driver-task-card {
  background: var(--glass-surface, rgba(255, 255, 255, 0.9));
  border: 1.5px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius-md, 16px);
  padding: 16px;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.driver-task-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.08);
}

.driver-task-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
}

.driver-task-id-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.driver-task-number {
  font-family: var(--font-mono, monospace);
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--navy-900, #0f172a);
}

.driver-type-pill {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 5px;
}

.driver-type-pill.pickup {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.driver-type-pill.delivery {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.driver-type-pill.linehaul {
  background: #faf5ff;
  color: #7e22ce;
  border: 1px solid #f3e8ff;
}

.driver-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

/* Status variants */
.driver-status-badge.assigned { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.driver-status-badge.in_progress { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.driver-status-badge.arrived_pickup { background: #cffafe; color: #0e7490; border: 1px solid #a5f3fc; }
.driver-status-badge.pickup_confirmed { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.driver-status-badge.out_for_delivery { background: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; }
.driver-status-badge.arrived { background: #fef08a; color: #854d0e; border: 1px solid #fde047; }
.driver-status-badge.delivery_confirmed { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.driver-status-badge.delivery_failed { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.driver-status-badge.reattempt_scheduled { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.driver-status-badge.return_initiated { background: #fce7f3; color: #be185d; border: 1px solid #fbcfe8; }

.driver-task-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.driver-awb-line {
  font-size: 0.82rem;
  color: var(--navy-500, #64748b);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.driver-awb-val {
  font-family: var(--font-mono, monospace);
  font-weight: 700;
  color: #1d4ed8;
}

.driver-address-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px;
  border: 1px solid #e2e8f0;
}

.driver-address-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.84rem;
  line-height: 1.35;
}

.driver-address-icon {
  flex-shrink: 0;
  margin-top: 2px;
}

.driver-address-text {
  color: var(--navy-800, #1e293b);
  font-weight: 500;
  flex: 1;
}

.driver-package-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--navy-600, #475569);
  padding: 4px 2px;
}

.driver-package-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.driver-task-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

/* Action Buttons (Strict min-height 48px touch targets) */
.btn-driver-action {
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
  transition: all 0.15s ease;
  flex: 1;
}

.btn-driver-action:active {
  transform: scale(0.97);
}

.btn-driver-action.btn-start {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-driver-action.btn-arrived {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
}

.btn-driver-action.btn-pickup {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.btn-driver-action.btn-delivery {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-driver-action.btn-pod {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.3);
}

.btn-driver-action.btn-fail {
  background: #ffffff;
  color: #dc2626;
  border: 1.5px solid #f87171;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.1);
  flex: 0 0 auto;
  min-width: 130px;
}

.btn-driver-action.btn-detail {
  background: #f1f5f9;
  color: var(--navy-700, #334155);
  border: 1px solid #cbd5e1;
  flex: 0 0 48px;
  padding: 0;
}

.btn-driver-action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* ==========================================================================
   7. Slide-Over & Modal Dialogs
   ========================================================================== */
.driver-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: driverFadeIn 0.2s ease;
}

@media (min-width: 640px) {
  .driver-modal-overlay {
    align-items: center;
    padding: 20px;
  }
}

.driver-modal-container {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  background: #ffffff;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: driverSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 640px) {
  .driver-modal-container {
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    max-height: 85vh;
  }
}

.driver-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.driver-modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--navy-900, #0f172a);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.driver-modal-close-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--navy-600, #475569);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.driver-modal-body {
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.driver-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  gap: 10px;
}

/* ==========================================================================
   8. Form Controls (POD & Fail Modal)
   ========================================================================== */
.driver-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.driver-form-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--navy-800, #1e293b);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.driver-form-label .req {
  color: #ef4444;
}

.driver-input,
.driver-select,
.driver-textarea {
  min-height: 48px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: var(--navy-900, #0f172a);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
}

.driver-textarea {
  min-height: 80px;
  resize: vertical;
}

.driver-input:focus,
.driver-select:focus,
.driver-textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Verification Method Segmented Selector */
.driver-verify-methods {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

@media (max-width: 480px) {
  .driver-verify-methods {
    grid-template-columns: repeat(2, 1fr);
  }
}

.driver-verify-btn {
  min-height: 48px;
  padding: 8px 6px;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: var(--navy-700, #334155);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  touch-action: manipulation;
  transition: all 0.15s ease;
}

.driver-verify-btn.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

/* Canvas Signature Pad */
.driver-signature-box {
  border: 1.5px dashed #94a3b8;
  border-radius: 14px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.driver-sig-canvas {
  width: 100%;
  height: 180px;
  touch-action: none; /* Prevents scroll while drawing */
  background: #ffffff;
  cursor: crosshair;
}

.driver-sig-toolbar {
  padding: 8px 12px;
  background: #f1f5f9;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--navy-500, #64748b);
}

.btn-sig-clear {
  padding: 6px 12px;
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #dc2626;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

/* GPS Badge */
.driver-gps-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  font-size: 0.78rem;
  color: #15803d;
  font-family: var(--font-mono, monospace);
  font-weight: 600;
}

/* ==========================================================================
   9. Empty & Loading States
   ========================================================================== */
.driver-empty-state {
  padding: 48px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #ffffff;
  border: 1.5px dashed #cbd5e1;
  border-radius: 16px;
  color: var(--navy-500, #64748b);
}

.driver-empty-state svg {
  color: var(--navy-400, #94a3b8);
}

.driver-empty-state h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--navy-800, #1e293b);
  margin: 0;
}

.driver-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: driverSpin 0.6s linear infinite;
  display: inline-block;
}

/* Keyframes */
@keyframes driverFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes driverSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes driverSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
