/* ==========================================================================
   Revotrax Fleet Tracking Web Portal - Modern Design System
   Glassmorphism + Dark/Light Mode + Full Arabic RTL Support
   ========================================================================== */

:root {
  /* Color Palette - Dark Theme (Default) */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-surface: rgba(17, 24, 39, 0.75);
  --bg-surface-solid: #162032;
  --bg-surface-hover: rgba(30, 41, 59, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;

  /* Typography */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Accent & Status Colors */
  --accent-primary: #2563eb;
  --accent-primary-hover: #1d4ed8;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  
  --status-moving: #10b981;
  --status-idle: #06b6d4;
  --status-parked: #f59e0b;
  --status-offline: #64748b;
  --status-alarm: #ef4444;

  /* Glassmorphism & Shadows */
  --glass-blur: blur(14px);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.25);

  /* Layout Constants */
  --header-height: 64px;
  --sidebar-width: 380px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-surface: rgba(255, 255, 255, 0.85);
  --bg-surface-solid: #ffffff;
  --bg-surface-hover: #e2e8f0;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

/* RTL Support */
html[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

/* ==========================================================================
   Login Screen
   ========================================================================== */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #1e293b 0%, #0a0e17 70%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: fadeIn 0.4s ease;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.login-brand-logo {
  width: 90px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.6));
  transition: transform var(--transition-fast);
}

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

.login-logo-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.login-logo-icon svg {
  width: 28px;
  height: 28px;
  color: #fff;
}

.login-logo-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

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

.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

html[dir="rtl"] .input-icon {
  left: auto;
  right: 14px;
}

.form-input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 44px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--transition-fast);
}

html[dir="rtl"] .form-input {
  padding: 0 44px 0 16px;
}

.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  background: rgba(0, 0, 0, 0.35);
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  font-size: 13px;
}

.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  height: 48px;
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
}

.login-lang-selector {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.lang-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.lang-btn.active, .lang-btn:hover {
  color: var(--text-primary);
  font-weight: 700;
}

/* ==========================================================================
   Main App Layout
   ========================================================================== */
#app-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* Header */
.app-header {
  height: var(--header-height);
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  flex-shrink: 0;
}

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

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 20px;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-logo-img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
  transition: transform var(--transition-fast);
}

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

.brand-icon {
  width: 34px;
  height: 34px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-icon svg {
  width: 20px;
  height: 20px;
  color: #fff;
}

/* Fleet Status Summary Badges */
.fleet-metrics-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.metric-pill:hover, .metric-pill.active {
  background: var(--bg-surface-hover);
  border-color: var(--border-focus);
}

.metric-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.metric-dot.total { background: var(--text-primary); }
.metric-dot.moving { background: var(--status-moving); }
.metric-dot.idle { background: var(--status-idle); }
.metric-dot.parked { background: var(--status-parked); }
.metric-dot.offline { background: var(--status-offline); }

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

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  cursor: pointer;
}

html[dir="rtl"] .user-profile-badge {
  padding: 4px 4px 4px 12px;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
}

/* App Main Body */
.app-body {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Fleet Sidebar
   ========================================================================== */
.fleet-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface-solid);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 900;
  transition: transform var(--transition-normal);
  flex-shrink: 0;
}

html[dir="rtl"] .fleet-sidebar {
  border-right: none;
  border-left: 1px solid var(--border-color);
}

/* Customer Filter in Sidebar */
.customer-filter-wrapper {
  padding: 12px 16px 10px 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
}

.customer-filter-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.custom-select-box {
  position: relative;
  display: flex;
  align-items: center;
}

.select-icon {
  position: absolute;
  left: 10px;
  font-size: 14px;
  pointer-events: none;
  z-index: 2;
}

html[dir="rtl"] .select-icon {
  left: auto;
  right: 10px;
}

.customer-dropdown {
  width: 100%;
  height: 38px;
  padding-left: 32px;
  padding-right: 12px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
}

html[dir="rtl"] .customer-dropdown {
  padding-left: 12px;
  padding-right: 32px;
}

.customer-dropdown:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.sidebar-search-box {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 38px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
}

html[dir="rtl"] .search-input-wrapper input {
  padding: 0 38px 0 14px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

html[dir="rtl"] .search-icon {
  left: auto;
  right: 12px;
}

/* Fleet List */
.fleet-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.fleet-list::-webkit-scrollbar {
  width: 6px;
}

.fleet-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

/* ==========================================================================
   Luxury High-Density Vehicle Cards (Compact & Elegant)
   ========================================================================== */
.vehicle-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px 8px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

html[dir="rtl"] .vehicle-card {
  padding: 8px 14px 8px 12px;
}

[data-theme="light"] .vehicle-card {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .vehicle-card:hover {
  background: #f8fafc;
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

[data-theme="light"] .vehicle-card.selected {
  background: #f0f7ff;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb, 0 4px 12px rgba(37, 99, 235, 0.12);
}

[data-theme="dark"] .vehicle-card:hover {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .vehicle-card.selected {
  background: rgba(37, 99, 235, 0.12);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary), 0 0 16px rgba(37, 99, 235, 0.25);
}

/* Status Indicator Edge Bar */
.vehicle-card::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  background: var(--status-offline);
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

html[dir="rtl"] .vehicle-card::before {
  left: auto;
  right: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.vehicle-card.moving::before { background: var(--status-moving); }
.vehicle-card.idle::before { background: var(--status-idle); }
.vehicle-card.parked::before { background: var(--status-parked); }
.vehicle-card.offline::before { background: var(--status-offline); }
.vehicle-card.alarm::before { background: var(--status-alarm); }

/* Card Row 1: Identity & Status */
.card-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.card-identity {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
}

.card-vehicle-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
}

.card-sub-imei {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Inter', monospace, sans-serif;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0.85;
}

/* Card Status Pill */
.card-status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.card-status-pill .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.card-status-pill.moving {
  color: #059669;
  background: rgba(16, 185, 129, 0.12);
}
.card-status-pill.moving .pulse-dot {
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

[data-theme="dark"] .card-status-pill.moving {
  color: #34d399;
  background: rgba(16, 185, 129, 0.18);
}

.card-status-pill.idle {
  color: #0891b2;
  background: rgba(6, 182, 212, 0.12);
}
.card-status-pill.idle .pulse-dot {
  background: #06b6d4;
  box-shadow: 0 0 6px #06b6d4;
}

.card-status-pill.parked {
  color: #d97706;
  background: rgba(245, 158, 11, 0.12);
}
.card-status-pill.parked .pulse-dot {
  background: #f59e0b;
}

.card-status-pill.offline {
  color: #64748b;
  background: rgba(100, 116, 139, 0.12);
}
.card-status-pill.offline .pulse-dot {
  background: #94a3b8;
}

/* Card Row 2: Telemetry Strip & Actions */
.card-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-telemetry-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.card-telemetry-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-secondary);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .card-telemetry-pill {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
}

.card-telemetry-pill.speed b {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
}

.card-telemetry-pill.speed small {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.8;
}

.card-telemetry-pill.speed.moving {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  color: #059669;
}
[data-theme="dark"] .card-telemetry-pill.speed.moving {
  color: #34d399;
}

.card-telemetry-pill.speed.moving b {
  color: #059669;
}
[data-theme="dark"] .card-telemetry-pill.speed.moving b {
  color: #34d399;
}

.card-telemetry-pill.acc {
  gap: 5px;
}

.card-telemetry-pill.acc .acc-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
}

.card-telemetry-pill.acc.on {
  color: #059669;
}
[data-theme="dark"] .card-telemetry-pill.acc.on {
  color: #34d399;
}

.card-telemetry-pill.acc.on .acc-dot {
  background: #10b981;
  box-shadow: 0 0 5px #10b981;
}

.card-telemetry-pill.fuel {
  gap: 4px;
  background: rgba(14, 165, 233, 0.08);
  color: #0284c7;
  border-color: rgba(14, 165, 233, 0.2);
}
[data-theme="dark"] .card-telemetry-pill.fuel {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.25);
}
.card-telemetry-pill.fuel b {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11.5px;
  font-weight: 800;
  color: inherit;
}

/* Compact Micro-Action Buttons */
.card-actions-compact {
  display: flex;
  align-items: center;
  gap: 4px;
}

.compact-action-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

[data-theme="dark"] .compact-action-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.compact-action-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
  transition: transform var(--transition-fast);
}

.compact-action-btn:hover {
  transform: translateY(-1px);
}

.compact-action-btn:hover svg {
  transform: scale(1.1);
}

/* Locate button hover */
.compact-action-btn.locate:hover {
  background: rgba(37, 99, 235, 0.12);
  border-color: #2563eb;
  color: #2563eb;
}
[data-theme="dark"] .compact-action-btn.locate:hover {
  background: rgba(37, 99, 235, 0.25);
  border-color: #3b82f6;
  color: #60a5fa;
}

/* Playback button hover */
.compact-action-btn.playback:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: #8b5cf6;
  color: #7c3aed;
}
[data-theme="dark"] .compact-action-btn.playback:hover {
  background: rgba(139, 92, 246, 0.25);
  border-color: #8b5cf6;
  color: #c084fc;
}

/* Command button hover */
.compact-action-btn.command:hover {
  background: rgba(245, 158, 11, 0.12);
  border-color: #d97706;
  color: #d97706;
}
[data-theme="dark"] .compact-action-btn.command:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: #f59e0b;
  color: #fbbf24;
}

/* ==========================================================================
   Map Container & Controls
   ========================================================================== */
.map-viewport {
  flex: 1;
  position: relative;
  background: #0d131f;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Custom Floating Map Controls */
.map-floating-toolbar {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

html[dir="rtl"] .map-floating-toolbar {
  right: auto;
  left: 16px;
}

.map-control-btn {
  width: 40px;
  height: 40px;
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
}

.map-control-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.map-control-btn.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--border-focus);
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.5);
}

/* Google Maps Controls Theme Integration */
[data-theme="dark"] .gm-style .gm-style-mtc button {
  background-color: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
  backdrop-filter: var(--glass-blur) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-sm) !important;
}

[data-theme="dark"] .gm-style .gm-style-mtc button:hover {
  background-color: var(--bg-surface-hover) !important;
}

[data-theme="dark"] .gm-style .gm-control-active {
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border-color) !important;
}

[data-theme="dark"] .gm-style .gm-control-active > img {
  filter: invert(1) brightness(1.5) !important;
}

[data-theme="dark"] .gm-style .gm-control-active:hover {
  background-color: var(--bg-surface-hover) !important;
}

/* Custom Leaflet Map Markers */
.vehicle-marker-icon {
  background: transparent;
  border: none;
}

.marker-pin {
  width: 40px;
  height: 40px;
  border-radius: 50% 50% 50% 0;
  background: var(--status-moving);
  position: absolute;
  transform: rotate(-45deg);
  left: 50%;
  top: 50%;
  margin: -20px 0 0 -20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Google Maps InfoWindow & Leaflet Popup Dark Glass Overrides
   ========================================================================== */

/* Google Maps InfoWindow Container Overrides */
.gm-style .gm-style-iw-c {
  background: linear-gradient(145deg, #131d35 0%, #0a0f1d 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  border-radius: 18px !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85), 0 0 25px rgba(56, 189, 248, 0.15) !important;
  padding: 0 !important;
  overflow: hidden !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
}

/* InfoWindow Inner Content */
.gm-style .gm-style-iw-d {
  padding: 0 !important;
  overflow: hidden !important;
  max-height: none !important;
}

/* Downward Pointer / Tip Arrow */
.gm-style .gm-style-iw-tc::after {
  background: #0a0f1d !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  border-top: none !important;
  border-left: none !important;
  box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.6) !important;
}

/* Close Button (X) */
.gm-style .gm-ui-hover-effect {
  top: 10px !important;
  right: 10px !important;
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.08) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
  outline: none !important;
}

html[dir="rtl"] .gm-style .gm-ui-hover-effect {
  right: auto !important;
  left: 10px !important;
}

.gm-style .gm-ui-hover-effect:hover {
  background: rgba(239, 68, 68, 0.25) !important;
}

.gm-style .gm-ui-hover-effect > span {
  background-color: #cbd5e1 !important;
}

/* Leaflet Popup Dark Glass */
.leaflet-popup-content-wrapper {
  background: linear-gradient(145deg, #131d35 0%, #0a0f1d 100%) !important;
  color: #f8fafc !important;
  border-radius: 18px !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85), 0 0 25px rgba(56, 189, 248, 0.15) !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  line-height: inherit !important;
}

.leaflet-popup-tip {
  background: #0a0f1d !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
}

/* Popup Modern Card Layout */
.popup-card-modern {
  width: 310px;
  padding: 18px;
  box-sizing: border-box;
  font-family: inherit;
  color: #f8fafc;
}

.popup-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.popup-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.popup-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2) 0%, rgba(37, 99, 235, 0.3) 100%);
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.popup-vehicle-title {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
  margin: 0;
  letter-spacing: -0.2px;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popup-vehicle-sub {
  font-size: 11px;
  color: #94a3b8;
  font-family: monospace;
  display: block;
}

.popup-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.popup-status-badge.moving {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.popup-status-badge.idle {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.popup-status-badge.parked {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.popup-status-badge.offline {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.status-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

/* Bento Telemetry Grid */
.popup-bento-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.bento-cell {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bento-label {
  font-size: 10px;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.bento-value {
  font-size: 13px;
  color: #ffffff;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.bento-value b {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
}

.bento-value small {
  font-size: 11px;
  color: #94a3b8;
}

.bento-cell.fuel-cell {
  background: rgba(14, 165, 233, 0.05);
  border-color: rgba(14, 165, 233, 0.2);
}

[data-theme="light"] .bento-cell.fuel-cell {
  background: #f0f9ff;
  border-color: rgba(14, 165, 233, 0.25);
}

.bento-value.fuel-value {
  color: #0284c7;
}

[data-theme="dark"] .bento-value.fuel-value {
  color: #38bdf8;
}

.fuel-bento-icon {
  font-size: 13px;
  line-height: 1;
}

.acc-indicator {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 800;
}

.acc-indicator.on {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.acc-indicator.off {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

/* Address Box */
.popup-address-pill {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 14px;
  font-size: 11.5px;
  line-height: 1.4;
  color: #cbd5e1;
}

.address-pin-icon {
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}

.address-text {
  word-break: break-word;
}

/* Actions Grid */
.popup-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.popup-btn-action {
  height: 36px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  outline: none;
}

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

.popup-btn-action.primary:hover {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  transform: translateY(-1px);
}

.popup-btn-action.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.popup-btn-action.warning:hover {
  background: rgba(245, 158, 11, 0.25);
  transform: translateY(-1px);
}

/* ==========================================================================
   Light Mode Luxury Overrides for Map Popups (InfoWindow & Leaflet)
   ========================================================================== */
[data-theme="light"] .gm-style .gm-style-iw-c {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.2) !important;
}

[data-theme="light"] .gm-style .gm-style-iw-tc::after {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  border-top: none !important;
  border-left: none !important;
  box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .gm-style .gm-ui-hover-effect {
  background: rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] .gm-style .gm-ui-hover-effect:hover {
  background: rgba(239, 68, 68, 0.15) !important;
}

[data-theme="light"] .gm-style .gm-ui-hover-effect > span {
  background-color: #475569 !important;
}

[data-theme="light"] .leaflet-popup-content-wrapper {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15) !important;
}

[data-theme="light"] .leaflet-popup-tip {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

[data-theme="light"] .popup-card-modern {
  color: #0f172a;
}

[data-theme="light"] .popup-card-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

[data-theme="light"] .popup-vehicle-title {
  color: #0f172a;
}

[data-theme="light"] .popup-vehicle-sub {
  color: #64748b;
}

[data-theme="light"] .popup-icon-badge {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(59, 130, 246, 0.15) 100%);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

[data-theme="light"] .bento-cell {
  background: #f8fafc;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .bento-label {
  color: #64748b;
}

[data-theme="light"] .bento-value {
  color: #0f172a;
}

[data-theme="light"] .bento-value b {
  color: #0f172a;
}

[data-theme="light"] .bento-value small {
  color: #64748b;
}

[data-theme="light"] .popup-address-pill {
  background: #f8fafc;
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: #334155;
}

[data-theme="light"] .popup-btn-action.warning {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

[data-theme="light"] .popup-btn-action.warning:hover {
  background: rgba(245, 158, 11, 0.22);
}

/* ==========================================================================
   Playback Bottom Bar
   ========================================================================== */
#playback-drawer {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(150%);
  width: 90%;
  max-width: 960px;
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  box-shadow: var(--shadow-lg);
  z-index: 800;
  transition: transform var(--transition-normal);
}

#playback-drawer.open {
  transform: translateX(-50%) translateY(0);
}

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

.playback-controls-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.playback-scrubber-wrapper {
  flex: 1;
}

.playback-slider {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.playback-stats-grid {
  display: flex;
  gap: 24px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Modal Dialogs & Toasts
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: modalScale 0.25s ease;
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Toast Notification Stack */
#toast-stack {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

html[dir="rtl"] #toast-stack {
  right: auto;
  left: 24px;
}

.toast {
  pointer-events: auto;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  min-width: 280px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s ease;
  font-size: 13px;
}

html[dir="rtl"] .toast {
  border-left: 1px solid var(--border-color);
  border-right: 4px solid var(--accent-primary);
}

.toast.error { border-left-color: var(--status-alarm); }
html[dir="rtl"] .toast.error { border-right-color: var(--status-alarm); }
.toast.success { border-left-color: var(--status-moving); }
html[dir="rtl"] .toast.success { border-right-color: var(--status-moving); }

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

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Responsive */
.mobile-only {
  display: none;
}

@media (max-width: 900px) {
  .mobile-only {
    display: flex;
  }
  .fleet-sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  html[dir="rtl"] .fleet-sidebar {
    left: auto;
    right: 0;
    transform: translateX(100%);
  }
  .fleet-sidebar.open {
    transform: translateX(0);
  }
  .fleet-metrics-bar {
    display: none;
  }
}

/* Badge Count for Alerts */
.badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--status-alarm);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(239, 68, 68, 0.5);
}

/* Alarms Slide-out Drawer */
.slide-drawer {
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  right: 0;
  width: 360px;
  max-width: 100vw;
  background: var(--bg-surface-solid);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 1500;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

html[dir="rtl"] .slide-drawer {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid var(--border-color);
  transform: translateX(-100%);
}

.slide-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alarm-item-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--status-alarm);
  border-radius: var(--radius-sm);
  padding: 12px;
  transition: background var(--transition-fast);
}

html[dir="rtl"] .alarm-item-card {
  border-left: 1px solid var(--border-color);
  border-right: 3px solid var(--status-alarm);
}

.alarm-item-card:hover {
  background: var(--bg-surface-hover);
}

/* Playback Quick Ranges */
.playback-quick-ranges {
  display: flex;
  gap: 6px;
}

.playback-quick-ranges .card-btn.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

