/* ============================================================
   F9GWP Matrix — ITA Matrix-Inspired Theme
   Based on Google Material Design used by ITA Matrix
   ============================================================ */

/* Redundant @import for fonts removed - handled by index.html for performance */

/* ============================================================
   CSS Custom Properties — Light Theme
   ============================================================ */
:root {
  --mat-primary: #1967d2;
  --mat-primary-light: #d2e3fc;
  --mat-primary-dark: #1558b0;
  --mat-accent: #c92786;
  --mat-accent-light: #fdcfe8;
  --f9-green: #008080;
  --f9-green-light: #00a78e;

  --mat-sys-background: #fafafa;
  --mat-sys-surface: #ffffff;
  --mat-sys-surface-variant: #f5f5f5;
  --mat-sys-surface-container: #eeeeee;
  --mat-sys-on-surface: rgba(0,0,0,0.87);
  --mat-sys-on-surface-variant: rgba(0,0,0,0.54);
  --mat-sys-outline: rgba(0,0,0,0.12);
  --mat-sys-outline-variant: rgba(0,0,0,0.06);

  --mat-toolbar-bg: #ffffff;
  --mat-toolbar-text: rgba(0,0,0,0.87);
  --mat-toolbar-border: rgba(0,0,0,0.12);
  --mat-card-bg: #ffffff;
  --mat-card-hover: rgba(0,0,0,0.02);

  --mat-input-bg: rgba(0,0,0,0.04);
  --mat-input-border: rgba(0,0,0,0.42);
  --mat-input-border-focus: var(--mat-primary);
  --mat-input-text: rgba(0,0,0,0.87);
  --mat-input-label: rgba(0,0,0,0.6);
  --mat-input-placeholder: rgba(0,0,0,0.42);

  --mat-table-header-bg: #fafafa;
  --mat-table-row-hover: rgba(0,0,0,0.04);
  --mat-table-border: rgba(0,0,0,0.12);

  --tb-grid-line: rgba(0,0,0,0.08);
  --tb-grid-midnight: rgba(0,0,0,0.25);
  --tb-time-text: rgba(0,0,0,0.54);
  --tb-layover-bg: rgba(0,0,0,0.06);
  --tb-layover-text: rgba(0,0,0,0.54);

  --mat-button-bg: var(--mat-primary);
  --mat-button-text: #ffffff;
  --mat-button-disabled-bg: rgba(0,0,0,0.12);
  --mat-button-disabled-text: rgba(0,0,0,0.26);

  --status-available: #1b873f;
  --status-limited: #e8710a;
  --status-unavail: #d93025;

  --elevation-1: 0 2px 1px -1px rgba(0,0,0,.2),0 1px 1px 0 rgba(0,0,0,.14),0 1px 3px 0 rgba(0,0,0,.12);
  --elevation-2: 0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12);
  --elevation-4: 0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12);

  --transition-fast: 200ms cubic-bezier(0.4,0,0.2,1);
  --transition-std: 300ms cubic-bezier(0.4,0,0.2,1);
}

/* ============================================================
   Dark Theme
   ============================================================ */
html.dark-theme {
  --mat-sys-background: #1e1e1e;
  --mat-sys-surface: #2d2d2d;
  --mat-sys-surface-variant: #383838;
  --mat-sys-surface-container: #333;
  --mat-sys-on-surface: rgba(255,255,255,0.87);
  --mat-sys-on-surface-variant: rgba(255,255,255,0.54);
  --mat-sys-outline: rgba(255,255,255,0.12);
  --mat-sys-outline-variant: rgba(255,255,255,0.06);

  --mat-toolbar-bg: #2d2d2d;
  --mat-toolbar-text: rgba(255,255,255,0.87);
  --mat-toolbar-border: rgba(255,255,255,0.12);
  --mat-card-bg: #2d2d2d;
  --mat-card-hover: rgba(255,255,255,0.04);

  --mat-input-bg: rgba(255,255,255,0.08);
  --mat-input-border: rgba(255,255,255,0.42);
  --mat-input-border-focus: #8ab4f8;
  --mat-input-text: rgba(255,255,255,0.87);
  --mat-input-label: rgba(255,255,255,0.6);
  --mat-input-placeholder: rgba(255,255,255,0.42);

  --mat-primary: #8ab4f8;
  --mat-primary-light: rgba(138,180,248,0.2);
  --mat-accent: #f48fb1;
  --mat-accent-light: rgba(244,143,177,0.2);

  --mat-table-header-bg: #333;
  --mat-table-row-hover: rgba(255,255,255,0.04);
  --mat-table-border: rgba(255,255,255,0.12);

  --tb-grid-line: rgba(255,255,255,0.08);
  --tb-grid-midnight: rgba(255,255,255,0.2);
  --tb-time-text: rgba(255,255,255,0.5);
  --tb-layover-bg: rgba(255,255,255,0.08);
  --tb-layover-text: rgba(255,255,255,0.5);

  --mat-button-bg: #8ab4f8;
  --mat-button-text: #1e1e1e;
  --mat-button-disabled-bg: rgba(255,255,255,0.12);
  --mat-button-disabled-text: rgba(255,255,255,0.38);

  --status-available: #81c995;
  --status-limited: #fdd663;
  --status-unavail: #f28b82;

  --elevation-1: 0 2px 1px -1px rgba(0,0,0,.4),0 1px 1px 0 rgba(0,0,0,.28),0 1px 3px 0 rgba(0,0,0,.24);
  --elevation-2: 0 3px 1px -2px rgba(0,0,0,.4),0 2px 2px 0 rgba(0,0,0,.28),0 1px 5px 0 rgba(0,0,0,.24);
  --elevation-4: 0 2px 4px -1px rgba(0,0,0,.4),0 4px 5px 0 rgba(0,0,0,.28),0 1px 10px 0 rgba(0,0,0,.24);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: Roboto,"Helvetica Neue",sans-serif;
  font-size: 14px; font-weight: 400; line-height: 20px; letter-spacing: .2px;
  color: var(--mat-sys-on-surface);
  background: var(--mat-sys-background);
  transition: background var(--transition-std), color var(--transition-std);
}
.mobile-unsupported-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.mobile-unsupported {
  max-width: 460px;
  text-align: center;
}
.mobile-unsupported p {
  font-family: "Google Sans",sans-serif;
  font-size: 24px;
  line-height: 1.3;
  color: var(--mat-sys-on-surface);
}

/* ============================================================
   Typography
   ============================================================ */
h1,.mat-headline { font-family: "Google Sans",sans-serif; font-size: 24px; font-weight: 400; }
h2,.mat-title { font-family: Roboto,sans-serif; font-size: 16px; font-weight: 500; }
h3,.mat-subheading { font-family: "Google Sans",sans-serif; font-size: 16px; font-weight: 500; }
.mat-caption { font-size: 12px; color: var(--mat-sys-on-surface-variant); }

/* ============================================================
   Toolbar
   ============================================================ */
.mat-toolbar {
  height: 56px; display: flex; align-items: center; padding: 0 16px;
  background: var(--mat-toolbar-bg); color: var(--mat-toolbar-text);
  border-bottom: 1px solid var(--mat-toolbar-border);
  box-shadow: var(--elevation-1); position: sticky; top: 0; z-index: 100;
  transition: background var(--transition-std);
}
.toolbar-title { font-family: "Google Sans",sans-serif; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.toolbar-title .f9-logo { color: var(--f9-green-light); font-weight: 700; font-size: 20px; }
.toolbar-spacer { flex: 1; }
.toolbar-actions { display: flex; align-items: center; gap: 4px; }

/* Icon Button */
.mat-icon-button {
  width: 40px; height: 40px; padding: 8px; border: none; border-radius: 50%;
  background: transparent; color: var(--mat-sys-on-surface-variant);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--transition-fast);
}
.mat-icon-button:hover { background: rgba(0,0,0,.04); }
html.dark-theme .mat-icon-button:hover { background: rgba(255,255,255,.08); }
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined'; font-weight: normal; font-style: normal;
  font-size: 24px; line-height: 1; display: inline-block; direction: ltr;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Container & Cards
   ============================================================ */
.main-container { max-width: 1400px; margin: 0 auto; padding: 16px; }
.mat-card {
  background: var(--mat-card-bg); border-radius: 8px;
  box-shadow: var(--elevation-1); transition: background var(--transition-std);
  overflow: hidden;
}
.mat-card-content { padding: 16px; }

/* ============================================================
   Search Form
   ============================================================ */
.search-card { margin-bottom: 16px; }
.search-form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label {
  font-size: 12px; font-weight: 500; color: var(--mat-input-label);
  letter-spacing: .3px; text-transform: uppercase;
}
.form-group input, .form-group select {
  height: 40px; padding: 0 12px; border: 1px solid var(--mat-input-border);
  border-radius: 4px; background: var(--mat-input-bg); color: var(--mat-input-text);
  font-family: Roboto,sans-serif; font-size: 14px;
  transition: border-color var(--transition-fast); outline: none;
}
.form-group input::placeholder { color: var(--mat-input-placeholder); }
.form-group input:focus, .form-group select:focus {
  border-color: var(--mat-input-border-focus); border-width: 2px; padding: 0 11px;
}
.form-group .input-helper { font-size: 11px; color: var(--mat-sys-on-surface-variant); margin-top: 2px; }
.checkbox-group { display: flex; align-items: center; gap: 8px; height: 40px; }
.checkbox-group input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--mat-primary); cursor: pointer; }
.checkbox-group label { font-size: 14px; text-transform: none; color: var(--mat-sys-on-surface); cursor: pointer; }
.checkbox-inline-row { display: flex; align-items: center; gap: 16px; white-space: nowrap; height: 40px; }
.checkbox-inline-row .checkbox-group { height: 40px; }

/* ============================================================
   Buttons
   ============================================================ */
.mat-flat-button {
  height: 36px; padding: 0 24px; border: none; border-radius: 4px;
  background: var(--mat-button-bg); color: var(--mat-button-text);
  font-family: "Google Sans",sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}
.mat-flat-button:hover { box-shadow: var(--elevation-2); filter: brightness(1.08); }
.mat-flat-button:disabled { background: var(--mat-button-disabled-bg); color: var(--mat-button-disabled-text); cursor: not-allowed; }
.mat-flat-button.mat-f9 { background: var(--f9-green); color: #fff; }
.mat-stroked-button {
  height: 36px; padding: 0 16px; border: 1px solid var(--mat-sys-outline); border-radius: 4px;
  background: transparent; color: var(--mat-primary);
  font-family: "Google Sans",sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: background var(--transition-fast);
}
.mat-stroked-button:hover { background: var(--mat-primary-light); }
.search-actions { display: flex; gap: 12px; align-items: center; padding-top: 4px; }
.advanced-toggle {
  display: inline-flex; align-items: center; gap: 4px; user-select: none; font-weight: 500;
  font-size: 13px; color: var(--mat-sys-on-surface-variant); cursor: pointer;
  padding: 6px 12px; border-radius: 4px; transition: background var(--transition-fast), color var(--transition-fast);
  margin-left: -12px; /* Pull left to align text with inputs */
}
.advanced-toggle:hover { background: var(--mat-card-hover); color: var(--mat-sys-on-surface); text-decoration: none; }
.advanced-section { display: none; }
.advanced-section.open { display: block; }

/* ============================================================
   Tabs
   ============================================================ */
.mat-tab-group { border-bottom: 1px solid var(--mat-sys-outline); display: flex; }
.mat-tab-label {
  height: 44px; padding: 0 16px; border: none; background: transparent;
  color: var(--mat-sys-on-surface-variant); font-family: "Google Sans",sans-serif;
  font-size: 14px; font-weight: 500; cursor: pointer; position: relative;
  display: inline-flex; align-items: center; gap: 6px; transition: color var(--transition-fast);
}
.mat-tab-label:hover { color: var(--mat-sys-on-surface); background: var(--mat-card-hover); }
.mat-tab-label.active { color: var(--mat-primary); }
.mat-tab-label.active::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 2px; background: var(--mat-primary);
}

/* ============================================================
   Results Header
   ============================================================ */
.results-header {
  display: flex; align-items: center; padding: 12px 16px; gap: 12px;
  border-bottom: 1px solid var(--mat-sys-outline); flex-wrap: wrap;
}
.results-count { font-family: "Google Sans",sans-serif; font-size: 16px; font-weight: 500; }
.results-time { font-size: 13px; color: var(--mat-sys-on-surface-variant); }
.search-status-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid var(--mat-sys-outline);
  color: var(--mat-sys-on-surface);
  background: var(--mat-sys-surface-variant);
}
.search-status-chip.status-ok {
  color: var(--status-available);
  border-color: rgba(27, 135, 63, 0.35);
  background: rgba(27, 135, 63, 0.12);
}
.search-status-chip.status-partial {
  color: var(--status-limited);
  border-color: rgba(232, 113, 10, 0.35);
  background: rgba(232, 113, 10, 0.12);
}
.search-status-chip.status-timeout {
  color: var(--status-unavail);
  border-color: rgba(217, 48, 37, 0.35);
  background: rgba(217, 48, 37, 0.12);
}
.sort-controls { margin-left: auto; }

/* ============================================================
   Results Table (ITA Matrix Style)
   ============================================================ */
.table-scroll { overflow-x: auto; max-width: 100%; padding: 8px 150px 8px 150px; }
.results-table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
.results-table thead { background: var(--mat-table-header-bg); }
.results-table th {
  padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 500;
  color: var(--mat-sys-on-surface-variant); border-bottom: 2px solid var(--mat-table-border);
  cursor: pointer; user-select: none; white-space: nowrap; transition: color var(--transition-fast);
  text-transform: uppercase; letter-spacing: .3px;
}
.results-table th:hover { color: var(--mat-sys-on-surface); }
.results-table th .sort-arrow { font-size: 12px; margin-left: 4px; opacity: .4; }
.results-table th.sorted .sort-arrow { opacity: 1; color: var(--mat-primary); }
.results-table td { padding: 10px 16px; border-bottom: 1px solid var(--mat-table-border); vertical-align: middle; }
.results-table .result-row { cursor: pointer; transition: background var(--transition-fast); }
.results-table .result-row:hover { background: var(--mat-table-row-hover); }
.results-table .result-row.expanded { background: var(--mat-primary-light); }
.results-table .truncation-notice {
  text-align: center;
  padding: 12px;
  background: var(--mat-card-bg);
  border-bottom: 2px solid var(--mat-table-border);
  color: var(--mat-sys-on-surface-variant);
  font-size: 13px;
}
.results-table .truncation-notice .material-symbols-outlined {
  vertical-align: middle;
  font-size: 16px;
  margin-right: 4px;
}

/* Column widths */
.results-table th:nth-child(1), .results-table td:nth-child(1) { width: 100px; }  /* Price */
.results-table th:nth-child(2), .results-table td:nth-child(2) { width: 100px; }  /* Depart */
.results-table th:nth-child(3), .results-table td:nth-child(3) { width: 100px; }  /* Arrive */
.results-table th:nth-child(4), .results-table td:nth-child(4) { width: 90px; text-align: center; } /* Duration */
.results-table th:nth-child(5), .results-table td:nth-child(5) { width: auto; line-height: 1.4; word-break: break-all; } /* Route */
.results-table th:nth-child(6), .results-table td:nth-child(6) { width: 40px; text-align: center; padding: 0; } /* Jump */
.results-table th:nth-child(7), .results-table td:nth-child(7) { width: 80px; text-align: center; } /* Stops */

/* Price button (ITA Matrix style) */
.price-btn {
  display: inline-block; padding: 4px 12px; border-radius: 4px;
  font-family: "Roboto Mono",monospace; font-size: 13px; font-weight: 600;
  white-space: nowrap; text-align: center; min-width: 72px;
}
.price-btn.best { background: var(--mat-accent); color: #fff; }
.price-btn.normal { background: var(--mat-primary); color: #fff; }

/* Time cells */
.col-depart, .col-arrive { white-space: nowrap; }
.time-main { font-weight: 600; font-size: 15px; font-family: "Roboto Mono",monospace; display: block; line-height: 1.3; }
.time-date { font-size: 11px; color: var(--mat-sys-on-surface-variant); display: block; }
.date-suffix { font-size: 11px; color: var(--status-limited); font-weight: 600; }

.jump-tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--mat-sys-on-surface-variant);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.jump-tb-btn:hover {
  background: var(--mat-card-hover); /* Assuming mat-sys-surface-container-highest is similar to mat-card-hover in dark theme */
  color: var(--mat-primary);
}
.jump-tb-btn .mat-icon { font-size: 18px; }

/* Route cell */
.col-route {
  font-family: "Roboto Mono",monospace; font-size: 12px; letter-spacing: -.2px;
  word-break: break-all;
}
.col-route .inherent { color: var(--mat-sys-on-surface-variant); }
.col-duration { white-space: nowrap; font-family: "Roboto Mono",monospace; font-size: 13px; }
.col-stops { white-space: nowrap; text-align: center; }
.col-price { white-space: nowrap; }

/* Detail row (expanded) */
.detail-row td { padding: 0 !important; border-bottom: 2px solid var(--mat-primary); }
.detail-panel {
  padding: 12px 16px; background: var(--mat-sys-surface-variant);
  display: flex; flex-direction: column; gap: 4px;
  --detail-row-pad-x: 12px;
  --detail-flight-col: 170px;
  --detail-time-col: 150px;
  --detail-airport-col: 140px;
  --detail-segment-text-indent: 16px;
}

/* Per-leg row inside detail */
.leg-row {
  display: grid;
  grid-template-columns: var(--detail-flight-col) var(--detail-time-col) var(--detail-airport-col) max-content max-content minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  row-gap: 6px;
  padding: 6px var(--detail-row-pad-x);
  background: var(--mat-card-bg); border-radius: 4px; font-size: 13px;
}
.leg-flight { font-weight: 500; color: var(--f9-green-light); min-width: 0; font-family: "Roboto Mono",monospace; font-size: 12px; white-space: nowrap; }
.leg-times { color: var(--mat-sys-on-surface); min-width: 0; font-family: "Roboto Mono",monospace; font-variant-numeric: tabular-nums; }
.leg-airports { color: var(--mat-sys-on-surface-variant); min-width: 0; font-family: "Roboto Mono",monospace; letter-spacing: .2px; }
.leg-price { font-weight: 500; color: var(--mat-accent); min-width: 60px; white-space: nowrap; }
.leg-avail { justify-self: start; cursor: help; }
.leg-book-link {
  color: var(--mat-primary); text-decoration: none; font-size: 12px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 3px; border: 1px solid var(--mat-primary);
  transition: background var(--transition-fast); justify-self: end;
}
.leg-book-link:hover { background: var(--mat-primary-light); text-decoration: none; }
.leg-layover-row {
  display: flex; align-items: center; gap: 6px; padding: 3px 12px;
  font-size: 12px; color: var(--status-limited); font-weight: 500;
}
.avail-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; border-radius: 10px; font-size: 11px;
  font-weight: 500; padding: 0 5px;
}
.avail-badge.high { background: rgba(27,135,63,.12); color: var(--status-available); }
.avail-badge.medium { background: rgba(232,113,10,.12); color: var(--status-limited); }
.avail-badge.low { background: rgba(217,48,37,.12); color: var(--status-unavail); }

.segment-row {
  display: grid;
  grid-template-columns: var(--detail-flight-col) var(--detail-time-col) var(--detail-airport-col) minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  row-gap: 6px;
  padding: 4px var(--detail-row-pad-x);
  background: var(--mat-sys-surface-variant); font-size: 12px;
  color: var(--mat-sys-on-surface-variant); position: relative;
}
.segment-layover-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  padding: 4px var(--detail-row-pad-x) 4px calc(var(--detail-row-pad-x) + var(--detail-segment-text-indent));
  gap: 6px;
  color: var(--status-limited);
  font-weight: 500;
}
.segment-layover-row .material-symbols-outlined {
  font-size: 14px;
  line-height: 1;
}
.segment-row::before {
  content: ''; position: absolute; left: calc(var(--detail-row-pad-x) + 6px); top: -6px; bottom: 0;
  width: 2px; background: var(--mat-sys-outline-variant);
}
.segment-flight {
  font-family: "Roboto Mono",monospace;
  font-size: 11px;
  min-width: 0;
  color: var(--mat-sys-on-surface-variant);
  white-space: nowrap;
  padding-left: var(--detail-segment-text-indent);
}
.segment-times { min-width: 0; font-family: "Roboto Mono",monospace; font-variant-numeric: tabular-nums; }
.segment-airports { min-width: 0; font-family: "Roboto Mono",monospace; letter-spacing: .2px; }

.detail-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
  align-items: baseline;
  white-space: nowrap;
}
.detail-pair .pair-left { text-align: right; }
.detail-pair .pair-symbol { text-align: center; color: var(--mat-sys-on-surface-variant); }
.detail-pair .pair-right { text-align: left; }

.truncation-notice { text-align: center; padding: 16px; font-size: 13px; color: var(--mat-sys-on-surface-variant); }

/* ============================================================
   Timebar (ITA Matrix Style)
   ============================================================ */
.timebar-container { overflow-x: auto; overflow-y: hidden; position: relative; display: flex; flex-direction: column; min-width: 100%; padding-bottom: 12px; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; }

.tb-scroll-wrapper {
  min-width: 1040px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.tb-header-wrap {
  display: flex;
  flex-direction: column;
  background: var(--mat-card-bg);
  border-bottom: 1px solid var(--mat-sys-outline);
  padding: 12px 0 8px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.timebar-tickmarks {
  display: flex;
  margin-bottom: 4px;
}
.timebar-tickmarks > .tick-left {
  width: 240px;
  min-width: 240px;
  padding-right: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  border-right: 1px solid var(--mat-sys-outline);
}
.timebar-tickmarks > .tick-right {
  flex: 1;
  position: relative;
  min-width: 800px;
}

.timebar-label.timezone {
  font-size: 11px;
  color: var(--mat-sys-on-surface-variant);
  line-height: 1;
}

.tb-date-label {
  position: absolute; font-size: 11px; font-weight: 500;
  color: var(--mat-sys-on-surface); bottom: 0; transform: translateX(-50%);
  white-space: nowrap;
}

.tb-hour-label {
  position: absolute; font-size: 11px; color: var(--tb-time-text);
  transform: translateX(-50%); white-space: nowrap; font-weight: 500; bottom: 0;
}

.tb-gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--tb-grid-line); z-index: 0; pointer-events: none;}
.tb-gridline.midnight { width: 2px; background: var(--tb-grid-midnight); }

.tb-background {
  position: absolute;
  top: 0; bottom: 0; left: 240px; right: 0;
  pointer-events: none;
  z-index: 0;
  min-width: 800px;
}

.tb-row {
  display: flex; align-items: center; min-height: 48px;
  border-bottom: 1px solid var(--mat-sys-outline-variant);
  transition: background var(--transition-fast);
  position: relative;
  z-index: 1;
  cursor: pointer;
}
.tb-row:hover { background: var(--mat-table-row-hover); }

.tb-labels-area {
  display: flex;
  width: 240px; min-width: 240px;
  background: inherit;
  border-right: 1px solid var(--mat-sys-outline);
  z-index: 2;
  align-items: center;
  padding: 4px 0 4px 16px;
}

.tb-price-col {
  width: 90px; flex-shrink: 0;
  font-family: inherit;
  display: flex;
  align-items: center;
}

.tb-route-col {
  flex: 1;
  font-size: 12px; font-weight: 500; color: var(--mat-sys-on-surface-variant);
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 0 12px;
}

.tb-route-label { font-size: 11px; color: var(--mat-sys-on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }

.tb-timeline-area {
  flex: 1;
  position: relative;
  min-width: 800px;
  height: 48px;
}

.tb-segment-area { position: relative; height: 100%; width: 100%; display: flex; align-items: center; }

.tb-segment {
  position: absolute; height: 18px; border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #fff;
  cursor: pointer; z-index: 2;
  transition: filter var(--transition-fast);
}
.tb-segment-text {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  white-space: nowrap; z-index: 4; pointer-events: none;
}
.tb-segment.airline-F9 { color: #fff; }

.tb-endpoint-label {
  position: absolute; top: 3px; height: 12px; line-height: 12px;
  font-size: 10px; font-weight: 600; color: var(--mat-sys-on-surface);
  white-space: nowrap; z-index: 1; pointer-events: none;
}
.tb-endpoint-label.start { transform: translateX(calc(-100% - 4px)); }
.tb-endpoint-label.end { transform: translateX(4px); }
.tb-segment:hover { filter: brightness(1.15); z-index: 3; }

.tb-layover {
  position: absolute; height: 16px; border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #666;
  background: #e0e0e0; pointer-events: auto; z-index: 1;
  cursor: help;
  transition: filter var(--transition-fast);
}
.tb-layover:hover { filter: brightness(0.96); }
.tb-layover-text {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  white-space: nowrap; z-index: 4; pointer-events: none;
}

/* Airline colors */
.airline-F9 { background: var(--f9-green) !important; }
.airline-B6 { background: var(--airline-b6); }
.airline-NK { background: var(--airline-nk); }
.airline-WN { background: var(--airline-wn); }
.airline-DL { background: var(--airline-dl); }
.airline-AS { background: #5B438E; }
.airline-UA { background: #4E963D; }
.airline-AA { background: #c0392b; }
.airline-HA { background: #C5993A; }
.airline-WS { background: #00a1e4; }
.airline-NK { background: #f7d733; color: #000; }
.airline-AC { background: #D71920; }
.airline-default { background: #757575; }

/* Jump Highlight */
@keyframes jump-highlight {
  0% { background: var(--mat-accent-light); }
  100% { background: transparent; }
}
.row-highlight {
  animation: jump-highlight 2s ease-out;
}

/* ============================================================
   Loading / Empty / Tooltip
   ============================================================ */
.loading-container { display: flex; flex-direction: column; align-items: center; padding: 48px 16px; gap: 16px; }
.mat-progress-spinner {
  width: 40px; height: 40px; border: 3px solid var(--mat-sys-outline);
  border-top-color: var(--mat-primary); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 48px 16px; color: var(--mat-sys-on-surface-variant); }
.empty-state .material-symbols-outlined { font-size: 48px; margin-bottom: 12px; opacity: .4; }

.tb-tooltip {
  position: fixed; z-index: 1000; background: rgba(50,50,50,.94); color: #fff;
  padding: 8px 12px; border-radius: 4px; font-size: 12px; line-height: 1.6;
  pointer-events: none; max-width: 320px; box-shadow: var(--elevation-4); display: none;
}
.tb-tooltip.visible { display: block; }

/* ============================================================
   API Docs
   ============================================================ */
.api-docs .endpoint { margin-bottom: 12px; padding: 12px; border-radius: 4px; background: var(--mat-sys-surface-variant); }
.endpoint-header { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.endpoint-method { font-family: "Google Sans",sans-serif; font-weight: 700; padding: 2px 8px; border-radius: 3px; font-size: 12px; }
.endpoint-method.get { background: rgba(27,135,63,.12); color: var(--status-available); }
.endpoint-path { font-family: "Roboto Mono",monospace; font-size: 14px; font-weight: 500; }
.endpoint-description { color: var(--mat-sys-on-surface-variant); margin-bottom: 8px; line-height: 1.5; }
.api-constraints-alert {
  margin-top: 20px;
  padding: 16px;
  background: var(--mat-card-bg);
  border-left: 4px solid var(--mat-primary);
  border-radius: 4px;
  font-size: 13px;
}
.api-constraints-title {
  margin: 0 0 8px 0;
  color: var(--mat-sys-on-surface);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.api-constraints-title .material-symbols-outlined {
  font-size: 18px;
  color: var(--mat-primary);
}
.api-constraints-text {
  margin: 0 0 12px 0;
  color: var(--mat-sys-on-surface-variant);
  line-height: 1.5;
}
.api-constraints-list {
  margin: 0;
  padding-left: 20px;
  color: var(--mat-sys-on-surface-variant);
  line-height: 1.6;
}
.param-table { width: 100%; margin-top: 8px; font-size: 13px; border-collapse: collapse; }
.param-table th { text-align: left; font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--mat-sys-outline); color: var(--mat-sys-on-surface-variant); font-size: 11px; text-transform: uppercase; }
.param-table td { padding: 6px 8px; border-bottom: 1px solid var(--mat-sys-outline-variant); }
.param-name { font-family: "Roboto Mono",monospace; font-weight: 500; color: var(--mat-primary); }
.param-optional { font-size: 11px; color: var(--mat-sys-on-surface-variant); }
.param-required { font-size: 11px; color: var(--status-available); }
.api-attribution {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--mat-sys-outline);
  border-radius: 4px;
  background: var(--mat-card-bg);
  color: var(--mat-sys-on-surface-variant);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
}
.api-attribution .material-symbols-outlined {
  font-size: 16px;
  color: var(--mat-primary);
  margin-top: 1px;
}
.api-attribution p { margin: 0; }
.api-attribution a { color: var(--mat-primary); text-decoration: none; }
.api-attribution a:hover { text-decoration: underline; }

/* Collapsible */
.collapsible-header { display: flex; align-items: center; padding: 12px 16px; cursor: pointer; user-select: none; gap: 8px; }
.collapsible-header:hover { background: var(--mat-card-hover); }
.collapsible-header .expand-icon { transition: transform var(--transition-fast); font-size: 20px; color: var(--mat-sys-on-surface-variant); }
.collapsible-header.expanded .expand-icon { transform: rotate(180deg); }
.collapsible-body { max-height: 0; overflow: hidden; transition: max-height var(--transition-std); }
.collapsible-body.open { max-height: 5000px; }

/* View panels */
.view-panel { display: none; }
.view-panel.active { display: block; }

/* ============================================================
   Autocomplete Panel
   ============================================================ */
.f9-autocomplete-panel {
  position: absolute;
  z-index: 1000;
  background: var(--mat-sys-surface);
  border-radius: 4px;
  box-shadow: var(--elevation-4);
  max-height: 256px;
  overflow-y: auto;
  min-width: 250px;
  display: none;
  font-family: Roboto, sans-serif;
  padding: 8px 0;
  animation: mat-autocomplete-in 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes mat-autocomplete-in {
  from { opacity: 0; transform: scaleY(0.8); transform-origin: top; }
  to { opacity: 1; transform: scaleY(1); transform-origin: top; }
}

.f9-autocomplete-option {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 48px;
  cursor: pointer;
  color: var(--mat-sys-on-surface);
  transition: background var(--transition-fast);
  font-family: Roboto, sans-serif;
  font-size: 16px;
}

.f9-autocomplete-option:hover,
.f9-autocomplete-option.active {
  background: var(--mat-sys-surface-variant);
}

.f9-autocomplete-option .mat-icon {
  margin-right: 16px;
  color: var(--mat-sys-on-surface-variant);
  font-size: 24px;
}

.f9-autocomplete-option-text {
  font-size: 16px;
  letter-spacing: 0.15px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .form-row,.form-row-3,.form-row-4 { grid-template-columns: 1fr; }
  .mat-toolbar { height: 48px; }
  .results-table th,.results-table td { padding: 8px 6px; font-size: 12px; }
  .results-table th { top: 48px; }
  .api-docs .endpoint { padding: 10px; }
  .api-attribution { flex-direction: column; gap: 6px; }
  .param-table th,.param-table td { padding: 6px; }
  .detail-panel {
    --detail-flight-col: 132px;
    --detail-time-col: 132px;
    --detail-airport-col: 120px;
  }
  .leg-row,
  .segment-row {
    display: flex;
    flex-wrap: wrap;
  }
  .leg-book-link {
    margin-left: auto;
  }
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); border-radius: 4px; }
html.dark-theme ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.4); }
html.dark-theme ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); }

/* ============================================================
   Status Text Link
   ============================================================ */
.data-status-text {
    display: inline-flex;
    align-items: center;
    color: var(--mat-sys-on-surface-variant);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
    padding: 6px 8px;
    border-radius: 4px;
    user-select: none;
}
.data-status-text:hover {
    color: var(--mat-primary);
    background: var(--mat-card-hover);
}
.data-status-text.error {
    color: var(--status-unavail);
}
.data-status-text.error:hover {
    background: rgba(217, 48, 37, 0.08);
}
