/* =====================================================================
   Serva - Referral page
   Phase 1 referral dashboard with link sharing, stats, rank progress,
   and recent referral activity.
   ===================================================================== */

.referral-page-wrap {
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(0, 180, 255, 0.08), transparent 38%),
        radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.07), transparent 48%),
        radial-gradient(circle at 50% 0%, rgba(168, 85, 247, 0.06), transparent 46%),
        #030816;
}

.referral-page-shell {
    max-width: none;
    margin: 0;
    padding: 2rem clamp(1rem, 3vw, 2.5rem) 4rem;
}

.referral-top-bar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 1rem;
}

.referral-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(0, 180, 255, 0.18);
    background: rgba(8, 18, 38, 0.74);
    color: #bfefff;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.referral-back-link:hover {
    transform: translateY(-1px);
    border-color: rgba(0, 224, 255, 0.44);
    background: rgba(0, 180, 255, 0.12);
}

.referral-page-hero {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.5rem;
    padding: clamp(1.35rem, 3vw, 2.25rem);
    margin-bottom: 1.25rem;
    border: 1px solid rgba(0, 180, 255, 0.16);
    border-radius: 30px;
    background:
        radial-gradient(circle at top left, rgba(0, 224, 255, 0.16), transparent 34%),
        radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.12), transparent 38%),
        linear-gradient(140deg, rgba(6, 14, 32, 0.96), rgba(3, 8, 20, 0.98));
    box-shadow: 0 22px 58px rgba(0, 0, 0, 0.36);
}

.referral-page-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.45;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, black, transparent 84%);
}

.referral-hero-copy {
    position: relative;
    z-index: 1;
}

.referral-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.38rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(34, 197, 94, 0.28);
    background: rgba(16, 185, 129, 0.12);
    color: #7af7b2;
    font-size: 0.84rem;
    font-weight: 800;
    margin-bottom: 0.85rem;
}

.referral-page-hero h1 {
    margin: 0 0 0.8rem;
    font-size: clamp(1.9rem, 4.6vw, 3.25rem);
    line-height: 1.08;
    letter-spacing: -0.02em;
}

.referral-page-hero p {
    margin: 0;
    max-width: 760px;
    color: var(--text-secondary);
    line-height: 1.9;
    font-weight: 600;
}

.referral-hero-orb {
    position: relative;
    z-index: 1;
    width: clamp(110px, 18vw, 190px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.34), transparent 20%),
        linear-gradient(145deg, rgba(0, 224, 255, 0.34), rgba(16, 185, 129, 0.18));
    border: 1px solid rgba(0, 224, 255, 0.32);
    box-shadow:
        0 0 55px rgba(0, 224, 255, 0.18),
        inset 0 0 30px rgba(255, 255, 255, 0.08);
}

.referral-hero-orb i {
    font-size: clamp(2.2rem, 6vw, 4.7rem);
    color: #eaffff;
    text-shadow: 0 0 18px rgba(0, 224, 255, 0.7);
}

.referral-orb-ring {
    position: absolute;
    inset: 14%;
    border-radius: 50%;
    border: 1px dashed rgba(255, 255, 255, 0.32);
    animation: referralSpin 18s linear infinite;
}

.referral-link-card,
.referral-rank-progress,
.referral-withdraw-card,
.referral-recent {
    border: 1px solid rgba(0, 180, 255, 0.16);
    border-radius: 24px;
    background: linear-gradient(150deg, rgba(8, 16, 36, 0.94), rgba(4, 8, 20, 0.92));
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.28);
}

.referral-link-card {
    position: relative;
    overflow: hidden;
    padding: clamp(1rem, 2.5vw, 1.4rem);
    margin-bottom: 1rem;
}

.referral-link-card::after {
    content: "";
    position: absolute;
    inset: auto -6rem -8rem auto;
    width: 18rem;
    height: 18rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.2), transparent 68%);
    pointer-events: none;
}

.referral-link-label {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #7ee7ff;
    font-weight: 800;
    margin-bottom: 0.75rem;
}

.referral-link-value-row {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.65rem;
    align-items: stretch;
}

.referral-link-value {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    direction: ltr;
    text-align: left;
    overflow: auto;
    color: #dffbff;
    background: rgba(0, 0, 0, 0.26);
    border: 1px solid rgba(0, 224, 255, 0.18);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 0.95rem;
    white-space: nowrap;
}

.referral-copy-btn,
.referral-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 48px;
    white-space: nowrap;
}

.referral-link-hint {
    position: relative;
    z-index: 1;
    margin: 0.85rem 0 0;
    color: var(--text-secondary);
    line-height: 1.75;
    font-size: 0.93rem;
}

.referral-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.referral-stat-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: linear-gradient(150deg, rgba(8, 16, 36, 0.96), rgba(4, 8, 20, 0.92));
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.referral-stat-card:hover {
    transform: translateY(-2px);
}

.referral-stat-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto auto;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(26%, -30%);
    opacity: 0.72;
}

.referral-stat-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 700;
}

.referral-stat-value {
    color: #fff;
    font-size: clamp(1.55rem, 3vw, 2rem);
    font-weight: 800;
    line-height: 1.1;
    direction: ltr;
    text-align: right;
}

.referral-stat--total {
    border-color: rgba(0, 224, 255, 0.28);
}

.referral-stat--total::before {
    background: radial-gradient(circle, rgba(0, 224, 255, 0.2), transparent 70%);
}

.referral-stat--total .referral-stat-label {
    color: #7ee7ff;
}

.referral-stat--monthly {
    border-color: rgba(168, 85, 247, 0.28);
}

.referral-stat--monthly::before {
    background: radial-gradient(circle, rgba(168, 85, 247, 0.2), transparent 70%);
}

.referral-stat--monthly .referral-stat-label {
    color: #d0afff;
}

.referral-stat--balance {
    border-color: rgba(34, 197, 94, 0.3);
}

.referral-stat--balance::before {
    background: radial-gradient(circle, rgba(34, 197, 94, 0.22), transparent 70%);
}

.referral-stat--balance .referral-stat-label {
    color: #8ef3b7;
}

.referral-stat--pending {
    border-color: rgba(245, 158, 11, 0.34);
}

.referral-stat--pending::before {
    background: radial-gradient(circle, rgba(245, 158, 11, 0.22), transparent 70%);
}

.referral-stat--pending .referral-stat-label {
    color: #ffd17a;
}

.referral-rank-progress {
    padding: clamp(1rem, 2.5vw, 1.35rem);
    margin-bottom: 1rem;
}

.referral-rank-head {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.referral-rank-current,
.referral-rank-next {
    min-height: 132px;
    padding: 1.1rem;
    border-radius: 20px;
    border: 1px solid rgba(0, 224, 255, 0.14);
    background:
        radial-gradient(circle at top right, rgba(0, 224, 255, 0.1), transparent 50%),
        rgba(0, 0, 0, 0.16);
}

.referral-rank-current {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.referral-rank-current-text {
    min-width: 0;
}

.referral-rank-badge {
    width: 72px;
    height: 72px;
    flex: 0 0 auto;
    object-fit: contain;
    filter: drop-shadow(0 6px 14px rgba(0, 224, 255, 0.28));
}

.referral-rank-badge.hidden {
    display: none;
}

.referral-ranks-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 14px;
    border: 1px solid rgba(0, 224, 255, 0.2);
    background: rgba(0, 224, 255, 0.06);
    color: #aef0ff;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.referral-ranks-link:hover {
    background: rgba(0, 224, 255, 0.12);
    border-color: rgba(0, 224, 255, 0.35);
}

.referral-ranks-link span {
    flex: 1 1 auto;
}

.referral-rank-next {
    border-color: rgba(34, 197, 94, 0.16);
    background:
        radial-gradient(circle at top right, rgba(34, 197, 94, 0.12), transparent 50%),
        rgba(0, 0, 0, 0.16);
}

.referral-rank-eyebrow {
    display: block;
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.referral-rank-current strong,
.referral-rank-next strong {
    display: block;
    color: #fff;
    font-size: 1.55rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.referral-rank-percent,
#referralRefsRemaining {
    color: #79e7ff;
    font-weight: 800;
}

.referral-progress-track {
    position: relative;
    height: 16px;
    overflow: hidden;
    border-radius: 999px;
    border: 1px solid rgba(0, 224, 255, 0.18);
    background: rgba(0, 0, 0, 0.3);
}

.referral-progress-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #22c55e, #00e0ff, #8b5cf6);
    box-shadow: 0 0 18px rgba(0, 224, 255, 0.28);
    transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.referral-emperor-banner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.95rem 1rem;
    margin-bottom: 1rem;
    border-radius: 18px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.12);
    color: #ffd17a;
    font-weight: 800;
}

.referral-withdraw-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.referral-withdraw-card {
    padding: clamp(1rem, 2.5vw, 1.35rem);
}

.referral-section-head--compact {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 0.9rem;
}

.referral-section-head--compact h2 {
    font-size: 1.12rem;
}

.referral-form-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.65rem;
}

.referral-form-row--stack {
    grid-template-columns: minmax(0, 1fr);
}

.referral-input {
    width: 100%;
    min-height: 48px;
    padding: 0.85rem 1rem;
    border-radius: 15px;
    border: 1px solid rgba(0, 224, 255, 0.16);
    background: rgba(0, 0, 0, 0.24);
    color: #fff;
    font-family: inherit;
    font-weight: 700;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.referral-input:focus {
    border-color: rgba(0, 224, 255, 0.42);
    box-shadow: 0 0 0 3px rgba(0, 224, 255, 0.08);
}

.referral-textarea {
    min-height: 96px;
    resize: vertical;
    line-height: 1.7;
}

.referral-action-btn {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    white-space: nowrap;
}

.referral-action-btn[disabled] {
    opacity: 0.62;
    cursor: wait;
}

.referral-cash-methods {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    margin-bottom: 0.65rem;
}

.referral-method-option {
    cursor: pointer;
}

.referral-method-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.referral-method-option span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 48px;
    padding: 0.75rem 1rem;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-weight: 900;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.referral-method-option input:checked + span {
    border-color: rgba(0, 224, 255, 0.42);
    background: rgba(0, 224, 255, 0.1);
    color: #aef0ff;
}

.referral-withdraw-note {
    margin: 0.75rem 0 0;
    color: var(--text-secondary);
    font-size: 0.86rem;
    line-height: 1.75;
}

.referral-recent {
    padding: clamp(1rem, 2.5vw, 1.35rem);
}

.referral-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.referral-section-head h2 {
    margin: 0;
    font-size: 1.25rem;
}

.referral-section-head p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.referral-recent-list {
    display: grid;
    gap: 0.75rem;
}

.referral-recent-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid rgba(0, 180, 255, 0.12);
    background: rgba(255, 255, 255, 0.035);
}

.referral-recent-main {
    display: grid;
    gap: 0.25rem;
}

.referral-recent-main strong {
    color: #fff;
    font-size: 1rem;
}

.referral-recent-date {
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.referral-recent-trailing {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.referral-recent-amount {
    direction: ltr;
    color: #8ef3b7;
    font-weight: 900;
}

.referral-recent-status {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.78rem;
    font-weight: 800;
}

.referral-recent-status.tone-success {
    color: #8ef3b7;
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.26);
}

.referral-recent-status.tone-warning {
    color: #ffd17a;
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.28);
}

.referral-recent-status.tone-danger {
    color: #ff9c9c;
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.28);
}

.referral-recent-status.tone-muted {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.referral-empty {
    display: grid;
    place-items: center;
    gap: 0.65rem;
    min-height: 190px;
    color: var(--text-secondary);
    text-align: center;
    border: 1px dashed rgba(0, 180, 255, 0.2);
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.14);
}

.referral-empty i {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: #7ee7ff;
    background: rgba(0, 224, 255, 0.12);
    font-size: 1.45rem;
}

.referral-empty p {
    margin: 0;
    max-width: 360px;
    line-height: 1.75;
}

@keyframes referralSpin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 920px) {
    .referral-page-hero {
        grid-template-columns: minmax(0, 1fr);
    }

    .referral-hero-orb {
        justify-self: center;
    }

    .referral-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .referral-page-shell {
        padding: 1rem 0.85rem 3rem;
    }

    .referral-link-value-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .referral-copy-btn,
    .referral-share-btn {
        width: 100%;
    }

    .referral-rank-head {
        grid-template-columns: minmax(0, 1fr);
    }

    .referral-withdraw-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .referral-form-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .referral-section-head {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .referral-page-hero,
    .referral-link-card,
    .referral-rank-progress,
    .referral-recent {
        border-radius: 20px;
    }

    .referral-summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .referral-recent-item {
        grid-template-columns: minmax(0, 1fr);
    }

    .referral-recent-trailing {
        justify-content: flex-start;
    }
}
