/* ================================================================
   ZugLive – Shared Stylesheet  |  Dark Theme
   ================================================================ */

:root {
  --bg:         #0D1117;
  --surface:    #161B22;
  --surface-2:  #21262D;
  --border:     #30363D;
  --text:       #E6EDF3;
  --muted:      #8B949E;
  --red:        #EC0016;
  --red-glow:   rgba(236, 0, 22, 0.20);
  --red-dim:    rgba(236, 0, 22, 0.12);
  --green:      #3FB950;
  --green-dim:  rgba(63, 185, 80, 0.14);
  --orange:     #D29922;
  --orange-dim: rgba(210, 153, 34, 0.14);
  --blue:       #58A6FF;
  --blue-dim:   rgba(88, 166, 255, 0.14);
  --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius:     8px;
  --radius-lg:  12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbars ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Navbar ─────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
}

.logo-pill {
  background: var(--red);
  color: white;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.navbar-nav {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.navbar-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}

.navbar-nav a:hover { color: var(--text); background: var(--surface-2); }

/* ── Surface / Cards ────────────────────────────────── */
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.surface-header {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.surface-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.surface-body { padding: 1.1rem; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: var(--font);
}
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }
.btn-lg { padding: 0.65rem 1.4rem; font-size: 0.95rem; }
.btn-block { width: 100%; }

.btn-primary  { background: var(--red); color: white; }
.btn-primary:hover { background: #c0001a; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-surface { background: var(--surface-2); color: var(--text); }
.btn-surface:hover { background: var(--border); }

/* ── Form controls ──────────────────────────────────── */
.form-group { margin-bottom: 0.85rem; }
.form-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control::placeholder { color: var(--muted); }
.form-control:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-dim);
}

/* ── Autocomplete ───────────────────────────────────── */
.ac-wrap { position: relative; }

.ac-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  max-height: 260px;
  overflow-y: auto;
  z-index: 9000;
  display: none;
}
.ac-list.open { display: block; }

.ac-item {
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  transition: background 0.1s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: var(--border); }
.ac-item small { color: var(--muted); font-size: 0.72rem; }

/* ── Tabs ───────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  padding: 0.65rem 1.1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s;
  font-family: var(--font);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--red); border-bottom-color: var(--red); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Train category badges ──────────────────────────── */
.train-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.tb-ice, .tb-ic, .tb-ec { background: var(--red); color: white; }
.tb-re, .tb-rb          { background: var(--blue); color: white; }
.tb-s                   { background: var(--green); color: #000; }
.tb-default             { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ── Platform badge ─────────────────────────────────── */
.platform-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid var(--border);
}

/* ── Delay indicators ───────────────────────────────── */
.delay { font-weight: 700; font-size: 0.85rem; }
.delay-ok     { color: var(--green); }
.delay-light  { color: var(--orange); }
.delay-heavy  { color: var(--red); }
.delay-cancel { color: var(--red); }

/* ── Time type indicator ────────────────────────────── */
.tt-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
}
.tt-real     { background: var(--green-dim); color: var(--green); }
.tt-schedule { background: var(--surface-2); color: var(--muted); }
.tt-preview  { background: var(--orange-dim); color: var(--orange); }

/* ── Journey Timeline ───────────────────────────────── */
.timeline { list-style: none; position: relative; }

.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.tl-stop {
  position: relative;
  padding: 0.65rem 0 0.65rem 42px;
  border-bottom: 1px solid var(--border);
}
.tl-stop:last-child { border-bottom: none; }

.tl-dot {
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  background: var(--surface);
  z-index: 1;
  transition: border-color 0.3s, background 0.3s;
}

.tl-stop.passed  .tl-dot { border-color: var(--green); background: var(--green); }
.tl-stop.current .tl-dot {
  border-color: var(--red);
  background: var(--red);
  box-shadow: 0 0 0 4px var(--red-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px var(--red-glow); }
  50%       { box-shadow: 0 0 0 7px var(--red-dim); }
}

.tl-stop.passed  { opacity: 0.65; }
.tl-stop.current { background: rgba(236,0,22,0.04); border-radius: var(--radius); }

.tl-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.tl-name:hover { color: var(--red); }

.tl-current-tag {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--red);
  background: var(--red-dim);
  padding: 1px 6px;
  border-radius: 3px;
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.5} }

.tl-times {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 0.25rem;
}

.tl-time-blk { min-width: 90px; }
.tl-time-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  display: block;
  margin-bottom: 1px;
}
.tl-time-sched { font-size: 0.9rem; font-weight: 600; }
.tl-time-row   { display: flex; align-items: center; gap: 0.4rem; margin-top: 2px; }
.tl-time-act   { font-size: 0.82rem; color: var(--muted); }

.tl-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
  flex-wrap: wrap;
}

.tl-hints {
  font-size: 0.75rem;
  color: var(--orange);
  margin-top: 0.3rem;
  line-height: 1.5;
}

/* ── Progress bar ───────────────────────────────────── */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 5px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--red);
  border-radius: 4px;
  transition: width 1s ease;
}

/* ── Stat boxes ─────────────────────────────────────── */
.stat-grid {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.stat-box {
  flex: 1;
  min-width: 90px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
}
.stat-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); display: block; margin-bottom: 2px; }
.stat-value { font-size: 1.15rem; font-weight: 800; color: var(--text); }
.stat-value.ok     { color: var(--green); }
.stat-value.light  { color: var(--orange); }
.stat-value.heavy  { color: var(--red); }

/* ── Map container ──────────────────────────────────── */
.map-box {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

/* ── Live pulse ─────────────────────────────────────── */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: live-pulse 1.5s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(1.5); }
}

/* ── Departure rows ─────────────────────────────────── */
.dep-list { list-style: none; }

.dep-row {
  display: grid;
  grid-template-areas:
    "badge time delay platform"
    "badge dir  tt    platform";
  grid-template-columns: 64px 1fr auto 42px;
  grid-template-rows: auto auto;
  gap: 1px 10px;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: grid;
}
.dep-row:hover { background: var(--surface-2); }
.dep-row.canceled { opacity: 0.55; }

.dep-badge   { grid-area: badge; display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.dep-time    { grid-area: time; font-size: 1.1rem; font-weight: 800; align-self: end; }
.dep-delay   { grid-area: delay; align-self: end; text-align: right; }
.dep-dir     { grid-area: dir; color: var(--muted); font-size: 0.82rem; align-self: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep-tt      { grid-area: tt; align-self: start; text-align: right; }
.dep-platform{ grid-area: platform; display: flex; align-items: center; justify-content: center; }

.dep-row .countdown {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 500;
}
.dep-row .countdown.soon { color: var(--orange); font-weight: 700; }
.dep-row .countdown.now  { color: var(--red);    font-weight: 700; }

/* ── Alerts / States ────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 3rem 1rem;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.5;
}
.alert-error { background: rgba(236,0,22,0.1); border: 1px solid rgba(236,0,22,0.3); color: #FF7B87; }
.alert-warn  { background: var(--orange-dim); border: 1px solid rgba(210,153,34,0.3); color: var(--orange); }
.alert-info  { background: var(--blue-dim); border: 1px solid rgba(88,166,255,0.3); color: var(--blue); }

/* ── Page layout ────────────────────────────────────── */
.page { max-width: 820px; margin: 0 auto; padding: 1rem; }
.page-lg { max-width: 1100px; margin: 0 auto; padding: 1rem; }

.section { margin-bottom: 1rem; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 600px) {
  .navbar       { padding: 0 0.85rem; }
  .navbar-nav   { display: none; }
  .page, .page-lg { padding: 0.75rem 0.6rem; }
  .dep-row {
    grid-template-areas:
      "badge time platform"
      "badge dir  platform"
      "badge delay tt";
    grid-template-columns: 64px 1fr 42px;
  }
  .dep-delay { text-align: left; }
  .dep-tt    { text-align: left; }
  .stat-box  { min-width: 70px; }
}
