/* Tribe Terminal admin console */

/* The gate/dashboard/header toggle via the `hidden` attribute. Author `display`
   rules below (flex/grid) would otherwise override it, leaving the dashboard,
   Sign-out, and download button visible before sign-in. Make `hidden` win. */
[hidden] { display: none !important; }

.admin-body { min-height: 100vh; }

.admin-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(5, 6, 9, 0.85);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.admin-tag {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--terminal);
  border: 1px solid rgba(49, 244, 109, 0.4);
  border-radius: 999px;
  padding: 4px 10px;
}
.admin-who { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who-wallet {
  font-family: "Space Grotesk", monospace;
  font-size: 14px;
  color: rgba(233, 242, 232, 0.85);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 6px 12px;
}
.admin-logout {
  border: 1px solid var(--line);
  background: transparent;
  color: rgba(233, 242, 232, 0.72);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 700;
  cursor: pointer;
}
.admin-logout:hover { color: var(--paper); border-color: rgba(255,255,255,0.3); }

.admin-main { width: min(100%, 1100px); margin: 0 auto; padding: 26px clamp(14px, 3vw, 26px) 60px; }

/* Gate */
.admin-gate { min-height: 60vh; display: grid; place-items: center; }
.gate-card {
  width: min(100%, 440px);
  text-align: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  padding: clamp(28px, 4vw, 42px);
}
.gate-card h1 { font-family: "Unbounded", sans-serif; margin: 0 0 12px; font-size: 30px; }
.gate-lede { color: rgba(233, 242, 232, 0.66); line-height: 1.55; margin: 0 0 22px; }
.gate-status { min-height: 20px; margin-top: 16px; color: var(--amber-soft); font-weight: 600; font-size: 14px; }
.gate-hint { margin: 14px 0 0; font-size: 12.5px; line-height: 1.5; color: rgba(233, 242, 232, 0.45); }

/* Wallet picker sheet (shown when more than one wallet is detected) */
.wallet-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: end center;
  background: rgba(3, 4, 6, 0.72);
  backdrop-filter: blur(6px);
  padding: 0;
  animation: wallet-fade 160ms ease;
}
@keyframes wallet-fade { from { opacity: 0; } to { opacity: 1; } }
.wallet-sheet {
  width: min(100%, 420px);
  margin: 0 auto;
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
  background: linear-gradient(180deg, #12161b, #0b0e12);
  padding: 8px 8px calc(14px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.5);
  animation: wallet-rise 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes wallet-rise { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.wallet-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 10px;
  font-family: "Unbounded", sans-serif;
  font-size: 15px;
  font-weight: 700;
}
.wallet-x {
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(233, 242, 232, 0.7);
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.wallet-x:hover { background: rgba(255, 255, 255, 0.12); color: var(--paper); }
.wallet-list { display: flex; flex-direction: column; gap: 6px; }
.wallet-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 80ms ease;
  min-height: 60px;
}
.wallet-opt:hover, .wallet-opt:focus-visible {
  background: rgba(49, 244, 109, 0.08);
  border-color: rgba(49, 244, 109, 0.4);
  outline: none;
}
.wallet-opt:active { transform: scale(0.99); }
.wallet-ico { width: 28px; height: 28px; border-radius: 8px; flex: none; object-fit: cover; }
.wallet-dot {
  display: inline-block;
  background: radial-gradient(circle at 30% 30%, var(--terminal), #0b6b34);
}
.wallet-name { flex: 1; font-weight: 700; font-size: 15px; color: var(--paper); }
.wallet-go { color: rgba(233, 242, 232, 0.4); font-size: 22px; line-height: 1; }

/* Dashboard grid */
.admin-dash {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.dash-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255,255,255,0.045), rgba(255,255,255,0.02));
  padding: clamp(18px, 2.4vw, 26px);
}
.dash-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-hint { margin: -6px 0 12px; font-size: 12.5px; line-height: 1.5; color: rgba(233, 242, 232, 0.5); }
.dash-card-head h2 { font-family: "Unbounded", sans-serif; font-size: 20px; margin: 0; }
.count { font-family: "Space Grotesk", sans-serif; font-size: 13px; font-weight: 600; color: var(--terminal); }
.mini-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: rgba(233, 242, 232, 0.8);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}
.mini-btn:hover { background: rgba(255,255,255,0.09); }
.mini-btn.ok { color: var(--terminal); border-color: rgba(49, 244, 109, 0.4); }
.mini-btn.ok:hover { background: rgba(49, 244, 109, 0.14); }
.mini-btn.danger { color: var(--red); border-color: rgba(255, 95, 87, 0.4); }
.mini-btn.danger:hover { background: rgba(255, 95, 87, 0.14); }

/* Build meta */
.build-meta { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 10px; font-size: 14px; align-items: baseline; }
.kv span { color: rgba(233, 242, 232, 0.55); }
.kv b { color: var(--paper); font-weight: 700; }
.kv code { font-family: "Space Grotesk", monospace; font-size: 12px; color: var(--terminal-soft); word-break: break-all; }
.kv.notes { grid-template-columns: 92px 1fr; }
.kv.notes p { margin: 0; color: rgba(233, 242, 232, 0.78); white-space: pre-wrap; }
#downloadBtn { width: 100%; margin-bottom: 18px; }

.upload-form { border-top: 1px solid var(--line); padding-top: 16px; }
.upload-form h3 { margin: 0 0 12px; font-size: 15px; color: rgba(233, 242, 232, 0.85); }
.upload-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.upload-form input[type="file"] { color: rgba(233, 242, 232, 0.7); font-size: 14px; }

/* Queues */
.queue { display: flex; flex-direction: column; gap: 12px; max-height: 520px; overflow-y: auto; }
.empty { color: rgba(233, 242, 232, 0.5); font-size: 14px; }
.item {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.22);
  padding: 14px;
}
.item.status-approved { border-color: rgba(49, 244, 109, 0.35); }
.item.status-denied { opacity: 0.6; }
.item.status-archived { opacity: 0.55; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-head b { font-size: 15px; word-break: break-all; }
.pill {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: rgba(233, 242, 232, 0.75);
  flex: none;
}
.status-approved .pill { background: rgba(49, 244, 109, 0.16); color: var(--terminal); }
.status-denied .pill { background: rgba(255, 95, 87, 0.16); color: var(--red); }
.item-sub { font-size: 13px; color: rgba(233, 242, 232, 0.6); margin-top: 4px; }
.item-body { font-size: 14px; line-height: 1.5; margin: 8px 0; color: rgba(233, 242, 232, 0.82); white-space: pre-wrap; }
.item-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: rgba(233, 242, 232, 0.5); }
.item-foot .actions { display: flex; gap: 6px; }

/* Audit */
.queue.audit { gap: 0; }
.audit-row {
  display: grid;
  grid-template-columns: 110px 92px 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 9px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 13px;
}
.audit-action {
  font-weight: 800;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: rgba(233, 242, 232, 0.7);
}
.audit-action.login { color: var(--terminal); }
.audit-action.build_download { color: var(--amber-soft); }
.audit-action.build_upload { color: var(--blue); }
.audit-wallet { font-family: "Space Grotesk", monospace; color: rgba(233, 242, 232, 0.75); }
.audit-detail { color: rgba(233, 242, 232, 0.6); word-break: break-all; }
.audit-time { color: rgba(233, 242, 232, 0.45); white-space: nowrap; }

/* Give every tap target a comfortable minimum on touch devices. */
@media (hover: none) and (pointer: coarse) {
  .mini-btn { padding: 8px 14px; }
  .admin-logout { padding: 9px 16px; }
  .item-foot .actions .mini-btn { min-height: 36px; }
  .button.primary { min-height: 48px; }
}

@media (max-width: 860px) {
  .admin-dash { grid-template-columns: 1fr; }
  .audit-row { grid-template-columns: 1fr 1fr; }
  .audit-time, .audit-detail { grid-column: span 2; }
}

/* Phones: collapse the header, stop the wallet pill from overflowing, and let
   forms/cards use the full width. */
@media (max-width: 560px) {
  .admin-header {
    gap: 10px;
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  .admin-header .brand span { font-size: 15px; }
  .admin-who { gap: 8px; width: 100%; margin-left: 0; order: 3; }
  .who-wallet {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 6px 10px;
  }
  .admin-main { padding: 18px 14px 48px; }
  .admin-gate { min-height: 50vh; }
  .gate-card h1 { font-size: 24px; }
  .dash-card { padding: 18px 15px; }
  .dash-card-head h2 { font-size: 18px; }
  .upload-row { grid-template-columns: 1fr; }
  .kv, .kv.notes { grid-template-columns: 78px 1fr; gap: 8px; }
  .item-head { flex-wrap: wrap; }
  .item-foot { flex-direction: column; align-items: flex-start; gap: 8px; }
  .item-foot .actions { width: 100%; flex-wrap: wrap; }
  .item-foot .actions .mini-btn { flex: 1; }
  .queue { max-height: none; }
}

/* Very small screens: audit log becomes a single readable column. */
@media (max-width: 400px) {
  .audit-row { grid-template-columns: 1fr; gap: 2px; }
  .audit-time, .audit-detail { grid-column: auto; }
}
