/* ==========================================================================
   MetroSathi - Mobile-First Transit Design System
   ========================================================================== */

:root {
  --font-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "Plus Jakarta Sans", system-ui, sans-serif;

  /* Theme: Light */
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-raised: #F1F5F9;
  --border: #E2E8F0;
  --border-focus: #2563EB;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-subtle: #94A3B8;

  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-subtle: #EFF6FF;
  --primary-fg: #FFFFFF;

  --accent-green: #10B981;
  --accent-amber: #F59E0B;
  --accent-red: #EF4444;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  --bg: #0B0F17;
  --surface: #131B2B;
  --surface-raised: #1C273C;
  --border: #2A3852;
  --border-focus: #3B82F6;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-subtle: #64748B;

  --primary: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-subtle: #1E293B;
  --primary-fg: #FFFFFF;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0F17;
    --surface: #131B2B;
    --surface-raised: #1C273C;
    --border: #2A3852;
    --border-focus: #3B82F6;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --text-subtle: #64748B;
    --primary: #3B82F6;
    --primary-hover: #60A5FA;
    --primary-subtle: #1E293B;
    --primary-fg: #FFFFFF;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: max(32px, env(safe-area-inset-bottom, 20px));
}

/* Base Container */
.app-container {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   Header & City Bar
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  margin: 0 -16px 4px -16px;
}

.header-inner {
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-main);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563EB, #7C3AED);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* City Switcher Pill Button */
.city-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.city-pill-btn:hover {
  border-color: var(--border-focus);
  background-color: var(--surface-raised);
}

.city-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.15s ease;
}

.icon-btn:hover {
  background-color: var(--surface-raised);
}

/* ==========================================================================
   City Tagline Banner
   ========================================================================== */
.city-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
}

.city-banner-text h1 {
  font-size: 16px;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
}

.city-banner-text p {
  font-size: 12px;
  color: var(--text-muted);
}

.city-lines-preview {
  display: flex;
  gap: 5px;
}

.line-chip {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Weather Bar (Above Planner)
   ========================================================================== */
.weather-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.weather-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.weather-icon {
  font-size: 18px;
}

.weather-tip {
  color: var(--text-muted);
  font-size: 12px;
}

/* ==========================================================================
   Planner Tabs (Journey Planner vs. Network Map)
   ========================================================================== */
.planner-tabs {
  display: flex;
  background-color: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 4px;
}

.planner-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.planner-tab-btn.active {
  background-color: var(--surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* Planner Heading */
.planner-heading {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  margin-bottom: 2px;
}

/* ==========================================================================
   Network Map Tab Panel
   ========================================================================== */
.map-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0;
}

.map-zoom-tools {
  display: flex;
  gap: 6px;
}

.zoom-btn {
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.zoom-btn:hover {
  background-color: var(--surface-raised);
}

.map-viewport {
  width: 100%;
  height: 420px;
  background-color: #FAFAFA;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="dark"] .map-viewport {
  background-color: #0F172A;
}

.map-canvas-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.map-image-render {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
  transform-origin: center center;
  box-shadow: var(--shadow-sm);
}

/* Section Title Center & Bottom */
.section-title-center {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  text-align: center;
  margin: 6px 0 10px 0;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin: 16px 0 8px 0;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Feedback link in footer / header */
.feedback-trigger-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.feedback-trigger-btn:hover {
  text-decoration: underline;
}

/* Journey Planner Card */
.planner-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.planner-inputs {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-row {
  display: flex;
  align-items: center;
  background-color: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.input-row:focus-within, .input-row.active {
  border-color: var(--border-focus);
  background-color: var(--surface);
  outline: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
}

.pin {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
}
.pin-origin { background-color: var(--accent-green); }
.pin-destination { background-color: var(--accent-red); }

.input-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.input-label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.input-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-val.placeholder {
  color: var(--text-subtle);
  font-weight: 400;
}

.swap-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 2;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.15s ease;
}

.swap-btn:hover {
  background-color: var(--surface-raised);
}

.swap-btn:active {
  transform: translateY(-50%) rotate(180deg);
}

/* Near Me Chip & Quick Bar */
.planner-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.near-me-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--accent-green) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-green) 35%, transparent);
  color: color-mix(in srgb, var(--accent-green) 85%, #000);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

[data-theme="dark"] .near-me-btn {
  color: #34D399;
}

.near-me-btn:hover {
  background: color-mix(in srgb, var(--accent-green) 20%, transparent);
}

/* Red Bold Reset Button */
.clear-btn {
  background: none;
  border: none;
  color: var(--accent-red);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease;
}

.clear-btn:hover {
  background-color: color-mix(in srgb, var(--accent-red) 10%, transparent);
}

/* Recent Trips Chips */
.recent-trips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.recent-trips::-webkit-scrollbar { display: none; }

.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
}

.recent-chip:hover {
  border-color: var(--border-focus);
  color: var(--text-main);
}

/* ==========================================================================
   Route Result Components
   ========================================================================== */
#route-result-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
}

.route-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.route-headline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.big-time {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.route-stats-row {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.badge-interchange {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--primary-subtle);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.badge-direct {
  background-color: color-mix(in srgb, var(--accent-green) 12%, transparent);
  color: #059669;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

/* Fare Ribbon */
.fare-ribbon {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 13px;
}

.fare-ribbon b {
  font-family: var(--font-display);
  font-size: 15px;
}

.fare-discount {
  color: var(--accent-green);
  font-weight: 600;
}

/* Turn-by-Turn Leg Cards */
.legs-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.leg-card {
  position: relative;
  display: grid;
  grid-template-columns: 8px 1fr;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.leg-stripe {
  width: 8px;
  height: 100%;
}

.leg-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.leg-line-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
}

.line-bullet {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.board-direction-box {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border: 1px solid var(--border);
  background-color: var(--surface-raised);
}

.platform-pill {
  min-width: 44px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.platform-pill small {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.direction-details {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.direction-details b {
  font-size: 14px;
  color: var(--text-main);
}

.direction-details span {
  font-size: 12px;
  color: var(--text-muted);
}

.interchange-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-amber);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.interchange-divider::before, .interchange-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--border);
}

/* Station Details Accordion */
details.stops-drawer {
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

details.stops-drawer summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}

details.stops-drawer ol {
  margin: 8px 0 4px 20px;
  padding: 0;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Action Buttons */
.route-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.btn:hover {
  background-color: var(--surface-raised);
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

/* ==========================================================================
   Modals & Bottom Sheet (City Picker & Station Search)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.bottom-sheet {
  width: 100%;
  max-width: 540px;
  background-color: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.open .bottom-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background-color: var(--border);
  align-self: center;
  margin-bottom: -4px;
}

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

.sheet-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.sheet-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
}

.search-input-wrap {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background-color: var(--surface-raised);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--border-focus);
  background-color: var(--surface);
}

.station-list, .city-grid {
  list-style: none;
  overflow-y: auto;
  max-height: 52vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}

.station-item-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.station-item-btn:hover {
  background-color: var(--surface-raised);
}

.station-item-name {
  font-weight: 500;
  font-size: 14px;
  flex: 1;
}

.station-item-dots {
  display: flex;
  gap: 4px;
}

/* City Cards in Switcher */
.city-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.city-card:hover {
  border-color: var(--border-focus);
  background-color: var(--surface-raised);
}

.city-card.selected {
  border-color: var(--primary);
  background-color: var(--primary-subtle);
}

.city-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.city-card-title b {
  font-size: 15px;
  display: block;
}

.city-card-title span {
  font-size: 12px;
  color: var(--text-muted);
}

/* Emergency Helpline & Footer */
.network-info-card {
  margin-top: 8px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.helpline-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
