/* ==============================================================
   FlightAware Labs — shared shell styles
   --------------------------------------------------------------
   The topbar, user menu, page-head, form card, and footer used
   by both /rebook and /inspector. Page-specific bits (the date
   chips on /rebook, the Inspector tile overrides at the bottom
   of this file, etc.) stay in their own page's <style> block.
   --------------------------------------------------------------
   Pages opt in by:
     1) <link rel="stylesheet" href="/labs-shell.css">  (after styles.css)
     2) <body data-labs-app="rebook">  (or "inspector")
   ============================================================== */

:root { --rb-page-max: 720px; }

/* The operator app's styles.css pins html, body to overflow:hidden +
   height:100vh for its flex-pinned multi-tab viewport. Labs pages are
   normal scrolling documents — override on both elements (operator app's
   rule applies to both, so we have to). */
body[data-labs-app] {
  /* nothing here — selector exists so the html,body override below has
     a hook to be defensive about, but no body property changes needed */
}
html:has(body[data-labs-app]),
body[data-labs-app] {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  height: auto !important;
  min-height: 100vh;
}
/* Tab-panel containers used by the rebook + inspector logic need to be
   plain blocks here (the operator app's flex-pinned wrapper would clip). */
body[data-labs-app] #tab-rebook.tab-panel,
body[data-labs-app] #tab-singleflight.tab-panel {
  display: block !important;
  height: auto !important;
  overflow: visible !important;
}

/* ───────────────────────────────────────────────────────────────
   TOP BAR — brand on the left, user menu on the right
   ─────────────────────────────────────────────────────────────── */
.rb-topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(180deg, var(--fa-navy) 0%, var(--fa-navy-deep) 100%);
  border-bottom: 1px solid rgba(0, 160, 226, 0.18);
  backdrop-filter: blur(8px);
}
/* Inner flex wrapper rendered by labs-header.js: brand · title · user menu.
   Works whether .rb-topbar is flex (fleetmap) or block (rebook/inspector
   legacy inline) because the inner is itself a full-width flex row. */
.rb-topbar-inner {
  display: flex; align-items: center; gap: 16px;
  width: 100%; box-sizing: border-box;
}
.rb-topbar-title {
  flex: 1; min-width: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px; letter-spacing: 0.04em;
  color: #8fb0d0;
}
/* Official FlightAware logo (forced white on the dark navy bar), with an
   inline ✈ + wordmark fallback if the CDN image is blocked. */
.fa-logo { height: 26px; width: auto; display: block; filter: brightness(0) invert(1); }
.fa-fallback { display: none; align-items: center; gap: 8px; }
.fa-fallback .rb-brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--fa-blue); display: inline-flex; align-items: center; justify-content: center; color: #001428; }
.fa-fallback .rb-wordmark { font-family: var(--font-body); font-size: 16px; font-weight: 700; color: var(--text-primary); }

.rb-brand { display: flex; align-items: center; gap: 10px; }
.rb-brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--fa-blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #001428;
}
.rb-wordmark {
  font-family: var(--font-body);
  font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--text-primary);
}
.rb-labs-pill {
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 800; letter-spacing: 0.14em;
  padding: 3px 7px; border-radius: 4px;
  background: rgba(0, 160, 226, 0.15);
  color: var(--fa-blue);
  border: 1px solid rgba(0, 160, 226, 0.4);
  text-transform: uppercase;
}

/* ───────────────────────────────────────────────────────────────
   USER MENU — avatar + dropdown
   ─────────────────────────────────────────────────────────────── */
.rb-user-menu { position: relative; }
.rb-avatar-btn {
  display: flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid transparent;
  padding: 4px 8px 4px 4px; border-radius: 999px;
  cursor: pointer; transition: background-color 0.15s, border-color 0.15s;
  color: var(--text-secondary);
}
.rb-avatar-btn:hover { background: rgba(0,160,226,0.08); border-color: rgba(0,160,226,0.25); color: var(--text-primary); }
.rb-avatar-btn[aria-expanded="true"] { background: rgba(0,160,226,0.12); border-color: rgba(0,160,226,0.45); color: var(--text-primary); }
.rb-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--fa-blue) 0%, #0085bc 100%);
  color: #001a36;
  font-family: var(--font-body); font-size: 12px; font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}
.rb-caret { opacity: 0.6; }

.rb-user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,160,226,0.08);
  padding: 6px;
  z-index: 200;
  display: none;
  animation: rb-dropdown-in 0.12s ease-out;
  /* The Labs app list outgrew the viewport (18+ apps) — cap the menu to the
     visible window and scroll inside it so the bottom entries stay reachable. */
  max-height: calc(100vh - 72px);
  max-height: calc(100dvh - 72px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.rb-user-dropdown.rb-open { display: block; }
@keyframes rb-dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rb-user-greeting {
  padding: 8px 12px 6px;
  font-size: 11px; color: var(--text-muted);
  letter-spacing: 0.02em;
}
.rb-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.rb-dropdown-section-label {
  padding: 8px 12px 4px;
  font-size: 9px; font-weight: 800; letter-spacing: 0.12em;
  color: var(--text-muted); text-transform: uppercase;
}
.rb-dropdown-item {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent; border: 0; border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-body); font-size: 13px;
  text-align: left; text-decoration: none;
  cursor: pointer; transition: background-color 0.1s;
  box-sizing: border-box;
}
.rb-dropdown-item:hover { background: rgba(0,160,226,0.12); }
.rb-dropdown-item.rb-current { background: rgba(0,160,226,0.06); cursor: default; }
.rb-dropdown-item.rb-current:hover { background: rgba(0,160,226,0.06); }
.rb-dropdown-item svg { flex-shrink: 0; margin-top: 1px; color: var(--text-secondary); }
.rb-dropdown-item:hover svg { color: var(--fa-blue); }
.rb-dropdown-item.rb-current svg { color: var(--fa-blue); }
.rb-dropdown-title { display: block; font-weight: 600; }
.rb-dropdown-sub { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ───────────────────────────────────────────────────────────────
   MAIN CANVAS + PAGE HEAD
   ─────────────────────────────────────────────────────────────── */
.rb-canvas { max-width: var(--rb-page-max); margin: 0 auto; padding: 0 20px 80px; }

.rb-pagehead { padding: 32px 0 20px; text-align: left; }
.rb-pagetitle {
  font-family: var(--font-body);
  font-size: 28px; font-weight: 600;
  line-height: 1.15; letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.rb-pagesub {
  font-size: 14px; line-height: 1.5;
  color: var(--text-secondary);
  max-width: 520px;
}

/* ───────────────────────────────────────────────────────────────
   SEARCH FORM CARD
   ─────────────────────────────────────────────────────────────── */
.rb-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
.rb-form-row { display: flex; flex-direction: column; gap: 14px; }
.rb-form-row.rb-form-row-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rb-field { display: flex; flex-direction: column; gap: 6px; }
.rb-field label {
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
}
.rb-field label .rb-opt {
  font-weight: 400; color: var(--text-muted);
  margin-left: 6px;
}
.rb-field input {
  width: 100%; min-height: 48px;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-mono); font-size: 16px; /* 16px = no iOS auto-zoom */
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.rb-field input:focus { outline: none; border-color: var(--fa-blue); box-shadow: 0 0 0 3px rgba(0, 160, 226, 0.18); }
.rb-field input::placeholder { color: var(--text-muted); opacity: 0.5; }

/* Collapsible advanced disclosure (date range, alt airports, etc.) */
.rb-advanced { margin-top: 14px; }
.rb-advanced summary {
  cursor: pointer; padding: 8px 0;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  list-style: none;
}
.rb-advanced summary::-webkit-details-marker { display: none; }
.rb-advanced summary::before { content: '+ '; color: var(--fa-blue); font-weight: 800; }
.rb-advanced[open] summary::before { content: '− '; }
.rb-advanced .rb-form-row { padding-top: 10px; }

/* ───────────────────────────────────────────────────────────────
   CTA + ABORT BUTTONS
   ─────────────────────────────────────────────────────────────── */
.rb-cta {
  width: 100%; min-height: 56px;
  margin-top: 16px;
  background: var(--fa-blue); color: #001a36;
  border: none; border-radius: 10px;
  font-family: var(--font-body); font-size: 16px; font-weight: 800; letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
.rb-cta:hover:not(:disabled) { filter: brightness(1.1); }
.rb-cta:active:not(:disabled) { transform: scale(0.99); }
.rb-cta:disabled {
  background: var(--bg-card-hover); color: var(--text-muted);
  cursor: not-allowed;
}
.rb-abort {
  width: 100%; min-height: 48px; margin-top: 10px;
  background: transparent; color: var(--danger);
  border: 1px solid var(--danger); border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}

/* ───────────────────────────────────────────────────────────────
   STATUS LINE + EXPORT BAR + RESULTS BODY + FOOTER
   ─────────────────────────────────────────────────────────────── */
.rb-status-line {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 4px 0;
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-muted);
}
.rb-status-line .rb-clock { color: var(--fa-blue); font-weight: 600; }

.rb-export-bar {
  display: flex; gap: 8px; padding: 16px 0 0;
  justify-content: flex-end;
}
.rb-export-bar button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  font-family: var(--font-mono);
  min-height: 36px;
  transition: all 0.15s;
}
.rb-export-bar button:hover:not(:disabled) {
  border-color: var(--fa-blue); color: var(--fa-blue);
}

.rb-results { padding-top: 24px; }
.rb-empty {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted); font-size: 14px;
}
.rb-empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }

.rb-footer {
  max-width: var(--rb-page-max); margin: 32px auto 0; padding: 16px 20px 32px;
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.rb-footer .rb-footer-dot { opacity: 0.4; }

/* ───────────────────────────────────────────────────────────────
   RESPONSIVE
   ─────────────────────────────────────────────────────────────── */
@media (min-width: 720px) {
  .rb-pagehead { padding: 48px 0 28px; }
  .rb-pagetitle { font-size: 32px; }
  .rb-pagesub { font-size: 15px; }
  .rb-form-row { flex-direction: row; }
  .rb-form-row.rb-form-row-stack { flex-direction: column; }
  .rb-field { flex: 1; }
}
@media (max-width: 480px) {
  .rb-canvas { padding: 0 16px 80px; }
  .rb-pagehead { padding: 24px 0 16px; }
  .rb-pagetitle { font-size: 24px; }
  .rb-pagesub { font-size: 13px; }
  .rb-form-card { padding: 16px; border-radius: 12px; }
}
@media (max-width: 400px) {
  .rb-wordmark { font-size: 14px; }
  .rb-labs-pill { padding: 2px 6px; font-size: 8px; }
  .rb-user-dropdown { min-width: 220px; }
}

/* ===============================================================
   INSPECTOR — tile polish
   --------------------------------------------------------------
   13-tab-inspector.js renders flight tiles with operator-era inline
   density (210×140, 9–12px fonts). The standalone /inspector shell
   has more breathing room than the operator toolkit, so we bump
   sizes via scoped !important overrides without touching the JS.
   Operator app's Inspector tab (no data-labs-app body attribute)
   keeps its current look.
   =============================================================== */
body[data-labs-app="inspector"] .sf-tile {
  width: 264px !important;
  min-height: 168px !important;
  padding: 14px 14px 14px 18px !important;
  border-radius: 12px !important;
}
/* Date label at the top */
body[data-labs-app="inspector"] .sf-tile > div[style*="font-size:9px"][style*="letter-spacing:0.05em"] {
  font-size: 10px !important;
  margin-bottom: 6px !important;
}
/* Ident — the biggest line on each tile */
body[data-labs-app="inspector"] .sf-tile span[style*="font-size:15px"][style*="font-weight:800"] {
  font-size: 18px !important;
}
/* Route */
body[data-labs-app="inspector"] .sf-tile span[style*="font-size:12px"][style*="font-weight:700"] {
  font-size: 14px !important;
}
/* Ground-time connector between tiles — bump for legibility */
body[data-labs-app="inspector"] .sf-tile + div + div div[style*="font-size:9px"][style*="white-space:nowrap"] {
  font-size: 10px !important;
}
/* Horizontal scrolling row of tiles — give it a touch more vertical air */
body[data-labs-app="inspector"] [style*="overflow-x:auto"] {
  padding-bottom: 8px;
}
