/* ============================================================
   Skybound — Base Design System
   Design tokens, resets, typography, shared components
   ============================================================ */

/* ── Google Fonts ────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Design Tokens ───────────────────────────────────────── */
:root {
  /* Colours */
  --bg:           #0f172a;
  --surface:      #1e293b;
  --surface-2:    #243047;
  --accent:       #3b82f6;
  --accent-dark:  #2563eb;
  --accent-glow:  rgba(59, 130, 246, 0.35);
  --cyan:         #0ea5e9;
  --text:         #f8fafc;
  --text-muted:   #94a3b8;
  --border:       rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --success:      #22c55e;

  /* Surface / overlay backgrounds (were hardcoded navy; var-ized so the
     airline environment can repaint them in one place — see body.airline-env) */
  --glass-bg:           rgba(15, 23, 42, 0.85);  /* .glass utility */
  --panel-bg:           rgba(15, 23, 42, 0.96);  /* notif panel, map popups, plane labels */
  --dropdown-bg:        rgba(15, 23, 42, 0.88);  /* user dropdown, badges, map controls */
  --surface-solid:      #1e293b;                 /* solid card/route surfaces */
  --accent-wash:        rgba(59, 130, 246, 0.10); /* nav active / route gradient / tints */
  --accent-wash-strong: rgba(59, 130, 246, 0.07);
  --accent-border:      rgba(59, 130, 246, 0.30); /* accent-tinted borders */
  /* RGB triples so page CSS can write rgba(var(--accent-rgb), <any-alpha>) and
     have the airline environment recolour every accent tint losslessly */
  --accent-rgb:         59, 130, 246;
  --cyan-rgb:           14, 165, 233;

  /* Typography */
  --font:         'Inter', system-ui, -apple-system, sans-serif;
  --text-xs:      0.75rem;
  --text-sm:      0.875rem;
  --text-base:    1rem;
  --text-lg:      1.125rem;
  --text-xl:      1.25rem;
  --text-2xl:     1.5rem;

  /* Spacing */
  --radius:       10px;
  --radius-lg:    16px;
  --radius-full:  9999px;

  /* Shadows */
  --shadow-card:  0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow:  0 0 20px var(--accent-glow);

  /* Transitions */
  --transition:   200ms ease;
}

/* ── Airline environment theme override ──────────────────────
   Baked onto <body class="airline-env"> on every /airline* page (desktop +
   mobile) EXCEPT the public airline-profile. Only this block changes — the
   personal palette in :root is untouched, so personal pages are unaffected.
   Everything (shell, glass, overlays, accents) is driven by the variables
   above, so this single override repaints the whole airline environment. */
body.airline-env {
  --bg:                 #0c1f17;  /* deep forest */
  --surface:            #143022;
  --surface-2:          #1b3d2c;
  --accent:             #10b981;  /* emerald */
  --accent-dark:        #059669;
  --accent-glow:        rgba(16, 185, 129, 0.35);
  --cyan:               #14b8a6;  /* teal */
  --glass-bg:           rgba(12, 31, 23, 0.85);
  --panel-bg:           rgba(12, 31, 23, 0.96);
  --dropdown-bg:        rgba(12, 31, 23, 0.88);
  --surface-solid:      #143022;
  --accent-wash:        rgba(16, 185, 129, 0.12);
  --accent-wash-strong: rgba(16, 185, 129, 0.08);
  --accent-border:      rgba(16, 185, 129, 0.30);
  --accent-rgb:         16, 185, 129;
  --cyan-rgb:           20, 184, 166;
  /* --text, --text-muted, --danger, --warning, --success unchanged */
}

/* ── Reset ───────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* Ensure dropdown options render with theme colors in all browsers.
   Without this, some browsers paint the open <option> list with white
   background but inherit the parent <select>'s light text color,
   producing white-on-white. */
select option,
select optgroup {
  background-color: var(--surface);
  color: var(--text);
}
ul, ol { list-style: none; }

/* ── Glassmorphism Utility ───────────────────────────────── */
.glass {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: var(--glass-bg);
  border: 1px solid var(--border);
}

/* ── Card Component ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ── Entrance Animation ──────────────────────────────────── */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeSlideUp 400ms ease forwards;
  opacity: 0;
}

/* Stagger delays for dashboard cards */
.animate-in:nth-child(1)  { animation-delay:   0ms; }
.animate-in:nth-child(2)  { animation-delay:  60ms; }
.animate-in:nth-child(3)  { animation-delay: 120ms; }
.animate-in:nth-child(4)  { animation-delay: 180ms; }
.animate-in:nth-child(5)  { animation-delay: 240ms; }
.animate-in:nth-child(6)  { animation-delay: 300ms; }
.animate-in:nth-child(7)  { animation-delay: 360ms; }
.animate-in:nth-child(8)  { animation-delay: 420ms; }

/* ── Skeleton Shimmer ────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(30, 41, 59, 0.9) 25%,
    rgba(51, 65, 85, 0.8) 50%,
    rgba(30, 41, 59, 0.9) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton-text {
  height: 1em;
  border-radius: var(--radius-full);
  margin-bottom: 0.5em;
}

.skeleton-text.w-3\/4 { width: 75%; }
.skeleton-text.w-1\/2 { width: 50%; }
.skeleton-text.w-full  { width: 100%; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar         { width: 6px; height: 6px; }
::-webkit-scrollbar-track   { background: transparent; }
::-webkit-scrollbar-thumb   { background: rgba(148, 163, 184, 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.4); }

/* ── Typography Utilities ────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-cyan   { color: var(--cyan); }
.text-sm     { font-size: var(--text-sm); }
.text-xs     { font-size: var(--text-xs); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold   { font-weight: 700; }

/* ── Badge ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-success { background: rgba(34, 197, 94, 0.15);  color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-danger  { background: rgba(239, 68, 68, 0.15);  color: var(--danger); }
.badge-info    { background: var(--accent-wash); color: var(--accent); }
.badge-maint   { background: rgba(239, 68, 68, 0.15);  color: #fca5a5; display: inline-flex; align-items: center; gap: 4px; }

/* ── Aircraft maintenance downtime cue ───────────────────── */
.fleet-card-maint { outline: 2px solid var(--danger); outline-offset: -2px; }
.maint-countdown { font-variant-numeric: tabular-nums; font-weight: 700; }
.maint-countdown.maint-soon { color: var(--danger); }

/* ── Pulsing Dot (live indicator) ────────────────────────── */
@keyframes pulse-ring {
  0%   { transform: scale(0.9); opacity: 1; }
  70%  { transform: scale(1.4); opacity: 0; }
  100% { transform: scale(1.4); opacity: 0; }
}

.pulse-dot {
  position: relative;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
}

.pulse-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-ring 1.5s ease-out infinite;
}

/* ── Focus Ring ──────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Weight Unit Toggle (sidebar) ───────────────────────── */
.nav-weight-toggle {
  width: 100%;
  text-align: left;
}

.wt-badge {
  margin-left: auto;
  background: var(--accent-wash);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

/* ============================================================
   Shared button / form / spinner utilities
   (Airline Module pages rely on these globally; existing pages
   define their own variants in their page CSS, which load after
   base.css and therefore override these.)
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  cursor: pointer;
  border: none;
  white-space: nowrap;
  text-decoration: none;
}
.btn-sm { padding: 6px 14px; font-size: var(--text-xs); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-ghost { background: rgba(255,255,255,0.06); color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,0.10); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.form-input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: var(--text-sm);
  color: var(--text);
  font-family: inherit;
  transition: border-color var(--transition), background var(--transition);
  width: 100%;
}
.form-input:focus { outline: none; border-color: var(--accent); background: var(--accent-wash); }
.form-label { display: block; font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.form-error { font-size: var(--text-xs); color: var(--danger); display: none; }
.form-group.has-error .form-input { border-color: var(--danger); }
.form-group.has-error .form-error { display: block; }

.spin { animation: spinAnim 0.8s linear infinite; display: inline-block; }
@keyframes spinAnim { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Pricing-simulator deep links (dispatch modal + schedule builder → /economy) */
.sim-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent, #10b981);
  text-decoration: none;
  white-space: nowrap;
}
.sim-link:hover { text-decoration: underline; }
.dispatch-modal-section-header .sim-link { margin-left: auto; }
#bSimLink { margin-top: 6px; }

/* Shared "Acquire aircraft" mode switcher — unifies the 3 acquire surfaces
   (/market resale, /hangar factory-new, /airline/hangars airline fleet). */
.acq-modes {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  margin-bottom: 16px;
}
.acq-modes-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}
.acq-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}
.acq-mode:hover { color: var(--text); background: var(--accent-wash); }
.acq-mode.active { color: var(--text); background: var(--accent-wash); border-color: var(--accent-border); }

/* Shared pre-flight step indicator — connects /my-flight (pick & price) and
   /dispatch (loadsheet & fuel) into one legible linear flow. */
.preflight-steps {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 12px;
  margin-bottom: 16px;
  font-size: var(--text-sm);
}
.pf-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}
a.pf-step:hover { color: var(--text); background: var(--accent-wash); }
.pf-step.active { color: var(--text); background: var(--accent-wash); border: 1px solid var(--accent-border); }
.pf-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text);
  font-size: 0.72rem;
}
.pf-step.active .pf-num { background: var(--accent); }
.pf-sep { color: var(--text-muted); opacity: 0.6; }
