/* uavnav.dev admin — additions on top of the NaviX main.css.
   Reuses its variables, cards, buttons, state items and legend. */

.admin-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Compact on-device-NaviX header: smaller logo, single wordmark, no subtitle. */
.admin-body .header {
  padding: 6px 16px;
}
.admin-body .header .logo {
  width: 32px;
  height: 32px;
}
.admin-body .header-title h1 {
  font-size: 17px;
}
.admin-body .lang-switch .lang-btn,
.admin-body .logout-btn {
  padding: 4px 10px;
  font-size: 12px;
}

.admin-main {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.logout-btn {
  text-decoration: none;
}

.lang-switch .lang-btn {
  text-decoration: none;
}

/* ── Page head ──────────────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.page-head h2 {
  font-size: 20px;
  font-weight: 700;
}

.page-sub {
  font-size: 12px;
  color: var(--gray-500);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.page-head .btn {
  margin-left: auto;
  text-decoration: none;
}

/* ── Per-flight log downloads ───────────────────────────────────── */
.dl-actions {
  margin-left: auto;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.dl-actions .btn {
  margin-left: 0;
  text-decoration: none;
}

/* ── Tables ─────────────────────────────────────────────────────── */
.card-header.card-blue-header {
  background: var(--primary);
  color: var(--white);
  border-bottom: none;
}

.card-header.card-gray-header {
  background: var(--gray-100);
  color: var(--gray-700);
}

.card-header.card-orange-header {
  background: var(--orange);
  color: var(--white);
  border-bottom: none;
}

/* Back arrow (flight detail), left of the session name. */
.back-btn,
.back-btn:link,
.back-btn:visited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  color: var(--gray-900);
  background: var(--white);
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
}
.back-btn:hover {
  background: var(--gray-100);
  color: var(--gray-900);
  border-color: var(--gray-400);
}

/* Mission progress bar (Ongoing Missions). */
.pbar {
  display: inline-block;
  width: 120px;
  max-width: 40vw;
  height: 8px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
}
.pbar-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 999px;
  transition: width 0.3s;
}
.pbar-label {
  margin-left: 8px;
  font-size: 11px;
  color: var(--gray-600);
}

.table-wrap {
  overflow-x: auto;
}

.rec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.rec-table th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.rec-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}

.rec-table tbody tr:last-child td {
  border-bottom: none;
}

.row-link {
  cursor: pointer;
}

.row-link:hover td {
  background: var(--gray-50);
}

.empty-cell {
  color: var(--gray-400);
  text-align: center;
  padding: 24px !important;
}

.err-cell {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Chips ──────────────────────────────────────────────────────── */
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}

.chip-green { background: #d1fae5; color: var(--success-dark); }
.chip-red { background: #fee2e2; color: var(--danger-dark); }
.chip-orange { background: #fef3c7; color: var(--orange-dark); }
.chip-gray { background: var(--gray-100); color: var(--gray-500); }

.ground-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  padding: 4px 0;
}

.ground-details[open] summary {
  margin-bottom: 8px;
}

/* ── Flight detail ──────────────────────────────────────────────── */
.flight-layout {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.flight-side {
  width: 320px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.flight-map {
  flex: 1;
  min-height: 560px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gray-200);
}

.flight-map #map {
  height: 100%;
  min-height: 560px;
}

.missions-map {
  height: 340px;
  border-radius: var(--radius);
  overflow: hidden;
}

.missions-map #map {
  height: 340px;
}

@media (max-width: 900px) {
  .flight-layout {
    flex-direction: column;
  }
  .flight-side {
    width: 100%;
    min-width: 0;
  }
  /* On a stacked layout the map needs its own visible height. */
  .flight-map,
  .flight-map #map {
    min-height: 60vh;
  }
}

/* ── Tablet / mobile ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .admin-main {
    padding: 12px;
    gap: 12px;
  }
  .admin-body .header {
    flex-wrap: wrap;
    gap: 8px;
    row-gap: 6px;
  }
  .admin-body .header-title h1 {
    font-size: 16px;
  }
  .page-head {
    gap: 10px;
  }
  .page-head h2 {
    font-size: 17px;
  }
  .page-head .btn {
    margin-left: 0;
  }
  /* Tables stay usable by scrolling horizontally inside their card. */
  .rec-table {
    font-size: 11px;
  }
  .rec-table th,
  .rec-table td {
    padding: 6px 8px;
  }
  .flight-map,
  .flight-map #map {
    min-height: 52vh;
  }
  .pbar {
    width: 90px;
  }
}

/* Never let the page itself scroll sideways; wide content scrolls in-card. */
@media (max-width: 480px) {
  .admin-body .header-right {
    gap: 6px;
  }
  .admin-body .lang-switch .lang-btn,
  .admin-body .logout-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
}

/* ── Login ──────────────────────────────────────────────────────── */
/* Exactly one viewport tall, centred, never scrolls. height:100% on both
   html and body resolves to the visible viewport on every browser (no
   100vh/dvh toolbar quirk, no :has() dependency); overflow:hidden kills
   any residual scroll. */
html.login-html {
  height: 100%;
  overflow: hidden;
}

body.login-body {
  height: 100%;
  min-height: 100%;   /* override main.css body { min-height: 100vh } */
  overflow: hidden;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  background: var(--gray-100);
}

.login-wrap {
  width: 100%;
  max-width: 380px;
}

.login-card {
  box-shadow: var(--shadow);
}

.login-header {
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: none;
}

.login-error {
  background: #fee2e2;
  color: var(--danger-dark);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  margin-bottom: 12px;
}
