/*
 * style.css — Adur & Worthing Live Bus Tracker
 *
 * All colours and spacing are defined as CSS custom properties (variables)
 * in :root so the design can be easily rebranded — for example, to match
 * Adur & Worthing Councils' colour palette — by changing only this block.
 *
 * FUTURE THEMING: Replace the values in :root below to rebrand.
 */

/* ===== DESIGN TOKENS ===== */
:root {
  /* Brand colours */
  --color-primary:        #005ea5;   /* Main blue — change for council branding */
  --color-primary-dark:   #004378;
  --color-primary-light:  #e8f1fb;
  --color-accent:         #f4a020;   /* Amber highlight for live/on-time */

  /* Status colours */
  --color-on-time:        #2e7d32;   /* Green */
  --color-early:          #1565c0;   /* Blue */
  --color-late:           #c62828;   /* Red */
  --color-unknown:        #616161;   /* Grey */

  /* Neutral palette */
  --color-bg:             #f5f7fa;
  --color-surface:        #ffffff;
  --color-border:         #dde3ec;
  --color-text:           #1a1a2e;
  --color-text-muted:     #5a6378;
  --color-text-inverse:   #ffffff;

  /* Typography */
  --font-family:          system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-size-xs:         0.72rem;
  --font-size-sm:         0.85rem;
  --font-size-base:       1rem;
  --font-size-lg:         1.125rem;
  --font-size-xl:         1.35rem;

  /* Spacing */
  --space-xs:   0.25rem;
  --space-sm:   0.5rem;
  --space-md:   1rem;
  --space-lg:   1.5rem;
  --space-xl:   2rem;

  /* Border radius */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.16);

  /* Transitions */
  --transition: 200ms ease;

  /* Layout */
  --header-height:       60px;
  --panel-width:         360px;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;           /* Prevent page scroll — map fills viewport */
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-primary);
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ===== HEADER ===== */
.site-header {
  height: var(--header-height);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  flex-shrink: 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 var(--space-lg);
  max-width: 100%;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.header-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-text-inverse);
}

.header-subtitle {
  font-size: var(--font-size-xs);
  opacity: 0.8;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.last-updated {
  font-size: var(--font-size-xs);
  opacity: 0.85;
  white-space: nowrap;
}

.btn-icon {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  color: var(--color-text-inverse);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background var(--transition);
}

.btn-icon:hover {
  background: rgba(255,255,255,0.25);
}

/* ===== MAIN LAYOUT ===== */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ===== MAP SECTION ===== */
.map-section {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

/* Map loading overlay */
.map-loading {
  position: absolute;
  inset: 0;
  background: rgba(245, 247, 250, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  z-index: 600;
  transition: opacity var(--transition);
}

.map-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ===== SPINNER ===== */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner.small {
  width: 24px;
  height: 24px;
  border-width: 3px;
}

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

/* ===== DEPARTURE PANEL ===== */
.departure-panel {
  width: var(--panel-width);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 900;
  transition: transform var(--transition), width var(--transition);
  flex-shrink: 0;
}

/* On mobile, the panel slides up from the bottom */
@media (max-width: 700px) {
  .main-layout {
    flex-direction: column;
  }

  .departure-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--color-border);
    max-height: 45vh;
    min-height: 0;
    flex-shrink: 0;
  }
}

/* Panel header */
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-md) var(--space-md) var(--space-sm);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-primary-light);
  flex-shrink: 0;
}

.panel-header-text {
  flex: 1;
  min-width: 0;
}

.panel-stop-name {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-stop-id {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--color-text-muted);
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
  margin-left: var(--space-sm);
}

.btn-close:hover {
  background: var(--color-border);
  color: var(--color-text);
}

/* Panel states */
.panel-loading,
.panel-error,
.panel-prompt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-muted);
}

.panel-prompt-icon {
  font-size: 2.5rem;
}

.panel-error {
  color: var(--color-late);
}

.btn-retry {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  transition: background var(--transition);
}

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

/* Departures container */
.departures-container {
  flex: 1;
  min-height: 0;           /* Allow shrinking below intrinsic content size */
  overflow-y: auto;
}

.departures-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.btn-text {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

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

/* Departures table */
.departures-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.departures-table thead {
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.departures-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
}

.departures-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.departures-table tr:last-child td {
  border-bottom: none;
}

.departures-table tr.departure-row {
  cursor: pointer;
}

.departures-table tr:hover td {
  background: var(--color-primary-light);
}

/* Service number badge */
.service-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-weight: 700;
  font-size: var(--font-size-xs);
  min-width: 36px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* Destination text */
.destination-text {
  color: var(--color-text);
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Due time */
.due-time {
  font-weight: 700;
  white-space: nowrap;
}

.due-time.due-imminent {
  color: var(--color-accent);
}

/* Status chips */
.status-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
}

.status-on-time {
  background: #e8f5e9;
  color: var(--color-on-time);
}

.status-early {
  background: #e3f2fd;
  color: var(--color-early);
}

.status-late {
  background: #ffebee;
  color: var(--color-late);
}

.status-scheduled {
  background: var(--color-bg);
  color: var(--color-unknown);
}

.departures-footer {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--color-border);
}

/* ===== NO DEPARTURES STATE ===== */
.no-departures {
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-text-inverse);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  z-index: 2000;
  max-width: 90vw;
  text-align: center;
  transition: opacity var(--transition);
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ===== UTILITY ===== */
.hidden {
  display: none !important;
}

/* ===== FOOTER ===== */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-align: center;
  flex-shrink: 0;
  z-index: 100;
}

/* ===== LEAFLET CUSTOM MARKERS ===== */

/* Bus stop icon (circular, primary blue) */
.stop-marker-icon {
  background: var(--color-primary);
  border: 2px solid var(--color-primary-dark);
  border-radius: 50%;
  width: 12px !important;
  height: 12px !important;
  transition: transform 0.15s;
}

.stop-marker-icon:hover {
  transform: scale(1.4);
}

/* Bus vehicle marker — divIcon root */
.bus-marker-divicon {
  background: transparent !important;
  border: none !important;
}

.bus-marker-wrapper {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

/* Operator icon image — rotated by bearing.
   Source icons should face EAST (right) at 0deg. */
.bus-icon-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.4s ease-out;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.45));
  display: block;
}

/* Route number overlaid on the icon. Stays upright (not rotated). */
.bus-icon-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
     0    0   2px rgba(0,0,0,0.85);
}

/* Fallback for operators without an icon — keeps the old amber box look */
.bus-icon-fallback {
  background: var(--color-accent);
  border: 2px solid #c07800;
  border-radius: 4px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  white-space: nowrap;
  padding: 0 4px;
  min-width: 26px;
  height: 18px;
  box-shadow: var(--shadow-sm);
}

/* Leaflet popup customisation */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: var(--font-family) !important;
}

.leaflet-popup-content {
  margin: 10px 14px !important;
  font-size: var(--font-size-sm) !important;
}

.popup-stop-name {
  font-weight: 700;
  color: var(--color-primary-dark);
  margin-bottom: 4px;
}

.popup-stop-id {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.popup-btn {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  width: 100%;
  transition: background var(--transition);
}

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

/* ===== TABBED PANEL ===== */
.panel-tabs-bar {
  display: flex;
  align-items: stretch;
  background: var(--color-primary);
  border-bottom: 1px solid var(--color-primary-dark);
  flex-shrink: 0;
}

.panel-tabs {
  display: flex;
  flex: 1;
  align-items: stretch;
  gap: 0;
}

.panel-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: var(--space-sm) var(--space-md);
  color: rgba(255, 255, 255, 0.75);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  border-bottom: 3px solid transparent;
  transition: color var(--transition),
              border-color var(--transition),
              background var(--transition);
}

.panel-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.panel-tab.active {
  color: #fff;
  border-bottom-color: var(--color-accent);
}

.panel-tab-icon {
  font-size: 1rem;
}

.panel-tab-label {
  letter-spacing: 0.02em;
}

.panel-tabs-bar .btn-close {
  color: rgba(255, 255, 255, 0.85);
  background: transparent;
  border-radius: 0;
  width: 44px;
  height: auto;
  align-self: stretch;
  padding: 0;
  font-size: 1.1rem;
  margin: 0;
}

.panel-tabs-bar .btn-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.panel-tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-tab-content.hidden {
  display: none !important;
}

/* ===== BUS INFO TAB ===== */
.bus-info-container {
  padding: var(--space-md);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  flex: 1;
}

.bus-info-hero {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.bus-info-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

.bus-info-icon-fallback {
  background: var(--color-accent);
  border-radius: 50%;
}

.bus-info-hero-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 0;
}

.service-badge-large {
  min-width: 48px;
  height: 32px;
  font-size: var(--font-size-base);
  padding: 0 10px;
}

.bus-info-operator {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.bus-info-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin: 0;
}

.bus-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  font-size: var(--font-size-sm);
}

.bus-info-row dt {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.bus-info-row dd {
  color: var(--color-text);
  font-weight: 600;
  text-align: right;
  margin: 0;
}

.bus-info-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--font-size-xs);
}

.follow-bus-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--color-primary-dark);
  font-weight: 600;
  transition: background var(--transition);
}

.follow-bus-toggle:hover {
  background: #d4e4f5;
}

.follow-bus-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.bus-info-footer {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: auto;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.upcoming-stops {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.upcoming-stops-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-border);
}

.upcoming-stops-loading {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  padding: var(--space-sm) 0;
}

.upcoming-stops-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.upcoming-stop {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 0;
  font-size: var(--font-size-sm);
  border-bottom: 1px dashed var(--color-border);
}

.upcoming-stop:last-child {
  border-bottom: none;
}

.upcoming-stop-marker {
  color: var(--color-primary);
  font-size: 0.8rem;
  text-align: center;
}

.upcoming-stop:first-child .upcoming-stop-marker {
  color: var(--color-accent);
}

.upcoming-stop-name {
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upcoming-stop-time {
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  font-size: var(--font-size-xs);
  white-space: nowrap;
}

.upcoming-stops-note {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
  font-style: italic;
}

.bus-info-lost {
  background: #fff3e0;
  color: #8a4b00;
  border: 1px solid #ffe0b2;
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-align: center;
}

/* ===== BUS POPUP (restyled) ===== */
.bus-popup {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.bus-popup-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

.bus-popup-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.bus-popup-icon-fallback {
  border-radius: 50%;
}

.bus-popup-destination {
  font-size: var(--font-size-xs);
  color: var(--color-text);
  margin: 0;
}

.bus-popup-status {
  margin: 0;
}

.bus-popup-hint {
  font-size: 10px;
  color: var(--color-text-muted);
  text-align: center;
  font-style: italic;
  margin-top: 2px;
}

/* ===== DARK MODE ===== */
body.dark-mode {
  --color-primary:        #1a5fa8;   /* Deeper blue for headers/bars */
  --color-primary-dark:   #0f3d6e;   /* Darker blue for active states */
  --color-primary-light:  #0d1f33;   /* Near-black blue for panel header bg */
  --color-accent:         #f4a020;

  --color-on-time:        #4caf50;
  --color-early:          #42a5f5;
  --color-late:           #ef5350;
  --color-unknown:        #9e9e9e;

  --color-bg:             #121418;   /* Near-black background */
  --color-surface:        #1c1f26;   /* Panel and card surfaces */
  --color-border:         #2c3040;
  --color-text:           #e2e8f0;
  --color-text-muted:     #8fa3c0;   /* Cool blue-grey muted text */
  --color-text-inverse:   #ffffff;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.6);
}

/* Header text colours in dark mode */
body.dark-mode .header-title {
  color: #93c5fd;   /* Cool blue title */
}

body.dark-mode .last-updated {
  color: #93c5fd;
  opacity: 1;
}

/* Panel header bg uses --color-primary-light (near-black blue) */
body.dark-mode .panel-header {
  background: var(--color-primary-light);
  border-bottom-color: var(--color-border);
}

body.dark-mode .panel-stop-name {
  color: #93c5fd;
}

/* Table header rows use bg colour */
body.dark-mode .departures-table thead {
  background: var(--color-bg);
}

body.dark-mode .departures-table tr:hover td {
  background: #1a2a3a;
}

/* Status chips in dark mode */
body.dark-mode .status-on-time {
  background: #1b3a1c;
  color: #81c784;
}

body.dark-mode .status-early {
  background: #0d2540;
  color: #64b5f6;
}

body.dark-mode .status-late {
  background: #3b1212;
  color: #ef9a9a;
}

body.dark-mode .status-scheduled {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

/* Follow toggle */
body.dark-mode .follow-bus-toggle {
  background: #0d1f33;
  color: #93c5fd;
}

body.dark-mode .follow-bus-toggle:hover {
  background: #122840;
}

/* Lost vehicle banner */
body.dark-mode .bus-info-lost {
  background: #2a1a00;
  color: #ffcc80;
  border-color: #5a3a00;
}

/* Leaflet popup in dark mode */
body.dark-mode .leaflet-popup-content-wrapper,
body.dark-mode .leaflet-popup-tip {
  background: var(--color-surface) !important;
  color: var(--color-text) !important;
  box-shadow: var(--shadow-lg) !important;
}

body.dark-mode .leaflet-popup-content-wrapper {
  border: 1px solid var(--color-border);
}

body.dark-mode .popup-stop-name {
  color: #93c5fd;
}

body.dark-mode .bus-popup-header {
  border-bottom-color: var(--color-border);
}

/* Map loading overlay */
body.dark-mode .map-loading {
  background: rgba(18, 20, 24, 0.9);
  color: var(--color-text);
}

/* Departures meta bar */
body.dark-mode .departures-meta {
  background: var(--color-bg);
}

/* Btn-text (↻ Refresh) — cool blue in dark mode */
body.dark-mode .btn-text {
  color: #93c5fd;
}

body.dark-mode .btn-text:hover {
  background: #0d1f33;
}
