/* =========================
   Fonts & Variables
========================= */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:           #0a0f1e;
  --surface:      #111827;
  --surface-2:    #1a2235;
  --border:       rgba(255,255,255,0.07);
  --accent:       #3b82f6;
  --accent-glow:  rgba(59,130,246,0.25);
  --accent-2:     #06b6d4;
  --text:         #e2e8f0;
  --text-muted:   #64748b;
  --arrival:      #10b981;
  --departure:    #f59e0b;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
}

/* =========================
   Base
========================= */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Sora', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  background-image:
    linear-gradient(rgba(59,130,246,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* =========================
   Header
========================= */

.site-header {
  background: rgba(10,15,30,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.logo {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo::before {
  content: '✈';
  font-size: 1.1rem;
  color: var(--accent);
}

.site-header nav {
  display: flex;
  gap: 0.25rem;
}

.site-header nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.site-header nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* =========================
   Page Layout
========================= */

h1 {
  text-align: center;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  padding: 2.5rem 1rem 0.5rem;
  background: linear-gradient(135deg, #fff 30%, var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.seo-content {
  max-width: 640px;
  margin: 0.5rem auto 1.5rem;
  text-align: center;
  padding: 0 1rem;
}

.seo-content h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.seo-content p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* =========================
   Search Container
========================= */

#search-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  max-width: 900px;
  margin: 0 auto 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

#search-container input,
#search-container select {
  flex: 1 1 160px;
  padding: 0.65rem 0.9rem;
  font-family: 'Sora', sans-serif;
  font-size: 0.9rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

#search-container select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
  cursor: pointer;
}

#search-container input::placeholder {
  color: var(--text-muted);
}

#search-container input:focus,
#search-container select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#search-btn {
  flex: 0 0 auto;
  padding: 0.65rem 1.8rem;
  font-family: 'Sora', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 0 16px var(--accent-glow);
  letter-spacing: 0.01em;
}

#search-btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(59,130,246,0.4);
}

#search-btn:active {
  transform: translateY(0);
}

#search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* =========================
   Jump Link
========================= */

#jump-to-history {
  display: block;
  text-align: center;
  margin: 0 auto 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
  letter-spacing: 0.02em;
}

#jump-to-history:hover {
  color: var(--accent);
}

/* =========================
   Search Results
========================= */

#search-results {
  max-width: 900px;
  margin: 0 auto 2rem;
  padding: 0 1rem;
}

#search-results > p {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

p.error {
  color: #f87171 !important;
}

/* =========================
   Flight Card
========================= */

.flight-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.6rem;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  animation: fadeUp 0.3s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flight-card:hover {
  border-color: rgba(59,130,246,0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.flight-card img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--surface-2);
  padding: 4px;
}

.flight-card strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.05em;
}

.flight-card br + *,
.flight-card {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.flight-card button {
  padding: 0.4rem 1rem;
  font-family: 'Sora', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.flight-card button:hover {
  background: var(--accent);
  color: #fff;
}

/* =========================
   History Section
========================= */

#local-history {
  max-width: 900px;
  margin: 0 auto 3rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

#local-history h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

#clear-history-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  padding: 0.35rem 0.8rem;
  font-family: 'Sora', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  background: transparent;
  color: #f87171;
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

#clear-history-btn::before {
  content: '×';
  font-size: 1rem;
  line-height: 1;
}

#clear-history-btn:hover {
  background: rgba(248,113,113,0.1);
  border-color: #f87171;
}

#history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#history-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  transition: border-color 0.2s;
}

#history-list li:hover {
  border-color: rgba(59,130,246,0.25);
}

#history-list span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  transition: color 0.2s;
}

#history-list span:hover {
  color: var(--accent);
}

.history-buttons {
  display: flex;
  gap: 0.3rem;
}

.history-buttons button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.history-buttons button:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface-2);
}

/* =========================
   History Label Editing
========================= */

.history-label-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  padding: 0.1rem 0;
}

.history-flight {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-flight:hover {
  color: var(--accent);
}

.history-user-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  cursor: pointer;
  transition: color 0.2s;
}

.history-user-label:hover {
  color: var(--accent);
}

.history-label-input {
  font-family: 'Sora', sans-serif;
  font-size: 0.78rem;
  padding: 0.2rem 0.4rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  outline: none;
  width: 140px;
}

.history-delete {
  color: #f87171 !important;
  border-color: rgba(248,113,113,0.3) !important;
}

.history-delete:hover {
  background: rgba(248,113,113,0.1) !important;
  border-color: #f87171 !important;
}

.history-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.5rem 0;
  list-style: none;
}

/* =========================
   Floating Nav Button
========================= */

#float-nav-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  padding: 0.55rem 1.1rem;
  font-family: 'Sora', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(59,130,246,0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s, background 0.2s;
}

#float-nav-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#float-nav-btn:hover {
  background: #2563eb;
  transform: translateY(-2px);
}

/* =========================
   Table (snapshot-table)
========================= */

#snapshot-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
  font-size: 0.88rem;
}

#snapshot-table th,
#snapshot-table td {
  border: 1px solid var(--border);
  padding: 0.6rem 0.8rem;
  text-align: center;
}

#snapshot-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

#snapshot-table tr:hover td {
  background: var(--surface-2);
}

@media (max-width: 600px) {
  #snapshot-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* =========================
   Snapshot Controls (flight detail)
========================= */

#snapshot-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 900px;
  margin: 0 auto 0.75rem;
  padding: 0 1rem;
}

#last-refreshed {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* =========================
   Content Card (about, contact)
========================= */

.content-card {
  max-width: 900px;
  margin: 0 auto 2rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  line-height: 1.8;
}

.content-card--narrow {
  max-width: 600px;
  padding: 2rem;
}

.content-card p {
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

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

/* =========================
   Page Hero (about, contact)
========================= */

.page-hero {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  max-width: 600px;
  margin: 0 auto;
}

.page-hero h1 {
  padding: 0 0 0.4rem;
}

.page-lead {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.6;
}

/* =========================
   Contact Email Button
========================= */

.contact-email {
  display: inline-block;
  margin: 0.75rem 0 1.25rem;
  padding: 0.6rem 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.contact-email:hover {
  background: var(--accent);
  color: #fff;
}

.contact-disclaimer {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  opacity: 0.7;
}

/* =========================
   Footer
========================= */

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.site-footer nav {
  margin-top: 0.5rem;
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--text);
}

/* =========================
   Responsive
========================= */

@media (max-width: 600px) {
  #search-container {
    padding: 1rem;
    gap: 0.5rem;
  }

  #search-container input,
  #search-container select {
    flex: 1 1 100%;
  }

  #search-btn {
    width: 100%;
  }

  .flight-card {
    grid-template-columns: auto 1fr;
  }

  .flight-card button {
    grid-column: 1 / -1;
    width: 100%;
  }
}
