/* ============================================================
   UVLIS — Referrals. Apple-glass premium: translucent surfaces,
   backdrop blur, quiet color, system typography. Self-contained
   (does NOT load tienda.css). Mobile-first — the whole document
   scrolls on mobile (iOS-safe) and the toast never overlaps the
   buttons.
   ============================================================ */

:root {
  --rf-font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', sans-serif;
  --rf-glass: rgba(255, 255, 255, 0.045);
  --rf-glass-hi: rgba(255, 255, 255, 0.08);
  --rf-line: rgba(255, 255, 255, 0.09);
  --rf-line-soft: rgba(255, 255, 255, 0.05);
  --rf-blur: blur(24px) saturate(160%);
  --rf-ink: #f5f5f7;
  --rf-dim: #a6a6b0;
  --rf-faint: #6f6f7a;
  --rf-gold: #f5b544;
}

/* ── Shell / layout ───────────────────────────────────────── */
.ref-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  font-family: var(--rf-font);
  background:
    radial-gradient(1100px 620px at 80% -10%, rgba(124, 58, 237, 0.10), transparent 62%),
    radial-gradient(900px 540px at 4% 0%, rgba(6, 182, 212, 0.05), transparent 55%),
    #050507;
}

.ref-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-height, 64px);
  padding: 0 18px;
  background: rgba(8, 8, 13, 0.6);
  -webkit-backdrop-filter: var(--rf-blur);
  backdrop-filter: var(--rf-blur);
  border-bottom: 1px solid var(--rf-line-soft);
  position: sticky;
  top: 0;
  z-index: 20;
}
.ref-topbar-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 1.02rem;
  color: var(--rf-ink);
}
.ref-topbar-title svg { width: 19px; height: 19px; }

.ref-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ref-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 36px 24px 64px;
}

/* ── Hero ─────────────────────────────────────────────────── */
.ref-hero {
  text-align: center;
  margin-bottom: 30px;
}
.ref-hero-badge {
  display: inline-block;
  padding: 6px 14px;
  background: var(--rf-glass);
  border: 1px solid var(--rf-line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--rf-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.ref-hero h1 {
  font-family: var(--rf-font);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--rf-ink);
  margin: 0 0 12px;
  line-height: 1.1;
}
.ref-hero p {
  color: var(--rf-dim);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.65;
}
.ref-reward-amount {
  color: var(--rf-gold);
  font-weight: 600;
}

/* ── Cards ────────────────────────────────────────────────── */
.ref-card {
  background: var(--rf-glass);
  border: 1px solid var(--rf-line);
  -webkit-backdrop-filter: var(--rf-blur);
  backdrop-filter: var(--rf-blur);
  border-radius: 24px;
  padding: 24px;
  margin-bottom: 18px;
}
.ref-card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  color: var(--rf-ink);
}

/* Link box (read-only display of the link) */
.ref-linkbox {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--rf-line);
  border-radius: 14px;
  color: var(--rf-ink);
  font-size: 0.95rem;
  padding: 15px;
  font-family: ui-monospace, 'SF Mono', 'Fira Code', monospace;
  line-height: 1.4;
  word-break: break-all;
  -webkit-user-select: all;
  user-select: all;
}

.ref-code-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.ref-code-label { color: var(--rf-dim); font-size: 0.9rem; }
.ref-code {
  font-family: ui-monospace, 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 0.15em;
  color: var(--rf-ink);
  background: var(--rf-glass-hi);
  border: 1px solid var(--rf-line);
  border-radius: 10px;
  padding: 6px 14px;
}

/* Actions */
.ref-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}
.ref-btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--rf-line);
  background: var(--rf-glass);
  color: var(--rf-dim);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.ref-btn:hover { color: var(--rf-ink); background: var(--rf-glass-hi); border-color: rgba(255, 255, 255, 0.16); transform: translateY(-1px); }
.ref-btn:active { transform: scale(0.97); }
.ref-btn svg { flex-shrink: 0; }
.ref-btn-primary {
  background: #fff;
  color: #050507;
  border-color: transparent;
  box-shadow: 0 8px 20px -8px rgba(255, 255, 255, 0.3);
}
.ref-btn-primary:hover { background: #e9e9ef; color: #050507; border-color: transparent; }
.ref-btn-whatsapp:hover { border-color: rgba(37, 211, 102, 0.5); color: #25d366; }

/* ── Stats ────────────────────────────────────────────────── */
.ref-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.ref-stat {
  background: var(--rf-glass);
  border: 1px solid var(--rf-line);
  -webkit-backdrop-filter: var(--rf-blur);
  backdrop-filter: var(--rf-blur);
  border-radius: 20px;
  padding: 20px;
  text-align: center;
}
.ref-stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--rf-ink);
  font-variant-numeric: tabular-nums;
}
.ref-stat-value.gold { color: var(--rf-gold); }
.ref-stat-label {
  font-size: 0.7rem;
  color: var(--rf-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 6px;
}

/* ── Invitees list ────────────────────────────────────────── */
.ref-list { display: flex; flex-direction: column; gap: 8px; }
.ref-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--rf-line-soft);
  border-radius: 14px;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.ref-list-item:hover { background: var(--rf-glass); border-color: var(--rf-line); }
.ref-list-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.ref-list-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ref-list-info { flex: 1; min-width: 0; }
.ref-list-name { font-weight: 600; color: var(--rf-ink); }
.ref-list-date { font-size: 0.78rem; color: var(--rf-faint); margin-top: 2px; }
.ref-list-reward {
  font-weight: 600;
  color: var(--rf-gold);
  font-size: 0.92rem;
  white-space: nowrap;
}
.ref-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--rf-faint);
}
.ref-empty-icon { font-size: 2.2rem; display: block; margin-bottom: 10px; opacity: 0.6; }

/* ── Toast (own; bottom-anchored, never full-height, never blocks) ── */
.ref-toast-container {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none; /* critical: container itself never intercepts taps */
  width: max-content;
  max-width: calc(100vw - 32px);
}
.ref-toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: rgba(22, 22, 30, 0.82);
  border: 1px solid var(--rf-line);
  -webkit-backdrop-filter: var(--rf-blur);
  backdrop-filter: var(--rf-blur);
  border-radius: 999px;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.85);
  color: var(--rf-ink);
  font-size: 0.9rem;
  font-weight: 600;
  animation: refToastIn 0.25s ease both;
}
.ref-toast.out { animation: refToastOut 0.2s ease both; }
@keyframes refToastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes refToastOut { to { opacity: 0; transform: translateY(12px); } }

/* ── Mobile: document scrolls natively (iOS-safe) ─────────── */
@media (max-width: 768px) {
  .ref-body .chat-page {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .ref-main { min-height: 100dvh; }
  .ref-scroll { overflow: visible; min-height: 0; }
}

@media (max-width: 600px) {
  .ref-content { padding: 24px 14px calc(48px + env(safe-area-inset-bottom)); }
  .ref-actions { grid-template-columns: 1fr; }
  .ref-stats { grid-template-columns: 1fr; }
}
