/* ═══════════════════════════════════════════════════
   UAV Pre-Flight Checklist — Stylesheet
   ═══════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ───────────────────────────────────── */
:root {
  --bg:          #131d33;
  --surface:     #161b22;
  --surface2:    #1c2330;
  --border:      rgba(255,255,255,0.08);
  --text:        #e6edf3;
  --text-muted:  #7d8590;
  --text-dim:    #484f58;

  --c1: #3B82F6; /* Mission     – blue   */
  --c2: #F59E0B; /* Pre-Flight  – amber  */
  --c3: #10B981; /* Takeoff     – green  */
  --c4: #F97316; /* Landing     – orange */
  --c5: #A78BFA; /* Post Flight – violet */

  --confirmed: #22c55e;
  --na:        #6b7280;
  --pending:   #F59E0B;
  --radius:    12px;
  --row-h:     52px;
  --font: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── HEADER ──────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,17,23,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 0;
}
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}
.logo svg { flex-shrink: 0; }
.header-meta {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.3;
}
.header-meta strong { color: var(--text); display: block; }

/* ── PROGRESS BAR ────────────────────────────────────── */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
}
.progress-bar-bg {
  flex: 1;
  height: 5px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--c1), var(--c3));
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  width: 0%;
}
.progress-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
}

/* ── SECTION NAV TABS ────────────────────────────────── */
.section-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.section-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.02em;
  position: relative;
}
.tab-btn .tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.2s;
}
.tab-btn.active { color: #fff; }
.tab-btn.done .tab-dot { background: var(--confirmed); }
.tab-btn .tab-check {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 9px;
  opacity: 0;
  transition: opacity 0.2s;
}
.tab-btn.done .tab-check { opacity: 1; }

/* ── MAIN CONTENT ────────────────────────────────────── */
main { padding: 16px 16px 120px; }

.section-card {
  display: none;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  animation: fadeSlide 0.25s ease;
}
.section-card.active { display: block; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── CARD HEADER ─────────────────────────────────────── */
.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-title { flex: 1; }
.card-title h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.card-title p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.card-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.3s;
}
.card-badge.complete {
  background: rgba(34,197,94,0.15);
  color: var(--confirmed);
}

/* ── COLUMN HEADERS ──────────────────────────────────── */
.col-headers {
  display: flex;
  align-items: center;
  padding: 0 18px;
  height: 32px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.col-item-label {
  flex: 1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.col-actions { display: flex; gap: 0; }
.col-action-label {
  width: 62px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ── CHECKLIST ROWS ──────────────────────────────────── */
.checklist-item {
  display: flex;
  align-items: center;
  min-height: var(--row-h);
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  gap: 8px;
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item:active { background: rgba(255,255,255,0.03); }

.item-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 20px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.item-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
  transition: color 0.2s;
}
.checklist-item.is-confirmed .item-label { color: var(--text-muted); text-decoration: line-through; text-decoration-color: rgba(34,197,94,0.4); }
.checklist-item.is-na .item-label        { color: var(--text-dim); font-style: italic; }
.checklist-item.is-pending .item-label   { color: var(--pending); }

/* ── CHECKBOX BUTTONS ────────────────────────────────── */
.check-actions {
  display: flex;
  gap: 0;
  flex-shrink: 0;
}
.check-btn {
  width: 62px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}
.check-box {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid var(--surface2);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  position: relative;
  overflow: hidden;
}
.check-box::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s;
  border-radius: 6px;
}

/* Per-button idle border colours */
.check-btn-confirmed .check-box { border-color: rgba(34,197,94,0.3); }
.check-btn-na .check-box        { border-color: rgba(107,114,128,0.3); }
.check-btn-pending .check-box   { border-color: rgba(245,158,11,0.3); }

.check-icon { opacity: 0; transition: all 0.2s; transform: scale(0.6); }

/* Confirmed active state */
.checklist-item.is-confirmed .check-btn-confirmed .check-box {
  background: var(--confirmed);
  border-color: var(--confirmed);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
}
.checklist-item.is-confirmed .check-btn-confirmed .check-icon { opacity: 1; transform: scale(1); }

/* N/A active state */
.checklist-item.is-na .check-btn-na .check-box {
  background: var(--na);
  border-color: var(--na);
  box-shadow: 0 0 0 3px rgba(107,114,128,0.2);
}
.checklist-item.is-na .check-btn-na .check-icon { opacity: 1; transform: scale(1); }

/* Pending active state */
.checklist-item.is-pending .check-btn-pending .check-box {
  background: var(--pending);
  border-color: var(--pending);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.2);
}
.checklist-item.is-pending .check-btn-pending .check-icon { opacity: 1; transform: scale(1); }

/* Press ripple */
.check-btn:active .check-box { transform: scale(0.88); }

/* ── BOTTOM NAV ──────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(13,17,23,0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  align-items: center;
}
.nav-btn {
  flex: 1;
  height: 48px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.02em;
}
.nav-btn:active { transform: scale(0.96); }
.btn-prev {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-prev:disabled { opacity: 0.3; cursor: default; }
.btn-prev:not(:disabled):hover { background: var(--surface); color: var(--text); }
.btn-next {
  background: var(--c1);
  color: #fff;
  box-shadow: 0 4px 16px rgba(59,130,246,0.35);
}
.btn-next:active { box-shadow: 0 2px 8px rgba(59,130,246,0.25); }
.btn-reset {
  width: 48px;
  flex: 0 0 48px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 18px;
}
.btn-print {
  width: 48px;
  flex: 0 0 48px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 18px;
}

/* ── SECTION COMPLETE BANNER ─────────────────────────── */
.complete-banner {
  display: none;
  align-items: center;
  gap: 10px;
  background: rgba(34,197,94,0.08);
  border-top: 1px solid rgba(34,197,94,0.2);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--confirmed);
}
.complete-banner.show { display: flex; }

/* ── ALL DONE SCREEN ─────────────────────────────────── */
.all-done {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 16px;
  animation: fadeSlide 0.3s ease;
}
.all-done.show { display: flex; }
.all-done .done-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(34,197,94,0.1);
  border: 2px solid rgba(34,197,94,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}
.all-done h2 { font-size: 22px; font-weight: 800; }
.all-done p  { color: var(--text-muted); font-size: 14px; line-height: 1.6; max-width: 280px; }

.done-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin-top: 8px;
}
.done-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}
.done-stat strong { display: block; font-size: 22px; font-weight: 800; }
.done-stat span   { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.done-stat-confirmed strong { color: var(--confirmed); }
.done-stat-na strong        { color: var(--na); }
.done-stat-pending strong   { color: var(--pending); }

/* ── DONE-SCREEN ACTION BUTTONS ─────────────────────── */
.done-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  margin-top: 8px;
}
.btn-done-action {
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  letter-spacing: 0.02em;
}
.btn-done-action:active { transform: scale(0.96); }
.btn-done-print {
  background: var(--c1);
  border: none;
  color: #fff;
  box-shadow: 0 4px 16px rgba(59,130,246,0.3);
}
.btn-done-csv {
  background: var(--c3);
  border: none;
  color: #fff;
  box-shadow: 0 4px 16px rgba(16,185,129,0.3);
}
.btn-done-restart {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ── SECTION COLOUR THEMING ──────────────────────────── */
[data-section="1"] .card-header { border-left: 3px solid var(--c1); }
[data-section="2"] .card-header { border-left: 3px solid var(--c2); }
[data-section="3"] .card-header { border-left: 3px solid var(--c3); }
[data-section="4"] .card-header { border-left: 3px solid var(--c4); }
[data-section="5"] .card-header { border-left: 3px solid var(--c5); }

[data-section="1"] .card-icon { background: rgba(59,130,246,0.12); }
[data-section="2"] .card-icon { background: rgba(245,158,11,0.12); }
[data-section="3"] .card-icon { background: rgba(16,185,129,0.12); }
[data-section="4"] .card-icon { background: rgba(249,115,22,0.12); }
[data-section="5"] .card-icon { background: rgba(167,139,250,0.12); }

[data-section="1"] .btn-next { background: var(--c1); box-shadow: 0 4px 16px rgba(59,130,246,0.35); }
[data-section="2"] .btn-next { background: var(--c2); color: #1a1100; box-shadow: 0 4px 16px rgba(245,158,11,0.35); }
[data-section="3"] .btn-next { background: var(--c3); box-shadow: 0 4px 16px rgba(16,185,129,0.35); }
[data-section="4"] .btn-next { background: var(--c4); box-shadow: 0 4px 16px rgba(249,115,22,0.35); }
[data-section="5"] .btn-next { background: var(--c5); box-shadow: 0 4px 16px rgba(167,139,250,0.35); }

/* ── PRINT STYLES ────────────────────────────────────── */
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  body { background: #fff !important; color: #111 !important; }

  header {
    position: static !important;
    background: #fff !important;
    backdrop-filter: none !important;
    border-bottom: 2px solid #111 !important;
    padding: 12px 16px !important;
  }
  .progress-wrap { display: none !important; }
  .logo { color: #111 !important; }
  .header-meta strong,
  .header-meta span { color: #111 !important; }

  .section-tabs    { display: none !important; }
  .bottom-nav      { display: none !important; }
  .all-done        { display: none !important; }
  .complete-banner { display: none !important; }

  main { padding: 12px 16px 0 !important; max-width: 100% !important; }

  .section-card {
    display: block !important;
    border: 1px solid #ccc !important;
    margin-bottom: 16px !important;
    break-inside: avoid;
    background: #fff !important;
  }
  .card-header {
    background: #f3f4f6 !important;
    border-bottom: 1px solid #ccc !important;
  }
  .card-title h2 { color: #111 !important; }
  .card-title p  { color: #555 !important; }
  .card-badge    { color: #111 !important; background: #e5e7eb !important; }
  .card-icon     { display: none !important; }

  .col-headers      { background: #e5e7eb !important; border-bottom: 1px solid #ccc !important; }
  .col-item-label   { color: #374151 !important; }
  .col-action-label { display: none !important; }

  .checklist-item {
    border-bottom: 1px solid #e5e7eb !important;
    min-height: 0 !important;
    padding: 7px 18px !important;
    background: #fff !important;
  }
  .item-number { color: #9ca3af !important; }
  .item-label  { color: #111 !important; font-size: 13px !important; }

  .checklist-item.is-confirmed .item-label { color: #15803d !important; text-decoration: line-through !important; }
  .checklist-item.is-na .item-label        { color: #9ca3af !important; }
  .checklist-item.is-pending .item-label   { color: #d97706 !important; }

  .check-actions { display: none !important; }

  .checklist-item::after {
    content: '☐';
    font-size: 12px;
    color: #9ca3af;
    margin-left: auto;
    flex-shrink: 0;
    padding-right: 4px;
  }
  .checklist-item.is-confirmed::after { content: '✓  Confirmed'; color: #15803d; font-weight: 700; }
  .checklist-item.is-na::after        { content: '—  N/A';       color: #6b7280; }
  .checklist-item.is-pending::after   { content: '⏳  Pending';  color: #d97706; font-weight: 700; }
}

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (min-width: 540px) {
  main { max-width: 540px; margin: 0 auto; }
  header {
    padding-left:  max(16px, calc((100vw - 540px) / 2 + 16px));
    padding-right: max(16px, calc((100vw - 540px) / 2 + 16px));
  }
  .section-tabs { padding-left: max(16px, calc((100vw - 540px) / 2 + 16px)); }
  .bottom-nav   { max-width: 540px; left: 50%; transform: translateX(-50%); border-radius: 0; }
}
