/* SWB Static — plain CSS, no framework. Light theme + debug panel. */

:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1b1f24;
  --muted: #667085;
  --line: #e4e8ee;
  --accent: #039cdd;
  --accent-ink: #ffffff;
  --danger: #d64545;
  --ok: #2e9e5b;
  --warn: #b8860b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  /* leave room for the debug panel when it's open */
  padding-bottom: 0;
}
body.debug-on { padding-bottom: 42vh; }

h1, h2, h3 { margin: 0; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand h1 { font-size: 1.25rem; }
.tagline { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.85rem; }

.debug-toggle {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
}
.debug-toggle[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.status {
  margin: 0;
  padding: 0.6rem 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  background: #eef4f8;
  border-bottom: 1px solid var(--line);
}

/* Layout */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  padding: 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.card.wide { grid-column: 1 / -1; }

.card-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.card-head .spacer { flex: 1; }
.card-head h2, .card-head h3 { font-size: 1rem; }

.hint { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.82rem; }

/* Buttons */
button {
  font: inherit;
}
.refresh, .danger {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
}
.refresh:hover { border-color: var(--accent); color: var(--accent); }
.danger { color: var(--danger); border-color: #f0c9c9; }
.danger:hover { background: #fdeaea; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Routes list */
.routes { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.route {
  display: grid;
  grid-template-columns: 3rem 1fr;
  grid-template-areas: "name termini" "name duid";
  gap: 0 0.6rem;
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--line);
}
.route-name {
  grid-area: name;
  align-self: center;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 6px;
  text-align: center;
  padding: 0.25rem 0;
}
.route-termini { grid-area: termini; font-size: 0.9rem; }
.route-duid { grid-area: duid; color: var(--muted); font-size: 0.72rem; font-family: var(--mono); }

/* Search + departures */
.search { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.search input {
  flex: 1;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.search button {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 8px;
  padding: 0 0.9rem;
  cursor: pointer;
}
.search-results { list-style: none; margin: 0 0 0.75rem; padding: 0; }
.search-hit {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  margin: 0.2rem 0;
  cursor: pointer;
}
.search-hit:hover { border-color: var(--accent); }

.departures { list-style: none; margin: 0; padding: 0; }
.dep {
  display: grid;
  grid-template-columns: 3.5rem 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.45rem 0.25rem;
  border-bottom: 1px solid var(--line);
}
.dep-line {
  font-weight: 700;
  text-align: center;
  background: #eef4f8;
  border-radius: 6px;
  padding: 0.15rem 0;
}
.dep-headsign { font-size: 0.9rem; }
.dep-time { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.dep.cancelled { opacity: 0.55; text-decoration: line-through; }

/* Location type tag (stop / address / poi) in journey search results */
.type-tag {
  display: inline-block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 700;
  color: var(--muted);
  background: #eef4f8;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.type-tag.type-stop { color: var(--accent); background: #e5f5fc; }
.type-tag.type-address { color: var(--warn); background: #fbf3e0; }
.type-tag.type-poi { color: var(--ok); background: #e6f5ec; }

/* Journey results */
.journeys { list-style: none; margin: 0; padding: 0; }
.journey {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.45rem 0.25rem;
  border-bottom: 1px solid var(--line);
}
.journey-time { font-family: var(--mono); font-size: 0.85rem; font-weight: 700; }
.journey-lines { font-size: 0.9rem; }
.journey-meta { font-size: 0.8rem; color: var(--muted); text-align: right; }


/* Cache table */
.cache-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.cache-table th, .cache-table td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
}
.cache-table th { color: var(--muted); font-weight: 600; }
.cache-table .mono { font-family: var(--mono); word-break: break-all; }

.footer {
  padding: 1rem 1.25rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}
.footer code { font-family: var(--mono); }

/* --- Debug panel --------------------------------------------------------- */
.dbg-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40vh;
  background: #0f172a;
  color: #e2e8f0;
  border-top: 2px solid var(--accent);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}
.dbg-panel.dbg-hidden { display: none; }

.dbg-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #1e293b;
  background: #0b1220;
}
.dbg-header strong { flex: 1; }
.dbg-header button {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
}

.dbg-feed {
  flex: 1;
  overflow: auto;
  padding: 0.5rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.dbg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid #1e293b;
}
.dbg-time { color: #64748b; }
.dbg-chan {
  color: #0b1220;
  background: #64748b;
  border-radius: 4px;
  padding: 0 0.4rem;
  font-size: 0.7rem;
  text-transform: uppercase;
}
.dbg-http .dbg-chan { background: #38bdf8; }
.dbg-cache .dbg-chan { background: #a3e635; }
.dbg-api .dbg-chan { background: #f0abfc; }
.dbg-ui .dbg-chan { background: #fbbf24; }
.dbg-debug .dbg-chan { background: #f87171; }

.dbg-msg { flex: 1 1 auto; }
.dbg-data { flex: 1 1 100%; margin-left: 1rem; }
.dbg-data summary { cursor: pointer; color: #94a3b8; }
.dbg-data pre {
  margin: 0.25rem 0 0;
  padding: 0.5rem;
  background: #0b1220;
  border-radius: 6px;
  overflow: auto;
  max-height: 200px;
  color: #cbd5e1;
}

@media (max-width: 640px) {
  .route { grid-template-columns: 2.6rem 1fr; }
  body.debug-on { padding-bottom: 50vh; }
  .dbg-panel { height: 50vh; }
}
