/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
  color: #f0f0f0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── Screens ──────────────────────────────────────────────────────────── */
.screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.screen.hidden { display: none; }

/* ── Header ───────────────────────────────────────────────────────────── */
.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #a78bfa;
}

.header-sub {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
  flex: 1;
  text-align: center;
}

.gate-label {
  font-size: 1.05rem;
  font-weight: 800;
  color: #a78bfa;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex: 1;
  text-align: center;
}

.header-clock {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: #34d399;
  white-space: nowrap;
  padding: 0.6rem 0.75rem;
  margin: -0.6rem -0.75rem;
  cursor: pointer;
  user-select: none;
}

.btn-ghost {
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.25rem 0;
  white-space: nowrap;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.btn-ghost:active { color: white; }

/* ── Screen body ──────────────────────────────────────────────────────── */
.screen-body {
  flex: 1;
  padding: 1.25rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  overflow-y: auto;
}

.screen-body-center {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.screen-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: white;
  text-align: center;
  margin-bottom: 0.25rem;
}

/* ── Fields ───────────────────────────────────────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.55);
}

.field-input {
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.07);
  color: white;
  font-size: 1.15rem;
  font-family: inherit;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.field-input::placeholder { color: rgba(255,255,255,0.25); font-weight: 400; }
.field-input:focus { border-color: #a78bfa; background: rgba(167,139,250,0.1); }

/* ── Error / saving ───────────────────────────────────────────────────── */
.error-msg {
  color: #f87171;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 1.2em;
  text-align: center;
}

.saving-indicator {
  text-align: center;
  color: #a78bfa;
  font-size: 0.9rem;
  font-weight: 600;
  animation: pulse-save 1s infinite alternate;
}
.saving-indicator.hidden { display: none; }

@keyframes pulse-save {
  from { opacity: 0.5; }
  to   { opacity: 1; }
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.02em;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }

.btn-full { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: white;
  box-shadow: 0 4px 18px rgba(124,58,237,0.45);
}

.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 2px solid rgba(255,255,255,0.2);
}

.btn-depart {
  background: linear-gradient(135deg, #059669, #34d399);
  color: white;
  font-size: 1.15rem;
  padding: 1.1rem;
  box-shadow: 0 4px 18px rgba(5,150,105,0.45);
}

.btn-cancel-changes {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 0.9rem;
  padding: 0.75rem;
}

.btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ── Departure card ───────────────────────────────────────────────────── */
.dep-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 1.25rem 1.25rem 1rem;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.dep-card-loading {
  text-align: center;
  color: rgba(255,255,255,0.35);
  font-size: 0.95rem;
}

.dep-card-content.hidden,
.dep-card-empty.hidden { display: none; }

.dep-route {
  font-size: 0.85rem;
  font-weight: 700;
  color: #a78bfa;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}

.dep-dest {
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  line-height: 1.15;
  margin-bottom: 0.6rem;
}

.dep-time-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.dep-time {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  color: #34d399;
}

.dep-countdown {
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
}

.dep-meta {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.45);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
}

.dep-meta-item { white-space: nowrap; }

.dep-meta-item.status-badge-delayed {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.dep-time.time-delayed {
  color: #fbbf24;
}

.dep-card-empty {
  text-align: center;
}
.empty-icon { font-size: 2rem; margin-bottom: 0.4rem; opacity: 0.4; }
.empty-text { color: rgba(255,255,255,0.35); font-size: 0.9rem; }

/* ── Section label ────────────────────────────────────────────────────── */
.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.4);
  margin-bottom: -0.4rem;
}

/* ── Timing toggle ───────────────────────────────────────────────────── */
.timing-toggle {
  display: flex;
  gap: 0.6rem;
}

.timing-btn {
  flex: 1;
  padding: 0.85rem 0.5rem;
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.timing-btn:active { transform: scale(0.96); }

.timing-btn.active[data-timing="on-time"]  { background: #166534; border-color: #34d399; color: #34d399; }
.timing-btn.active[data-timing="delayed"] { background: #78350f; border-color: #fbbf24; color: #fbbf24; }

/* ── Status grid ──────────────────────────────────────────────────────── */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.status-btn {
  padding: 0.85rem 0.5rem;
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.status-btn:active { transform: scale(0.96); }

.status-btn.active[data-status="Boarding"] { background: #1e3a5f; border-color: #60a5fa; color: #60a5fa; }
.status-btn.active[data-status="Cancelled"]{ background: #7f1d1d; border-color: #f87171; color: #f87171; }

/* ── Delay stepper ────────────────────────────────────────────────────── */
.delay-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.delay-row.hidden { display: none; }

.delay-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(255,255,255,0.07);
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.12);
}

.stepper-btn {
  flex: 0 0 56px;
  height: 52px;
  background: rgba(255,255,255,0.05);
  border: none;
  color: white;
  font-size: 1.6rem;
  font-weight: 300;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}
.stepper-btn:active { background: rgba(255,255,255,0.15); }

.stepper-val {
  flex: 1;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  color: #fbbf24;
}

/* ── Device row ───────────────────────────────────────────────────────── */
.device-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.device-hint {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.35);
  min-height: 1em;
  transition: color 0.2s;
}

.device-hint.hint-active {
  color: #34d399;
  font-weight: 600;
}

/* ── Action rows ──────────────────────────────────────────────────────── */
.action-row { display: flex; gap: 0.6rem; }
.action-row-secondary { margin-top: -0.4rem; }

/* ── Debug bar ────────────────────────────────────────────────────────── */
.debug-bar {
  background: #e94560;
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.05em;
  text-align: center;
  padding: 0.25rem 1rem;
  flex-shrink: 0;
}
.debug-bar.hidden { display: none; }

/* ── Confirm modal ───────────────────────────────────────────────────── */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.confirm-backdrop.hidden { display: none; }

.confirm-box {
  background: #1e2a3a;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 22px 22px 0 0;
  padding: 1.75rem 1.5rem 2rem;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: slideUp 0.22s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.confirm-icon {
  font-size: 2.25rem;
  text-align: center;
}

.confirm-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: white;
  text-align: center;
}

.confirm-body {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.7);
  text-align: center;
  line-height: 1.5;
}

.confirm-gps-note {
  font-size: 0.82rem;
  color: #34d399;
  text-align: center;
  font-weight: 600;
  min-height: 1em;
}

.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

/* ── Departed screen ──────────────────────────────────────────────────── */
.departed-icon {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
}

.departed-summary {
  background: rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  margin: 0.75rem 0;
  width: 100%;
  font-size: 1rem;
  line-height: 1.7;
  color: rgba(255,255,255,0.85);
  text-align: left;
}

.departed-summary strong { color: white; }

.departed-note {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.4);
  margin-bottom: 0.5rem;
  min-height: 1em;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.5rem;
}
