/* ==========================================================================
   ZEVVY MAPS - PROFESSIONAL EV ROUTE PLANNER
   Modern, Clean Design System
   ========================================================================== */

:root {
  /* Zevvy Brand Colors - Green/Teal Theme */
  --primary-50: #e6f7f4;
  --primary-100: #b3e6db;
  --primary-200: #80d5c2;
  --primary-300: #4dc4a9;
  --primary-400: #26b896;
  --primary-500: #00a884;  /* Main Zevvy Green */
  --primary-600: #009874;
  --primary-700: #008564;
  --primary-800: #007254;
  --primary-900: #005f44;

  /* Secondary - Dark Teal */
  --secondary-500: #00695c;
  --secondary-600: #00564a;
  --secondary-700: #004d42;

  /* Success */
  --success-500: #10b981;
  --success-600: #059669;

  /* Warning */
  --warning-500: #f59e0b;
  --warning-600: #d97706;

  /* Error */
  --error-500: #ef4444;
  --error-600: #dc2626;

  /* Neutral Grays - Light Mode */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Background & Text */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #9ca3af;
  --border-color: #e5e7eb;

  /* Typography - Smaller sizes */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  --text-xs: 0.688rem;    /* 11px */
  --text-sm: 0.813rem;    /* 13px */
  --text-base: 0.938rem;  /* 15px */
  --text-lg: 1.063rem;    /* 17px */
  --text-xl: 1.125rem;    /* 18px */
  --text-2xl: 1.375rem;   /* 22px */
  --text-3xl: 1.75rem;    /* 28px */

  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Spacing - Tighter spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --radius-full: 9999px;

  /* Shadows - Subtle */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 2px 4px -1px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 4px 8px -2px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 8px 16px -4px rgb(0 0 0 / 0.12);
  --shadow-2xl: 0 16px 32px -8px rgb(0 0 0 / 0.15);

  /* Transitions */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index */
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-fixed: 1200;
  --z-modal-backdrop: 1300;
  --z-modal: 1400;
  --z-tooltip: 1600;
}

/* Dark Mode */
[data-theme="dark"] {
  --gray-50: #1f2937;
  --gray-100: #374151;
  --gray-200: #4b5563;
  --gray-300: #6b7280;
  --gray-400: #9ca3af;
  --gray-500: #d1d5db;
  --gray-600: #e5e7eb;
  --gray-700: #f3f4f6;
  --gray-800: #f9fafb;
  --gray-900: #ffffff;

  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --bg-tertiary: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-tertiary: #9ca3af;
  --border-color: #374151;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 2px 4px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 4px 8px -2px rgb(0 0 0 / 0.5);
  --shadow-xl: 0 8px 16px -4px rgb(0 0 0 / 0.6);
  --shadow-2xl: 0 16px 32px -8px rgb(0 0 0 / 0.7);
}

/* ========== GLOBAL RESETS ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-50);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== CUSTOM SCROLLBAR ========== */
.custom-scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: var(--gray-100); border-radius: var(--radius-full); }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: var(--radius-full); }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ========== HEADER ========== */
.header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  box-shadow: var(--shadow-md);
}

.logo-text {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: white;
  letter-spacing: -0.02em;
}

.logo-mark {
  width: 24px;
  height: 24px;
  display: block;
}

/* ========== BUTTONS========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem 1rem;  /* Tighter padding */
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary-500), var(--secondary-600));
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  background: linear-gradient(135deg, var(--secondary-600), var(--secondary-700));
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: white;
  color: var(--primary-600);
  border: 1.5px solid var(--primary-500);
}
.btn-outline:hover {
  background: var(--primary-50);
  border-color: var(--primary-600);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-danger {
  background: linear-gradient(135deg, var(--error-500), var(--error-600));
  color: white;
}

.btn-sm { padding: 0.438rem 0.75rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.75rem 1.25rem; font-size: var(--text-base); }
.btn-icon { padding: 0.5rem; border-radius: var(--radius-full); }

/* ========== CARDS ========== */
.card {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--gray-200);
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

/* ========== INPUTS ========== */
.input-group {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.input-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--gray-700);
}

.input {
  width: 100%;
  padding: 0.625rem var(--space-4);  /* Tighter padding */
  font-size: var(--text-sm);  /* Smaller text */
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-lg);
  transition: all var(--transition-base);
  background: white;
  color: var(--gray-900);
}

.input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.input-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

.input-with-icon {
  padding-left: 2.25rem;  /* Adjusted for smaller icon */
}

/* ========== MODALS ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.2s ease-out;
}

.modal {
  background: white;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease-out;
  position: relative;
}

.modal-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--gray-200);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--gray-900);
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.modal-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  padding: var(--space-2);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-full);
  color: var(--gray-500);
  transition: all var(--transition-base);
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-tooltip);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 360px;
  pointer-events: none;
}

.toast {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: start;
  gap: var(--space-3);
  animation: slideInRight 0.3s ease-out;
  border-left: 3px solid var(--primary-500);
  pointer-events: auto;
  min-width: 280px;
}

.toast-success { border-left-color: var(--success-500); }
.toast-error { border-left-color: var(--error-500); }
.toast-warning { border-left-color: var(--warning-500); }

.toast-content {
  flex: 1;
  font-size: var(--text-sm);
}

.toast-title {
  font-weight: var(--font-semibold);
  color: var(--gray-900);
  margin-bottom: 0.125rem;
}

.toast-message {
  color: var(--gray-600);
  font-size: var(--text-xs);
}

.toast-close {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  color: var(--gray-600);
}

/* ========== AUTOCOMPLETE ========== */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: var(--space-2);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-height: 240px;  /* Reduced height */
  overflow-y: auto;
  z-index: var(--z-dropdown);
  animation: slideDown 0.15s ease-out;
  border: 1px solid var(--gray-200);
}

.autocomplete-item {
  padding: var(--space-2) var(--space-4);  /* Tighter padding */
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--gray-100);
  font-size: var(--text-sm);  /* Smaller text */
  color: var(--gray-700);
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover {
  background: var(--primary-50);
  color: var(--primary-700);
}

/* ========== PROGRESS BARS ========== */
.progress-bar {
  width: 100%;
  height: 6px;  /* Thinner */
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-500), var(--primary-400));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* ========== BADGES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.188rem var(--space-2);  /* Smaller */
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-success {
  background: var(--success-50);
  color: var(--success-700);
}

.badge-warning {
  background: var(--warning-50);
  color: var(--warning-600);
}

.badge-error {
  background: var(--error-50);
  color: var(--error-600);
}

/* ========== VEHICLE CARD ========== */
.vehicle-card {
  background: linear-gradient(135deg, var(--gray-50) 0%, white 100%);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: var(--space-3);  /* Tighter */
  cursor: pointer;
  transition: all var(--transition-base);
}

.vehicle-card:hover {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-md);
}

.vehicle-icon {
  width: 40px;  /* Smaller */
  height: 40px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-sm);
}

/* ========== TAB NAVIGATION ========== */
.tab-group {
  display: flex;
  gap: var(--space-2);
  background: var(--gray-100);
  padding: var(--space-2);
  border-radius: var(--radius-lg);
}

.tab {
  flex: 1;
  padding: var(--space-2) var(--space-3);  /* Tighter */
  border: none;
  background: transparent;
  color: var(--gray-600);
  font-weight: var(--font-medium);
  font-size: var(--text-sm);  /* Smaller */
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
}

.tab-active {
  background: white;
  color: var(--primary-600);
  box-shadow: var(--shadow-sm);
}

/* ========== EMPTY STATES ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  text-align: center;
}

.empty-state-icon {
  width: 48px;  /* Smaller */
  height: 48px;
  background: var(--gray-100);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
  color: var(--gray-400);
}

.empty-state-title {
  font-size: var(--text-base);  /* Smaller */
  font-weight: var(--font-semibold);
  color: var(--gray-900);
  margin-bottom: var(--space-2);
}

.empty-state-description {
  color: var(--gray-600);
  font-size: var(--text-sm);
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

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

/* ========== MAP ========== */
#map {
  position: absolute;
  inset: 0;
  height: 100%;
  min-height: 100%;
  width: 100%;
  z-index: 0;
  background: transparent;
  transform-origin: center center;
  will-change: transform;
}

.map-shell {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.leaflet-container {
  background: transparent;
}

.mobile-search-card {
  background: white;
}

.mobile-bottom-sheet {
  background: white;
  border-top: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: var(--z-fixed);
  background: white;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
}

#map.compass-mode {
  transition: transform 80ms linear;
}

.map-control-panel {
  position: absolute;
  right: var(--space-3);
  top: var(--space-3);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-dropdown);
}

.map-control-btn {
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-control-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary-500);
}

.map-control-btn.is-active {
  background: var(--primary-100);
  border-color: var(--primary-500);
  color: var(--primary-700);
}

/* ========== RESPONSIVE MOBILE FIXES ========== */
@media (max-width: 768px) {
  .header {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: 16px;
    right: 16px;
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    background: white;
    border: 1px solid var(--gray-200);
  }

  .header .logo-text {
    font-size: var(--text-base);
    color: var(--gray-900);
  }

  .header i {
    color: var(--gray-700) !important;
  }

  .logo-container {
    gap: var(--space-2);
  }

  #sidebar {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: 100%;
    background: transparent;
    pointer-events: none;
    box-shadow: none;
  }

  #mode-toggle-container.mobile-mode-toggle {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 64px);
    left: 16px;
    right: 16px;
    z-index: var(--z-fixed);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    pointer-events: auto;
  }

  .mobile-search-card {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 118px);
    left: 16px;
    right: 16px;
    z-index: var(--z-fixed);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    pointer-events: auto;
  }

  .mobile-bottom-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-fixed);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    pointer-events: auto;
    max-height: 55vh;
    display: flex;
    flex-direction: column;
  }

  .mobile-actions-card {
    border-top: 1px solid var(--gray-200);
  }

  #results-panel {
    flex: 1;
    overflow-y: auto;
  }

  #logged-in-view,
  #logged-out-view,
  #guest-mode-view {
    pointer-events: none;
  }

  .mobile-search-card,
  .mobile-bottom-sheet,
  .header,
  .mobile-mode-toggle,
  #guest-mode-view,
  #logged-out-view,
  .sidebar-toggle {
    pointer-events: auto;
  }
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .header {
    padding: var(--space-2) var(--space-3) !important;
  }

  .logo-text {
    font-size: var(--text-lg);
  }

  :root {
    --text-xs: 0.688rem;   /* Even smaller on mobile */
    --text-sm: 0.813rem;
    --text-base: 0.875rem;
    --text-lg: 1rem;
    --text-xl: 1.063rem;
  }

  .modal {
    max-width: 95vw;
    margin: var(--space-2);
  }

  .toast-container {
    left: var(--space-3);
    right: var(--space-3);
    max-width: none;
  }

  .btn {
    padding: 0.563rem 0.875rem;  /* Tighter on mobile */
    font-size: 0.813rem;
  }

  .btn-lg {
    padding: 0.688rem 1.125rem;
  }

  /* Fix white patch bug - ensure results panel is visible */
  #sidebar {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  #results-panel {
    flex: 1;
    overflow-y: auto;
    background: white;
    min-height: 120px;
  }

  .map-shell {
    height: 100vh;
  }

  .map-control-panel {
    right: var(--space-2);
    top: auto;
    bottom: 220px;
    padding: var(--space-1);
  }

  .map-control-btn {
    padding: var(--space-2);
  }
}

/* ========== UTILITY CLASSES ========== */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.w-full { width: 100%; }
.text-center { text-align: center; }
.transition { transition: all var(--transition-base); }

/* ========== LOADING SPINNER ========== */
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== STAR RATING ========== */
.star-rating {
  display: flex;
  gap: var(--space-1);
}

.star {
  color: var(--gray-300);
  font-size: var(--text-2xl);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  padding: 0;
}

.star:hover,
.star.active {
  color: #fbbf24;
}

/* ========== LEAFLET CUSTOMIZATION ========== */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-xl) !important;
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  padding: var(--space-3) !important;
  font-size: var(--text-sm) !important;
}

/* ========== NAVIGATION STATUS ========== */
.navigation-active {
  background: linear-gradient(135deg, var(--primary-50), var(--primary-100));
  border: 2px solid var(--primary-500);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  margin: var(--space-3) 0;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}
