/* ============================================
   Container Dispatch Management System
   Design System - Global Styles
   ============================================ */

:root {
  /* Colors */
  --primary: #000000;
  --primary-container: #131b2e;
  --on-primary: #ffffff;
  --on-primary-container: #7c839b;
  --secondary: #505f76;
  --secondary-container: #d0e1fb;
  --on-secondary: #ffffff;
  --on-secondary-container: #54647a;
  --surface: #f7f9fb;
  --surface-dim: #d8dadc;
  --surface-bright: #f7f9fb;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f2f4f6;
  --surface-container: #eceef0;
  --surface-container-high: #e6e8ea;
  --surface-container-highest: #e0e3e5;
  --on-surface: #191c1e;
  --on-surface-variant: #45464d;
  --outline: #76777d;
  --outline-variant: #c6c6cd;
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --on-error: #ffffff;

  /* Status Colors */
  --status-active: #1a7f4b;
  --status-active-bg: #d4f0e2;
  --status-pending: #b45309;
  --status-pending-bg: #fef3c7;
  --status-transit: #1d4ed8;
  --status-transit-bg: #dbeafe;
  --status-completed: #374151;
  --status-completed-bg: #f3f4f6;
  --status-danger: #ba1a1a;
  --status-danger-bg: #ffdad6;

  /* Typography */
  --font-headline: 'Roboto', sans-serif;
  --font-body: 'Roboto', sans-serif;

  /* Spacing */
  --xs: 4px;
  --sm: 8px;
  --md: 16px;
  --lg: 24px;
  --xl: 32px;

  /* Radius */
  --radius-sm: 2px;
  --radius: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: rgba(255,255,255,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--on-surface);
  font-size: 16px;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }

/* ============ LAYOUT ============ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: var(--lg) var(--md);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--sm);
}

.sidebar-logo .logo-icon svg { color: white; }

.sidebar-logo h1 {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
}

.sidebar-logo p {
  font-size: 11px;
  color: var(--sidebar-text);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--md) 0;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #475569;
  padding: var(--sm) var(--md);
  margin-top: var(--sm);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sm);
  padding: 10px var(--md);
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 0;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #ffffff;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: #3b82f6;
  border-radius: 0 2px 2px 0;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Nav Group (Expandable Menu) */
.nav-group {
  margin: 2px 0;
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px var(--md);
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-group-header:hover {
  background: rgba(255,255,255,0.06);
  color: #ffffff;
}

.nav-group.active .nav-group-header {
  color: #ffffff;
}

.nav-group-arrow {
  transition: transform 0.2s;
  opacity: 0.6;
}

.nav-group.expanded .nav-group-arrow {
  transform: rotate(180deg);
}

.nav-group-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.nav-group.expanded .nav-group-content {
  max-height: 500px;
}

.nav-subitem {
  padding-left: 48px !important;
  font-size: 12px !important;
}

.nav-subitem::before {
  display: none !important;
}

.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--md);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--sm);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
  flex-shrink: 0;
}

.user-name { font-size: 12px; font-weight: 600; color: #e2e8f0; }
.user-role { font-size: 11px; color: var(--sidebar-text); }

/* ============ MAIN CONTENT ============ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============ TOPBAR ============ */
.topbar {
  background: var(--surface-container-lowest);
  border-bottom: 1px solid var(--outline-variant);
  padding: 0 var(--lg);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: var(--md);
}

.topbar-left { 
  display: flex; 
  align-items: center; 
  gap: var(--md);
  flex: 1;
  min-width: 0; /* Allow text truncation */
}

.topbar-title { 
  font-size: 16px; 
  font-weight: 600; 
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-subtitle { 
  font-size: 12px; 
  color: var(--on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right { 
  display: flex; 
  align-items: center; 
  gap: var(--sm);
  flex-shrink: 0;
}

.topbar-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-lg);
  border: none;
  background: var(--surface-container-low);
  color: var(--on-surface-variant);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}

.topbar-btn:hover { background: var(--surface-container); }
.topbar-btn svg { width: 18px; height: 18px; }

/* ============ PAGE CONTENT ============ */
.page-content {
  padding: var(--lg);
  flex: 1;
}

/* ============ STATS GRID ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--md);
  margin-bottom: var(--lg);
}

.stat-card {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  padding: var(--md);
  border: 1px solid var(--outline-variant);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sm);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--on-surface-variant);
}

.stat-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
}

.stat-icon svg { width: 16px; height: 16px; }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--on-surface);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-change {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up { color: var(--status-active); }
.stat-change.down { color: var(--status-danger); }

/* ============ CARD ============ */
.card {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  border: 1px solid var(--outline-variant);
  overflow: hidden;
}

.card-header {
  padding: var(--md) var(--lg);
  border-bottom: 1px solid var(--outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--on-surface);
}

.card-subtitle {
  font-size: 12px;
  color: var(--on-surface-variant);
  margin-top: 2px;
}

.card-body { padding: var(--md) var(--lg); }

/* ============ TABLE ============ */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

thead th {
  background: var(--surface-container-high);
  padding: 10px var(--md);
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--on-surface-variant);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--outline-variant);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-container-low); }

tbody td {
  padding: 10px var(--md);
  color: var(--on-surface);
  vertical-align: middle;
}

.td-mono {
  font-family: 'Roboto', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-container);
}

/* ============ BADGE / STATUS ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}

.badge-active { background: var(--status-active-bg); color: var(--status-active); }
.badge-active .badge-dot { background: var(--status-active); }

.badge-pending { background: var(--status-pending-bg); color: var(--status-pending); }
.badge-pending .badge-dot { background: var(--status-pending); }

.badge-transit { background: var(--status-transit-bg); color: var(--status-transit); }
.badge-transit .badge-dot { background: var(--status-transit); }

.badge-completed { background: var(--status-completed-bg); color: var(--status-completed); }
.badge-completed .badge-dot { background: var(--status-completed); }

.badge-danger { background: var(--status-danger-bg); color: var(--status-danger); }
.badge-danger .badge-dot { background: var(--status-danger); }

/* Badge cho loại công việc - màu sắc rõ ràng và khác biệt */
.badge-export { 
  background: #ffedd5; 
  color: #ea580c; 
  font-weight: 600;
}
.badge-export .badge-dot { background: #ea580c; }

.badge-import { 
  background: #d1fae5; 
  color: #059669; 
  font-weight: 600;
}
.badge-import .badge-dot { background: #059669; }

.badge-transfer { 
  background: #e0e7ff; 
  color: #6366f1; 
  font-weight: 600;
}
.badge-transfer .badge-dot { background: #6366f1; }

.badge-warning { 
  background: #fef3c7; 
  color: #d97706; 
  font-weight: 600;
}
.badge-warning .badge-dot { background: #d97706; }

.badge-error { 
  background: #fee2e2; 
  color: #dc2626; 
  font-weight: 600;
}
.badge-error .badge-dot { background: #dc2626; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sm);
  padding: 8px var(--md);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary-container);
  color: var(--on-primary);
}
.btn-primary:hover { background: #1e2a42; }

.btn-secondary {
  background: var(--surface-container-high);
  color: var(--on-surface);
  border: 1px solid var(--outline-variant);
}
/* .btn-secondary:hover { background: var(--surface-container-highest); } */

.btn-ghost {
  background: transparent;
  color: var(--on-surface-variant);
}
.btn-ghost:hover { background: var(--surface-container-low); }

.btn-danger {
  background: var(--error-container);
  color: var(--error);
}
.btn-danger:hover { background: #ffc9c5; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ============ FORM ============ */
.form-group { margin-bottom: var(--md); }

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--on-surface-variant);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px var(--md);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--on-surface);
  background: var(--surface-container-lowest);
  outline: none;
  transition: border-color 0.15s;
  font-family: var(--font-body);
}

.form-control:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-control::placeholder { color: var(--outline); }

select.form-control { cursor: pointer; }

/* ============ SEARCH ============ */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 10px;
  width: 15px; height: 15px;
  color: var(--outline);
  pointer-events: none;
}

.search-box input {
  padding-left: 34px;
  width: 240px;
}

/* ============ FILTER BAR ============ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sm);
  padding: var(--md) var(--lg);
  border-bottom: 1px solid var(--outline-variant);
  flex-wrap: wrap;
}

/* ============ PROGRESS BAR ============ */
.progress-bar {
  height: 6px;
  background: var(--surface-container-high);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
}

/* ============ AVATAR ============ */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-container-high);
  padding: 3px;
  border-radius: var(--radius-lg);
  width: fit-content;
}

.tab {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--on-surface-variant);
  transition: all 0.15s;
  border: none;
  background: transparent;
}

.tab.active {
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  transform: translateY(10px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: var(--lg);
  border-bottom: 1px solid var(--outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: var(--lg); }
.modal-footer {
  padding: var(--md) var(--lg);
  border-top: 1px solid var(--outline-variant);
  display: flex;
  justify-content: flex-end;
  gap: var(--sm);
}

/* ============ TOAST ============ */
.toast-container {
  position: fixed;
  bottom: var(--lg);
  right: var(--lg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--sm);
}

.toast {
  background: var(--primary-container);
  color: white;
  padding: var(--sm) var(--md);
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  gap: var(--sm);
  animation: slideIn 0.3s ease;
}

.toast.success { background: var(--status-active); }
.toast.error { background: var(--error); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============ CHART PLACEHOLDER ============ */
.chart-area {
  height: 200px;
  background: var(--surface-container-low);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: var(--md);
  overflow: hidden;
}

.chart-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  opacity: 0.8;
  transition: opacity 0.15s;
  cursor: pointer;
}

.chart-bar:hover { opacity: 1; }

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: var(--xl) var(--lg);
  color: var(--on-surface-variant);
}

.empty-state svg {
  width: 48px; height: 48px;
  margin-bottom: var(--md);
  opacity: 0.4;
}

/* ============ GRID LAYOUTS ============ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--md); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--md); }
.grid-cols-3-1 { display: grid; grid-template-columns: 3fr 1fr; gap: var(--md); }
.grid-cols-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--md); }

/* ============ UTILITIES ============ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--sm); }
.gap-md { gap: var(--md); }
.mt-sm { margin-top: var(--sm); }
.mt-md { margin-top: var(--md); }
.mt-lg { margin-top: var(--lg); }
.mb-md { margin-bottom: var(--md); }
.mb-lg { margin-bottom: var(--lg); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--on-surface-variant); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--outline-variant); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--outline); }

/* ============ RESPONSIVE ============ */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3-1 { grid-template-columns: 1fr; }
  .grid-cols-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ============================================
   RESPONSIVE ENHANCEMENTS FOR ADMIN PAGES
   Mobile-first approach for all management pages
   ============================================ */

/* Tablet & Small Desktop (768px - 1024px) */
@media (max-width: 1024px) {
  /* Topbar adjustments */
  .topbar {
    padding: 0 var(--md);
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
  }

  .topbar-left {
    flex: 1;
    min-width: 200px;
  }

  .topbar-right {
    flex-wrap: wrap;
    gap: 6px;
  }

  .topbar-title {
    font-size: 15px;
  }

  .topbar-subtitle {
    font-size: 11px;
  }

  /* Button adjustments */
  .btn {
    padding: 7px 12px;
    font-size: 12px;
  }

  .btn-sm {
    padding: 4px 8px;
    font-size: 11px;
  }

  /* Hide button text on smaller screens, keep icons */
  .btn svg {
    width: 14px;
    height: 14px;
  }

  /* Table adjustments */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 800px;
    font-size: 12px;
  }

  thead th {
    padding: 8px 10px;
    font-size: 10px;
  }

  tbody td {
    padding: 8px 10px;
  }

  /* Filter bar */
  .filter-bar {
    padding: var(--sm) var(--md);
    gap: 6px;
  }

  .search-box input {
    width: 180px;
  }

  /* Stats grid */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-value {
    font-size: 24px;
  }

  /* Card adjustments */
  .card-header {
    padding: var(--sm) var(--md);
  }

  .card-body {
    padding: var(--sm) var(--md);
  }

  /* Modal adjustments */
  .modal {
    max-width: 90%;
  }

  .modal-body {
    padding: var(--md);
  }

  /* Grid layouts */
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
  /* Sidebar - Hidden by default, show with toggle */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Main content takes full width */
  .main-content {
    margin-left: 0;
    width: 100%;
  }

  /* Topbar mobile */
  .topbar {
    padding: 8px 12px;
    height: auto;
    min-height: 50px;
  }

  .topbar-left {
    width: auto;
    flex: 1;
    min-width: 0;
  }

  .topbar-title {
    font-size: 14px;
  }

  .topbar-subtitle {
    display: none; /* Hide subtitle on mobile */
  }

  .topbar-right {
    width: 100vw;
    flex-shrink: 0;
  }

  /* Hide button text, show only icons on mobile */
  .btn:not(.btn-icon) span {
    /* display: none; */
  }

  .btn:not(.btn-icon) {
    padding: 8px;
  }

  .btn svg {
    margin: 0;
  }

  /* Page content */
  .page-content {
    padding: 12px;
  }

  /* Stats grid - 2 columns on mobile */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }

  .stat-card {
    padding: 10px;
  }

  .stat-label {
    font-size: 10px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-change {
    font-size: 10px;
  }

  /* Card */
  .card {
    margin-bottom: 12px;
  }

  .card-header {
    padding: 10px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .card-title {
    font-size: 13px;
  }

  .card-body {
    padding: 10px 12px;
  }

  /* Table - Horizontal scroll */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px; /* Extend to edges */
    padding: 0 12px;
  }

  table {
    min-width: 700px;
    font-size: 11px;
  }

  thead th {
    padding: 6px 8px;
    font-size: 9px;
    position: sticky;
    top: 0;
    background: var(--surface-container-high);
    z-index: 10;
  }

  tbody td {
    padding: 6px 8px;
  }

  /* Action buttons in table */
  tbody td .btn {
    padding: 4px;
  }

  tbody td .btn svg {
    width: 12px;
    height: 12px;
  }

  /* Filter bar */
  .filter-bar {
    padding: 8px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .search-box {
    width: 100%;
  }

  .search-box input {
    width: 100%;
  }

  .filter-bar select.form-control {
    width: 100%;
  }

  .filter-bar .btn {
    width: 100%;
    justify-content: center;
  }

  /* Form */
  .form-group {
    margin-bottom: 12px;
  }

  .form-label {
    font-size: 11px;
  }

  .form-control {
    padding: 8px 12px;
    font-size: 12px;
  }

  /* Grid layouts - All single column on mobile */
  .grid-2,
  .grid-3,
  .grid-cols-2-1,
  .grid-cols-3-1 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Modal */
  .modal-overlay {
    padding: 12px;
    align-items: flex-end; /* Bottom sheet style */
  }

  .modal {
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .modal-header {
    padding: 12px 16px;
  }

  .modal-title {
    font-size: 14px;
  }

  .modal-body {
    padding: 12px 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }

  /* Badge */
  .badge {
    font-size: 14px;
    padding: 2px 6px;
  }

  /* Toast */
  .toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    font-size: 12px;
    padding: 8px 12px;
  }

  /* Avatar */
  .avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  /* User info in table */
  .user-info {
    gap: 6px;
  }

  .user-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  .user-name {
    font-size: 11px;
  }

  .user-role {
    font-size: 10px;
  }

  /* Tabs */
  .tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    font-size: 11px;
    padding: 5px 12px;
    white-space: nowrap;
  }

  /* Progress bar */
  .progress-bar {
    height: 4px;
  }

  /* Chart */
  .chart-area {
    height: 150px;
    padding: 8px;
  }
}

/* Extra Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
  /* Stats grid - Single column for very small screens */
  .stats-grid {
    grid-template-columns: 1fr;
  }

  /* Topbar */
  .topbar {
    padding: 6px 10px;
  }

  .topbar-title {
    font-size: 13px;
  }

  /* Page content */
  .page-content {
    padding: 10px;
  }

  /* Card */
  .card-header {
    padding: 8px 10px;
  }

  .card-body {
    padding: 8px 10px;
  }

  /* Table */
  table {
    min-width: 600px;
    font-size: 10px;
  }

  thead th {
    padding: 5px 6px;
    font-size: 8px;
  }

  tbody td {
    padding: 5px 6px;
  }

  /* Modal */
  .modal-header {
    padding: 10px 12px;
  }

  .modal-title {
    font-size: 13px;
  }

  .modal-body {
    padding: 10px 12px;
  }

  .modal-footer {
    padding: 10px 12px;
  }

  /* Form */
  .form-control {
    padding: 7px 10px;
    font-size: 11px;
  }

  /* Buttons */
  .btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .btn-sm {
    padding: 4px 6px;
    font-size: 10px;
  }
}

/* Landscape Mobile (max-height: 500px) */
@media (max-height: 500px) and (orientation: landscape) {
  .modal {
    max-height: 85vh;
  }

  .modal-body {
    max-height: 60vh;
    overflow-y: auto;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Print styles */
@media print {
  .sidebar,
  .topbar,
  .btn,
  .modal-overlay,
  .toast-container {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
  }

  .page-content {
    padding: 0;
  }

  .card {
    border: 1px solid #000;
    page-break-inside: avoid;
  }

  table {
    page-break-inside: auto;
  }

  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
}

/* ============================================
   SPECIFIC PAGE RESPONSIVE FIXES
   ============================================ */

/* Productions page specific */
@media (max-width: 768px) {
  .prod-wrap {
    padding: 12px;
  }

  .prod-title {
    font-size: 18px;
  }

  .prod-sub {
    font-size: 12px;
    margin-bottom: 12px;
  }

  .list-note {
    font-size: 11px;
  }

  /* Productions form grid */
  .prod-wrap .grid {
    gap: 8px;
  }

  .prod-wrap .col-3,
  .prod-wrap .col-4,
  .prod-wrap .col-6 {
    grid-column: span 12;
  }

  .prod-wrap .field label {
    font-size: 12px;
  }

  .prod-wrap .field input,
  .prod-wrap .field select {
    padding: 8px;
    font-size: 12px;
  }

  /* Select2 mobile adjustments */
  .select2-container--default .select2-selection--single {
    height: 38px;
  }

  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px;
    font-size: 12px;
  }
}

/* Container page specific */
@media (max-width: 768px) {
  /* Container stats */
  .stats-grid[style*="grid-template-columns:repeat(auto-fit"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* Users page specific */
@media (max-width: 768px) {
  /* User management buttons */
  .topbar-right button[onclick*="Modal"] span {
    display: none;
  }

  /* User table - Show essential columns only */
  tbody td:nth-child(5), /* Phòng ban */
  tbody td:nth-child(7)  /* Đăng nhập lần cuối */ {
    display: none;
  }

  thead th:nth-child(5),
  thead th:nth-child(7) {
    display: none;
  }
}

/* Driver page specific */
@media (max-width: 768px) {
  /* Driver stats */
  .stat-card .stat-change {
    font-size: 10px;
  }

  /* Active tasks sidebar */
  .grid-cols-2-1 {
    grid-template-columns: 1fr;
  }

  /* Task list */
  #taskList > div {
    padding: 10px;
  }

  /* Driver table - Hide less important columns */
  tbody td:nth-child(5), /* Vị trí */
  tbody td:nth-child(6)  /* Chuyến */ {
    display: none;
  }

  thead th:nth-child(5),
  thead th:nth-child(6) {
    display: none;
  }
}

/* Vehicles page specific */
@media (max-width: 768px) {
  /* Vehicle table - Hide ghi chú column on mobile */
  tbody td:nth-child(4) { /* Ghi chú */
    display: none;
  }

  thead th:nth-child(4) {
    display: none;
  }
}

/* ============================================
   MOBILE MENU TOGGLE
   ============================================ */
.mobile-menu-toggle {
  display: none !important;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--surface-container-low);
  color: var(--on-surface);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-md);
  margin-right: 8px;
  flex-shrink: 0;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.mobile-menu-toggle:hover {
  background: var(--surface-container);
  transform: scale(1.05);
}

.mobile-menu-toggle:active {
  transform: scale(0.95);
}

.mobile-menu-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

/* Rotate icon when sidebar is open */
.mobile-menu-toggle.active svg {
  transform: rotate(90deg);
}

/* Ripple effect */
.mobile-menu-toggle::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: scale(0);
  opacity: 0;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.mobile-menu-toggle:active::after {
  transform: scale(2);
  opacity: 1;
  transition: transform 0s, opacity 0s;
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Add overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
  }

  .sidebar-overlay.active {
    display: block;
    opacity: 1;
  }

  /* Sidebar adjustments for mobile */
  .sidebar {
    z-index: 150;
    box-shadow: 2px 0 20px rgba(0,0,0,0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Slide in animation */
  @keyframes slideIn {
    from {
      transform: translateX(-100%);
      opacity: 0.8;
    }
    to {
      transform: translateX(0);
      opacity: 1;
    }
  }

  .sidebar.open {
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Touch target size for mobile */
@media (max-width: 768px) {
  button,
  a,
  input,
  select,
  textarea {
    min-height: 44px; /* iOS recommended touch target */
  }

  .btn-icon {
    min-width: 44px;
    min-height: 44px;
  }
}
