/* ── Flight Finder — styles ──────────────────────────────────────── */

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --border: #475569;
  --text: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --accent: #38bdf8;
  --accent-dim: #0ea5e9;
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --orange: #fb923c;
  --red: #f87171;
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── header ─────────────────────────────────────────────────────── */

.kicker {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 8px;
}
.top {
  padding: 28px 24px 14px;
  max-width: 1120px;
  margin: 0 auto;
}
.top h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.brand-mark {
  width: 1em;
  height: 1em;
  flex: 0 0 1em;
  display: block;
}
.lede {
  color: var(--text-2);
  font-size: 14px;
  margin-top: 4px;
}

/* ── search box ─────────────────────────────────────────────────── */

.search-box,
.summary,
.controls,
.count-row,
.results,
.empty,
footer {
  max-width: 1120px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
}
.search-box { padding-bottom: 16px; }
.swap-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 20px;
  align-items: stretch;
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 24px 4px;
}
.overview:not(:has(#decisions:not([hidden]))) {
  grid-template-columns: 1fr;
}
.coverage,
.decisions {
  margin-top: 4px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.coverage-table-wrap {
  flex: 1;
  display: flex;
  overflow-x: auto;
}
.coverage-table {
  height: 100%;
}
.decision-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.decision-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.decisions h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-2);
  margin-bottom: 10px;
}
.decision-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.decision-card .stat-value {
  font-size: 16px;
  margin: 2px 0;
}
.decision-note {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.4;
}
.fc-also {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-2);
}
.fc-also a {
  color: var(--accent);
  text-decoration: none;
}
.fc-also a:hover { text-decoration: underline; }
.coverage h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-2);
  margin-bottom: 10px;
}
.coverage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.coverage-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-3);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.coverage-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--surface-2);
  vertical-align: middle;
}
.coverage-table td:last-child {
  max-width: 220px;
}
.coverage-table td:last-child .fc-amount {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}
.coverage-table td:last-child .fc-fare {
  display: inline;
  font-size: 12px;
}
.coverage-table td:last-child .fc-fare + .fc-fare::before {
  content: " · ";
  color: var(--text-3);
}
.status-ok { color: var(--green); font-weight: 600; }
.status-blocked, .status-error { color: var(--red); font-weight: 600; }
.status-empty, .status-not_captured, .status-skipped { color: var(--orange); font-weight: 600; }
.search-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 120px;
}
.field-sm { max-width: 90px; flex: 0 0 90px; }

.field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-2);
}
.optional { font-weight: 400; text-transform: none; color: var(--text-3); }

.field input,
.field select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
}
.field input::placeholder { color: var(--text-3); }
.field input[type="text"] { text-transform: uppercase; }

.swap-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 18px;
  padding: 6px 10px;
  cursor: pointer;
  align-self: flex-end;
  margin-bottom: 1px;
  transition: background 0.15s;
}
.swap-btn:hover { background: var(--surface-2); }

.hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-3);
}
.hint code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--accent);
}

/* ── controls ───────────────────────────────────────────────────── */

.controls {
  margin: 16px auto 0;
  padding-top: 8px;
  padding-bottom: 12px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.pills { display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px 5px 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
}
.brand-sep {
  margin: 0 6px;
  color: var(--text-3);
}
.logo-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: #f8fafc;
  overflow: hidden;
  flex-shrink: 0;
}
.logo-chip img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}
.pill:hover { border-color: var(--accent); color: var(--text); }
.pill.is-on {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

.tools { display: flex; gap: 12px; margin-left: auto; }
.tools label {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tools select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  font-family: var(--font);
}

/* ── summary stats ──────────────────────────────────────────────── */

.summary {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  flex: 1;
  min-width: 120px;
}
.stat.best {
  border-color: var(--green);
  background: var(--green-dim);
}
.stat.stopwatch {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
}
.stat.stopwatch .stat-value { color: var(--accent); white-space: nowrap; }

.timing {
  margin: 12px auto 0;
}
.timing-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-2);
  margin-bottom: 8px;
}
.timing-row {
  display: grid;
  grid-template-columns: 120px 70px 1fr 90px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  margin-bottom: 6px;
}
.timing-name { color: var(--text); font-weight: 500; }
.timing-sec { color: var(--accent); font-variant-numeric: tabular-nums; }
.timing-bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.timing-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}
.timing-bar.is-blocked > span { background: var(--red); }
.timing-bar.is-empty > span { background: var(--text-3); }
.timing-meta { color: var(--text-3); font-size: 12px; text-align: right; }

.stat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-2);
  margin-bottom: 2px;
}
.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
}
.stat.best .stat-value { color: var(--green); }
.stat-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}
.stat-time { font-size: 14px; }

/* ── count row ──────────────────────────────────────────────────── */

.count-row {
  margin: 0 auto;
  padding-top: 8px;
  padding-bottom: 4px;
}
.count {
  font-size: 13px;
  color: var(--text-3);
}

/* ── results list ───────────────────────────────────────────────── */

.results {
  padding-top: 0;
  padding-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  transition: border-color 0.15s;
}
.flight-card:hover { border-color: var(--accent); }
.flight-card.cheapest { border-color: var(--green); }

.fc-route {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fc-times {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fc-arrow { color: var(--text-3); font-size: 14px; }
.fc-airline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-2);
}
.fc-source .brand { justify-content: flex-end; }
.fc-meta {
  font-size: 12px;
  color: var(--text-3);
}

.fc-details {
  text-align: center;
  min-width: 100px;
}
.fc-duration {
  font-size: 14px;
  font-weight: 500;
}
.fc-stops {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}
.fc-stops.nonstop { color: var(--green); }
.fc-stop-cities {
  font-size: 11px;
  color: var(--text-3);
}

.fc-price {
  text-align: right;
  min-width: 110px;
}
.fc-amount {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.fc-fare {
  line-height: 1.25;
}
.fc-fare + .fc-fare {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.flight-card.cheapest .fc-amount { color: var(--green); }
.fc-source {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.fc-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
}
.fc-link:hover { text-decoration: underline; }

.badge-cheapest {
  display: inline-block;
  background: var(--green-dim);
  color: var(--green);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

/* ── empty / footer ─────────────────────────────────────────────── */

.empty {
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
  padding: 40px 24px;
}

footer {
  padding-top: 16px;
  padding-bottom: 32px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* ── responsive (mobile only — desktop rules above stay unchanged) ─ */

@media (max-width: 640px) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .top {
    padding: 18px 16px 10px;
  }
  .top h1 {
    font-size: 24px;
    line-height: 1.15;
  }
  .lede {
    font-size: 13px;
    line-height: 1.45;
  }

  .search-box,
  .summary,
  .controls,
  .count-row,
  .results,
  .empty,
  footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .overview {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 8px 16px 4px;
  }

  .decision-grid {
    display: grid;
    grid-template-columns: 1fr;
  }
  .decision-card,
  .coverage-table {
    flex: none;
    height: auto;
  }

  .search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: end;
  }
  .search-row .field {
    min-width: 0;
  }
  .search-row .field:nth-child(1),
  .search-row .field:nth-child(3) {
    flex: 1 1 calc((100% - 40px - 16px) / 2);
  }
  .search-row .field:nth-child(4),
  .search-row .field:nth-child(5) {
    flex: 1 1 0;
  }
  .field input,
  .field select {
    font-size: 16px;
    padding: 10px 8px;
    width: 100%;
    min-width: 0;
  }
  .search-row .field-sm {
    flex: 0 0 4rem;
    max-width: 4rem;
    min-width: 0;
  }
  .search-row .field-sm input {
    width: 100%;
    text-align: center;
    padding-left: 4px;
    padding-right: 4px;
  }
  .swap-btn {
    flex: 0 0 40px;
    width: 40px;
    height: 42px;
    margin: 0;
    padding: 0;
    align-self: end;
  }

  .hint {
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }
  .stat.stopwatch {
    grid-column: 1 / -1;
  }
  .stat {
    min-width: 0;
    padding: 8px 8px;
  }
  .stat-value {
    font-size: 16px;
  }
  .stat-time {
    font-size: 12px;
    word-break: break-word;
  }
  .stat-detail {
    font-size: 10px;
    line-height: 1.3;
  }

  .coverage-table-wrap {
    display: block;
    overflow: visible;
  }
  .coverage-table thead {
    display: none;
  }
  .coverage-table,
  .coverage-table tbody {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
  }
  .coverage-table tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .coverage-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 10px;
    row-gap: 2px;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
  }
  .coverage-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    min-width: 0;
    border-bottom: 0;
    padding: 3px 0;
    vertical-align: middle;
  }
  .coverage-table td::before {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-3);
  }
  .coverage-table td:nth-child(1) {
    grid-column: 1 / -1;
    padding-bottom: 6px;
    margin-bottom: 2px;
    border-bottom: 1px solid var(--surface-2);
  }
  .coverage-table td:nth-child(1)::before { content: none; }
  .coverage-table td:nth-child(2)::before { content: "Camada"; }
  .coverage-table td:nth-child(3)::before { content: "Status"; }
  .coverage-table td:nth-child(4)::before { content: "Tempo"; }
  .coverage-table td:nth-child(5)::before { content: "Voos"; }
  .coverage-table td:nth-child(6) {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-top: 6px;
    margin-top: 2px;
    border-top: 1px solid var(--surface-2);
    max-width: none;
  }
  .coverage-table td:nth-child(6)::before { content: "Melhor"; }
  .coverage-table td:last-child .fc-amount,
  .coverage-table td:last-child .fc-fare {
    display: inline;
    font-size: 13px;
  }
  .coverage-table td:last-child .brand {
    gap: 4px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-top: 12px;
  }
  .pills {
    width: 100%;
  }
  .pill {
    font-size: 13px;
    padding: 8px 12px 8px 8px;
    min-height: 40px;
  }
  .tools {
    margin-left: 0;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .tools label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }
  .tools select {
    width: 100%;
    font-size: 16px;
    padding: 10px 12px;
    min-height: 44px;
  }

  .flight-card {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "route price"
      "details details";
    gap: 6px 12px;
    padding: 12px;
    align-items: start;
  }
  .fc-route { grid-area: route; min-width: 0; }
  .fc-details {
    grid-area: details;
    text-align: left;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    align-items: baseline;
  }
  .fc-price {
    grid-area: price;
    text-align: right;
    min-width: 0;
  }
  .fc-times {
    font-size: 16px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .fc-amount {
    font-size: 18px;
  }
  .badge-cheapest {
    margin-left: 0;
  }
  .fc-source .brand {
    justify-content: flex-end;
  }
  .fc-link {
    display: inline-block;
    padding: 6px 0;
    font-size: 13px;
  }

  footer {
    text-align: left;
    line-height: 1.5;
    padding-bottom: 28px;
  }
}
