/* styles.css — Flight in the Air (app00046). Dark aviation look. */

:root {
  --bg: #0A0F1E;
  --surface: #131A2C;
  --surface-2: #1B2440;
  --border: rgba(255, 255, 255, 0.08);
  --text: #E6EAF2;
  --text-dim: #8A93A8;
  --accent: #4FC3F7;
  --accent-soft: rgba(79, 195, 247, 0.35);
  --amber: #FFB74D;
  --green: #4ADE80;
  --red: #F87171;
  --radius: 16px;
  --radius-sm: 10px;
  --tabbar-h: 58px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  padding-top: env(safe-area-inset-top); /* keep content below the iOS status bar in standalone PWA */
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- layout ---------- */

.page { display: none; padding: 16px 16px 24px; max-width: 560px; margin: 0 auto; }
.page.active { display: block; }

.page-title {
  font-size: 26px; font-weight: 700; letter-spacing: -0.01em;
  padding: 10px 0 14px;
  display: flex; align-items: center; justify-content: space-between;
}

.section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-dim);
  margin: 18px 0 8px;
}

/* ---------- top banners ---------- */

.banner {
  position: sticky; top: 0; z-index: 30;
  padding: 10px 16px; text-align: center; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.banner.update { background: var(--accent); color: #06263a; }
.banner.offline { background: var(--surface-2); color: var(--text-dim); cursor: default; }
.hidden { display: none !important; }

/* ---------- flight card ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  cursor: pointer;
}

.card-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-dim);
}

.pill {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 999px; border: 1px solid transparent;
}
/* derived-status pills */
.pill.upcoming  { color: var(--accent); border-color: var(--accent); }
.pill.inflight  { color: #06263a; background: var(--green); }
.pill.delayed   { color: #06263a; background: var(--amber); }
.pill.flown     { color: var(--text-dim); border-color: var(--border); }
.pill.cancelled { color: var(--red); border-color: var(--red); text-decoration: line-through; }
/* legacy status values (pre-auto-status data) */
.pill.planned   { color: var(--text-dim); border-color: var(--text-dim); }
.pill.ticketed  { color: var(--accent); border-color: var(--accent); }
.pill.checked-in{ color: #06263a; background: var(--green); }
.pill.watching  { color: var(--amber); border-color: var(--amber); }
.pill.live      { color: #06263a; background: var(--amber); }
.pill-group { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* traveler role radio (I'm flying / Someone else) */
.role-row { display: flex; gap: 8px; }
.role-opt {
  flex: 1; text-align: center; cursor: pointer;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px; font-size: 14px; font-weight: 600; color: var(--text-dim); user-select: none;
}
.role-opt.active { color: var(--accent); border-color: var(--accent); background: rgba(79,195,247,0.08); }
.role-row input { display: none; }

/* notification preference checkboxes */
.notify-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.notify-opt {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 10px 11px; font-size: 14px; cursor: pointer;
}
.notify-opt input { accent-color: var(--accent); width: 18px; height: 18px; }

.card-body {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 8px;
  padding: 16px 14px;
}

.endpoint .iata { font-size: 34px; font-weight: 700; letter-spacing: 0.02em; }
.endpoint .time { font-size: 17px; font-weight: 600; margin-top: 2px; }
.endpoint .date { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.endpoint .date sup { color: var(--accent); font-weight: 700; }
.endpoint.arr { text-align: right; }

.card-mid { display: flex; flex-direction: column; align-items: center; min-width: 90px; }
.flight-line {
  position: relative; width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--text-dim), var(--accent));
  border-radius: 1px;
}
.flight-line svg {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--surface); padding: 0 3px;
}
.card-mid .dur { font-size: 11px; color: var(--text-dim); margin-top: 8px; }

.card-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 14px 14px;
}
.chip {
  background: var(--surface-2); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-dim);
  padding: 4px 9px;
}
.chip b { color: var(--text); font-weight: 600; }

.cancelled-card .iata, .cancelled-card .time { text-decoration: line-through; opacity: 0.55; }

/* ---------- 4-stage timeline ---------- */

.stepper-wrap {
  border-top: 1px solid var(--border);
  padding: 16px 14px 18px;
}

.countdown { text-align: center; margin-bottom: 14px; }
.countdown .cd-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-dim);
}
.countdown .cd-value {
  font-size: 22px; font-weight: 700; color: var(--accent); margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.stepper { display: flex; align-items: flex-start; }
.step { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; width: 54px; }
.step .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface-2); margin-top: -4px;
}
.step.done .dot { background: var(--accent); }
.step .st-label {
  font-size: 9px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-dim); margin-top: 7px; text-align: center;
}
.step.done .st-label { color: var(--text); }
.step .st-time { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

.seg { flex: 1 1 auto; position: relative; height: 2px; background: var(--surface-2); margin-top: 0; }
.seg .seg-fill { position: absolute; left: 0; top: 0; height: 100%; background: var(--accent); }
.seg .plane {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 6px var(--accent));
}

/* ---------- forms ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 10px; }
.form-grid .full { grid-column: 1 / -1; }

.field label {
  display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 11px; font-size: 15px; font-family: inherit;
  outline: none; appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field .hint { font-size: 11px; color: var(--text-dim); margin-top: 3px; min-height: 14px; }
.field input::placeholder, .field textarea::placeholder { color: rgba(138, 147, 168, 0.6); }

.btn {
  display: block; width: 100%; text-align: center;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; margin-top: 10px;
}
.btn.primary { background: var(--accent); color: #06263a; border-color: transparent; }
.btn.danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn.small { display: inline-block; width: auto; padding: 8px 14px; font-size: 13px; margin: 0; }
.btn.ghost { background: transparent; border: 1px dashed var(--border); color: var(--text-dim); font-weight: 500; margin-top: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* read-only auto-filled flight summary */
.auto-info {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-top: 12px;
}
.auto-info .pill { margin-bottom: 8px; }
.auto-info .ai-line1 { font-size: 17px; font-weight: 600; }
.auto-info .ai-line2 { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.auto-info.empty { color: var(--text-dim); font-size: 13px; }

.msg { font-size: 13px; margin-top: 8px; min-height: 18px; }
.msg.ok { color: var(--green); }
.msg.err { color: var(--red); }
.msg.dim { color: var(--text-dim); }

/* ---------- stats ---------- */

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.tile .t-num { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .t-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dim); margin-top: 2px;
}
.tile .t-sub { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

.map-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px; margin: 12px 0;
  overflow: hidden;
}
.map-card svg { display: block; width: 100%; height: auto; }

.rank-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 13px; margin-bottom: 7px;
  font-size: 14px;
}
.rank-row .rr-count { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }

.toggle-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-dim); margin: 6px 0 12px;
}
.toggle-row input { accent-color: var(--accent); width: 18px; height: 18px; }

/* ---------- settings ---------- */

.settings-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.settings-card p.help { font-size: 12px; color: var(--text-dim); margin: 6px 0 10px; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--text-dim);
  border-radius: 999px; padding: 3px 10px; margin-left: 8px;
}

/* ---------- preview table (imports) ---------- */

.preview-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
.preview-table th, .preview-table td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.preview-table th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 10px; }
.preview-wrap { overflow-x: auto; }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around; align-items: stretch;
  background: rgba(19, 26, 44, 0.96);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-dim); text-decoration: none; font-size: 10px; font-weight: 600;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 39;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #06263a; border: none;
  font-size: 28px; font-weight: 400; line-height: 1;
  box-shadow: 0 4px 16px rgba(79, 195, 247, 0.4);
  cursor: pointer;
}

.empty-state {
  text-align: center; color: var(--text-dim); padding: 48px 20px;
  white-space: pre-line; font-size: 14px;
}

.back-link { color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 600; }

@media (min-width: 700px) {
  body { font-size: 16px; }
}
