/* CSS Variables */
:root {
  --primary: #1E3A8A;
  --primary-light: #3B5CC6;
  --primary-dark: #00236F;
  --secondary: #F97316;
  --secondary-light: #FB923C;
  --success: #10B981;
  --success-light: #D1FAE5;
  --error: #EF4444;
  --error-light: #FEE2E2;
  --warning: #F59E0B;
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --surface-hover: #F9FAFB;
  --border: #E5E7EB;
  --border-focus: #1E3A8A;
  --text: #374151;
  --text-dark: #121C2A;
  --text-light: #6B7280;
  --text-muted: #9CA3AF;
  --radius-sm: 0.25rem;
  --radius: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --transition: all 0.2s ease;
}

/* Reset / Normalize */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body {
  line-height: 1.5;
  font-size: 1rem;
}
a {
  text-decoration: none;
  color: inherit;
}
button, input, select, textarea {
  font-family: inherit;
}
ul, ol {
  list-style: none;
}

/* Typography */
.display-lg { font-size: 2.25rem; font-weight: 700; line-height: 1.2; color: var(--text-dark); }
.headline-md { font-size: 1.5rem; font-weight: 600; line-height: 1.3; color: var(--text-dark); }
.headline-sm { font-size: 1.25rem; font-weight: 600; line-height: 1.4; color: var(--text-dark); }
.body-lg { font-size: 1.125rem; font-weight: 400; line-height: 1.6; }
.body-md { font-size: 1rem; font-weight: 400; line-height: 1.5; }
.label-md { font-size: 0.875rem; font-weight: 500; line-height: 1.4; color: var(--text-light); }
.mono-data { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background-color: var(--primary-light); }
.btn-secondary {
  background-color: var(--secondary);
  color: white;
}
.btn-secondary:hover:not(:disabled) { background-color: var(--secondary-light); }
.btn-outline {
  background-color: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) { background-color: var(--surface-hover); }
.btn-ghost {
  background-color: transparent;
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background-color: var(--surface-hover); }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-dark);
}
.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
}

/* Cards */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}
.badge-ok {
  background-color: var(--success-light);
  color: #065F46; /* darker success text */
}
.badge-ng {
  background-color: var(--error-light);
  color: #991B1B; /* darker error text */
}
.badge-warning {
  background-color: #FEF3C7;
  color: #92400E;
}
.badge-pill {
  border-radius: var(--radius-full);
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.table th, .table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.table th {
  background-color: var(--surface-hover);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: 0.05em;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background-color: var(--surface-hover); }

/* Layout: Admin Sidebar & Collapsible Mode */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 250px;
  background: linear-gradient(180deg, #1E3A8A 0%, #172554 100%);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  box-shadow: 4px 0 15px rgba(0,0,0,0.05);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar-header {
  padding: 1.125rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  min-height: 64px;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.sidebar-toggle-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.85);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}


.sidebar-nav { flex: 1; padding: 1.25rem 0.75rem; display: flex; flex-direction: column; gap: 0.375rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: rgba(255,255,255,0.7);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.75rem;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}
.nav-item:hover {
  background-color: rgba(255,255,255,0.1);
  color: white;
}
.nav-item.active {
  background: rgba(255,255,255,0.18);
  color: white;
  font-weight: 700;
  box-shadow: inset 0 1px 0 0 rgba(255,255,255,0.2);
}
.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.avatar {
  width: 32px; height: 32px;
  background-color: var(--secondary);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.875rem; color: white;
}
.admin-main {
  flex: 1;
  margin-left: 250px;
  padding: 2rem;
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: calc(100% - 250px);
  max-width: 100%;
}

/* =========================================================
   COLLAPSED SIDEBAR STATE (MINIMIZED MODE - DESKTOP ONLY)
========================================================= */
@media (min-width: 769px) {
  html.sidebar-collapsed .admin-sidebar,
  body.sidebar-collapsed .admin-sidebar {
    width: 72px;
  }
  html.sidebar-collapsed .admin-main,
  body.sidebar-collapsed .admin-main {
    margin-left: 72px;
    width: calc(100% - 72px);
  }
  html.sidebar-collapsed .sidebar-logo,
  body.sidebar-collapsed .sidebar-logo,
  html.sidebar-collapsed .nav-item span,
  html.sidebar-collapsed .user-info,
  html.sidebar-collapsed .sidebar-footer-text,
  body.sidebar-collapsed .sidebar-logo,
  body.sidebar-collapsed .nav-item span,
  body.sidebar-collapsed .user-info,
  body.sidebar-collapsed .sidebar-footer-text {
    display: none !important;
  }
  html.sidebar-collapsed .sidebar-header,
  body.sidebar-collapsed .sidebar-header {
    padding: 1.125rem 0.5rem;
    justify-content: center !important;
  }
  html.sidebar-collapsed .nav-item,
  body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem;
  }
  html.sidebar-collapsed .sidebar-footer,
  body.sidebar-collapsed .sidebar-footer {
    padding: 0.75rem;
    align-items: center;
  }
  html.sidebar-collapsed .sidebar-footer-user,
  body.sidebar-collapsed .sidebar-footer-user {
    justify-content: center !important;
    margin-bottom: 8px !important;
  }
  html.sidebar-collapsed .logout-btn,
  body.sidebar-collapsed .logout-btn {
    justify-content: center !important;
    padding: 8px !important;
  }
}



/* 1920x1080 Resolution High-Def Optimization */
@media (min-width: 1600px) {
  .admin-main {
    padding: 2.25rem 3rem;
  }
}


/* Layout: Driver App */
.driver-layout {
  min-height: 100vh;
  background-color: var(--bg);
  position: relative;
  padding-bottom: 80px; /* Space for bottom nav */
}
.driver-header {
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 30;
}
.driver-logo {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 700; color: var(--primary); font-size: 1.125rem;
}
.driver-content { padding: 1rem; }
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #FFFFFF;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0 12px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    border-top: 1px solid #E5E7EB;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 20px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    color: #9CA3AF;
    transition: all 0.25s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item svg {
    transition: all 0.25s ease;
}

.bottom-nav-item:active {
    transform: scale(0.92);
}

.bottom-nav-item.active {
    color: #F97316;
    background: rgba(249, 115, 22, 0.08);
    font-weight: 600;
}

.bottom-nav-item.active svg {
    stroke: #F97316;
    transform: translateY(-2px);
}

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: #F97316;
    border-radius: 0 0 4px 4px;
}

.bottom-nav-item:not(.active):hover {
    color: #374151;
    background: rgba(0, 0, 0, 0.04);
}

.bottom-nav-item:not(.active):hover svg {
    stroke: #374151;
}

/* Stats Cards */
.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
}
.stat-icon.primary { background-color: rgba(30, 58, 138, 0.1); color: var(--primary); }
.stat-icon.secondary { background-color: rgba(249, 115, 22, 0.1); color: var(--secondary); }
.stat-icon.success { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-info .stat-label { font-size: 0.875rem; color: var(--text-light); }
.stat-info .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text-dark); margin-top: 0.25rem; }

/* Utilities */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-4 { padding: 1rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }

@media (max-width: 768px) {
  .admin-layout {
    flex-direction: column !important;
  }
  .admin-sidebar {
    display: none !important;
  }
  .admin-main {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 1rem 0.75rem !important;
    min-height: calc(100vh - 56px);
  }
  .admin-main .card {
    padding: 1rem !important;
    border-radius: 0.75rem !important;
  }
  .admin-action-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }
  .admin-search-wrapper {
    width: 100% !important;
    max-width: 100% !important;
  }
  .admin-add-btn {
    width: 100% !important;
    justify-content: center !important;
  }
  .admin-main .grid-cols-2,
  .admin-main .grid-cols-3,
  .admin-main .grid-cols-4 {
    grid-template-columns: 1fr !important;
  }
  .admin-main .table-responsive {
    border-radius: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ==========================================================================
   Cross-Browser Form Control Normalization (Safari / Chrome / Firefox / Edge)
   ========================================================================== */
select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-color: #ffffff !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 14px 14px !important;
  padding-left: 16px !important;
  padding-right: 36px !important;
  border: 1px solid #D1D5DB !important;
  border-radius: 8px !important;
  height: 38px !important;
  font-size: 13px !important;
  color: #374151 !important;
  outline: none !important;
  box-sizing: border-box !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

select:focus {
  border-color: #1E3A8A !important;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12) !important;
}

input[type="month"], input[type="date"] {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-color: #ffffff !important;
  border: 1px solid #D1D5DB !important;
  border-radius: 8px !important;
  height: 38px !important;
  padding: 8px 16px !important;
  font-size: 13px !important;
  color: #374151 !important;
  outline: none !important;
  box-sizing: border-box !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

input[type="month"]:focus, input[type="date"]:focus {
  border-color: #1E3A8A !important;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12) !important;
}

/* Remove native Safari & Chrome number input steppers for flat UI */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}
input[type="number"] {
  -moz-appearance: textfield !important;
}

/* ==========================================================================
   Filter Bar Alignment & Mobile Responsiveness
   ========================================================================== */
.admin-filter-bar {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  flex-wrap: wrap !important;
  background: #ffffff !important;
  border: 1px solid #E5E7EB !important;
  border-radius: 10px !important;
  padding: 12px 16px !important;
  margin-bottom: 20px !important;
}

.admin-filter-bar-range {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
}

@media (max-width: 768px) {
  .admin-filter-bar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 14px !important;
    padding: 18px 16px !important;
  }
  .admin-filter-bar > div {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    flex: none !important;
  }
  .admin-filter-bar-btn {
    width: 100% !important;
    margin-left: 0 !important;
    margin-top: 6px !important;
  }
  .admin-filter-bar-btn a {
    width: 100% !important;
    height: 38px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    box-sizing: border-box !important;
  }
}

/* ==========================================================================
   Responsive Tables & Header Wrappers
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
}

.flex-header-responsive {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .flex-header-responsive {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .flex-header-responsive > div {
    width: 100% !important;
  }
  .flex-header-responsive button, 
  .flex-header-responsive a.btn {
    width: 100% !important;
    justify-content: center !important;
  }
  .admin-action-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  .admin-search-wrapper {
    width: 100% !important;
  }
  .admin-add-btn {
    width: 100% !important;
    justify-content: center !important;
  }
}



