/* =============================================
   FareFort - Main Stylesheet
   Modern, accessible flight search UI
   ============================================= */

/* ---------------------------------------------
   CSS Custom Properties (Design Tokens)
   --------------------------------------------- */
:root {
  /* Colors - Dark Theme */
  --color-bg-primary: #0f172a;
  --color-bg-secondary: #1e293b;
  --color-bg-tertiary: rgba(30, 41, 59, 0.7);
  --color-bg-card: rgba(15, 23, 42, 0.6);
  --color-bg-overlay: rgba(0, 0, 0, 0.5);
  
  --color-text-primary: #e2e8f0;
  --color-text-secondary: #cbd5e1;
  --color-text-muted: #94a3b8;
  
  --color-accent: #3b82f6;
  --color-accent-hover: #60a5fa;
  --color-link: #93c5fd;
  --color-success: #22c55e;
  --color-border: rgba(148, 163, 184, 0.25);
  
  /* Typography */
  --font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  
  /* Layout */
  --max-width: 1100px;
  --header-height: 64px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ---------------------------------------------
   Reset & Base
   --------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------------------------------------------
   Typography
   --------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-4);
  line-height: 1.2;
  font-weight: 700;
}

h1 { font-size: clamp(1.75rem, 4vw, var(--font-size-4xl)); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

p {
  margin: 0 0 var(--space-4);
  color: var(--color-text-secondary);
}

a {
  color: var(--color-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

strong { color: var(--color-text-primary); }

/* ---------------------------------------------
   Layout Components
   --------------------------------------------- */
.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------
   Site Header
   --------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg-primary);
  border-bottom: 1px solid var(--color-border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  gap: var(--space-4);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--color-text-primary);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.site-logo:hover {
  opacity: 0.9;
  text-decoration: none;
  color: var(--color-text-primary);
}

.site-logo svg,
.site-logo img {
  width: 32px;
  height: 32px;
}

.site-logo .logo-text {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.site-nav a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
}

.site-nav a:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  text-decoration: none;
}

/* Legacy header support */
.sitehead {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 var(--space-4);
  padding: var(--space-3) 0;
  background: var(--color-bg-primary);
}

.brand {
  font-weight: 700;
  color: var(--color-text-primary);
  text-decoration: none;
}

.brand:hover {
  text-decoration: underline;
}

/* ---------------------------------------------
   Hero Section
   --------------------------------------------- */
.hero {
  padding: var(--space-8) 0 var(--space-6);
  text-align: center;
}

.hero h1 {
  margin-bottom: var(--space-3);
}

.hero p {
  max-width: 640px;
  margin: 0 auto var(--space-6);
  font-size: var(--font-size-lg);
}

/* ---------------------------------------------
   Main Content
   --------------------------------------------- */
main {
  padding: var(--space-6) 0;
}

/* ---------------------------------------------
   Embed / Iframe Container
   --------------------------------------------- */
.embed {
  position: relative;
  margin: var(--space-6) 0;
  border-radius: var(--border-radius);
  overflow: hidden;
  background: var(--color-bg-secondary);
}

.embed iframe {
  display: block;
  width: 100%;
  min-height: 700px;
  border: 0;
  border-radius: var(--border-radius);
  background: #0b1225;
}

.embed iframe#ff-search {
  min-height: 1400px;
}

/* Loading skeleton for iframe */
.embed::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(110deg, var(--color-bg-secondary) 8%, #334155 18%, var(--color-bg-secondary) 33%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
  border-radius: var(--border-radius);
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.embed.loaded::before {
  opacity: 0;
  pointer-events: none;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Loading spinner */
.embed::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border: 3px solid var(--color-bg-tertiary);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transition: opacity var(--transition-slow);
}

.embed.loaded::after {
  opacity: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile iframe adjustments */
@media (max-width: 640px) {
  .embed iframe,
  .embed iframe#ff-search {
    min-height: 520px;
    height: 85vh;
  }
}

@media (min-width: 641px) {
  .embed iframe#ff-search {
    min-height: 1400px;
  }
}

/* ---------------------------------------------
   Panel / Card Component
   --------------------------------------------- */
.panel {
  margin: var(--space-6) 0;
  padding: var(--space-6);
  border-radius: var(--border-radius);
  background: var(--color-bg-card);
  box-shadow: var(--shadow-lg);
}

.panel h2 {
  margin-bottom: var(--space-4);
}

.panel p {
  margin-bottom: var(--space-4);
}

.panel p:last-child {
  margin-bottom: 0;
}

/* ---------------------------------------------
   Routes Grid
   --------------------------------------------- */
.routes {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 481px) {
  .routes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 720px) {
  .routes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.routes a.route,
a.route {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--border-radius-sm);
  background: var(--color-bg-tertiary);
  color: var(--color-link);
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.routes a.route:hover,
a.route:hover {
  background: var(--color-bg-secondary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

/* Route icon (plane) */
.routes a.route::before {
  content: '✈';
  font-size: var(--font-size-sm);
  opacity: 0.7;
}

/* ---------------------------------------------
   Hub Grid (Browse by Origin)
   --------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

@media (min-width: 520px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 720px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 980px) {
  .grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.hub {
  display: block;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--border-radius-sm);
  background: var(--color-bg-tertiary);
  color: var(--color-link);
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.hub:hover {
  background: var(--color-bg-secondary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

/* ---------------------------------------------
   Links List
   --------------------------------------------- */
.links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.links li {
  margin-bottom: var(--space-2);
}

.links a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius-sm);
  background: var(--color-bg-tertiary);
  transition: all var(--transition-fast);
}

.links a:hover {
  background: var(--color-bg-secondary);
  text-decoration: none;
}

/* ---------------------------------------------
   Site Footer
   --------------------------------------------- */
.site-footer {
  margin-top: var(--space-12);
  padding: var(--space-8) 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-primary);
}

.site-footer .wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
}

@media (min-width: 720px) {
  .footer-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.footer-col h4 {
  margin: 0 0 var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-col a {
  display: block;
  padding: var(--space-2) 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.footer-col a:hover {
  color: var(--color-link);
}

.footer-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-align: center;
}

@media (min-width: 640px) {
  .footer-bottom {
    flex-direction: row;
    justify-content: space-between;
  }
}

/* Legacy footer support */
.sitefoot {
  margin-top: var(--space-10);
  padding: var(--space-6) 0;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.footgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

@media (min-width: 720px) {
  .footgrid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.footcol h4 {
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
}

.footcol p {
  margin: var(--space-2) 0;
}

.footcol a {
  color: var(--color-link);
}

/* ---------------------------------------------
   Consent Banner
   --------------------------------------------- */
#ff-consent-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  padding: var(--space-4) var(--space-6);
  background: rgba(15, 23, 42, 0.98);
  color: var(--color-text-primary);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  font-size: var(--font-size-sm);
}

#ff-consent-banner .consent-content {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

@media (min-width: 768px) {
  #ff-consent-banner .consent-content {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

#ff-consent-banner .consent-text {
  flex: 1;
  color: var(--color-text-secondary);
}

#ff-consent-banner .consent-text a {
  color: var(--color-link);
}

#ff-consent-banner .actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

#ff-consent-banner button {
  cursor: pointer;
  border: 0;
  border-radius: var(--border-radius-sm);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
}

#ff-consent-accept {
  background: var(--color-success);
  color: var(--color-bg-primary);
}

#ff-consent-accept:hover {
  filter: brightness(1.1);
}

#ff-consent-reject {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

#ff-consent-reject:hover {
  background: var(--color-bg-tertiary);
}

#ff-consent-manage {
  background: transparent;
  color: var(--color-link);
  text-decoration: underline;
}

/* Consent Modal */
#ff-consent-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  background: var(--color-bg-overlay);
  backdrop-filter: blur(4px);
}

#ff-consent-modal .card {
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  padding: var(--space-6);
  border-radius: var(--border-radius);
  max-width: 480px;
  width: 92%;
  box-shadow: var(--shadow-lg);
}

#ff-consent-modal h3 {
  margin: 0 0 var(--space-4);
}

#ff-consent-modal .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}

#ff-consent-modal label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

#ff-consent-save {
  width: 100%;
  margin-top: var(--space-4);
  padding: var(--space-3);
  background: var(--color-success);
  color: var(--color-bg-primary);
  border: 0;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

#ff-consent-save:hover {
  filter: brightness(1.1);
}

/* ---------------------------------------------
   Utility Classes
   --------------------------------------------- */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

/* ---------------------------------------------
   Print Styles
   --------------------------------------------- */
@media print {
  .site-header,
  .site-footer,
  #ff-consent-banner,
  #ff-consent-modal,
  .embed {
    display: none !important;
  }
}
