/* ============================================================
   referrals.css — Page-specific styles for referrals.html
   Foundation tokens: variables.css
   Base layout:       base.css
   Shared components: components.css
   This file adds only what is unique to the Referrals page.
   ============================================================ */

/* ── Loading overlay ─────────────────────────────────────────── */

.ref-loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.ref-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-neutral);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: ref-spin 0.75s linear infinite;
}

@keyframes ref-spin {
  to { transform: rotate(360deg); }
}

/* ── Page header icon button ─────────────────────────────────── */

.ref-icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-full);
  color: var(--gold);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.ref-icon-btn:hover { background: var(--gold-glow); }

.ref-add-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ── Search ───────────────────────────────────────────────────── */

.ref-search-wrap {
  position: relative;
  margin-bottom: var(--sp-5);
}

.ref-search-icon {
  position: absolute;
  left: var(--sp-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.ref-search-bar {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-neutral);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  padding: var(--sp-3) var(--sp-4) var(--sp-3) calc(var(--sp-4) + 16px + var(--sp-2));
  outline: none;
  transition: border-color var(--transition-fast);
}

.ref-search-bar:focus { border-color: var(--gold); }
.ref-search-bar::placeholder { color: var(--text-muted); }

/* ── Stats row ────────────────────────────────────────────────── */

.ref-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.ref-stat-card {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--sp-4) var(--sp-2);
  gap: var(--sp-1);
}

.ref-stat-card .stat-card-value { font-size: var(--text-xl); }

.ref-stat-value--warning { color: var(--warning); }
.ref-stat-value--success { color: var(--success); }
.ref-stat-value--danger  { color: var(--danger);  }

@media (max-width: 500px) {
  .ref-stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-2);
  }
}

/* ── Referral list ────────────────────────────────────────────── */

.ref-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.ref-card {
  background: var(--bg-card);
  border: 1px solid var(--border-neutral);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5);
  transition: border-color var(--transition-fast);
}

.ref-card:hover { border-color: var(--gold-border); }

.ref-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.ref-card-name {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.ref-card-contact {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.ref-code-pill {
  display: inline-block;
  background: var(--bg-input);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.ref-card-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--border-neutral);
  border-bottom: 1px solid var(--border-neutral);
  margin-bottom: var(--sp-3);
}

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

.ref-metric-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}

.ref-metric-value {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
}

.ref-metric-value--success { color: var(--success); }
.ref-metric-value--warning { color: var(--warning); }
.ref-metric-value--danger  { color: var(--danger); }

.ref-card-bottom {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
}

.ref-mini-btn {
  background: transparent;
  border: 1px solid var(--border-neutral);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.ref-mini-btn:hover { border-color: var(--gold); background: var(--gold-glow); }

/* ── Empty state ──────────────────────────────────────────────── */

.ref-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--sp-10) var(--sp-4);
  color: var(--text-muted);
}

.ref-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--sp-4);
  opacity: 0.5;
}

.ref-empty p {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-1);
}

.ref-empty span { font-size: var(--text-sm); }

/* ── Modals ───────────────────────────────────────────────────── */

.ref-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  z-index: 9000;
  animation: ref-fade-in 0.15s ease;
}

@keyframes ref-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ref-modal {
  max-width: 420px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: ref-modal-up 0.18s ease;
}

@keyframes ref-modal-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ref-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.ref-modal-header .modal-title { margin-bottom: 0; }

.ref-modal-close {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.ref-modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.ref-field-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: var(--sp-3) 0 6px;
}

.ref-field-label:first-child { margin-top: 0; }

.ref-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-neutral);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  padding: var(--sp-3);
  outline: none;
  transition: border-color var(--transition-fast);
}

.ref-input:focus { border-color: var(--gold); }
.ref-input::placeholder { color: var(--text-muted); }

/* PIN reveal box */
.ref-pin-reveal {
  background: var(--bg-input);
  border: 1px dashed var(--gold-border);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
  margin-top: var(--sp-2);
  text-align: center;
}

.ref-pin-reveal-row {
  margin-bottom: var(--sp-3);
}

.ref-pin-reveal-row:last-of-type { margin-bottom: 0; }

.ref-pin-reveal-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}

.ref-pin-reveal-value {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 3px;
  font-family: var(--font-mono);
}

.ref-pin-reveal-note {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-4);
  line-height: 1.5;
}
