/* ====================================
   Authentication UI Styles
   ==================================== */

/* ====================================
   Login Modal
   ==================================== */

#authLoginModal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease-out;
}

#authLoginModal.hidden {
    display: none;
}

.auth-modal-content {
    background: linear-gradient(135deg, rgba(30, 27, 75, 0.98) 0%, rgba(76, 29, 149, 0.95) 100%);
    border-radius: 0;
    border: none;
    box-shadow: none;
    width: 100%;
    height: 100%;
    max-width: none;
    padding: 48px 32px;
    position: relative;
    animation: fadeIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

.auth-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.7);
}

.auth-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: rotate(90deg);
}

.auth-modal-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.auth-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
}

.auth-modal-subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
}

/* Login and Magic Link Views - constrain width on large screens */
#authLoginView,
#authMagicLinkSentView {
    width: 100%;
    max-width: 480px;
}

/* Login Form */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-form-label {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-form-input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
}

.auth-form-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.auth-form-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.auth-form-error {
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #fca5a5;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-form-error.hidden {
    display: none;
}

.auth-form-button {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.auth-form-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
}

.auth-form-button:active:not(:disabled) {
    transform: translateY(0);
}

.auth-form-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Magic Link Sent View */
.auth-success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounceIn 0.5s ease-out;
}

.auth-sent-email {
    font-weight: 600;
    color: #a78bfa;
}

.auth-modal-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.auth-footer-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
}

.auth-footer-link {
    font-size: 13px;
    color: #a78bfa;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s ease;
}

.auth-footer-link:hover {
    color: #c4b5fd;
    text-decoration: underline;
}

/* ====================================
   User HUD (Top Bar)
   ==================================== */

#authUserHUD {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.2s ease;
}

#authUserHUD:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.25);
}

#authUserHUD.hidden {
    display: none;
}

.auth-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.auth-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.auth-user-email {
    font-size: 13px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.auth-user-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
}

.auth-user-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.auth-user-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.7);
}

.auth-user-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.1);
}

/* ====================================
   Sync Status Indicator
   ==================================== */

#authSyncStatus {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

#authSyncStatus.hidden {
    display: none;
}

.auth-sync-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-sync-icon.syncing {
    color: #3b82f6;
    animation: spin 1s linear infinite;
}

.auth-sync-icon.synced {
    color: #10b981;
}

.auth-sync-icon.error {
    color: #ef4444;
}

.auth-sync-icon.offline {
    color: #f59e0b;
}

.auth-sync-text {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

/* ====================================
   Mode Indicator (Dev/Prod)
   ==================================== */

#authModeIndicator {
    position: fixed;
    bottom: 16px;
    left: 16px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 9998;
    pointer-events: none;
}

#authModeIndicator.hidden {
    display: none;
}

.auth-mode-text {
    font-size: 11px;
    font-weight: 700;
    color: #fbbf24;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ====================================
   Login Button (Top Bar)
   ==================================== */

#authLoginBtn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
}

#authLoginBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

#authLoginBtn:active {
    transform: translateY(0);
}

#authLoginBtn.hidden {
    display: none;
}

/* ====================================
   Animations
   ==================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ====================================
   Mobile Responsive
   ==================================== */

@media (max-width: 640px) {
    .auth-modal-content {
        padding: 32px 20px;
    }

    #authLoginView,
    #authMagicLinkSentView {
        max-width: 100%;
    }

    .auth-modal-title {
        font-size: 20px;
    }

    .auth-modal-subtitle {
        font-size: 13px;
    }

    .auth-user-email {
        max-width: 120px;
    }

    #authUserHUD {
        gap: 8px;
        padding: 6px 10px;
    }

    .auth-user-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .auth-user-info {
        display: none;
    }

    #authModeIndicator {
        bottom: 80px;
        left: 8px;
    }
}

/* ====================================
   Referral Panel
   ==================================== */

#referralPanel {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease-out;
}

#referralPanel.hidden {
    display: none;
}

.referral-panel-content {
    background: linear-gradient(135deg, rgba(30, 27, 75, 0.98) 0%, rgba(76, 29, 149, 0.95) 100%);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 520px;
    padding: 32px;
    position: relative;
    animation: slideInUp 0.3s ease-out;
}

.referral-panel-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.7);
}

.referral-panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: rotate(90deg);
}

.referral-panel-header {
    text-align: center;
    margin-bottom: 28px;
}

.referral-panel-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
}

.referral-panel-title {
    font-size: 24px;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
}

.referral-panel-subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
}

.referral-link-container {
    margin-bottom: 24px;
}

.referral-link-label {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: block;
}

.referral-link-input-group {
    display: flex;
    gap: 8px;
}

.referral-link-input {
    flex: 1;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-size: 14px;
    outline: none;
    font-family: monospace;
}

.referral-link-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: #8b5cf6;
}

.referral-copy-button {
    padding: 14px 20px;
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.referral-copy-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(139, 92, 246, 0.5);
}

.referral-copy-button:active:not(:disabled) {
    transform: translateY(0);
}

.referral-copy-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.referral-copy-button.copied {
    background: linear-gradient(135deg, #10b981, #059669);
}

.referral-stats-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.referral-stat-card {
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    text-align: center;
}

.referral-stat-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.referral-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: white;
}

.referral-stat-value.loading {
    color: rgba(255, 255, 255, 0.4);
    font-size: 20px;
}

.referral-info-box {
    padding: 16px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    display: flex;
    align-items: start;
    gap: 12px;
    margin-bottom: 20px;
}

.referral-info-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: #a78bfa;
}

.referral-info-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
}

/* Referral Button in Menu */
#referralMenuBtn {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(236, 72, 153, 0.2));
    border-color: rgba(139, 92, 246, 0.3);
}

#referralMenuBtn:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(236, 72, 153, 0.3));
    border-color: rgba(139, 92, 246, 0.5);
}

#referralMenuBtn i {
    color: #ec4899;
}

/* Loading State */
.referral-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.referral-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.referral-loading-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
}

/* ====================================
   Dark Mode Override (if needed)
   ==================================== */

@media (prefers-color-scheme: dark) {
    /* Already dark themed */
}

/* ====================================
   Mobile Responsive - Referral Panel
   ==================================== */

@media (max-width: 640px) {
    .referral-panel-content {
        width: 95%;
        padding: 24px 20px;
    }

    .referral-panel-title {
        font-size: 20px;
    }

    .referral-stats-container {
        grid-template-columns: 1fr;
    }

    .referral-link-input-group {
        flex-direction: column;
    }

    .referral-copy-button {
        width: 100%;
        justify-content: center;
    }
}
