/* =========================================================================
   Śremskie autobusy — arkusz stylów
   Motyw: "tablica odjazdów" — spokojna, czytelna baza + jeden mocny akcent
   (bursztynowy) zarezerwowany dla najbliższego odjazdu i wyboru użytkownika.
   ========================================================================= */

:root {
  --bg: #f5f6f4;
  --bg-elevated: #ffffff;
  --bg-sunken: #eceeea;
  --ink: #16232a;
  --ink-soft: #56666d;
  --hairline: rgba(22, 35, 42, 0.12);
  --accent: #e2a63b;
  --accent-ink: #16343a;
  --live: #3e8e7e;
  --danger: #c1503a;
  --radius: 14px;
  --radius-sm: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101a1d;
    --bg-elevated: #17262a;
    --bg-sunken: #0c1417;
    --ink: #edefea;
    --ink-soft: #9fb0b3;
    --hairline: rgba(237, 239, 234, 0.14);
    --accent: #e8b354;
    --accent-ink: #16343a;
    --live: #57a692;
    --danger: #e07a63;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #101a1d;
  --bg-elevated: #17262a;
  --bg-sunken: #0c1417;
  --ink: #edefea;
  --ink-soft: #9fb0b3;
  --hairline: rgba(237, 239, 234, 0.14);
  --accent: #e8b354;
  --accent-ink: #16343a;
  --live: #57a692;
  --danger: #e07a63;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(64px + var(--safe-bottom));
}

h1, h2, p { margin: 0; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: max(14px, var(--safe-top));
  padding-bottom: 10px;
}
.topbar h1 {
  flex: 1;
  font-size: 19px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.01em;
}
.topbar--brand h1 {
  text-align: left;
  font-size: 24px;
}
.topbar-spacer { width: 36px; display: inline-block; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--ink);
  flex-shrink: 0;
}
.icon-btn:active { background: var(--bg-sunken); }
.fav-btn.is-fav { color: var(--danger); }

/* ---------- Search ---------- */
.search-wrap {
  position: relative;
  margin-bottom: 18px;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  display: grid;
}
#from-search, #to-search {
  width: 100%;
  padding: 13px 14px 13px 40px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 17px;
}
#from-search::placeholder, #to-search::placeholder { color: var(--ink-soft); }
/* iOS wstawia własny przycisk czyszczenia — zostawiamy jak jest */
.search-wrap--to { margin-top: -8px; }

/* ---------- Skąd → Dokąd: nagłówek połączenia ---------- */
.conn-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
  padding: 0 2px;
}
.conn-header .icon-btn { margin-left: auto; }
.conn-arrow { color: var(--ink-soft); font-weight: 400; }
.conn-times {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.list-row.is-muted { opacity: 0.55; }

/* ---------- Sekcje i listy ---------- */
.section { margin-bottom: 22px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
  padding: 0 2px;
}
.list {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--hairline);
}
.list-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
  min-height: 44px;
}
.list-row:last-child { border-bottom: none; }
.list-row:active { background: var(--bg-sunken); }
.list-row--stack { flex-direction: column; align-items: stretch; gap: 6px; }
.list-row-top { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.list-row-main { font-size: 16px; font-weight: 600; }
.list-row-sub { font-size: 13px; color: var(--ink-soft); }
.row-heart { color: var(--danger); display: grid; }
.chev { color: var(--ink-soft); display: grid; flex-shrink: 0; }

.tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--bg-sunken);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag--sm { font-size: 11px; padding: 1px 6px; margin-left: 4px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--ink);
}
.chip--past { color: var(--ink-soft); opacity: 0.55; }
.chip--next { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* ---------- Hero: najbliższy odjazd ---------- */
.hero-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.hero-label { font-size: 13px; font-weight: 600; opacity: 0.75; }
.hero-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.hero-line { font-size: 17px; font-weight: 700; }
.hero-time {
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.hero-dir { font-size: 13px; opacity: 0.8; }
.hero-countdown { font-size: 14px; font-weight: 700; }

/* ---------- Segmented control ---------- */
.segmented {
  display: inline-flex;
  background: var(--bg-sunken);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 16px;
  gap: 2px;
}
.segmented--full { display: flex; width: 100%; }
.segmented button {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  min-height: 36px;
}
.segmented--full button { flex: 1; text-align: center; }
.segmented button.is-active {
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.route-label {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 14px;
}

/* ---------- Banery i puste stany ---------- */
.banner {
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 16px;
}
.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--ink-soft);
}
.empty-title { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.empty-body { font-size: 14px; margin-bottom: 14px; }

.footnote { font-size: 12px; color: var(--ink-soft); padding: 10px 2px 4px; }

/* ---------- Przyciski ---------- */
.btn-secondary {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
}
.btn-full { width: 100%; text-align: center; }

/* ---------- Info card (Ustawienia) ---------- */
.info-card {
  background: var(--bg-elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--hairline);
}
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: var(--ink-soft); }
.info-row span:last-child { text-align: right; font-weight: 600; }

/* ---------- Tabela rozkładu ---------- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  margin-bottom: 6px;
}
table.timetable {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
table.timetable th,
table.timetable td {
  padding: 10px 12px;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--hairline);
}
table.timetable thead th {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  background: var(--bg-elevated);
}
table.timetable .stopcol {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  background: var(--bg-elevated);
  box-shadow: 1px 0 0 var(--hairline);
}
.stop-link { text-align: left; font-weight: 600; min-height: auto; padding: 2px 0; }
table.timetable td.is-empty { color: var(--ink-soft); opacity: 0.5; }
table.timetable td.is-past { color: var(--ink-soft); opacity: 0.5; }
table.timetable th.is-next,
table.timetable td.is-next {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-elevated));
  font-weight: 700;
}
table.timetable tbody tr:last-child td,
table.timetable tbody tr:last-child th { border-bottom: none; }

/* ---------- Dolna nawigacja ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--bg-elevated);
  border-top: 1px solid var(--hairline);
  padding-bottom: var(--safe-bottom);
  z-index: 10;
}
.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  min-height: 44px;
}
.tabbar button svg { display: block; }
.tabbar button.is-active { color: var(--accent); }

@media (prefers-reduced-motion: no-preference) {
  .list-row, .icon-btn, .segmented button { transition: background-color 0.15s ease; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
