:root {
  /* MD3 Dark Theme Colors - Seed: #1565C0 */
  --md-sys-color-primary: #A0CAFD;
  --md-sys-color-on-primary: #003258;
  --md-sys-color-primary-container: #00497D;
  --md-sys-color-on-primary-container: #D1E4FF;
  
  --md-sys-color-secondary: #BAC8DB;
  --md-sys-color-on-secondary: #253140;
  --md-sys-color-secondary-container: #3B4858;
  --md-sys-color-on-secondary-container: #D7E3F7;
  
  --md-sys-color-tertiary: #D5BEE5;
  --md-sys-color-on-tertiary: #3A2948;
  --md-sys-color-tertiary-container: #524060;
  --md-sys-color-on-tertiary-container: #F1DBFF;
  
  --md-sys-color-error: #FFB4AB;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000A;
  --md-sys-color-on-error-container: #FFDAD6;
  
  --md-sys-color-surface: #111318;
  --md-sys-color-surface-variant: #43474E;
  --md-sys-color-on-surface: #E1E2E9;
  --md-sys-color-on-surface-variant: #C3C6CF;
  
  --md-sys-color-surface-container-lowest: #0C0E13;
  --md-sys-color-surface-container-low: #191C20;
  --md-sys-color-surface-container: #1D2024;
  --md-sys-color-surface-container-high: #282A2F;
  --md-sys-color-surface-container-highest: #33353A;
  
  --md-sys-color-outline: #8D9199;
  --md-sys-color-outline-variant: #43474E;
  
  --md-sys-color-inverse-surface: #E1E2E9;
  --md-sys-color-inverse-on-surface: #2E3036;
  --md-sys-color-inverse-primary: #1565C0;
  
  /* Extended Custom Transport Colors */
  --md-extended-color-success: #6DD58C;
  --md-extended-color-on-success: #003919;
  --md-extended-color-warning: #FFB95A;
  --md-extended-color-on-warning: #422D00;

  /* Shape Tokens */
  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-extra-large: 28px;
  --md-sys-shape-corner-full: 9999px;

  /* Motion Tokens */
  --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --md-sys-motion-easing-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1);
  --md-sys-motion-easing-emphasized-accelerate: cubic-bezier(0.3, 0, 0.8, 0.15);
  --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);

  /* Elevation Surface Tokens */
  --md-sys-elevation-level1: var(--md-sys-color-surface-container-low);
  --md-sys-elevation-level2: var(--md-sys-color-surface-container);
  --md-sys-elevation-level3: var(--md-sys-color-surface-container-high);
  --md-sys-elevation-level4: var(--md-sys-color-surface-container-highest);
  --md-sys-elevation-level5: #3B3E44;

  /* Typography */
  --md-sys-typescale-font: 'Roboto Flex', 'Roboto', system-ui, sans-serif;
}

/* =========================================
   Global Reset & Defaults
   ========================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--md-sys-typescale-font);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  overflow: hidden;
  user-select: text;
  font-size: 16px;
  line-height: 1.5;
}

button, .drag-handle-zone, md-tabs, .logo-badge, .brand-title {
  user-select: none;
}

:focus-visible {
  outline: 2px solid var(--md-sys-color-primary) !important;
  outline-offset: 2px !important;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-corner-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--md-sys-color-outline);
}

/* =========================================
   Application Layout
   ========================================= */
#app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* Desktop Sidebar */
#sidebar {
  width: 420px;
  height: 100%;
  background-color: var(--md-sys-color-surface-container-low);
  border-right: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  z-index: 500;
  transition: height 0.35s var(--md-sys-motion-easing-emphasized);
}

/* Desktop: Drag handle is hidden */
.drag-handle-zone {
  display: none;
}

#map {
  flex-grow: 1;
  height: 100%;
  background-color: var(--md-sys-color-surface-container-lowest);
  z-index: 1;
}

/* =========================================
   Mobile Layout (Responsive Bottom Sheet)
   ========================================= */
@media (max-width: 768px) {
  #app-container {
    flex-direction: column;
  }

  #map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
  }

  #sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: var(--md-sys-shape-corner-extra-large) var(--md-sys-shape-corner-extra-large) 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
    background-color: var(--md-sys-elevation-level2);
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    will-change: height;
    z-index: 500;
  }

  .drag-handle-zone {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 24px;
    width: 100%;
    cursor: grab;
    touch-action: none;
    padding-top: 4px;
  }

  .drag-handle-bar {
    width: 36px;
    height: 4px;
    border-radius: var(--md-sys-shape-corner-full);
    background-color: var(--md-sys-color-outline);
  }

  /* Bottom Sheet States */
  #sidebar.sheet-collapsed {
    height: calc(84px + env(safe-area-inset-bottom, 0px));
  }
  #sidebar.sheet-half {
    height: 44vh;
    height: 44dvh;
  }
  #sidebar.sheet-expanded {
    height: calc(85vh - 16px);
    height: calc(85dvh - env(safe-area-inset-top, 16px) - 16px);
  }

  /* Compact collapsed state on mobile: hides massive brand bar, reveals 90% map */
  #sidebar.sheet-collapsed .brand {
    display: none !important;
  }
  #sidebar.sheet-collapsed .sidebar-header {
    padding: 0 16px 10px 16px;
    gap: 0;
  }
  #sidebar.sheet-collapsed #main-tabs,
  #sidebar.sheet-collapsed #chips-carousel,
  #sidebar.sheet-collapsed .sidebar-content {
    display: none !important;
  }

  /* Compact route/stop detail card on mobile: leaves 70% of screen for the map */
  #sidebar.detail-active.sheet-collapsed,
  #sidebar.detail-active.sheet-half {
    height: 230px;
  }
  #sidebar.detail-active.sheet-expanded {
    height: calc(85dvh - env(safe-area-inset-top, 16px) - 16px);
  }

  #sidebar.sheet-expanded .sidebar-header,
  #sidebar.sheet-expanded .detail-header {
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
  }

  .sidebar-content {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #sidebar.detail-active .sidebar-header,
  #sidebar.detail-active #main-tabs {
    display: none !important;
  }
}

/* =========================================
   Sidebar Header & Branding
   ========================================= */
.sidebar-header {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--md-sys-shape-corner-medium);
  background-color: var(--md-sys-color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon {
  color: var(--md-sys-color-on-primary);
  font-size: 26px;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--md-sys-color-on-surface);
}

.brand-subtitle {
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--md-sys-color-surface-container-highest);
  padding: 6px 12px;
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 11px;
  font-weight: 700;
  color: var(--md-extended-color-success);
  border: 1px solid rgba(109, 213, 140, 0.2);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--md-extended-color-success);
  border-radius: 50%;
  position: relative;
}

.pulse-dot::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  background-color: var(--md-extended-color-success);
  animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* =========================================
   Search
   ========================================= */
.search-container {
  display: flex;
  align-items: center;
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-corner-full);
  height: 52px;
  padding: 0 16px;
  gap: 12px;
  transition: background-color 0.2s;
}

.search-container:focus-within {
  background-color: var(--md-sys-elevation-level5);
}

.search-icon, .search-clear {
  color: var(--md-sys-color-on-surface-variant);
}

.search-clear {
  cursor: pointer;
  padding: 4px;
}

.search-input {
  flex-grow: 1;
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  font-size: 15px;
  outline: none;
}

.search-input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

/* =========================================
   Chips Carousel
   ========================================= */
.chips-carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 16px 12px 16px;
  flex-shrink: 0;
  scrollbar-width: none;
}

.chips-carousel::-webkit-scrollbar {
  display: none;
}

/* =========================================
   Tabs Navigation
   ========================================= */
.tabs-nav {
  display: flex;
  padding: 0 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  flex-shrink: 0;
}

/* =========================================
   Content Area & Route Cards
   ========================================= */
.sidebar-content {
  flex-grow: 1;
  overflow-y: auto;
  position: relative;
}

#main-list {
  display: flex;
  flex-direction: column;
}

/* Route Badges & Items */
.route-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 32px;
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-radius: var(--md-sys-shape-corner-full);
  font-weight: 700;
  font-size: 15px;
  padding: 0 8px;
}

.route-price {
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
}

.badge-lowfloor {
  display: inline-flex;
  align-items: center;
  color: var(--md-extended-color-success);
}

.favorite-btn.active md-icon {
  color: #FFB95A;
  font-variation-settings: 'FILL' 1;
}

/* =========================================
   Detail Views (Route & Stop)
   ========================================= */
.detail-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.detail-header {
  padding: 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--md-sys-color-surface-container);
}

.detail-header-top {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.detail-title-wrap {
  flex-grow: 1;
  min-width: 0;
}

.detail-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-subtitle {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

/* Direction Switcher */
.direction-switcher {
  display: flex;
  padding: 8px 16px;
  gap: 8px;
  background-color: var(--md-sys-color-surface-container-low);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.dir-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  color: var(--md-sys-color-on-surface-variant);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dir-btn.active {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

/* Timeline Container */
.timeline-container {
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.timeline-item {
  display: flex;
  gap: 16px;
  position: relative;
  min-height: 48px;
  cursor: pointer;
  outline: none;
}

.timeline-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 24px;
  flex-shrink: 0;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--md-sys-color-surface-container-highest);
  border: 2px solid var(--md-sys-color-outline);
  z-index: 2;
  transition: transform 0.2s, background-color 0.2s;
}

.timeline-dot.terminal {
  width: 14px;
  height: 14px;
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}

.timeline-item:hover .timeline-dot,
.timeline-item:focus-visible .timeline-dot {
  transform: scale(1.3);
  background-color: var(--md-sys-color-primary);
}

.timeline-line {
  width: 2px;
  flex-grow: 1;
  background-color: var(--md-sys-color-outline-variant);
  margin: 4px 0;
}

.timeline-content {
  flex-grow: 1;
  padding-bottom: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.timeline-stop-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.timeline-bus-slot {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.timeline-bus-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  padding: 2px 8px;
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 11px;
  font-weight: 700;
}

/* =========================================
   Stop Platforms Switcher
   ========================================= */
.stop-platforms-container {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 0 0;
  scrollbar-width: none;
}

.stop-platforms-container::-webkit-scrollbar {
  display: none;
}

.platform-pill {
  flex: 1;
  min-width: 120px;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: var(--md-sys-shape-corner-medium);
  background-color: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 2px;
  outline: none;
}

.platform-pill.active {
  background-color: var(--md-sys-color-secondary-container);
  border-color: var(--md-sys-color-primary);
}

.platform-pill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
}

.platform-pill-badge {
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface-variant);
  border-radius: var(--md-sys-shape-corner-full);
  padding: 1px 6px;
  font-size: 10px;
}

.platform-pill.active .platform-pill-badge {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.platform-pill-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================
   ETA & Schedule Containers
   ========================================= */
.stop-live-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background-color: var(--md-sys-color-surface-container-lowest);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.live-dot {
  width: 8px;
  height: 8px;
  background-color: var(--md-extended-color-success);
  border-radius: 50%;
  display: inline-block;
  animation: livePulse 1.5s infinite;
  margin-right: 6px;
}

@keyframes livePulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.live-text {
  font-size: 11px;
  font-weight: 700;
  color: var(--md-extended-color-success);
}

.stop-last-updated {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

.eta-container, .schedule-container {
  padding: 8px 0;
}

.eta-time.approaching {
  color: var(--md-extended-color-success);
  animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* =========================================
   Floating Map Controls
   ========================================= */
.map-floating-controls {
  position: absolute;
  right: 16px;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 400;
  touch-action: manipulation;
}

@media (max-width: 768px) {
  .map-floating-controls {
    top: auto;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    transition: bottom 0.35s var(--md-sys-motion-easing-emphasized);
    z-index: 450;
  }
}

/* =========================================
   Map Markers (Leaflet DivIcons)
   ========================================= */
.leaflet-div-icon {
  background: transparent !important;
  border: none !important;
}

.custom-stop-icon-wrapper,
.custom-platform-icon-wrapper,
.custom-vehicle-icon,
.user-location-icon {
  background: transparent !important;
  border: none !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.vehicle-marker {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vehicle-arrow-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.vehicle-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 11px solid var(--md-sys-color-primary);
  top: -6px;
  z-index: 1;
}

.vehicle-arrow.stale {
  border-bottom-color: var(--md-sys-color-outline) !important;
}

.vehicle-icon-circle {
  width: 32px;
  height: 32px;
  background-color: var(--md-sys-color-primary-container);
  border: 2px solid var(--md-sys-color-on-primary-container);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  z-index: 2;
}

.vehicle-icon-circle.stale {
  background-color: var(--md-sys-color-surface-container-highest) !important;
  border-color: var(--md-sys-color-outline) !important;
  opacity: 0.7;
}

.vehicle-icon-circle .material-symbols-outlined {
  color: var(--md-sys-color-on-primary-container);
  font-size: 18px;
}

.vehicle-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  padding: 1px 6px;
  border-radius: var(--md-sys-shape-corner-small);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  z-index: 3;
}

.vehicle-label.stale {
  opacity: 0.7;
  border-color: var(--md-sys-color-outline);
}

.custom-stop-marker {
  width: 12px;
  height: 12px;
  background-color: var(--md-sys-color-surface);
  border: 3px solid var(--md-sys-color-primary);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  margin: 6px auto;
}

.custom-stop-marker.terminal {
  width: 16px;
  height: 16px;
  background-color: var(--md-sys-color-primary);
  border: 3px solid var(--md-sys-color-surface);
  margin: 4px auto;
}

.custom-platform-marker {
  width: 32px;
  height: 32px;
  background-color: var(--md-sys-color-surface-container-high);
  border: 2px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.custom-platform-marker.active {
  background-color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-on-primary);
  color: var(--md-sys-color-on-primary);
}

.platform-tag {
  position: absolute;
  bottom: -14px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  background: rgba(0,0,0,0.7);
  padding: 0 4px;
  border-radius: 4px;
}

.user-marker {
  width: 20px;
  height: 20px;
  background-color: var(--md-sys-color-primary);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(160, 202, 253, 0.4);
  margin: 2px auto;
}

/* =========================================
   Vehicle Popups & Tooltips (Leaflet override)
   ========================================= */
.vehicle-popup-content {
  font-family: var(--md-sys-typescale-font);
  font-size: 14px;
  min-width: 180px;
}
.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.popup-route-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--md-sys-color-primary);
}
.popup-badge {
  color: var(--md-extended-color-success);
  font-size: 12px;
  font-weight: 500;
}
.popup-info {
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 4px;
}
.popup-footer {
  color: var(--md-sys-color-outline);
  font-size: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--md-sys-color-surface-container-highest);
  padding-top: 6px;
}

.leaflet-tooltip.leaflet-custom-tooltip {
  background-color: var(--md-sys-color-surface-container-high) !important;
  color: var(--md-sys-color-on-surface) !important;
  border: 1px solid var(--md-sys-color-outline-variant) !important;
  border-radius: var(--md-sys-shape-corner-small) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
  padding: 6px 10px !important;
  font-family: var(--md-sys-typescale-font) !important;
}

.leaflet-tooltip-top.leaflet-custom-tooltip::before {
  border-top-color: var(--md-sys-color-surface-container-high) !important;
}

/* =========================================
   Empty States & Loading
   ========================================= */
.state-empty, .state-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 16px;
  color: var(--md-sys-color-on-surface-variant);
  gap: 16px;
  height: 100%;
}

.state-empty .material-symbols-outlined {
  font-size: 48px;
  opacity: 0.5;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--md-sys-color-surface-container-highest);
  border-top: 4px solid var(--md-sys-color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* =========================================
   Toast Notifications
   ========================================= */
.md3-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  background-color: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  padding: 14px 24px;
  border-radius: var(--md-sys-shape-corner-extra-small);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
}

.md3-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 768px) {
  .md3-toast {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
}

/* =========================================
   Leaflet Theme Overrides (Dark MD3)
   ========================================= */
.leaflet-container {
  font-family: var(--md-sys-typescale-font) !important;
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background-color: var(--md-sys-color-surface-container-high) !important;
  color: var(--md-sys-color-on-surface) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
}

.leaflet-popup-content-wrapper {
  border-radius: var(--md-sys-shape-corner-medium) !important;
  border: 1px solid var(--md-sys-color-outline-variant);
}

.leaflet-container a.leaflet-popup-close-button {
  color: var(--md-sys-color-on-surface-variant) !important;
  padding: 8px !important;
}

.leaflet-bar a {
  background-color: var(--md-sys-color-surface-container-high) !important;
  color: var(--md-sys-color-on-surface) !important;
  border-color: var(--md-sys-color-outline-variant) !important;
}

.leaflet-bar a:hover {
  background-color: var(--md-sys-color-surface-container-highest) !important;
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
