/* ─── LAYOUT ─────────────────────────────────────────────────────────────────
   Mobile-first. Base styles target narrow screens (≥320px).
   @media blocks expand behaviour for tablet (≥600px) and desktop (≥900px).
   ──────────────────────────────────────────────────────────────────────────── */

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;       /* scroll is handled by inner containers */
}

/* ── Connection bar ─────────────────────────────────────────────── */
/* Dark strip pinned to the top; never scrolls away */

/* Brand: always visible; text hidden on mobile, shown tablet+ */
.conn-brand {
  display: flex;
  flex-shrink: 0;
}

.conn-brand-text {
  display: none;
}

.conn-bar {
  flex-shrink: 0;
  background: var(--color-dark);
  padding: 9px 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  z-index: 10;
}

/* ── Info panel ─────────────────────────────────────────────────── */
/* Overlays entire viewport, slides in from the right */
.info-panel {
  position: fixed;
  inset: 0;
  background: var(--color-dark);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-panel);
  overflow-y: auto;
}

.info-panel.open {
  transform: translateX(0);
}

/* ── Page wrapper ───────────────────────────────────────────────── */
/* Fills the remaining viewport below the connection bar */
.page {
  flex: 1;
  overflow-y: auto;       /* default: simple scroll for non-checklist pages */
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Checklist-specific layout: inner components own their own scroll */
.page-checklist {
  overflow: hidden;
}

.proc-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  padding: 13px 16px 11px;
}

/* Mobile drawer toggle — hidden from tablet up (sidebar is always shown there) */
.proc-menu-toggle {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--color-ink-mid);
  font-size: 19px;
  line-height: 1;
  padding: 0;
  margin-right: 12px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Backdrop behind the off-canvas drawer (mobile only) */
.proc-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 21, 18, 0.45);
  z-index: 40;
}

/* Ring + stats: mobile hidden, shown at tablet+ */
.proc-header-right {
  display: none;
}

.proc-header-left {
  flex: 1;
  min-width: 0;
}

/* Two-column wrapper (used inside .page-checklist) */
.proc-layout {
  flex: 1;
  display: flex;
  flex-direction: column;  /* mobile: sidebar hidden, column layout */
  overflow: hidden;
}

/* Sidebar: off-canvas drawer on mobile, static column tablet+ (media query below) */
.proc-sidebar {
  display: none;
  width: 270px;
  flex-shrink: 0;
  flex-direction: column;
  background: var(--color-dark);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

/* Mobile: when opened via the toggle, slide in as a fixed overlay */
.proc-sidebar.is-open {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  width: 84vw;
  max-width: 320px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
}

/* Main content column */
.proc-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  /* Anchor for the absolutely positioned .suggest-banner overlay */
  position: relative;
}

.checklist-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  background: var(--color-bg);
}

.checklist-scroll::-webkit-scrollbar {
  width: 3px;
}

.checklist-scroll::-webkit-scrollbar-thumb {
  background: var(--color-border-mid);
  border-radius: 3px;
}

.nav-bar {
  flex-shrink: 0;
  background: var(--color-card);
  border-top: 1px solid var(--color-border);
  padding: 10px 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Tablet (≥600px) ────────────────────────────────────────────── */
@media (min-width: 600px) {
  .conn-brand-text {
    display: inline;
  }

  .conn-logo {
    display: none;
  }

  .info-panel {
    width: 360px;
    left: auto;             /* slide from right edge only */
  }

  /* Two-column layout: sidebar + main */
  .proc-layout {
    flex-direction: row;
    overflow: hidden;
  }

  .proc-sidebar,
  .proc-sidebar.is-open {
    display: flex;          /* show sidebar from tablet up */
    position: static;       /* never off-canvas on tablet+ */
    width: 270px;
    max-width: none;
    box-shadow: none;
  }

  /* Drawer affordances are mobile-only */
  .proc-menu-toggle,
  .proc-sidebar-backdrop {
    display: none;
  }

  /* No ☰ to clear here, so the banner overlay can span the full width */
  .suggest-banner {
    left: 0;
    border-bottom-left-radius: 0;
  }

  /* Main area fills remaining width */
  .proc-main {
    flex: 1;
    overflow: hidden;
  }

  /* Proc header: two-section row on tablet+ */
  .proc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 12px;
  }

  .proc-header-left {
    flex: 1;
    min-width: 0;
  }

  .proc-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    margin-left: 16px;
  }

  /* Hide mobile progress bar, show ring + stats */
  .proc-meta {
    display: none;
  }

  .proc-header-right {
    display: flex;
  }
}

/* ── Desktop (≥900px) ───────────────────────────────────────────── */
@media (min-width: 900px) {
  .conn-bar {
    display: flex;
    align-items: center;
    padding: 10px 24px 8px;
  }

  /* Status group expands to fill space and centres its content */
  .conn-status-group {
    flex: 1;
    justify-content: center;
  }

  /* Info button always at the right edge, no margin needed */
  .conn-actions {
    flex-shrink: 0;
    margin-left: 0;
  }

  .page {
    background: var(--color-bg);
  }

  .proc-sidebar {
    width: 300px;           /* wider sidebar on desktop, matching mockup */
  }

  .proc-sidebar-header,
  .proc-sidebar-item {
    padding-left: 18px;
    padding-right: 18px;
  }

  .flight-info {
    padding: 10px 18px;
  }

  .proc-header {
    padding: 16px 24px 14px;
  }

  .checklist-scroll {
    padding: 12px 4px;
  }

  .nav-bar {
    padding: 12px 20px;
  }
}

/* ── Auth pages: dark sidebar + centered form (≥600px) ─────────── */

/* The sidebar div is always in the DOM; hidden on mobile */
.auth-sidebar {
  display: none;
}

/* Right-hand scrollable area: always flex column, fills remaining width */
.auth-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-width: 0;
}

@media (min-width: 600px) {
  .page.auth-page {
    flex-direction: row;
    overflow: hidden;
  }

  .auth-sidebar {
    display: block;
    width: 270px;
    flex-shrink: 0;
    background: var(--color-dark);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
  }
}

@media (min-width: 900px) {
  .auth-sidebar {
    width: 300px;
  }
}

/* ── Setup / New Flight page ────────────────────────────────────── */
/* Scrollable full-width page — no sidebar */
.setup-page {
  overflow-y: auto;
  background: var(--color-bg);
}

.setup-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 16px 80px;
}

/* Two-column grid — collapses to single column below 680px */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (min-width: 681px) {
  .danger-zone-wrapper {
    grid-column: 1;
  }
}

@media (max-width: 680px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

/* ── Sidebar export link: desktop only ─────────────────────────── */
.sidebar-export-link {
  display: none;
}

@media (min-width: 900px) {
  .sidebar-export-link {
    display: block;
    margin: 8px 18px 16px;
    padding: 7px 10px;
    font-size: 0.75rem;
    color: var(--color-teal-bright);
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    text-align: center;
    transition: color var(--transition-fast), border-color var(--transition-fast);
  }

  .sidebar-export-link:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
  }
}
