/* ================================================================
   Trip Flight Search — Frontend Styles
   RTL-first, mobile-first, CSS custom properties
   ================================================================ */

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

.tfs-wrap {
  --tfs-primary: #005baa;
  --tfs-accent:  #ff6600;
  --tfs-radius:  14px;
  --tfs-shadow:  0 4px 24px rgba(0,0,0,.10);
  --tfs-border:  #dde3eb;
  --tfs-bg:      #f7f9fc;
  --tfs-text:    #1a1f2e;
  --tfs-muted:   #6b7280;
  --tfs-green:   #16a34a;
  --tfs-red:     #dc2626;
  --tfs-gold:    #d97706;
  font-family: 'Segoe UI', Tahoma, 'Noto Sans Arabic', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--tfs-text);
  direction: rtl;
  text-align: right;
  margin: 20px 0;
}

/* ── Form box ──────────────────────────────────────────────────── */
.tfs-form-box {
  background: #fff;
  border-radius: var(--tfs-radius);
  box-shadow: var(--tfs-shadow);
  overflow: hidden;
}

.tfs-form-header {
  background: linear-gradient(135deg, var(--tfs-primary), color-mix(in srgb, var(--tfs-primary) 70%, #001e4a));
  padding: 22px 28px;
  color: #fff;
}

.tfs-form-header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tfs-header-plane {
  font-size: 32px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}

.tfs-form-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}

.tfs-form-subtitle {
  font-size: .85rem;
  opacity: .85;
  margin-top: 3px;
}

.tfs-form-body {
  padding: 24px 28px 28px;
}

/* ── Trip type tabs ────────────────────────────────────────────── */
.tfs-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--tfs-border);
  padding-bottom: 0;
}

.tfs-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: .9rem;
  font-family: inherit;
  color: var(--tfs-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  border-radius: 4px 4px 0 0;
  transition: color .2s, border-color .2s;
}

.tfs-tab:hover { color: var(--tfs-primary); }

.tfs-tab--active {
  color: var(--tfs-primary);
  font-weight: 600;
  border-bottom-color: var(--tfs-primary);
}

/* ── Airports row ──────────────────────────────────────────────── */
.tfs-airports-row {
  display: grid;
  grid-template-columns: 1fr 44px 1fr;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}

.tfs-field { display: flex; flex-direction: column; gap: 6px; }

.tfs-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--tfs-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ── Autocomplete ──────────────────────────────────────────────── */
.tfs-ac-wrap {
  position: relative;
}

.tfs-field-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tfs-muted);
  pointer-events: none;
  z-index: 1;
}

.tfs-input {
  width: 100%;
  padding: 11px 38px 11px 14px;
  border: 1.5px solid var(--tfs-border);
  border-radius: 10px;
  font-size: .95rem;
  font-family: inherit;
  color: var(--tfs-text);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  direction: rtl;
}

.tfs-input:focus {
  outline: none;
  border-color: var(--tfs-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tfs-primary) 15%, transparent);
}

.tfs-input-icon-wrap { position: relative; }

.tfs-select { appearance: none; cursor: pointer; padding-left: 32px; }

/* Select arrow */
.tfs-input-icon-wrap::after {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--tfs-muted);
  pointer-events: none;
}
.tfs-ac-wrap::after { display: none; }

/* Dropdown */
.tfs-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0; left: 0;
  background: #fff;
  border: 1.5px solid var(--tfs-border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  z-index: 9999;
  max-height: 280px;
  overflow-y: auto;
}

.tfs-dropdown.tfs-dropdown--open { display: block; }

.tfs-ac-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f4f8;
  transition: background .15s;
}
.tfs-ac-item:last-child { border-bottom: none; }
.tfs-ac-item:hover,
.tfs-ac-item--active { background: #f0f6ff; }

.tfs-ac-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tfs-ac-city   { font-weight: 600; font-size: .95rem; }
.tfs-ac-iata   { font-size: .8rem; font-weight: 700; color: var(--tfs-primary); background: #e8f0fe; padding: 2px 7px; border-radius: 5px; }
.tfs-ac-name   { font-size: .8rem; color: var(--tfs-muted); margin-top: 2px; }
.tfs-ac-empty  { padding: 14px; color: var(--tfs-muted); font-size: .9rem; text-align: center; }

/* ── Swap button ───────────────────────────────────────────────── */
.tfs-swap {
  width: 44px; height: 44px;
  border: 1.5px solid var(--tfs-border);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tfs-primary);
  transition: all .2s;
  margin-bottom: 0;
  align-self: flex-end;
}
.tfs-swap:hover {
  background: var(--tfs-primary);
  color: #fff;
  border-color: var(--tfs-primary);
  transform: rotate(180deg);
}

/* ── Options row ───────────────────────────────────────────────── */
.tfs-options-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

/* ── Search button ─────────────────────────────────────────────── */
.tfs-btn-search {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--tfs-primary), color-mix(in srgb, var(--tfs-primary) 80%, #003));
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity .2s, transform .1s, box-shadow .2s;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--tfs-primary) 40%, transparent);
}
.tfs-btn-search:hover { opacity: .93; box-shadow: 0 6px 20px color-mix(in srgb, var(--tfs-primary) 50%, transparent); }
.tfs-btn-search:active { transform: scale(.99); }
.tfs-btn-search:disabled { opacity: .6; cursor: not-allowed; }

/* ── Results container ─────────────────────────────────────────── */
.tfs-results { margin-top: 22px; }

.tfs-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tfs-results-summary {
  font-size: 1rem;
  font-weight: 600;
  color: var(--tfs-text);
}

.tfs-btn-modify {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: none;
  border: 1.5px solid var(--tfs-border);
  border-radius: 8px;
  font-size: .85rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--tfs-muted);
  transition: all .2s;
}
.tfs-btn-modify:hover { border-color: var(--tfs-primary); color: var(--tfs-primary); }

/* ── Toolbar ───────────────────────────────────────────────────── */
.tfs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--tfs-border);
  border-radius: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tfs-toolbar-label { font-size: .8rem; color: var(--tfs-muted); font-weight: 600; }

.tfs-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.tfs-filter {
  padding: 5px 12px;
  border: 1.5px solid var(--tfs-border);
  border-radius: 20px;
  background: #fff;
  font-size: .83rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--tfs-muted);
  transition: all .2s;
}
.tfs-filter:hover { border-color: var(--tfs-primary); color: var(--tfs-primary); }
.tfs-filter--active {
  background: var(--tfs-primary);
  border-color: var(--tfs-primary);
  color: #fff;
  font-weight: 600;
}

.tfs-sort-wrap { display: flex; align-items: center; gap: 8px; }

.tfs-sort-select {
  padding: 5px 28px 5px 10px;
  border: 1.5px solid var(--tfs-border);
  border-radius: 7px;
  font-size: .83rem;
  font-family: inherit;
  color: var(--tfs-text);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%236b7280' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E") no-repeat left 8px center;
  appearance: none;
  cursor: pointer;
  direction: rtl;
}

/* ── Loading ───────────────────────────────────────────────────── */
.tfs-loading {
  text-align: center;
  padding: 48px 20px;
  color: var(--tfs-muted);
  display: none;
}
.tfs-loading.tfs-loading--active { display: block; }

.tfs-spinner {
  width: 42px; height: 42px;
  border: 3px solid var(--tfs-border);
  border-top-color: var(--tfs-primary);
  border-radius: 50%;
  animation: tfs-spin .8s linear infinite;
  margin: 0 auto 14px;
}
@keyframes tfs-spin { to { transform: rotate(360deg); } }

/* ── Flight cards ──────────────────────────────────────────────── */
.tfs-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tfs-card {
  background: #fff;
  border: 1.5px solid var(--tfs-border);
  border-radius: 14px;
  overflow: hidden;
  transition: box-shadow .2s, transform .15s;
}
.tfs-card:hover {
  box-shadow: 0 6px 28px rgba(0,0,0,.10);
  transform: translateY(-1px);
}
.tfs-card--best {
  border-color: var(--tfs-primary);
}

/* Card body = flex row: airline | route | price */
.tfs-card-body {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 100px;
}

/* ── Airline column ─────────── */
.tfs-card-airline {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  padding: 16px 18px;
  width: 170px;
  flex-shrink: 0;
}

.tfs-airline-logo {
  height: 34px;
  width: auto;
  max-width: 86px;
  object-fit: contain;
  border-radius: 5px;
}

.tfs-airline-fallback {
  width: 42px; height: 42px;
  border-radius: 9px;
  background: var(--tfs-primary);
  color: #fff;
  font-weight: 700;
  font-size: .88rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tfs-airline-name { font-weight: 600; font-size: .88rem; line-height: 1.3; }
.tfs-airline-code { font-size: .72rem; color: var(--tfs-muted); }

.tfs-badge-best {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  background: #fef9c3;
  color: var(--tfs-gold);
  border: 1px solid #fde68a;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ── Route column ───────────── */
.tfs-card-route {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px;
  border-inline-start: 1px solid var(--tfs-border);
  border-inline-end: 1px solid var(--tfs-border);
}

.tfs-time-block { text-align: center; flex-shrink: 0; }

.tfs-time {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--tfs-text);
  line-height: 1;
  direction: ltr;
}

.tfs-iata-label {
  font-size: .72rem;
  color: var(--tfs-muted);
  font-weight: 600;
  margin-top: 3px;
}

.tfs-route-mid {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 100px;
}

.tfs-duration-label { font-size: .78rem; color: var(--tfs-muted); font-weight: 500; }

.tfs-route-line {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 100%;
}

.tfs-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--tfs-primary);
  flex-shrink: 0;
}

.tfs-line {
  flex: 1;
  height: 1.5px;
  background: color-mix(in srgb, var(--tfs-primary) 25%, var(--tfs-border));
}

.tfs-plane-icon {
  font-size: .85rem;
  flex-shrink: 0;
  display: inline-block;
  transform: rotate(-90deg);
}

.tfs-stop-label {
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.tfs-stop-label--direct { color: var(--tfs-green); background: #dcfce7; }
.tfs-stop-label--stop   { color: var(--tfs-gold);  background: #fef3c7; }

/* ── Price column ───────────── */
.tfs-card-price {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 20px;
  width: 170px;
  flex-shrink: 0;
  text-align: center;
}

.tfs-price-amount {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--tfs-primary);
  line-height: 1;
  direction: ltr;
  white-space: nowrap;
}

.tfs-price-currency {
  font-size: .82rem;
  font-weight: 600;
  vertical-align: super;
  color: var(--tfs-primary);
}

.tfs-price-note { font-size: .75rem; color: var(--tfs-muted); }

.tfs-btn-book {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--tfs-accent), color-mix(in srgb, var(--tfs-accent) 80%, #8b0000));
  color: #fff;
  text-decoration: none;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  transition: opacity .2s, box-shadow .2s;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--tfs-accent) 35%, transparent);
  white-space: nowrap;
}
.tfs-btn-book:hover { opacity: .9; box-shadow: 0 5px 16px color-mix(in srgb, var(--tfs-accent) 45%, transparent); }

/* Card footer tags */
.tfs-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--tfs-bg);
  border-top: 1px solid var(--tfs-border);
  flex-wrap: wrap;
}

.tfs-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 500;
  background: #e8f0fe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.tfs-tag--bag   { background: #f0fdf4; color: var(--tfs-green); border-color: #bbf7d0; }
.tfs-tag--seats { background: #fff7ed; color: var(--tfs-accent); border-color: #fed7aa; }
.tfs-tag--ref   { background: #f0fdf4; color: var(--tfs-green); border-color: #bbf7d0; }

/* ── No results ────────────────────────────────────────────────── */
.tfs-no-results {
  text-align: center;
  padding: 50px 20px;
  color: var(--tfs-muted);
  background: #fff;
  border: 1.5px dashed var(--tfs-border);
  border-radius: 14px;
}
.tfs-no-results span { font-size: 2.5rem; display: block; margin-bottom: 12px; }

/* ── CTA banner ────────────────────────────────────────────────── */
.tfs-cta-wrap {
  margin-top: 16px;
  background: linear-gradient(135deg, var(--tfs-primary), color-mix(in srgb, var(--tfs-primary) 70%, #001));
  border-radius: 14px;
  padding: 20px 24px;
  color: #fff;
}

.tfs-cta-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.tfs-cta-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tfs-cta-text strong { font-size: 1rem; }
.tfs-cta-text span   { font-size: .85rem; opacity: .85; }

.tfs-btn-viewall {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: #fff;
  color: var(--tfs-primary);
  text-decoration: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: .9rem;
  white-space: nowrap;
  transition: opacity .2s;
  box-shadow: 0 3px 10px rgba(0,0,0,.2);
}
.tfs-btn-viewall:hover { opacity: .92; }

/* ── Disclaimer ────────────────────────────────────────────────── */
.tfs-disclaimer {
  margin-top: 14px;
  font-size: .78rem;
  color: var(--tfs-muted);
  line-height: 1.6;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--tfs-border);
  border-radius: 8px;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .tfs-card-body {
    flex-direction: column;
    align-items: stretch;
  }
  .tfs-card-airline {
    flex-direction: row;
    align-items: center;
    width: 100%;
    padding: 14px 18px 10px;
    gap: 10px;
  }
  .tfs-card-route {
    border-inline-start: none;
    border-inline-end: none;
    border-top: 1px solid var(--tfs-border);
    border-bottom: 1px solid var(--tfs-border);
    padding: 14px 18px;
    width: 100%;
  }
  .tfs-card-price {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 18px;
  }
  .tfs-btn-book { width: auto; min-width: 130px; }
}

@media (max-width: 680px) {
  .tfs-form-body { padding: 16px; }
  .tfs-airports-row { grid-template-columns: 1fr 40px 1fr; gap: 8px; }
  .tfs-options-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tfs-form-header { padding: 16px; }
  .tfs-form-title { font-size: 1.1rem; }
  .tfs-header-plane { font-size: 24px; }
  .tfs-time { font-size: 1.1rem; }
  .tfs-price-amount { font-size: 1.2rem; }
  .tfs-cta-inner { flex-direction: column; align-items: flex-start; }
  .tfs-btn-viewall { width: 100%; justify-content: center; }
  .tfs-card-airline { width: 100%; }
  .tfs-card-price { width: 100%; }
}

@media (max-width: 440px) {
  .tfs-options-row { grid-template-columns: 1fr; }
  .tfs-airports-row { grid-template-columns: 1fr; }
  .tfs-swap { display: none; }
  .tfs-toolbar { flex-direction: column; align-items: flex-start; }
  .tfs-card-price { flex-direction: column; align-items: flex-start; gap: 10px; }
  .tfs-btn-book { width: 100%; }
}
