/* Zindigon Builds — Admin.
   Built on top of /assets/site.css (shared design system) — reuses
   --bg/--bg-elev/--line/--fg/--accent/--serif/--sans/--mono/--r, plus the
   existing .card/.btn/.form/.field/.input/.textarea/.auth-card patterns.
   Everything below is additive: admin-only layout, tables, status badges,
   and the repeatable requirement/artifact/loadout row groups. */

body.builds-admin {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.builds-admin > main { flex: 1 0 auto; }

/* ───────── Gate states (loading / signed out / not admin) ───────── */
.ba-gate-note {
  margin-top: 14px;
  font-size: 13px;
  color: var(--fg-mute);
}
.ba-gate-note button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}
.ba-tabs-row {
  display: flex;
  gap: 8px;
}
.ba-authbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-mute);
}
.ba-authbar strong { color: var(--fg); font-family: var(--sans); font-weight: 500; }

/* Small screens: the brand lockup + admin chip + username + Sign Out
   button don't fit on one row at phone widths. Wrap instead of clipping
   so Sign Out stays reachable. */
@media (max-width: 480px) {
  body.builds-admin .nav {
    flex-wrap: wrap;
    row-gap: 10px;
  }
  body.builds-admin .ba-authbar {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }
  body.builds-admin .ba-authbar span:not(.ba-admin-chip) strong {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: bottom;
  }
}
.ba-admin-chip {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--accent-line);
  color: var(--accent);
}

/* ───────── Admin section tabs (Builds / Reference Data) ───────── */
.ba-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.ba-tab {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-mute);
  background: none;
  border: none;
  padding: 10px 4px 12px;
  margin-right: 18px;
  cursor: pointer;
  position: relative;
}
.ba-tab:hover { color: var(--fg-soft); }
.ba-tab.active { color: var(--fg); }
.ba-tab.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
}

/* ───────── Build list ───────── */
.ba-list-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.ba-list-head .spacer { flex: 1; }
.ba-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.ba-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.ba-table th {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-faint);
  font-weight: 500;
  text-align: left;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.ba-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  background: var(--bg-elev);
  vertical-align: middle;
}
.ba-table tr:last-child td { border-bottom: 0; }
.ba-table tr:hover td { background: var(--bg-elev-2); }
.ba-table .name { color: var(--fg); font-weight: 500; }
.ba-table .muted { color: var(--fg-mute); font-size: 12px; }
.ba-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ba-row-actions button {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--fg-soft);
  padding: 5px 10px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
}
.ba-row-actions button:hover { color: var(--fg); border-color: var(--line-2); background: rgba(255,255,255,0.04); }
.ba-row-actions button.danger:hover { color: #ff8a8a; border-color: rgba(220,80,80,0.4); }
.ba-row-actions button.accent:hover { color: var(--accent); border-color: var(--accent-line); }

.ba-status {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--fg-mute);
  display: inline-block;
}
.ba-status.draft     { border-color: rgba(220,180,80,0.4); color: #e0c25a; }
.ba-status.published { border-color: var(--accent-line); color: var(--accent); }
.ba-status.archived  { border-color: var(--line-2); color: var(--fg-faint); }

.ba-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--fg-mute);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

/* ───────── Build form ───────── */
.ba-form-section {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  padding: 24px;
  margin-bottom: 20px;
}
.ba-form-section h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 20px;
  margin: 0 0 4px;
}
.ba-form-section .hint {
  font-size: 12px;
  color: var(--fg-mute);
  margin: 0 0 18px;
}
.ba-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.ba-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
@media (max-width: 760px) {
  .ba-grid-2, .ba-grid-3 { grid-template-columns: 1fr; }
}
.ba-form-section .form { max-width: none; gap: 16px; }

.ba-tray-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin: 4px 0 8px;
}
.ba-tray-label:not(:first-child) {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.ba-loadout-slot {
  display: grid;
  grid-template-columns: 32px 1fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.ba-loadout-slot:last-child { border-bottom: 0; }
.ba-loadout-slot .num {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-mute);
  width: 32px;
}
@media (max-width: 640px) {
  .ba-loadout-slot { grid-template-columns: 1fr; gap: 6px; }
}

.ba-repeat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) 36px;
  gap: 10px;
  align-items: end;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.ba-repeat-row:last-of-type { border-bottom: 0; }
.ba-repeat-row .field { gap: 4px; }
.ba-repeat-row .field label { font-size: 10px; }
.ba-repeat-remove {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--fg-mute);
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  align-self: end;
}
.ba-repeat-remove:hover { color: #ff8a8a; border-color: rgba(220,80,80,0.4); }
@media (max-width: 640px) {
  /* auto-fit with a 120px minimum still packs 2-3 cramped columns at
     phone widths (fields truncate, Min Rank shrinks to a sliver). Stack
     one field per row instead, matching .ba-loadout-slot's breakpoint. */
  .ba-repeat-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .ba-repeat-remove {
    justify-self: end;
    align-self: auto;
  }
}
.ba-repeat-empty {
  padding: 16px 0;
  color: var(--fg-faint);
  font-family: var(--mono);
  font-size: 12px;
}
.ba-add-row {
  margin-top: 14px;
}

.ba-form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  padding: 16px 0;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
}

/* ───────── Reference data tab ───────── */
.ba-ref-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.ba-ref-tabs button {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--fg-soft);
  padding: 7px 14px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.ba-ref-tabs button.active {
  border-color: var(--accent-line);
  color: var(--accent);
  background: color-mix(in oklch, var(--accent) 8%, var(--bg-elev));
}
.ba-ref-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}
.ba-ref-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.ba-ref-item .name { color: var(--fg); font-weight: 500; font-size: 13px; }
.ba-ref-item .slug { font-family: var(--mono); font-size: 11px; color: var(--fg-faint); }
.ba-ref-item .tags { margin-top: 0; }
.ba-ref-item .spacer { flex: 1; }
.ba-ref-item button {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--fg-mute);
  padding: 4px 9px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 10px;
  cursor: pointer;
}
.ba-ref-item button:hover { color: #ff8a8a; border-color: rgba(220,80,80,0.4); }
.ba-ref-add-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.ba-ref-add-form .field { min-width: 160px; flex: 1; }
.ba-role-checks {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.ba-role-checks label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--fg-soft);
  text-transform: none;
  letter-spacing: 0;
}

/* ───────── Toast / save status ───────── */
.ba-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  padding: 12px 16px;
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 12px;
  border: 1px solid var(--line-2);
  background: var(--bg-elev-2);
  color: var(--fg);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  max-width: 360px;
  display: none;
}
.ba-toast.show { display: block; }
.ba-toast.error { border-color: rgba(220,80,80,0.4); color: #ff8a8a; }
.ba-toast.ok { border-color: var(--accent-line); color: var(--accent); }
