/* ==========================================================================
   FlowSync 2.0 — Apple Maps (iOS) Design System
   Parchment Canvas (#F6F1E6), .regularMaterial Blurs, SF Pro System Hierarchy,
   Maps Blue (#0A84FF), Maps Red (#FF3B30), and Native iOS Controls & Dark Mode.
   ========================================================================== */

:root {
  /* Cartography & Canvas (Light Parchment) */
  --map-canvas-bg: #F6F1E6;
  --map-cream: #F6F1E6;
  --map-water: #B9D9EB;
  --map-park: #D6E5C9;
  --map-road: #FFFFFF;
  --map-road-outline: #D5CFC0;
  --map-label: #594F3F;

  /* Primary System Accents */
  --maps-blue: #0A84FF;
  --maps-blue-pressed: #0967D2;
  --maps-red: #FF3B30;
  --maps-green: #34C759;
  --maps-amber: #FF9500;
  --maps-yellow: #FFCC00;
  --maps-purple: #AF52DE;
  --maps-teal: #5AC8FA;
  --maps-indigo: #5856D6;

  /* iOS Surfaces & Materials (Light) */
  --card-canvas: #FFFFFF;
  --surface-gray: #F2F2F7;
  --surface-gray-2: #E5E5EA;
  --surface-gray-3: #D1D1D6;
  --divider: rgba(60, 60, 67, 0.14);
  --material-blur: rgba(255, 255, 255, 0.82);
  --material-blur-border: rgba(255, 255, 255, 0.65);
  
  /* Text (Light) */
  --ink: #000000;
  --ink-secondary: rgba(60, 60, 67, 0.60);
  --ink-tertiary: rgba(60, 60, 67, 0.30);
  --ink-quaternary: rgba(60, 60, 67, 0.18);
  --text-white: #FFFFFF;
  --card-border: rgba(0, 0, 0, 0.06);
  --shadow-color: rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   Apple Maps iOS Dark Mode
   Cool Charcoal Canvas (#000000), Warm Dark Land (#2A2826), Deep Navy Water (#1C2638),
   Dark Card Surfaces (#1C1C1E), Brighter Maps Blue (#409CFF).
   ========================================================================== */
body.dark-mode {
  --map-canvas-bg: #1C1C1E;
  --map-cream: #2A2826;
  --map-water: #1C2638;
  --map-park: #2C3A2A;
  --map-road: #38383A;
  --map-road-outline: #2C2C2E;
  --map-label: #EBEBF5;

  /* Boosted Accents for Dark Mode Legibility */
  --maps-blue: #409CFF;
  --maps-blue-pressed: #0A84FF;
  --maps-red: #FF453A;
  --maps-green: #30D158;
  --maps-amber: #FF9F0A;
  --maps-yellow: #FFD60A;
  --maps-purple: #BF5AF2;
  --maps-teal: #64D2FF;
  --maps-indigo: #5E5CE6;

  /* iOS Surfaces & Materials (Dark) */
  --card-canvas: #1C1C1E;
  --surface-gray: #2C2C2E;
  --surface-gray-2: #3A3A3C;
  --surface-gray-3: #48484A;
  --divider: rgba(255, 255, 255, 0.12);
  --material-blur: rgba(28, 28, 30, 0.84);
  --material-blur-border: rgba(255, 255, 255, 0.10);

  /* Text (Dark) */
  --ink: #FFFFFF;
  --ink-secondary: rgba(235, 235, 245, 0.60);
  --ink-tertiary: rgba(235, 235, 245, 0.30);
  --ink-quaternary: rgba(235, 235, 245, 0.18);
  --card-border: rgba(255, 255, 255, 0.08);
  --shadow-color: rgba(0, 0, 0, 0.35);
}

/* Typography & Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--map-canvas-bg);
  color: var(--ink);
  overflow: hidden;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  transition: background-color 0.3s ease, color 0.3s ease;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Apple .regularMaterial Blur */
.ios-material {
  background: var(--material-blur);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  border: 1px solid var(--material-blur-border);
  box-shadow: 0 8px 32px var(--shadow-color), 0 2px 6px rgba(0, 0, 0, 0.04);
}

.ios-card {
  background: var(--card-canvas);
  border: 1px solid var(--card-border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
  color: var(--ink);
}

/* Apple Maps Floating Controls Stack (Top-Right) */
.map-control-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--material-blur);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--material-blur-border);
  box-shadow: 0 4px 14px var(--shadow-color), 0 1px 3px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-control-btn:hover {
  transform: scale(1.06);
  background: var(--surface-gray-2);
}

.map-control-btn:active {
  transform: scale(0.95);
}

/* Apple Maps Current Location Puck */
.location-puck-container {
  position: relative;
  width: 22px;
  height: 22px;
}

.location-puck-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--maps-blue);
  border: 3px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(10, 132, 255, 0.4);
  position: relative;
  z-index: 2;
}

.location-puck-pulse {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(10, 132, 255, 0.35);
  animation: apple-puck-pulse 2000ms infinite ease-out;
  z-index: 1;
}

@keyframes apple-puck-pulse {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Category Pill */
.category-pill {
  flex-shrink: 0;
  width: 68px;
  padding: 10px 6px;
  border-radius: 14px;
  background: var(--card-canvas);
  border: 1px solid var(--card-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-color);
}

.category-pill:active {
  transform: scale(0.96);
}

/* iOS Segmented Control */
.ios-segmented {
  background: var(--surface-gray);
  padding: 3px;
  border-radius: 10px;
  display: flex;
  border: 1px solid var(--card-border);
}

.ios-segment-btn {
  flex: 1;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.ios-segment-btn.active {
  background: var(--card-canvas);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* iOS Primary Buttons */
.ios-btn-primary {
  background: var(--maps-blue);
  color: #FFFFFF;
  font-weight: 600;
  border-radius: 12px;
  padding: 10px 18px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(10, 132, 255, 0.28);
}

.ios-btn-primary:hover {
  background: var(--maps-blue-pressed);
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.38);
}

.ios-btn-primary:active {
  transform: scale(0.98);
}

.ios-btn-secondary {
  background: var(--surface-gray);
  color: var(--maps-blue);
  font-weight: 600;
  border-radius: 12px;
  padding: 10px 18px;
  border: 1px solid var(--surface-gray-2);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ios-btn-secondary:hover {
  background: var(--surface-gray-2);
}

.ios-btn-emergency {
  background: var(--maps-red);
  color: #FFFFFF;
  font-weight: 600;
  border-radius: 12px;
  padding: 10px 16px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(255, 59, 48, 0.28);
}

.ios-btn-emergency:hover {
  background: #E02B20;
}

.ios-btn-emergency:active {
  transform: scale(0.98);
}

/* iOS Style Theme Toggle Switch */
.theme-toggle-container {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-gray);
  padding: 3px 6px;
  border-radius: 20px;
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle-container:hover {
  background: var(--surface-gray-2);
}

.theme-toggle-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-secondary);
  transition: all 0.2s ease;
}

.theme-toggle-btn.active {
  background: var(--card-canvas);
  color: var(--maps-blue);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* Leaflet Container on Canvas */
.leaflet-container {
  background-color: var(--map-canvas-bg) !important;
  outline: none;
  font-family: inherit;
  transition: background-color 0.3s ease;
}

/* Apple Maps Tooltip & Callout */
.leaflet-tooltip {
  background: var(--card-canvas) !important;
  border: 1px solid var(--card-border) !important;
  color: var(--ink) !important;
  box-shadow: 0 6px 20px var(--shadow-color) !important;
  border-radius: 10px !important;
  padding: 6px 10px !important;
  font-family: inherit !important;
  font-size: 12px !important;
}

.leaflet-popup-content-wrapper {
  background: var(--card-canvas) !important;
  color: var(--ink) !important;
  border-radius: 16px !important;
  box-shadow: 0 10px 30px var(--shadow-color) !important;
  padding: 4px !important;
}

.leaflet-popup-tip {
  background: var(--card-canvas) !important;
}

/* Route Option Card in Place Card / MaaS View */
.trip-option-card {
  background: var(--card-canvas);
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.trip-option-card:hover {
  transform: translateY(-2px);
  border-color: rgba(10, 132, 255, 0.4);
  box-shadow: 0 6px 18px rgba(10, 132, 255, 0.12);
}

.trip-option-card.active-route {
  border-color: var(--maps-blue);
  background: rgba(10, 132, 255, 0.05);
  box-shadow: 0 0 0 2px var(--maps-blue), 0 8px 24px rgba(10, 132, 255, 0.16);
}

/* Signal Dot Badges */
.signal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.signal-dot.green {
  background: var(--maps-green);
  box-shadow: 0 0 6px var(--maps-green);
}

.signal-dot.yellow {
  background: var(--maps-amber);
  box-shadow: 0 0 6px var(--maps-amber);
}

.signal-dot.red {
  background: var(--maps-red);
  box-shadow: 0 0 6px var(--maps-red);
}

/* Real-Time ATCS Signal Head Housing (3-Lamp Vertical) */
.signal-head-housing {
  background: #111113;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 4px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.signal-head-lamp {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.signal-head-lamp.active-red {
  background: #FF3B30;
  box-shadow: 0 0 8px #FF3B30;
}

.signal-head-lamp.active-yellow {
  background: #FF9500;
  box-shadow: 0 0 8px #FF9500;
}

.signal-head-lamp.active-green {
  background: #34C759;
  box-shadow: 0 0 8px #34C759;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(120, 120, 128, 0.25);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 120, 128, 0.45);
}
