/* ============================================================
   Spill — ambassador portal styles (dashboard, leaderboard, admin, join)
   Consumes tokens from styles.css :root. RESTYLE ONLY — hooks preserved.
   ============================================================ */

.portal {
  width: min(1100px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) 0 80px;
}

.portal-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.portal-title h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 0.96;
  margin: 6px 0 0;
}

.portal-title .eyebrow {
  margin: 0;
}

.portal-title .muted {
  margin: 6px 0 0;
}

.portal-nav {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 800;
  color: var(--text-muted);
}

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04));
  box-shadow: var(--shadow-md);
  padding: 22px;
}

/* ---------- Metrics ---------- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  transition: transform var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out);
}

.metric:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.24);
}

.metric .metric-value {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: clamp(2rem, 4vw, 2.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric .metric-label {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric.rank .metric-value {
  background: var(--cta-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Two-column portal grid ---------- */
.portal-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

/* ---------- Referral link ---------- */
.referral-link {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.referral-link input {
  flex: 1;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.06);
  color: white;
  padding: 0 14px;
  font-family: Inter, system-ui, -apple-system, sans-serif;
}

/* ---------- Buttons ---------- */
.btn {
  border: 0;
  border-radius: var(--r-pill);
  background: var(--cta-grad);
  color: white;
  cursor: pointer;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-weight: 600;
  padding: 12px 20px;
  min-height: 44px;
  box-shadow: 0 12px 26px rgba(242, 43, 212, 0.26);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), filter var(--t-fast) var(--ease-out);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(242, 43, 212, 0.38);
  filter: saturate(1.08);
}

.btn:active {
  transform: translateY(0);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.ghost:hover {
  background: var(--surface-2);
  filter: none;
}

.btn.small {
  padding: 8px 14px;
  min-height: 36px;
  font-size: 0.85rem;
}

/* ---------- Content vault card ---------- */
.vault-card {
  border-color: rgba(255, 232, 71, 0.34);
  background:
    radial-gradient(circle at 88% 0%, rgba(255, 157, 31, 0.16), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04));
}

/* ---------- QR card ---------- */
.qr-card {
  text-align: center;
}

.qr-card canvas,
.qr-card img {
  width: 220px;
  height: 220px;
  border-radius: var(--r-md);
  background: white;
  padding: 10px;
  margin: 12px auto;
  box-shadow: var(--shadow-sm);
}

.qr-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ---------- Charts ---------- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.chart-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-weight: 600;
}

.chart svg {
  width: 100%;
  height: 140px;
  display: block;
}

.bar-click {
  fill: var(--accent);
}

.bar-signup {
  fill: var(--primary);
}

/* ---------- Tables (leaderboard / admin) ---------- */
.card:has(> .lb-table) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
}

@media (max-width: 860px) {
  .lb-table {
    min-width: 600px;
  }
}

.lb-table th,
.lb-table td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
}

.lb-table th {
  color: var(--text-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lb-table tbody tr {
  transition: background var(--t-fast) var(--ease-out);
}

.lb-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.lb-table td.num,
.lb-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.lb-rank {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
}

.lb-table tr:nth-child(1) .lb-rank {
  background: linear-gradient(135deg, var(--warm), var(--highlight));
  color: #2a0030;
}

.lb-table tr:nth-child(2) .lb-rank {
  background: linear-gradient(135deg, #cfd3dc, #9aa0ad);
  color: #1b1d22;
}

.lb-table tr:nth-child(3) .lb-rank {
  background: linear-gradient(135deg, #e0a36b, #b9763a);
  color: #2a1300;
}

/* ---------- Gate (token / secret entry) ---------- */
.gate {
  width: min(440px, 100%);
  margin: 12vh auto 0;
  text-align: center;
}

.gate h1 {
  font-size: 2rem;
}

.gate input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.06);
  color: white;
  padding: 0 14px;
  margin: 12px 0;
}

.gate input:focus {
  border-color: var(--highlight);
  box-shadow: 0 0 0 4px rgba(255, 232, 71, 0.16);
  outline: none;
}

/* ---------- Status pills ---------- */
.status-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-active {
  background: rgba(82, 224, 150, 0.18);
  color: #7df0b3;
}

.status-disabled {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.status-flagged {
  background: rgba(255, 109, 109, 0.18);
  color: #ff9a9a;
}

/* ---------- Live dot (SVG) ---------- */
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  color: var(--text-muted);
}

.live-dot svg {
  width: 12px;
  height: 12px;
}

.live-dot .pulse {
  transform-origin: center;
  animation: live-pulse 1.8s var(--ease-out) infinite;
}

@keyframes live-pulse {
  0% { opacity: 1; transform: scale(1); }
  70% { opacity: 0.25; transform: scale(1.8); }
  100% { opacity: 0; transform: scale(2.2); }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: white;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-weight: 800;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Utilities ---------- */
.muted {
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

/* ---------- Admin form ---------- */
.admin-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.admin-form .field {
  font-size: 0.8rem;
}

.admin-form input,
.admin-form select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.06);
  color: white;
  padding: 0 12px;
}

.admin-form input:focus,
.admin-form select:focus {
  border-color: var(--highlight);
  box-shadow: 0 0 0 4px rgba(255, 232, 71, 0.16);
  outline: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

@media (max-width: 860px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .portal-grid,
  .charts-grid,
  .admin-form {
    grid-template-columns: 1fr;
  }
}

/* ---- Legal consent (join flow) ---- */
.consent {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  padding: 14px 16px 6px;
  margin: 14px 0 4px;
}
.consent legend {
  padding: 0 6px;
}
.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.consent-row input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}
.consent-row a {
  text-decoration: underline;
  font-weight: 700;
}
