/* ---------- Design tokens ---------- */
:root {
  --bg: #0b1020;
  --bg-gradient: radial-gradient(
      1200px 600px at 75% -10%,
      rgba(99, 102, 241, 0.22),
      transparent 60%
    ),
    radial-gradient(900px 500px at 5% 0%, rgba(56, 189, 248, 0.16), transparent 55%);
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-3: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #e8ecf6;
  --text-dim: #98a2bd;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --indigo: #6366f1;
  --indigo-2: #4f46e5;
  --success: #34d399;
  --radius: 16px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
}
.muted {
  color: var(--text-dim);
  font-weight: 400;
}

/* ---------- Topbar ---------- */
.topbar {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px);
  background: rgba(11, 16, 32, 0.6);
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand__logo {
  font-size: 28px;
  filter: drop-shadow(0 4px 10px rgba(56, 189, 248, 0.5));
}
.brand__title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand__subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- Layout (single column) ---------- */
.layout {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- AI hero search bar ---------- */
.ai {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.16),
    rgba(56, 189, 248, 0.12)
  );
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 8px 8px 8px 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ai__bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18), var(--shadow);
}
.ai__icon {
  font-size: 22px;
  flex: 0 0 auto;
  filter: drop-shadow(0 3px 8px rgba(99, 102, 241, 0.5));
}
.ai__input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  padding: 12px 4px;
}
.ai__input::placeholder {
  color: var(--text-dim);
}
.ai__send {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--indigo), var(--indigo-2));
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.ai__send:hover {
  transform: translateY(-1px);
}
.ai__send:disabled {
  opacity: 0.5;
  cursor: progress;
  transform: none;
}
.ai__status {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 15px;
  animation: rise 0.28s ease both;
  /* Long agent answers must wrap, never overflow the card horizontally. */
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ai__status::before {
  content: "🤖";
  flex: 0 0 auto;
}
.ai__status strong {
  color: #fff;
}
.ai__status .typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
}
.ai__suggests {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Geolocation hint under "Von" ---------- */
.geo {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  animation: rise 0.3s ease both;
}
.geo__list {
  color: var(--accent);
  font-weight: 600;
}
.geo__toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  color: var(--text);
}
.geo__toggle input {
  accent-color: var(--accent);
}

/* ---------- Search form ---------- */
.search {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.search__row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  position: relative;
  min-width: 0;
}
.field--narrow {
  flex: 0 0 130px;
}
.field--stops {
  flex: 1;
}
.field--trip {
  flex: 0 0 auto;
}
/* One-way mode greys out and disables the return-date field. */
.field.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}
.field__input {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field__input::placeholder {
  color: var(--text-dim);
}
.field__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}
/* native date/select tweaks for dark UI */
.field__input[type="date"] {
  color-scheme: dark;
}
select.field__input {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%2398a2bd' stroke-width='1.5' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.swap {
  flex: 0 0 auto;
  margin-bottom: 6px;
  width: 40px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.swap:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Autosuggest dropdown */
.suggest {
  list-style: none;
  margin: 0;
  padding: 6px;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 40;
  margin-top: 6px;
  background: #131a2e;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
}
.suggest li {
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
}
.suggest li:hover,
.suggest li.is-active {
  background: var(--surface-3);
}
.suggest .iata {
  font-weight: 700;
  color: var(--accent);
  font-size: 13px;
  min-width: 34px;
}
.suggest .where {
  color: var(--text-dim);
  font-size: 12.5px;
}

/* Segmented stop buttons */
.segmented {
  display: flex;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
}
.seg {
  flex: 1;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 9px;
  padding: 9px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.seg:hover {
  color: var(--text);
}
.seg.is-active {
  background: linear-gradient(135deg, var(--indigo), var(--indigo-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.search__submit {
  margin-top: 4px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #06283d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 14px;
  padding: 15px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  box-shadow: 0 10px 26px rgba(14, 165, 233, 0.32);
}
.search__submit:hover {
  transform: translateY(-1px);
}
.search__submit:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

/* ---------- Results ---------- */
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 2px 12px;
}
.results-count {
  font-weight: 600;
  font-size: 15px;
}
.sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}
.sort__select {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  outline: none;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  animation: rise 0.3s ease both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.card__legs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.leg {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.leg__time {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.leg__path {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-dim);
  min-width: 90px;
}
.leg__line {
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
  position: relative;
}
.leg__line::after {
  content: "✈";
  position: absolute;
  right: -2px;
  top: -9px;
  font-size: 12px;
  color: var(--accent);
}
.leg__meta {
  font-size: 11.5px;
  color: var(--text-dim);
}
.leg__air {
  font-size: 12.5px;
  color: var(--text-dim);
  min-width: 60px;
}
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-dim);
}
.badge--direct {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.card__buy {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  text-align: right;
}
.card__price {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.card__price small {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}
.card__origin {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 9px;
  border-radius: 999px;
}
.book-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06283d;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.32);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.book-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(14, 165, 233, 0.45);
}

/* status / empty / loading */
.status {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
  padding: 26px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.55;
}
.skeleton {
  height: 92px;
  border-radius: 16px;
  background: linear-gradient(
    100deg,
    var(--surface) 30%,
    var(--surface-2) 50%,
    var(--surface) 70%
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------- Suggestion chips + typing dots ---------- */
.chip {
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 13px;
  cursor: pointer;
  text-align: left;
  line-height: 1.35;
  transition: all 0.15s ease;
}
.chip:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
}
.typing {
  display: inline-flex;
  gap: 4px;
}
.typing span {
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
}

/* brief highlight when the AI fills a field */
.field--filled .field__input,
.flash {
  animation: flash 1.1s ease;
}
@keyframes flash {
  0% {
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.5);
    border-color: var(--success);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
  .search__row {
    flex-wrap: wrap;
  }
  .field--narrow {
    flex: 1 1 120px;
  }
  .field--stops {
    flex: 1 1 100%;
  }
  .card {
    grid-template-columns: 1fr;
  }
  .card__buy {
    align-items: stretch;
    text-align: left;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}
