/* ============================================================
   Referral Page Styles
   Uses app theme tokens: --bg, --bg2, --text, --hint,
   --accent, --accent-soft, --border, --nav-border
   Icons are inline SVG (no emoji) for a clean modern UI.
   ============================================================ */

/* === View container === */
.referral-view {
    padding: 16px 14px 110px;
    max-width: 480px;
    margin: 0 auto;
    box-sizing: border-box;
    animation: refFadeIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes refFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* === Header === */
.referral-header { margin-bottom: 16px; }
.referral-header h1 {
    font-size: 26px;
    font-weight: 800;
    margin: 0 0 4px;
    color: var(--text);
    letter-spacing: -0.02em;
}
.referral-header p {
    font-size: 14px;
    margin: 0;
    color: var(--hint);
}

/* === Hero card (referral link) === */
.ref-hero {
    background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 70%, #6b46ff) 100%);
    border-radius: 22px;
    padding: 22px 18px;
    color: #fff;
    box-shadow: 0 12px 30px -10px color-mix(in srgb, var(--accent) 60%, transparent);
    margin-bottom: 14px;
    position: relative;
    overflow: hidden;
}
.ref-hero::before {
    content: "";
    position: absolute;
    top: -40px;
    right: -40px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
}
.ref-hero::after {
    content: "";
    position: absolute;
    bottom: -30px;
    left: -20px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}
.ref-hero-content { position: relative; z-index: 1; }
.ref-hero-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin-bottom: 12px;
}
.ref-hero-title {
    font-size: 18px;
    font-weight: 800;
    margin: 0 0 5px;
    line-height: 1.3;
    letter-spacing: -0.01em;
}
.ref-hero-desc {
    font-size: 13px;
    margin: 0 0 14px;
    opacity: 0.92;
    line-height: 1.5;
}
.ref-hero-link-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 12px;
    padding: 4px 4px 4px 12px;
    backdrop-filter: blur(6px);
}
.ref-hero-link {
    flex: 1;
    font-size: 12px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.2px;
    opacity: 0.95;
}
.ref-copy-btn {
    background: #fff;
    color: var(--accent);
    border: none;
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s ease, opacity 0.12s ease, background 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}
.ref-copy-btn svg { flex-shrink: 0; }
.ref-copy-btn:active { transform: scale(0.94); opacity: 0.85; }
.ref-copy-btn.copied { background: #34c759; color: #fff; }

/* === Share button row under hero === */
.ref-share-row { display: flex; gap: 8px; margin-top: 10px; }
.ref-share-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 11px;
    padding: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform 0.12s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}
.ref-share-btn:active { transform: scale(0.96); }
.ref-share-btn:hover { background: rgba(255, 255, 255, 0.26); }

/* === Stats row === */
.ref-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.ref-stat {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 6px;
    text-align: center;
    transition: transform 0.12s ease;
}
.ref-stat:active { transform: scale(0.97); }
.ref-stat-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 6px;
}
.ref-stat-icon svg { width: 17px; height: 17px; }
.ref-stat-value {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.01em;
}
.ref-stat-label {
    font-size: 10px;
    color: var(--hint);
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

/* === Section title === */
.ref-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 4px 2px 10px;
}
.ref-section-title h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.ref-section-title .ref-count {
    font-size: 12px;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 700;
}

/* === Invite list === */
.ref-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ref-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 11px 13px;
    cursor: pointer;
    transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease;
    animation: refSlideIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ref-item:hover { background: color-mix(in srgb, var(--accent) 5%, var(--bg)); }
.ref-item:active { transform: scale(0.98); }
@keyframes refSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ref-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--accent);
    font-size: 16px;
    border: 1.5px solid var(--border);
}
.ref-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ref-item-info { flex: 1; min-width: 0; }
.ref-item-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ref-item-meta {
    font-size: 11.5px;
    color: var(--hint);
    display: flex;
    align-items: center;
    gap: 5px;
}
.ref-item-meta svg { opacity: 0.7; flex-shrink: 0; }
.ref-item-status {
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 10px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ref-item-status.active {
    background: color-mix(in srgb, #34c759 18%, transparent);
    color: #34c759;
}
.ref-item-status.pending {
    background: color-mix(in srgb, #ff9f0a 18%, transparent);
    color: #ff9f0a;
}
.ref-item-chevron {
    color: var(--hint);
    flex-shrink: 0;
    opacity: 0.5;
    display: flex;
    align-items: center;
}

/* === Empty state === */
.ref-empty {
    text-align: center;
    padding: 40px 20px;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 18px;
}
.ref-empty-icon {
    color: var(--accent);
    opacity: 0.6;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
}
.ref-empty-text {
    font-size: 14.5px;
    color: var(--text);
    font-weight: 700;
    margin: 0 0 4px;
}
.ref-empty-hint {
    font-size: 12.5px;
    color: var(--hint);
    margin: 0;
    line-height: 1.5;
}

/* === Skeleton loading === */
.ref-skeleton { display: flex; flex-direction: column; gap: 10px; }
.ref-skeleton > div {
    background: linear-gradient(90deg, var(--bg) 25%, color-mix(in srgb, var(--bg) 60%, var(--bg2)) 50%, var(--bg) 75%);
    background-size: 200% 100%;
    animation: refShimmer 1.4s infinite;
    border-radius: 16px;
}
.ref-skeleton-card { height: 200px; }
.ref-skeleton-card-sm { height: 80px; }
.ref-skeleton-item { height: 64px; }
@keyframes refShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   Referral Detail Modal (opens when avatar/name tapped)
   ============================================================ */
.ref-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}
.ref-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.ref-modal {
    background: var(--bg2);
    width: 100%;
    max-width: 480px;
    border-radius: 24px 24px 0 0;
    padding: 8px 20px 28px;
    transform: translateY(100%);
    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
}
.ref-modal-overlay.active .ref-modal { transform: translateY(0); }
.ref-modal-handle {
    width: 38px;
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    margin: 0 auto 18px;
}

.ref-modal-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 22px;
}
.ref-modal-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 12px;
    border: 2.5px solid var(--accent);
    overflow: hidden;
}
.ref-modal-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ref-modal-name {
    font-size: 19px;
    font-weight: 800;
    color: var(--text);
    margin: 0 0 3px;
    letter-spacing: -0.01em;
}
.ref-modal-username {
    font-size: 13px;
    color: var(--hint);
    margin: 0;
}

.ref-modal-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 22px;
}
.ref-modal-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 13px 15px;
}
.ref-modal-stat-label {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13.5px;
    color: var(--hint);
    font-weight: 600;
}
.ref-modal-stat-label svg {
    color: var(--accent);
    opacity: 0.8;
    flex-shrink: 0;
}
.ref-modal-stat-value {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
    text-align: right;
}
.ref-modal-stat-value.success { color: #34c759; }
.ref-modal-stat-value.muted { color: var(--hint); font-weight: 700; }

.ref-modal-close {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s ease, opacity 0.12s ease;
}
.ref-modal-close:active { transform: scale(0.98); opacity: 0.9; }
