/* =============================================
   station.css  –  TÅGradar stationstavla
   ============================================= */

body.station-page {
  background: #0b1220;
  color: #e2e8f0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  min-height: 100vh;
}

/* ── Station search in header ─────────────────── */
.station-searchbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: auto;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  padding: 0 10px;
  transition: background 0.15s, border-color 0.15s;
}

.station-searchbar:focus-within {
  background: rgba(255,255,255,0.13);
  border-color: rgba(99,160,255,0.55);
}

.station-searchbar-icon {
  font-size: 16px;
  color: rgba(255,255,255,0.35);
  pointer-events: none;
  margin-right: 6px;
  line-height: 1;
}

.station-searchbar input {
  width: min(220px, 36vw);
  padding: 7px 0;
  border: none;
  outline: none;
  background: transparent;
  color: #f1f5f9;
  font: 500 13px/1 system-ui;
}

.station-searchbar input::placeholder {
  color: rgba(255,255,255,0.3);
}

/* Autocomplete dropdown */
.station-autocomplete {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 280px;
  background: #131f35;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  box-shadow: 0 20px 48px rgba(0,0,0,0.55);
  overflow: hidden;
  z-index: 99999;
}

.ac-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.ac-item:last-child { border-bottom: none; }

.ac-item:hover,
.ac-item--active {
  background: rgba(99,160,255,0.1);
}

.ac-name {
  font: 500 13px/1.2 system-ui;
  color: #e2e8f0;
}

.ac-name mark {
  background: transparent;
  color: #60a5fa;
  font-weight: 700;
}

.ac-sig {
  font: 600 11px/1 system-ui;
  color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.06);
  padding: 2px 7px;
  border-radius: 5px;
  flex: 0 0 auto;
  margin-left: 10px;
}

/* ── Hero ─────────────────────────────────────── */
.station-hero {
  padding-top: 48px;
  background: linear-gradient(135deg, #0f2444 0%, #0b1220 100%);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.station-hero-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 28px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0;
}

.back-link {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 13px/1 system-ui;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  margin-bottom: 16px;
  transition: color 0.15s;
  width: fit-content;
}
.back-link:hover { color: rgba(255,255,255,0.85); }

.station-hero-content {
  grid-column: 1;
  grid-row: 2;
}

.station-clock {
  grid-column: 2;
  grid-row: 2;
  align-self: flex-end;
  font: 400 28px/1 "SF Mono", "Fira Code", monospace;
  font-variant-numeric: slashed-zero tabular-nums;
  color: #60a5fa;
  letter-spacing: -0.3px;
  opacity: 0.9;
}

.station-sig-badge {
  display: inline-block;
  font: 700 11px/1 system-ui;
  color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.station-name {
  margin: 0 0 6px;
  font: 700 30px/1.1 system-ui;
  letter-spacing: -0.5px;
  color: #f1f5f9;
}

.station-name--prompt {
  color: rgba(255,255,255,0.4);
  font-weight: 500;
}

.station-date {
  margin: 0;
  font: 500 13px/1 system-ui;
  color: rgba(255,255,255,0.4);

}

/* Skeleton loaders */
.skeleton {
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  animation: skeletonPulse 1.4s ease-in-out infinite;
}
.sk-station-title { width: 200px; height: 32px; margin-bottom: 10px; }
.sk-station-sub   { width: 140px; height: 14px; }
.sk-row { height: 60px; margin-bottom: 2px; border-radius: 4px; }

.board-skeleton {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

@keyframes skeletonPulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.9; }
}

/* ── Body ─────────────────────────────────────── */
.station-body {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 20px 80px;
}

/* ── Controls ─────────────────────────────────── */
.board-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toggle-group {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 4px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: rgba(255,255,255,0.45);
  font: 600 13px/1 system-ui;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.75);
}

.toggle-btn--active {
  background: rgba(99,160,255,0.15);
  color: #93c5fd;
}

.toggle-icon {
  font-size: 14px;
}

.board-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.board-count {
  font: 500 12px/1 system-ui;
  color: rgba(255,255,255,0.3);
}

.refresh-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: background 0.3s;
}

.refresh-dot.refreshing {
  background: #60a5fa;
  animation: dotPulse 0.8s ease-in-out infinite alternate;
}

@keyframes dotPulse {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}

.refresh-label {
  font: 500 11px/1 system-ui;
  color: rgba(255,255,255,0.25);
}

/* ── Board header (column labels) ─────────────── */
.board-header {
  display: grid;
  grid-template-columns: 90px 1fr 60px 70px 110px;
  gap: 0;
  padding: 0 14px 8px;
  font: 600 11px/1 system-ui;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 4px;
}

/* ── Board rows ───────────────────────────────── */
.board-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.board-row {
  display: grid;
  grid-template-columns: 90px 1fr 60px 70px 110px;
  gap: 0;
  align-items: center;
  padding: 13px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  animation: rowFadeIn 0.3s ease both;
}

@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.board-row:hover {
  background: rgba(255,255,255,0.055);
  border-color: rgba(255,255,255,0.07);
}

.row-departed .col-dest,
.row-departed .col-track,
.row-departed .col-train {
  opacity: 0.35;
}

.row-canceled .col-dest,
.row-canceled .col-track,
.row-canceled .col-train {
  opacity: 0.35;
}

/* ── Column: Time ─────────────────────────────── */
.col-time {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.time-adv {
  font: 400 18px/1 "SF Mono", "Fira Code", monospace;
  color: #f1f5f9;
  letter-spacing: -0.3px;
}

.time-adv.time-departed {
  color: rgba(255,255,255,0.35);
}

.time-struck {
  font: 500 14px/1 "SF Mono", "Fira Code", monospace;
  color: rgba(255,255,255,0.3);
  text-decoration: line-through;
}

.time-real {
  font: 700 17px/1 "SF Mono", "Fira Code", monospace;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  border: none !important;
}

.time-real.on-time      { color: #86efac; }
.time-real.delay-yellow { color: #fde047; }
.time-real.delay-orange { color: #fdba74; }
.time-real.delay-red    { color: #fca5a5; }
.time-real.delay-maroon { color: #fca5a5; }

/* Departed trains – muted delay colors */
.time-real--departed { opacity: 0.4; }

/* ── Column: Destination ──────────────────────── */
.col-dest {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 12px;
}

.row-dest {
  font: 600 15px/1.2 system-ui;
  color: #f1f5f9;
}

.row-dest--canceled {
  text-decoration: line-through;
  opacity: 0.45;
}

.row-via {
  font: 400 12px/1 system-ui;
  color: rgba(255,255,255,0.4);
}

.row-product {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font: 500 11px/1 system-ui;
  color: rgba(255,255,255,0.4);
  margin-top: 1px;
}

/* Colored circle with logo inside */
.row-logo-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 20px;
  background: var(--pc, #475569);
}

.row-logo {
  width: 13px;
  height: 13px;
  object-fit: contain;
}

/* ── Column: Track ────────────────────────────── */
.col-track {
  font: 600 14px/1 system-ui;
  color: rgba(255,255,255,0.6);
}

.track-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 4px 7px;
  border-radius: 7px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  font: 700 13px/1 system-ui;
  color: rgba(255,255,255,0.7);
}

/* ── Column: Train number ─────────────────────── */
.col-train {
  font: 600 14px/1 system-ui;
  display: flex;
  align-items: center;
  gap: 5px;
}

.train-link {
  color: #60a5fa;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid rgba(96,165,250,0.2);
  transition: background 0.15s, border-color 0.15s;
  display: inline-block;
}

.train-link:hover {
  background: rgba(96,165,250,0.1);
  border-color: rgba(96,165,250,0.4);
}

/* ── Map icon button (visar tåg på realtidskartan) ── */
.map-icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(96,165,250,0.08);
  border: 1px solid rgba(96,165,250,0.2);
  color: rgba(96,165,250,0.6);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.map-icon-btn--visible {
  display: inline-flex;
}
.map-icon-btn:hover {
  background: rgba(96,165,250,0.18);
  color: #60a5fa;
  border-color: rgba(96,165,250,0.5);
}

/* ── Column: Status badge ─────────────────────── */
.col-status {
  display: flex;
  justify-content: flex-end;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 99px;
  font: 600 11px/1 system-ui;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.status-ontime {
  background: transparent;
  color: #86efac;
  border: none;
  padding-left: 0;
  padding-right: 0;
}

.status-departed {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.3);
  border: 1px solid rgba(255,255,255,0.08);
}

.status-canceled {
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.2);
}

.delay-yellow {
  background: rgba(250,204,21,0.12);
  color: #fde047;
  border: 1px solid rgba(250,204,21,0.2);
}

.delay-orange {
  background: rgba(249,115,22,0.12);
  color: #fdba74;
  border: 1px solid rgba(249,115,22,0.2);
}

.delay-red {
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.2);
}

.delay-maroon {
  background: rgba(127,29,29,0.18);
  color: #fca5a5;
  border: 1px solid rgba(127,29,29,0.3);
}

/* ── Empty / error ────────────────────────────── */
.board-empty {
  color: rgba(255,255,255,0.3);
  font: 500 14px/1 system-ui;
  padding: 32px 0;
  text-align: center;
}

.board-error {
  color: #fca5a5;
  font: 500 14px/1.5 system-ui;
  padding: 20px;
  background: rgba(239,68,68,0.08);
  border-radius: 12px;
  border: 1px solid rgba(239,68,68,0.2);
  margin-top: 20px;
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 640px) {
  .station-clock {
    font-size: 20px;
  }

  .station-searchbar input {
    width: min(150px, 32vw);
  }

  /* Hide table-style header on mobile */
  .board-header {
    display: none;
  }

  /*
   * Mobil kortlayout:
   *
   *  ┌──────────────────────────────────────────┐
   *  │ TID (72px)   DESTINATION          SPÅR   │
   *  │              Operatör (produkt)           │
   *  │              ⚠ Störning  ⚠ Störning       │
   *  │              [Tågnr]  ▶                   │
   *  └──────────────────────────────────────────┘
   */
  .board-row {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    grid-template-rows: auto;
    align-items: start;
    gap: 0;
    padding: 12px 12px;
    border-radius: 10px;
  }

  /* Tid: vänstra kolumnen, alla rader */
  .col-time {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    padding-top: 1px;
  }

  /* Destination + produkt + störningar + tågnr: mitten */
  .col-dest {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    padding-right: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  /* Spår: höger kolumn */
  .col-track {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
  }

  /* Tågnummer: inne i col-dest via order, visas som sista element */
  .col-train {
    grid-column: 2;
    grid-row: 2;
    margin-top: 4px;
  }

  /* Dölj status-badge på mobil */
  .col-status {
    display: none;
  }

  /* Produkt-raden: operatör-logga + namn */
  .row-product {
    font-size: 11px;
    gap: 5px;
  }

  /* Störningsbadgar: egen rad */
  .row-deviations-line {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .time-adv {
    font-size: 17px;
  }

  .time-real {
    font-size: 15px;
  }

  .row-dest {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ── Hero search (moved from header) ─────────────── */
.station-hero-inner {
  /* override grid to fit search row */
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  gap: 0;
  align-items: start;
}

.back-link {
  grid-column: 1 / -1;
  grid-row: 1;
}

.station-hero-content {
  grid-column: 1;
  grid-row: 2;
}

.station-clock {
  grid-column: 2;
  grid-row: 2;
  align-self: end;
}

.hero-search-wrap {
  grid-column: 1 / -1;
  grid-row: 3;
  position: relative;
  margin-top: 18px;
  max-width: 420px;
}

/* Override header searchbar styles for hero context */
.hero-search-wrap .station-searchbar {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 0 14px;
  width: 100%;
  box-sizing: border-box;
}

.hero-search-wrap .station-searchbar:focus-within {
  background: rgba(255,255,255,0.15);
  border-color: rgba(99,160,255,0.6);
  box-shadow: 0 0 0 3px rgba(99,160,255,0.12);
}

.hero-search-wrap .station-searchbar input {
  width: 100%;
  padding: 11px 0;
  font: 500 15px/1 system-ui;
  color: #f1f5f9;
}

.hero-search-wrap .station-searchbar input::placeholder {
  color: rgba(255,255,255,0.35);
}

.hero-search-wrap .station-autocomplete {
  top: auto;
  left: 0;
  right: 0;
  min-width: unset;
  width: 100%;
}

/* On mobile the autocomplete should always sit just below the search bar (first child of wrap) */
@media (max-width: 540px) {
  .hero-search-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .hero-search-wrap .hero-search-row {
    order: 1;
  }

  .hero-search-wrap .station-autocomplete {
    order: 2;
    position: static !important;
    margin-top: 4px;
  }
}

@media (max-width: 640px) {
  .hero-search-wrap {
    max-width: 100%;
  }
}

/* ── Deviations ───────────────────────────────── */
.row-deviations {
  display: contents;
}

.row-deviations-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.deviation-tag {
  font: 500 11px/1 system-ui;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(251,191,36,0.1);
  color: #fcd34d;
  border: 1px solid rgba(251,191,36,0.2);
}

/* ── Date picker ──────────────────────────────── */
.hero-search-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.hero-search-row .station-searchbar {
  flex: 1;
}

.date-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 0 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.date-picker-wrap:focus-within {
  background: rgba(255,255,255,0.15);
  border-color: rgba(99,160,255,0.6);
  box-shadow: 0 0 0 3px rgba(99,160,255,0.12);
}

.today-btn {
  background: rgba(99,160,255,0.15);
  border: 1px solid rgba(99,160,255,0.3);
  border-radius: 12px;
  color: #93c5fd;
  font: 600 12px/1 system-ui;
  padding: 0 14px;
  height: 100%;
  min-height: 44px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex: 0 0 auto;
  align-self: stretch;
}
.today-btn:hover {
  background: rgba(99,160,255,0.25);
}

#datePicker {
  background: transparent;
  border: none;
  outline: none;
  color: #f1f5f9;
  font: 500 14px/1 system-ui;
  cursor: pointer;
  padding: 11px 0;
  /* Style the native date input to match dark theme */
  color-scheme: dark;
}

@media (max-width: 540px) {
  .hero-search-wrap {
    max-width: 100%;
  }

  /* Keep search row horizontal but let it wrap neatly */
  .hero-search-row {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    align-items: stretch;
  }

  /* Search bar takes full width on first line */
  .hero-search-row .station-searchbar {
    flex: 1 1 100%;
    min-width: 0;
  }

  /* Date picker: shrinks to fit, no forced full width */
  .date-picker-wrap {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0 10px;
  }

  #datePicker {
    font-size: 13px;
    padding: 10px 0;
    width: 100%;
    min-width: 0;
  }

  /* Today button: compact */
  .today-btn {
    flex: 0 0 auto;
    padding: 0 14px;
    min-height: 40px;
    font-size: 13px;
  }
}
