/* map-style.css — Classic dark flat transit map */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #d4d0c8;
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  background: #1a1a1a;
}

/* ===== MAP ===== */
#map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

/* ===== MAP NAVIGATION BAR ===== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #222222;
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1000;
  border-bottom: 1px solid #3a3a3a;
}

/* Keep #header-bar selector for map-app.js compatibility */
#header-bar {
  /* All styles are on .nav */
}

.nav-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.nav-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.header-subtitle {
  font-size: 0.8rem;
  color: #a09a90;
  font-weight: 500;
}

.nav-links {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: #a09a90;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 3px;
}

.nav-link:hover {
  color: #d4d0c8;
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: #7a9bb5;
  background: rgba(122, 155, 181, 0.12);
}

.btn-icon { flex-shrink: 0; }

.nav-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.feed-status {
  font-size: 0.75rem;
  color: #a09a90;
  background: #2a2a2a;
  padding: 4px 8px;
  border-radius: 3px;
  border: 1px solid #3a3a3a;
}

.feed-status.stale {
  color: #d32f2f;
  background: rgba(211, 47, 47, 0.15);
  border-color: rgba(211, 47, 47, 0.3);
}

.header-btn {
  padding: 6px 16px;
  background: rgba(122, 155, 181, 0.15);
  color: #7a9bb5;
  border: 1px solid rgba(122, 155, 181, 0.3);
  border-radius: 3px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.header-btn:hover {
  background: rgba(122, 155, 181, 0.25);
  border-color: rgba(122, 155, 181, 0.5);
}

.header-btn-outline {
  background: transparent;
  color: #a09a90;
  border: 1px solid #3a3a3a;
}

.header-btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #d4d0c8;
}

/* ===== MAP PANELS (shared) ===== */
.map-panel {
  position: fixed;
  z-index: 999;
  background: #222222;
  border-radius: 4px;
  border: 1px solid #3a3a3a;
}

.panel-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #6e6a62;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.panel-close:hover {
  color: #d4d0c8;
}

/* ===== LINE FILTER PANEL ===== */
.filter-panel {
  top: 62px;
  right: 12px;
  min-width: 180px;
}

.panel-toggle {
  display: block;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: #d4d0c8;
  cursor: pointer;
  text-align: left;
  border-radius: 3px;
}

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

.filter-list {
  padding: 4px 10px 10px;
  max-height: 400px;
  overflow-y: auto;
}

.filter-list.hidden {
  display: none;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  font-size: 0.8rem;
  cursor: pointer;
  color: #d4d0c8;
}

.filter-item:hover {
  color: #fff;
}

.filter-item input {
  margin: 0;
  cursor: pointer;
  accent-color: #7a9bb5;
}

.filter-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.filter-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== TRAIN INFO PANEL ===== */
.train-panel {
  top: 62px;
  right: 12px;
  width: 320px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 16px;
}

.train-panel.hidden {
  display: none;
}

.train-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.train-id {
  font-size: 1.2rem;
  font-weight: 700;
  color: #d4d0c8;
}

.train-line {
  font-size: 0.85rem;
  color: #a09a90;
  margin-bottom: 12px;
}

.train-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.status-on-time {
  background: rgba(76, 175, 80, 0.15);
  color: #4caf50;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.status-delayed {
  background: rgba(230, 168, 23, 0.15);
  color: #e6a817;
  border: 1px solid rgba(230, 168, 23, 0.3);
}

.status-severe {
  background: rgba(211, 47, 47, 0.15);
  color: #d32f2f;
  border: 1px solid rgba(211, 47, 47, 0.3);
}

.status-cancelled {
  background: rgba(160, 154, 144, 0.1);
  color: #a09a90;
  border: 1px solid rgba(160, 154, 144, 0.2);
  text-decoration: line-through;
}

/* Prominent "STOPPED AT STATION" banner in train panel */
.stopped-panel-badge {
  display: block;
  text-align: center;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: #2a3535;
  border: 1px solid #4a8a8a;
  border-radius: 3px;
  color: #5cb8b8;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.train-details {
  font-size: 0.85rem;
  color: #a09a90;
}

.train-details dt {
  font-weight: 600;
  color: #d4d0c8;
  margin-top: 8px;
}

.train-details dd {
  margin-left: 0;
  margin-bottom: 4px;
}

.train-stops {
  margin-top: 12px;
  font-size: 0.8rem;
}

.train-stops h4 {
  font-size: 0.85rem;
  color: #d4d0c8;
  margin-bottom: 6px;
}

.stop-item {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid #3a3a3a;
  color: #a09a90;
}

.stop-delay {
  font-weight: 600;
}

.stop-delay.delayed {
  color: #e6a817;
}

.train-subscribe-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 8px;
  background: rgba(122, 155, 181, 0.15);
  color: #7a9bb5;
  border: 1px solid rgba(122, 155, 181, 0.3);
  border-radius: 3px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.train-subscribe-btn:hover {
  background: rgba(122, 155, 181, 0.25);
  border-color: rgba(122, 155, 181, 0.5);
}

/* ===== SUBSCRIBE SIDEBAR ===== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1100;
  display: flex;
  justify-content: flex-end;
}

.overlay.hidden {
  display: none;
}

.sidebar {
  width: 400px;
  max-width: 100vw;
  height: 100vh;
  background: #222222;
  padding: 24px;
  overflow-y: auto;
  border-left: 1px solid #3a3a3a;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.sidebar-header h2 {
  font-size: 1.2rem;
  color: #d4d0c8;
}

/* Form styles — dark theme */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: #d4d0c8;
}

.optional {
  font-weight: 400;
  color: #6e6a62;
  font-size: 0.8rem;
}

input, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #3a3a3a;
  border-radius: 3px;
  font-size: 0.9rem;
  color: #d4d0c8;
  background: #1a1a1a;
}

input:focus, select:focus {
  outline: none;
  border-color: #7a9bb5;
}

input::placeholder {
  color: #6e6a62;
}

select:disabled {
  background: #1a1a1a;
  color: #6e6a62;
}

small {
  display: block;
  margin-top: 3px;
  color: #6e6a62;
  font-size: 0.75rem;
}

.window-hint {
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > div {
  flex: 1;
}

button[type="submit"] {
  width: 100%;
  padding: 10px;
  background: #7a9bb5;
  color: #fff;
  border: 1px solid #6889a0;
  border-radius: 3px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

button[type="submit"]:hover {
  background: #6889a0;
}

button[type="submit"]:disabled {
  background: #444;
  color: #a09a90;
  cursor: not-allowed;
}

.message {
  margin-top: 16px;
  padding: 12px;
  border-radius: 6px;
  text-align: center;
  font-weight: 500;
  font-size: 0.9rem;
}

.message.success {
  background: rgba(76, 175, 80, 0.1);
  color: #4caf50;
  border: 1px solid rgba(76, 175, 80, 0.25);
}

.message.error {
  background: rgba(211, 47, 47, 0.1);
  color: #d32f2f;
  border: 1px solid rgba(211, 47, 47, 0.25);
}

/* ===== MAP DISCLAIMER ===== */
.map-disclaimer {
  position: fixed;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  font-size: 0.65rem;
  color: #6e6a62;
  background: #222222;
  padding: 2px 10px;
  border-radius: 3px;
  text-align: center;
  pointer-events: none;
  border: 1px solid #3a3a3a;
}

/* ===== LINE TOOLTIP ===== */
.line-tooltip {
  background: #2a2a2a !important;
  color: #d4d0c8 !important;
  border: 1px solid #3a3a3a !important;
  border-radius: 3px !important;
  padding: 4px 10px !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
}

.line-tooltip::before {
  border-top-color: #2a2a2a !important;
}

/* ===== STATION POPUP (dark) ===== */
.station-popup {
  color: #1e293b;
}

/* ===== CUSTOM LEAFLET MARKER STYLES ===== */

/* Train marker — base */
.train-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  font-size: 10px;
  font-weight: 700;
  color: white;
}

.train-marker.on-time {
  background: #4caf50;
}

.train-marker.delayed {
  background: #e6a817;
}

.train-marker.severe {
  background: #d32f2f;
}

.train-marker.cancelled {
  background: #6e6a62;
}

/* Compact marker (regional zoom) */
.train-marker--compact {
  border-width: 1.5px;
}

/* ===== STOPPED AT STATION ===== */

/* Stopped marker: rounded square + teal border */
.train-marker--stopped {
  border-radius: 4px;
  border: 3px solid #5cb8b8;
  position: relative;
}

.train-marker--stopped.train-marker--compact {
  border-radius: 3px;
  border-width: 2px;
}

/* Station name badge shown below stopped trains */
.stopped-badge {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a3535;
  color: #5cb8b8;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid #4a8a8a;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Train label */
.train-label {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a2a;
  color: #d4d0c8;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid #3a3a3a;
}

.train-label-line {
  color: #a09a90;
  font-weight: 500;
  margin-left: 3px;
}

/* Delay badge */
.delay-badge {
  position: absolute;
  top: -8px;
  right: -12px;
  background: #d32f2f;
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid #e44;
}

/* Station label */
.station-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.station-label span {
  display: inline-block;
  background: #2a2a2a;
  color: #d4d0c8;
  padding: 1px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  border-left: 2px solid var(--line-color, #6e6a62);
}

/* Refreshing indicator */
.refreshing #feed-status {
  opacity: 0.6;
}

/* ===== SCROLLBAR (dark) ===== */
.train-panel::-webkit-scrollbar,
.filter-list::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.train-panel::-webkit-scrollbar-track,
.filter-list::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.train-panel::-webkit-scrollbar-thumb,
.filter-list::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 2px;
}

/* ===== BOTTOM NAV (mobile) ===== */
.bottom-nav {
  display: none;
}

/* ===== ACCESSIBILITY ===== */
:focus-visible {
  outline: 2px solid #7a9bb5;
  outline-offset: 2px;
}
button:focus:not(:focus-visible) { outline: none; }

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 640px) {
  .sidebar {
    width: 100vw;
  }

  .train-panel {
    top: auto;
    bottom: 60px;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 45vh;
    border-radius: 4px 4px 0 0;
  }

  .header-subtitle {
    display: none;
  }

  .nav-links {
    display: none;
  }

  .filter-panel {
    top: 62px;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #222222;
    border-top: 1px solid #3a3a3a;
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 16px;
    text-decoration: none;
    color: #6e6a62;
    font-size: 0.75rem;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-item.active {
    color: #7a9bb5;
  }

  .bottom-nav-item svg {
    width: 22px;
    height: 22px;
  }

  .map-disclaimer {
    bottom: 64px;
  }
}
