/* frontend-user/css/referral.css */

/* ===== REFERRAL PAGE – MOBILE-FIRST ===== */

/* Fixed header */
.fixed-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-row.top {
    margin-bottom: 0.3rem;
}
.header-row .left-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.header-row .left-group img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}
.header-row .left-group .brand {
    font-weight: 600;
    font-size: 1.2rem;
}
.header-row .left-group .btn-text {
    font-size: 0.9rem;
    padding: 0.3rem 0.6rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
}
.header-row .left-group .btn-text:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.header-row .right-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.header-row .btn-outline {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 0.3rem 0.6rem;
    border-radius: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.header-row .btn-outline:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.header-row.bottom .title-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.header-row.bottom .title-area h1 {
    font-size: 1.2rem;
    margin: 0;
}
#header-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Main content */
main {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

/* Referral header */
.referral-header {
    margin-bottom: 2rem;
}
.referral-header h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.code-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 0.5rem 0;
}
.code-display .code {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 2px dashed var(--accent);
    letter-spacing: 2px;
    font-family: monospace;
}
.earn-info {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}
.earn-info strong {
    color: var(--success);
}

/* Wallet section */
.wallet-section {
    margin-bottom: 2rem;
}
.wallet-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.wallet-balance {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
.wallet-balance .label {
    font-size: 1rem;
    color: var(--text-secondary);
}
.wallet-balance .amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}
.wallet-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.stat {
    text-align: center;
}
.stat .stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat .stat-value {
    font-size: 1.25rem;
    font-weight: 600;
}
.withdraw-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.5rem;
}

/* Referrals section */
.referrals-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.referrals-section h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}
.referral-list {
    max-height: 400px;
    overflow-y: auto;
}
.referral-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}
.referral-item:last-child {
    border-bottom: none;
}
.referral-item.active {
    border-left: 3px solid var(--success);
    padding-left: 0.75rem;
}
.ref-info {
    display: flex;
    flex-direction: column;
}
.ref-name {
    font-weight: 500;
}
.ref-email {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.ref-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.ref-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Agent badge */
.agent-badge {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
}
.become-agent {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    text-align: center;
    border: 1px dashed var(--border);
}
.become-agent a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}
.become-agent a:hover {
    text-decoration: underline;
}

/* Withdrawal status */
.withdraw-status {
    margin-top: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}
.withdraw-status.success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}
.withdraw-status.error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}
.withdraw-status.info {
    background: rgba(37, 99, 235, 0.2);
    color: var(--accent);
}

/* No data */
.no-data {
    color: var(--text-muted);
    font-style: italic;
    padding: 1rem 0;
    text-align: center;
}

/* Error state */
.error-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.error-state p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* Action buttons */
.action-buttons {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Modal (withdrawal) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 1rem;
}
.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}
.modal-body .form-group {
    margin-bottom: 1rem;
}
.modal-body .form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}
.modal-body .form-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
}
.modal-footer {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

/* Responsive */
@media (max-width: 640px) {
    .code-display {
        flex-direction: column;
        align-items: stretch;
    }
    .code-display .code {
        text-align: center;
        font-size: 1.2rem;
        padding: 0.4rem 0.8rem;
    }
    .code-display .btn {
        width: 100%;
    }
    .referral-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .wallet-stats {
        grid-template-columns: 1fr 1fr;
    }
    .wallet-balance {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    .modal {
        margin: 1rem;
        padding: 1rem;
    }
}