/* ==========================================================================
   Self-Hosted OSM Map Dashboard - Global Stylesheet
   Design Paradigm: Premium Dark Glassmorphism with Harmonious Glowing Accents
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables / Design System Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Color Palette */
  --bg-primary: #0a0b0d;
  --bg-secondary: #121318;
  --glass-bg: rgba(18, 19, 26, 0.72);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-border-focus: rgba(99, 102, 241, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --color-primary: #6366f1; /* Indigo */
  --color-primary-hover: #4f46e5;
  --color-secondary: #06b6d4; /* Cyan */
  --color-success: #10b981; /* Emerald */
  --color-warning: #f59e0b; /* Amber */
  --color-danger: #ef4444; /* Rose */
  
  --glow-primary: rgba(99, 102, 241, 0.25);
  --glow-secondary: rgba(6, 118, 212, 0.25);
  
  /* Layout & Sizing */
  --sidebar-width: 390px;
  --sidebar-collapsed-width: 0px;
  --header-height: 70px;
  --drawer-height: 320px;
  --drawer-collapsed-height: 48px;
  
  /* Shadows & Radius */
  --shadow-sm: 0 2px 8px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, 0.5);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 30px;
  
  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
body.light-theme {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-border-focus: rgba(99, 102, 241, 0.6);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --color-primary: #4f46e5;
  --color-primary-hover: #3730a3;
  --color-secondary: #0891b2;
  
  --glow-primary: rgba(79, 70, 229, 0.15);
  --glow-secondary: rgba(8, 145, 178, 0.15);
  --glass-shadow: 0 8px 32px 0 rgba(148, 163, 184, 0.15);
}

/* --------------------------------------------------------------------------
   Reset & Core Elements
   -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Scrollbars styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Glassmorphism Panel Helper */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* --------------------------------------------------------------------------
   App Layout
   -------------------------------------------------------------------------- */
#app-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
}

/* --------------------------------------------------------------------------
   Sidebar - Interaction Layer
   -------------------------------------------------------------------------- */
#sidebar {
  position: absolute;
  top: 20px;
  left: 20px;
  bottom: 20px;
  width: var(--sidebar-width);
  z-index: 1000;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition-normal), opacity var(--transition-normal);
}

#sidebar.collapsed {
  transform: translateX(calc(-100% - 40px));
  pointer-events: none;
  opacity: 0;
}

/* Sidebar Toggle Handle Button */
#toggle-sidebar-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}
#toggle-sidebar-btn:hover {
  background: var(--glass-border);
  color: var(--text-primary);
}

/* Sidebar Header */
.sidebar-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--glass-border);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 15px var(--glow-primary);
}
.logo-icon i {
  width: 18px;
  height: 18px;
}
.logo-text h1 {
  font-size: 1.15rem;
  line-height: 1.1;
  background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-text .badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-secondary);
  background: var(--glow-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

/* Auth warning panel */
#auth-status-bar {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--glass-border);
  transition: all var(--transition-normal);
}
#auth-status-bar.auth-warning {
  background: rgba(245, 158, 11, 0.08);
  color: var(--color-warning);
}
#auth-status-bar.auth-success {
  background: rgba(16, 185, 129, 0.08);
  color: var(--color-success);
}
.status-content {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-content i {
  width: 16px;
  height: 16px;
}
.text-btn {
  background: none;
  border: none;
  font-weight: 600;
  font-size: 0.8rem;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* Tabs */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.1);
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}
.tab-btn i {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  transition: transform var(--transition-fast);
}
.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}
.tab-btn:hover i {
  transform: translateY(-1px);
  opacity: 1;
}
.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background: rgba(99, 102, 241, 0.04);
}
.tab-btn.active i {
  opacity: 1;
  color: var(--color-primary);
}

/* Tab Panel Contents */
.tab-content-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
  animation: fadeIn var(--transition-normal);
}

/* --------------------------------------------------------------------------
   UI Form Elements & Wrappers
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 16px;
}
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-wrapper {
  position: relative;
  width: 100%;
}
.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
input[type="text"], input[type="password"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 10px 40px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--glass-border-focus);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 3px var(--glow-primary);
}
.input-wrapper .icon-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}
.input-wrapper .icon-btn:hover {
  background: var(--glass-border);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Autocomplete Suggestions Panel
   -------------------------------------------------------------------------- */
.suggestions-panel {
  margin-top: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
  z-index: 1001;
  position: relative;
}
.suggestion-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.suggestion-item:last-child {
  border-bottom: none;
}
.suggestion-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.suggestion-icon {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  color: var(--color-primary);
}
.suggestion-meta {
  flex: 1;
}
.suggestion-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.suggestion-address {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Hide helper class */
.hide {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Details and Result cards
   -------------------------------------------------------------------------- */
.results-section {
  margin-top: 20px;
  animation: slideUp var(--transition-normal);
}
.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 6px;
}

.details-card {
  margin-top: 15px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
  animation: fadeIn var(--transition-normal);
}
.details-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.details-title h3 {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.details-title span {
  font-size: 0.7rem;
  color: var(--color-secondary);
  font-weight: 600;
  text-transform: uppercase;
}
.details-body {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 15px;
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  padding: 10px 0;
}
.details-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.details-row:last-child {
  margin-bottom: 0;
}
.row-label {
  font-weight: 600;
  color: var(--text-muted);
}
.row-val {
  color: var(--text-primary);
  text-align: right;
}
.details-actions {
  display: flex;
  gap: 8px;
}

/* Interactive elements list for results */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-list-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.result-list-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--color-primary);
}
.item-meta {
  flex: 1;
}
.item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.item-address {
  font-size: 0.7rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

/* --------------------------------------------------------------------------
   Routing Form Elements
   -------------------------------------------------------------------------- */
.route-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.route-point {
  position: relative;
}
.point-indicator {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}
.point-indicator.start {
  background: var(--color-success);
}
.point-indicator.end {
  background: var(--color-danger);
}
.route-point input {
  padding-left: 44px;
  cursor: pointer;
  text-overflow: ellipsis;
}
.route-point input:focus {
  border-color: var(--glass-border);
  box-shadow: none;
}

/* Routing Travel Profile Selector */
.profile-selectors {
  display: flex;
  gap: 8px;
}
.profile-btn {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.profile-btn i {
  width: 18px;
  height: 18px;
}
.profile-btn span {
  font-size: 0.68rem;
  font-weight: 600;
}
.profile-btn:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}
.profile-btn.active {
  border-color: var(--color-secondary);
  color: var(--color-secondary);
  background: rgba(6, 182, 212, 0.05);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.15);
}

.route-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.primary-btn {
  flex: 2;
  background: linear-gradient(135deg, var(--color-primary), #4f46e5);
  border: none;
  color: #ffffff;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 14px var(--glow-primary);
}
.primary-btn:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--glow-primary);
}
.primary-btn:active:not(:disabled) {
  transform: translateY(0);
}
.primary-btn:disabled {
  background: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.5;
}
.primary-btn i {
  width: 18px;
  height: 18px;
}

.secondary-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Route Result Panel and turn-by-turn lists */
.route-summary-card {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  margin-bottom: 20px;
}
.summary-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}
.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-secondary);
}
.summary-separator {
  width: 1px;
  height: 30px;
  background: var(--glass-border);
}

.directions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}
.direction-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  font-size: 0.78rem;
  line-height: 1.4;
  cursor: pointer;
}
.direction-step:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--color-primary);
}
.step-icon {
  margin-top: 1px;
  width: 16px;
  height: 16px;
  color: var(--color-primary);
}
.step-meta {
  flex: 1;
}
.step-text {
  color: var(--text-primary);
  margin-bottom: 2px;
}
.step-metrics {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Tools Page elements
   -------------------------------------------------------------------------- */
.tools-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.tool-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px;
}
.tool-info {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 80%;
}
.tool-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--glow-primary);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tool-icon i {
  width: 16px;
  height: 16px;
}
.tool-meta h4 {
  font-size: 0.85rem;
  margin-bottom: 2px;
}
.tool-meta p {
  font-size: 0.7rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Custom CSS Toggle Switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-switch label {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--glass-border);
  border-radius: var(--radius-xl);
  transition: var(--transition-fast);
  border: 1px solid var(--glass-border);
}
.toggle-switch label:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  transition: var(--transition-fast);
}
.toggle-switch input:checked + label {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}
.toggle-switch input:checked + label:before {
  transform: translateX(20px);
  background-color: #ffffff;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.action-btn {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.action-btn i {
  width: 20px;
  height: 20px;
  color: var(--color-primary);
}
.action-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}
.action-btn.danger i {
  color: var(--color-danger);
}
.action-btn.danger:hover {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
}

.info-card {
  display: flex;
  gap: 12px;
  background: rgba(6, 182, 212, 0.04);
  border: 1px solid rgba(6, 182, 212, 0.12);
  border-radius: var(--radius-md);
  padding: 14px;
}
.card-icon {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  color: var(--color-secondary);
}
.card-content p {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
}
.arrow-link {
  font-size: 0.72rem;
  color: var(--color-secondary);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.arrow-link i {
  width: 12px;
  height: 12px;
}
.arrow-link:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Full Screen Map & OVERRIDES
   -------------------------------------------------------------------------- */
#map-viewport {
  flex: 1;
  height: 100%;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
}

/* Adjust Leaflet zoom controls to fit our layout */
.leaflet-control-zoom {
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
  box-shadow: var(--shadow-md) !important;
  margin-top: 90px !important; /* Move below top controls */
  margin-left: 20px !important;
}
.leaflet-bar a {
  background: var(--glass-bg) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--glass-border) !important;
}
.leaflet-bar a:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}
.leaflet-bar a.leaflet-disabled {
  opacity: 0.3 !important;
  background: var(--glass-bg) !important;
}

/* Overriding Leaflet attribution panel to modern glass */
.leaflet-control-attribution {
  background: var(--glass-bg) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius-sm) !important;
  margin: 10px !important;
  font-size: 0.65rem !important;
}
.leaflet-control-attribution a {
  color: var(--color-secondary) !important;
}

/* Custom dark/glass popups */
.leaflet-popup-content-wrapper {
  background: var(--glass-bg) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid var(--glass-border) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
}
.leaflet-popup-tip {
  background: var(--glass-bg) !important;
  border: 1px solid var(--glass-border) !important;
}
.leaflet-popup-content {
  font-size: 0.78rem !important;
  line-height: 1.4 !important;
  margin: 12px 16px !important;
}

/* Leaflet marker labels and indicators */
.custom-div-icon {
  background: none;
  border: none;
}
.pulse-ring {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--glow-secondary);
  border: 2px solid var(--color-secondary);
  position: absolute;
  top: -12px;
  left: -12px;
  animation: pulseMarker 1.8s infinite ease-out;
}
.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-secondary);
  position: absolute;
  top: -5px;
  left: -5px;
}

/* --------------------------------------------------------------------------
   Top-Right Map Controls
   -------------------------------------------------------------------------- */
.map-controls-top-right {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  gap: 10px;
}

.glass-btn {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}
.glass-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}
.glass-btn i {
  width: 18px;
  height: 18px;
}

/* Key badge indicator for API Key settings button */
.key-badge-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--bg-primary);
}
.key-badge-dot.active {
  background: var(--color-success);
}
.key-badge-dot.inactive {
  background: var(--color-warning);
}

/* Dropdown Basemap Style Selector */
.basemap-control {
  position: relative;
}
.dropdown-panel {
  position: absolute;
  top: 50px;
  right: 0;
  width: 200px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: slideDown var(--transition-fast);
}
.basemap-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: all var(--transition-fast);
}
.basemap-option:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}
.basemap-option.active {
  color: var(--color-primary);
  background: rgba(99, 102, 241, 0.05);
}
.color-preview {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.color-preview.dark { background: #0c0d12; }
.color-preview.light { background: #f8fafc; }
.color-preview.streets { background: #e0f2fe; }

/* --------------------------------------------------------------------------
   Toast Banner (Map Overlay Notifications)
   -------------------------------------------------------------------------- */
.toast-card {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 19, 26, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-secondary);
  border-radius: var(--radius-xl);
  padding: 10px 20px;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  animation: slideUpToast 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.pulse-icon {
  width: 16px;
  height: 16px;
  animation: pulseScale 1.5s infinite;
}
.text-accent {
  color: var(--color-secondary) !important;
}

/* --------------------------------------------------------------------------
   Developer Sandbox & API Drawer (Bottom Layer)
   -------------------------------------------------------------------------- */
#dev-drawer {
  position: absolute;
  left: calc(var(--sidebar-width) + 40px);
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: var(--drawer-height);
  transition: height var(--transition-normal);
}

/* Drawer Collapsed States */
#dev-drawer.collapsed {
  height: var(--drawer-collapsed-height);
}
#dev-drawer.collapsed .drawer-body {
  opacity: 0;
  pointer-events: none;
}

#dev-drawer-header {
  height: var(--drawer-collapsed-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--glass-border);
  cursor: pointer;
}
#dev-drawer-header:hover {
  background: rgba(255, 255, 255, 0.02);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.terminal-icon {
  width: 18px;
  height: 18px;
  color: var(--color-success);
}
#dev-drawer-header h2 {
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}
.endpoint-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--glass-border);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}
#toggle-drawer-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
}

.drawer-body {
  flex: 1;
  padding: 16px;
  overflow: hidden;
  transition: opacity var(--transition-normal);
}
.dev-log-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: 100%;
}
.log-section {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.log-header h3 {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.copy-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.copy-btn i {
  width: 12px;
  height: 12px;
}
.copy-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.code-container {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px;
  overflow-y: auto;
  font-family: 'Consolas', 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: pre-wrap;
}
.code-container code {
  font-family: inherit;
  color: #a7f3d0; /* Soft mint color */
}
#json-code-block {
  color: #93c5fd; /* Soft blue color */
}

/* Adjust map viewport margin when sidebar collapses */
#sidebar.collapsed ~ #dev-drawer {
  left: 20px;
}

/* --------------------------------------------------------------------------
   Settings & Guide Dialog Modals
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: modalScale var(--transition-normal);
}
.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-title-area h2 {
  font-size: 1.1rem;
}
.modal-icon {
  width: 22px;
  height: 22px;
}
.close-modal-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  padding: 4px;
  border-radius: var(--radius-sm);
}
.close-modal-btn:hover {
  background: var(--glass-border);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
}
.modal-body p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

/* Config Status Alerts */
#auth-check-msg {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#auth-check-msg.success {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid var(--color-success);
  color: var(--color-success);
}
#auth-check-msg.error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid var(--color-danger);
  color: var(--color-danger);
}
#auth-check-msg.loading {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid var(--color-warning);
  color: var(--color-warning);
}

.modal-footer {
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.1);
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Offline PBF Guide Modal Styles */
.guide-card {
  max-width: 650px;
}
.guide-card .modal-body {
  max-height: 450px;
  overflow-y: auto;
}
.markdown-content h3 {
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-top: 18px;
  margin-bottom: 6px;
}
.markdown-content p {
  font-size: 0.8rem;
  margin-bottom: 8px;
}
.markdown-content code {
  font-family: 'Consolas', 'Courier New', monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--color-secondary);
}
.markdown-content .code-container {
  margin-bottom: 12px;
}

/* --------------------------------------------------------------------------
   Animations (Interactive Visual Aesthetics)
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes modalScale {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes slideUpToast {
  from { transform: translate(-50%, 40px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
@keyframes pulseMarker {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes pulseScale {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* --------------------------------------------------------------------------
   Route Alternative Option Cards (Google Maps style comparison)
   -------------------------------------------------------------------------- */
.route-options-comparison {
  animation: slideUp var(--transition-normal);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.route-option-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
}
.route-option-card:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--text-muted);
}
.route-option-card.active {
  background: rgba(99, 102, 241, 0.05);
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
}
.option-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.option-name {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.route-tag {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-xl);
  text-transform: uppercase;
}
.route-tag.fastest {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.route-tag.shortest {
  background: rgba(6, 182, 212, 0.1);
  color: var(--color-secondary);
  border: 1px solid rgba(6, 182, 212, 0.2);
}
.route-tag.fastest-shortest {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.1));
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.route-tag.alt {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
}
.option-metrics {
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.option-duration {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}
.option-distance {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Responsive Media Queries
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  #dev-drawer {
    display: none !important; /* Hide developer sandbox on tablets/mobile */
  }
}

@media (max-width: 600px) {
  #sidebar {
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    border-radius: 0;
  }
  .map-controls-top-right {
    top: auto;
    bottom: 20px;
  }
  .leaflet-control-zoom {
    display: none !important;
  }
}
