/* =========================================================
   Smart Transport Management System - Main Design System
   Modern, Sleek, Responsive CSS with Glassmorphism & High Usability
   ========================================================= */

:root {
  /* Color Palette */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --primary-dark: #3730a3;
  
  --secondary: #0ea5e9;
  --secondary-hover: #0284c7;
  
  --success: #10b981;
  --success-bg: #d1fae5;
  --success-text: #065f46;

  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;

  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;

  --whatsapp: #25d366;
  --whatsapp-hover: #1ebd58;

  --dark-bg: #0f172a;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #818cf8;

  /* Elevation Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Layout dimensions */
  --sidebar-width: 270px;
  --header-height: 70px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100vw !important;
  margin: 0 !important;
  padding: 0 !important;
}

body {
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100vw !important;
  margin: 0 !important;
  padding: 0 !important;
  position: relative;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

/* =========================================================
   Layout: App Shell (Sidebar + Main Content Area)
   ========================================================= */

.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100% !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
  position: relative;
  box-sizing: border-box;
}

/* Sidebar Styling */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #ffffff;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.brand-logo-img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  object-fit: contain;
  background: #ffffff;
  padding: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.brand-logo:hover .brand-logo-img {
  transform: scale(1.05);
}

.brand-img-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin: 0 auto 0.85rem auto;
  display: block;
  border-radius: 20px;
  background: #ffffff;
  padding: 5px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  border: 1px solid #e2e8f0;
}

.close-sidebar-btn {
  display: none;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.2rem;
  cursor: pointer;
}

.sidebar-menu-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.sidebar-menu-wrapper::-webkit-scrollbar {
  width: 4px;
}
.sidebar-menu-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.sidebar-category {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0.75rem 0.75rem 0.25rem 0.75rem;
  font-weight: 700;
}

.nav-item {
  margin-bottom: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  color: var(--sidebar-text);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.92rem;
  transition: var(--transition);
}

.nav-link i {
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
  transition: transform 0.2s;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #f1f5f9;
  transform: translateX(3px);
}

.nav-link.active {
  background: linear-gradient(135deg, var(--primary), #4338ca);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.nav-link.active i {
  color: #ffffff;
}

/* Sidebar Dropdown Button & Submenu Styling */
button.nav-link {
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  outline: none;
}

.nav-link.has-active-child {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-weight: 600;
}

.nav-link.has-active-child > i:first-child {
  color: #38bdf8;
}

.submenu-arrow {
  margin-left: auto;
  font-size: 0.72rem;
  color: #64748b;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s;
}

.nav-link:hover .submenu-arrow {
  color: #cbd5e1;
}

.nav-item.has-submenu.open .submenu-arrow {
  transform: rotate(180deg);
  color: #38bdf8;
}

/* Submenu Container */
.submenu {
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.35rem 0 0.35rem 0.85rem;
  margin-left: 0.85rem;
  border-left: 2px solid rgba(255, 255, 255, 0.12);
  margin-top: 0.25rem;
  margin-bottom: 0.45rem;
  animation: submenuFadeIn 0.25s ease-out;
}

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

.submenu.show,
.nav-item.has-submenu.open .submenu {
  display: flex;
}

/* Submenu Links */
.submenu-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  color: #94a3b8;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 500;
  transition: var(--transition);
  text-decoration: none;
}

.submenu-link i {
  font-size: 0.95rem;
  width: 20px;
  text-align: center;
  color: #64748b;
  transition: color 0.2s, transform 0.2s;
}

.submenu-link:hover {
  background: var(--sidebar-hover);
  color: #f1f5f9;
  transform: translateX(3px);
}

.submenu-link:hover i {
  color: #38bdf8;
}

.submenu-link.active {
  background: rgba(79, 70, 229, 0.25);
  color: #a5b4fc;
  border: 1px solid rgba(129, 140, 248, 0.35);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}

.submenu-link.active i {
  color: #818cf8;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  background: rgba(15, 23, 42, 0.7);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.driver-gps-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  color: #34d399;
  font-size: 0.82rem;
  font-weight: 500;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Backdrop for Mobile Navigation */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 90;
}

/* =========================================================
   Main Content Layout
   ========================================================= */

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0 !important; /* CRITICAL: Allows flex child to shrink properly */
  width: calc(100% - var(--sidebar-width));
  max-width: 100%;
  overflow-x: hidden !important;
  transition: margin-left 0.3s ease;
  background: var(--bg-main);
  box-sizing: border-box;
}

/* Top Navigation Header */
.app-header {
  height: var(--header-height);
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1020; /* High z-index so sticky header always stays above maps and scrolling content */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* Fix Leaflet Map Z-Index Stacking: Prevent map and zoom controls from overlapping sticky header on scroll */
.leaflet-container {
  position: relative;
  z-index: 1 !important;
}

.leaflet-top,
.leaflet-bottom {
  z-index: 10 !important;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.toggle-sidebar-btn {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: var(--transition);
}

.toggle-sidebar-btn:hover {
  background: #e2e8f0;
  color: var(--primary);
}

.header-title-box h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.header-title-box p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.whatsapp-fast-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #25d366;
  color: #fff !important;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-full);
  box-shadow: 0 3px 10px rgba(37, 211, 102, 0.3);
  transition: var(--transition);
}

.whatsapp-fast-btn:hover {
  background: #1ebd58;
  transform: translateY(-1px);
}

/* User Profile Dropdown */
.user-dropdown {
  position: relative;
}

.user-profile-trigger {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.75rem 0.35rem 0.35rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.user-profile-trigger:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.user-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.user-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 220px;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0;
  z-index: 100;
  animation: dropdownFade 0.2s ease;
}

.user-dropdown-menu.show {
  display: block;
}

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  color: var(--text-main);
  transition: var(--transition);
}

.dropdown-item i {
  font-size: 1rem;
  width: 20px;
  color: var(--text-muted);
}

.dropdown-item:hover {
  background: #f8fafc;
  color: var(--primary);
}

.dropdown-item:hover i {
  color: var(--primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.4rem 0;
}

.dropdown-item.danger-link {
  color: var(--danger);
}
.dropdown-item.danger-link i {
  color: var(--danger);
}
.dropdown-item.danger-link:hover {
  background: var(--danger-bg);
}

/* Page Content Body */
.page-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1600px;
  width: 100% !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
  margin: 0 auto;
}

/* =========================================================
   Card & Grid System
   ========================================================= */

.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: #cbd5e1;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.secondary::before { background: var(--secondary); }

.stat-info .stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}

.stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-info .stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.stat-card.primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.success .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card.warning .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-card.secondary .stat-icon { background: #e0f2fe; color: var(--secondary); }

/* Main Content Box / Cards */
.content-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow: hidden;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: #ffffff;
}

.card-title-box {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.card-title-box i {
  font-size: 1.2rem;
  color: var(--primary);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-body {
  padding: 1.5rem;
}

/* =========================================================
   Search & Filter Bar (CNIC, Mobile, Truck #, Date Wise)
   ========================================================= */

.filter-toolbar {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  padding: 1.1rem 1.5rem;
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) auto;
  gap: 0.85rem;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
}

.form-control, .form-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.88rem;
  color: var(--text-main);
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
}

/* =========================================================
   Buttons & Controls
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #f1f5f9;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}
.btn-success:hover {
  background: #059669;
  color: #ffffff;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}
.btn-danger:hover {
  background: #dc2626;
  color: #ffffff;
}

.btn-whatsapp {
  background: var(--whatsapp);
  color: #ffffff !important;
}
.btn-whatsapp:hover {
  background: var(--whatsapp-hover);
}

.btn-sm {
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* =========================================================
   Responsive Tables
   ========================================================= */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  padding: 0.9rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 0.95rem 1rem;
  font-size: 0.88rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Badges for Truck Types & Status */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-wheeler {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #ddd6fe;
}

.badge-22-wheeler {
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 700;
  border: 1px solid #c7d2fe;
}

.badge-status-available {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-status-ontrip {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-status-maintenance {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge-status-loading {
  background: var(--warning-bg);
  color: var(--warning-text);
}

/* Action Button Group */
.table-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* =========================================================
   Strict 20-Records Pagination Component (1, 2, 3, 4, 5...)
   ========================================================= */

.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination-info strong {
  color: var(--text-main);
}

.pagination-list {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-main);
  transition: var(--transition);
}

.page-link:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--primary);
}

.page-link.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

.page-disabled {
  color: #94a3b8;
  cursor: not-allowed;
  border-color: #f1f5f9;
  background: #f8fafc;
}

.page-disabled:hover {
  background: #f8fafc;
  color: #94a3b8;
}

.page-dots {
  border: none;
  background: none;
  color: var(--text-muted);
}

/* =========================================================
   "See Password" Input Wrapper Component
   ========================================================= */

.password-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-group .form-control {
  padding-right: 42px;
}

.toggle-password-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: color 0.2s;
}

.toggle-password-btn:hover {
  color: var(--primary);
}

/* =========================================================
   Modals & Popups
   ========================================================= */

.modal-backdrop-custom {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop-custom.show {
  display: flex;
}

.modal-dialog-custom {
  background: #ffffff;
  width: 100%;
  max-width: 650px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header-custom {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.modal-header-custom h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close-btn:hover {
  background: #e2e8f0;
  color: var(--danger);
}

.modal-body-custom {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer-custom {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* =========================================================
   Authentication Pages (Login & Forgot Password)
   ========================================================= */

.auth-page-wrapper {
  min-height: 100vh;
  width: 100% !important;
  max-width: 100vw !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #312e81 100%);
  padding: 1.25rem 0.75rem;
  position: relative;
  overflow: hidden;
  box-sizing: border-box !important;
}

.auth-page-wrapper::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(0,0,0,0) 70%);
  top: -150px;
  right: -100px;
  border-radius: 50%;
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  box-sizing: border-box !important;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  padding: 2.25rem 1.5rem;
  position: relative;
  z-index: 10;
}

.auth-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-brand .brand-icon {
  margin: 0 auto 0.75rem;
  width: 48px;
  height: 48px;
  font-size: 1.5rem;
}

.auth-brand h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: #0f172a;
}

.auth-brand p {
  font-size: 0.88rem;
  color: #64748b;
  margin-top: 0.25rem;
}

/* Alerts */
.alert {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid #fca5a5;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid #6ee7b7;
}

/* =========================================================
   Live Leaflet Map Styling
   ========================================================= */

#truckLiveMap {
  width: 100%;
  height: 520px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.map-sidebar-list {
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.truck-map-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.truck-map-item:hover {
  background: #f8fafc;
}

.truck-map-item.selected {
  background: #eef2ff;
  border-left: 4px solid var(--primary);
}

/* =========================================================
   Mobile & Responsive Breakpoints
   ========================================================= */

@media (max-width: 991px) {
  /* Complete Sidebar Off-Screen Isolation on Mobile */
  .app-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: -320px !important;
    width: 280px !important;
    max-width: 85vw !important;
    transform: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: 9999 !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s !important;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.4) !important;
  }

  .app-sidebar.open {
    left: 0 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .sidebar-backdrop.show {
    display: block;
    z-index: 9990;
  }

  .close-sidebar-btn {
    display: block;
  }

  /* Full 100% Width for Wrapper & Main Area */
  .app-wrapper {
    display: block !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
  }

  .app-main {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .page-content {
    padding: 0.85rem 0.6rem !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* Stack ALL multi-column grids cleanly into full-width vertical column */
  .dashboard-grid,
  .map-layout-grid,
  .settings-grid,
  .templates-layout-grid,
  .dashboard-stats-grid {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    gap: 1rem !important;
  }

  .dashboard-grid > div,
  .map-layout-grid > div,
  .settings-grid > div,
  .templates-layout-grid > div {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  #dashboardMiniMap,
  #truckLiveMap {
    height: 340px !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Sticky Bulk Actions Toolbar */
  #bulkActionBar {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin-bottom: 1rem !important;
    padding: 0.85rem !important;
  }

  #bulkActionBar > div {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  #bulkActionBar .btn {
    width: 100% !important;
    justify-content: center !important;
  }
}

/* Mobile Devices (Screen < 768px & < 480px) */
@media (max-width: 768px) {
  :root {
    --header-height: 58px;
  }

  body {
    font-size: 14px;
  }

  .hide-mobile-sm {
    display: none !important;
  }

  .app-header {
    padding: 0 0.65rem !important;
    height: 58px !important;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }

  .header-left {
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
  }

  .toggle-sidebar-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    flex-shrink: 0;
  }

  .header-title-box {
    min-width: 0;
  }

  .header-title-box h1 {
    font-size: 0.95rem !important;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }

  .header-subtitle {
    display: none !important;
  }

  .header-right {
    gap: 0.35rem !important;
    flex-shrink: 0;
  }

  .driver-gps-status {
    padding: 0.3rem 0.55rem !important;
    font-size: 0.72rem !important;
  }

  .user-info {
    display: none !important;
  }

  .user-profile-trigger {
    padding: 0.2rem;
  }

  .content-card {
    padding: 0.85rem !important;
    margin-bottom: 0.85rem !important;
    border-radius: 12px !important;
  }

  .card-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
    padding: 0.85rem !important;
  }

  .card-header .btn, 
  .card-header .btn-group {
    width: 100% !important;
    justify-content: center !important;
  }

  .card-actions {
    width: 100% !important;
    flex-wrap: wrap !important;
  }

  /* Table Isolated Horizontal Touch Scroll */
  .table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-bottom: 0.75rem !important;
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border-color) !important;
    box-sizing: border-box !important;
    display: block !important;
  }

  .table, .data-table {
    min-width: 580px !important;
    font-size: 0.83rem !important;
  }

  .table th, .table td,
  .data-table th, .data-table td {
    padding: 0.65rem 0.55rem !important;
    white-space: nowrap !important;
  }

  /* Modals: Mobile Friendly Centered Drawer */
  .modal-dialog-custom {
    width: 95% !important;
    max-width: 95% !important;
    margin: 1rem auto !important;
    border-radius: var(--radius-lg) !important;
    max-height: 92vh !important;
    box-sizing: border-box !important;
  }

  .modal-header-custom {
    padding: 0.95rem 1.15rem !important;
  }

  .modal-header-custom h3 {
    font-size: 1rem !important;
  }

  .modal-body-custom {
    padding: 1rem !important;
  }

  .modal-footer-custom {
    padding: 0.85rem 1rem !important;
    flex-direction: column-reverse !important;
    gap: 0.5rem !important;
  }

  .modal-footer-custom .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Filters, Inputs & Forms Auto-Stacking */
  .filter-form,
  .form-row,
  .row {
    grid-template-columns: 1fr !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .col, [class*="col-"] {
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
    box-sizing: border-box !important;
  }

  .pagination-container {
    flex-direction: column !important;
    align-items: center !important;
    gap: 0.65rem !important;
    text-align: center !important;
  }

  /* Quick Actions / Button Strips */
  div[style*="display: flex; gap: 0.75rem"],
  div[style*="display: flex; gap: 0.6rem"],
  div[style*="display: flex; gap: 0.5rem"] {
    flex-wrap: wrap !important;
  }
}

@media (max-width: 576px) {
  div[style*="display: flex; gap: 0.75rem"],
  div[style*="display: flex; gap: 0.6rem"] {
    flex-direction: column !important;
    width: 100% !important;
  }

  div[style*="display: flex; gap: 0.75rem"] > .btn,
  div[style*="display: flex; gap: 0.6rem"] > .btn {
    width: 100% !important;
    justify-content: center !important;
  }
}

@media (max-width: 991px) {
  *, *::before, *::after {
    box-sizing: border-box !important;
  }

  html, body {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    position: relative !important;
  }

  .app-wrapper,
  .app-main,
  .page-content {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* Footer styling on mobile */
  footer {
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    padding: 1rem 0.75rem !important;
  }

  footer > div {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 0.65rem !important;
  }

  /* Any custom modals or containers */
  #bulkWhatsAppModal > div,
  #imageLightboxModal > div,
  .modal-dialog-custom {
    max-width: 95vw !important;
    width: 95vw !important;
    margin: 0.5rem auto !important;
    box-sizing: border-box !important;
  }
}

@media (max-width: 480px) {
  .hide-mobile-xs {
    display: none !important;
  }

  .header-title-box h1 {
    max-width: 110px !important;
    font-size: 0.88rem !important;
  }

  .btn {
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
  }

  .auth-card {
    padding: 1.35rem 1rem !important;
  }

  .stat-card {
    padding: 1rem !important;
  }

  .stat-info .stat-value {
    font-size: 1.45rem !important;
  }
}

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