/* ============================================================
   Zugplaner – Dark Mode UI
   ============================================================ */

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

:root {
  --bg:        #080810;
  --surface:   #0f0f1a;
  --surface2:  #161622;
  --surface3:  #1e1e2e;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.12);
  --accent:    #4f7cff;
  --accent2:   #7c4fff;
  --green:     #34d399;
  --amber:     #fbbf24;
  --red:       #f87171;
  --text:      #f1f1f8;
  --muted:     #6b6b8a;
  --muted2:    #9494b0;
  --mono:      'DM Mono', monospace;
  --sans:      'Syne', sans-serif;
  --radius:    14px;
  --radius-sm: 8px;
  --nav-h:     80px;
  --header-h:  56px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---- Login ---- */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 100;
}

.login-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(79,124,255,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(124,79,255,0.08) 0%, transparent 60%),
              var(--bg);
}

.login-card {
  position: relative;
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 36px 28px;
  display: flex; flex-direction: column; gap: 16px;
}

.login-logo {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; margin-bottom: 4px;
}

.login-title {
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.02em;
}

.login-sub { font-size: 13px; color: var(--muted2); margin-top: -8px; }

.login-error {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px; color: var(--red);
}

/* ---- Forms ---- */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.flex1 { flex: 1; }

.form-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
}

.form-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  width: 100%;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--accent);
  background: var(--surface3);
}

.form-input::placeholder { color: var(--muted); }

/* ---- Buttons ---- */
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  border: none; border-radius: var(--radius-sm);
  padding: 13px 20px;
  color: #fff; font-family: var(--sans);
  font-size: 14px; font-weight: 700;
  cursor: pointer; letter-spacing: 0.04em;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary.full { width: 100%; }

.btn-secondary {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  color: var(--text); font-family: var(--sans);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-secondary.full { width: 100%; }
.btn-secondary:hover { background: var(--surface3); }

.btn-ghost {
  background: transparent; border: none;
  padding: 11px 20px;
  color: var(--muted2); font-family: var(--sans);
  font-size: 14px; cursor: pointer;
  transition: color 0.2s;
}
.btn-ghost.full { width: 100%; }
.btn-ghost:hover { color: var(--red); }

/* ---- App Layout ---- */
#app { display: flex; flex-direction: column; height: 100dvh; }

.app-header {
  height: var(--header-h);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(8,8,16,0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  flex-shrink: 0;
}

.header-logo {
  font-size: 17px; font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--text), var(--muted2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-right { display: flex; align-items: center; gap: 12px; }

.header-clock {
  font-family: var(--mono);
  font-size: 12px; color: var(--muted);
}

.header-user {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted2);
  cursor: pointer; padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.header-user:hover { border-color: var(--border2); }

.app-main {
  flex: 1; overflow-y: auto;
  padding-bottom: var(--nav-h);
}

/* ---- Tabs ---- */
.tab-content { display: none; padding: 20px; }
.tab-content.active { display: block; }

/* ---- Bottom Nav ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  background: rgba(8,8,16,0.95);
  backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}

.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  font-family: var(--sans); font-size: 10px;
  font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.2s;
  padding: 8px 4px;
}

.nav-item svg { transition: transform 0.2s; }
.nav-item.active { color: var(--accent); }
.nav-item.active svg { transform: translateY(-1px); }

/* ---- Loading / Empty ---- */
.loading-state, .empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 60px 20px;
  color: var(--muted); font-size: 14px;
}

.empty-hint { font-size: 12px; color: var(--muted); text-align: center; }

.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Dienst Cards ---- */
.shift-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.shift-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; border-bottom: 1px solid var(--border);
}

.shift-badge {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  padding: 4px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 700; color: #fff;
  letter-spacing: 0.06em; flex-shrink: 0;
}

.shift-title { font-size: 16px; font-weight: 700; }
.shift-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.shift-phase {
  margin-left: auto; flex-shrink: 0;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 20px;
}
.phase-selected { background: rgba(79,124,255,0.15); color: var(--accent); }
.phase-monitoring { background: rgba(52,211,153,0.15); color: var(--green); }
.phase-pending { background: rgba(107,107,138,0.15); color: var(--muted2); }

/* ---- Connection Cards ---- */
.conn-section-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); padding: 12px 16px 8px;
}

.conn-card {
  margin: 0 12px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.conn-card::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: 3px 0 0 3px;
}
.conn-card.cat-comfortable::before { background: var(--green); }
.conn-card.cat-ok::before { background: var(--amber); }
.conn-card.cat-tight::before { background: var(--red); }

.conn-card:hover { border-color: var(--border2); }
.conn-card.is-selected {
  border-color: var(--accent);
  background: rgba(79,124,255,0.06);
}

.conn-card-top {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}

.conn-times {
  font-family: var(--mono);
  font-size: 20px; font-weight: 500;
  letter-spacing: -0.02em;
}

.conn-arrow { color: var(--muted); }

.conn-meta {
  margin-left: auto;
  display: flex; flex-direction: column;
  align-items: flex-end; gap: 3px;
}

.conn-dur {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}

.conn-buffer {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  font-family: var(--mono);
}
.buf-comfortable { background: rgba(52,211,153,0.12); color: var(--green); }
.buf-ok { background: rgba(251,191,36,0.12); color: var(--amber); }
.buf-tight { background: rgba(248,113,113,0.12); color: var(--red); }

.selected-badge {
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.12em; color: var(--accent);
  text-transform: uppercase; margin-left: 6px;
}

.conn-legs { display: flex; flex-direction: column; gap: 4px; }

.leg-row {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted2);
}

.leg-badge {
  background: var(--surface3); border: 1px solid var(--border2);
  padding: 1px 7px; border-radius: 4px;
  font-family: var(--mono); font-size: 10px;
  color: var(--text); white-space: nowrap; flex-shrink: 0;
}

.leg-time {
  margin-left: auto; font-family: var(--mono);
  font-size: 10px; color: var(--muted);
  white-space: nowrap;
}

.tight-warn {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--amber);
  margin-top: 6px;
}
.tight-warn svg { flex-shrink: 0; }

.conn-card-bottom { padding: 0 12px 12px; }

/* ---- Live Tab ---- */
.live-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.live-top {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
}

.live-indicator {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52,211,153,0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(52,211,153,0); }
}

.live-label {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--green);
}

.live-updated {
  margin-left: auto; font-family: var(--mono);
  font-size: 10px; color: var(--muted);
}

.live-train-name {
  font-size: 22px; font-weight: 800;
  letter-spacing: -0.02em; margin-bottom: 3px;
}

.live-route-desc {
  font-size: 12px; color: var(--muted2); margin-bottom: 16px;
}

.progress-bar {
  height: 3px; background: var(--border2);
  border-radius: 2px; margin-bottom: 18px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width 1s ease;
}

.stop-list { display: flex; flex-direction: column; gap: 10px; }

.stop-row {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px;
}

.stop-indicator { position: relative; width: 12px; height: 12px; flex-shrink: 0; }
.stop-dot-outer {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface3); border: 1.5px solid var(--border2);
}
.stop-dot-outer.passed { background: var(--accent); border-color: var(--accent); }
.stop-dot-outer.current {
  background: var(--green); border-color: var(--green);
  box-shadow: 0 0 8px rgba(52,211,153,0.5);
}

.stop-name { flex: 1; color: var(--muted2); }
.stop-name.current { color: var(--text); font-weight: 600; }
.stop-name.passed { color: var(--muted); }

.stop-times { display: flex; gap: 6px; align-items: center; }
.stop-time { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.stop-delay { font-family: var(--mono); font-size: 11px; color: var(--amber); }

/* ---- Search Tab ---- */
.search-container { display: flex; flex-direction: column; gap: 14px; }

.search-route { display: flex; flex-direction: column; }

.route-point { display: flex; align-items: flex-start; gap: 10px; }

.route-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
  margin-top: 32px;
}
.route-dot.dest { background: var(--red); }

.via-section { display: flex; gap: 10px; padding: 8px 0; }

.via-line-container {
  width: 10px; display: flex;
  justify-content: center; padding: 0;
}

.via-vertical-line {
  width: 1.5px;
  background: linear-gradient(var(--border2), var(--border2));
  flex: 1; min-height: 8px;
}

.via-content { flex: 1; display: flex; flex-direction: column; gap: 8px; }

.via-list { display: flex; flex-direction: column; gap: 8px; }

.via-item { display: flex; gap: 8px; align-items: flex-end; }
.via-item .form-input { flex: 1; }

.btn-remove-via {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 13px;
  color: var(--muted); cursor: pointer; flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}
.btn-remove-via:hover { border-color: var(--red); color: var(--red); }

.btn-add-via {
  background: transparent;
  border: 1px dashed var(--border2);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  color: var(--muted2); font-family: var(--sans);
  font-size: 12px; font-weight: 600;
  cursor: pointer; align-self: flex-start;
  display: flex; align-items: center; gap: 6px;
  transition: border-color 0.2s, color 0.2s;
}
.btn-add-via:hover { border-color: var(--accent); color: var(--accent); }

.search-options { display: flex; gap: 10px; }

.search-toggle-row {
  display: flex; align-items: center;
}

.toggle-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--muted2); cursor: pointer;
}

.toggle-switch { position: relative; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  display: block; width: 38px; height: 22px;
  background: var(--surface3); border: 1px solid var(--border2);
  border-radius: 11px; transition: background 0.2s;
  cursor: pointer;
}
.toggle-track::after {
  content: ''; position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: var(--muted2); border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(16px); background: #fff;
}

.search-results { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

/* ---- Autocomplete ---- */
.autocomplete-list {
  position: absolute; z-index: 50;
  background: var(--surface3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  max-height: 200px; overflow-y: auto;
  display: none;
}
.autocomplete-list.visible { display: block; }
.ac-item {
  padding: 10px 14px; font-size: 13px;
  cursor: pointer; transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: var(--surface2); }

/* ---- Settings ---- */
.settings-container { display: flex; flex-direction: column; gap: 20px; }

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}

.settings-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700;
  color: var(--muted2);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.settings-msg {
  padding: 12px; border-radius: var(--radius-sm);
  font-size: 13px; text-align: center;
}
.settings-msg.success {
  background: rgba(52,211,153,0.1); color: var(--green);
  border: 1px solid rgba(52,211,153,0.2);
}
.settings-msg.error {
  background: rgba(248,113,113,0.1); color: var(--red);
  border: 1px solid rgba(248,113,113,0.2);
}
