/**
 * Authentication UI Styles
 * Inspired by MINIMAX Audio design - modern, clean, professional
 */

/* ==================== Quota Display (MINIMAX style) ==================== */

#quotaDisplay {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#quotaDisplay:hover {
    background: rgba(99, 102, 241, 0.15);
    transform: translateY(-1px);
}

.quota-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.quota-icon svg {
    width: 18px;
    height: 18px;
    stroke: white;
    stroke-width: 2;
}

.quota-number {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* Low quota warning state */
#quotaDisplay.quota-low .quota-icon {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    animation: pulse-quota 2s ease-in-out infinite;
}

#quotaDisplay.quota-low .quota-number {
    color: #dc2626;
}

@keyframes pulse-quota {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Dark mode */
body.dark #quotaDisplay {
    background: rgba(99, 102, 241, 0.15);
}

body.dark #quotaDisplay:hover {
    background: rgba(99, 102, 241, 0.2);
}

body.dark .quota-number {
    color: #e0e7ff;
}

body.dark #quotaDisplay.quota-low .quota-number {
    color: #fca5a5;
}

/* ==================== Upgrade Button ==================== */

.upgrade-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.upgrade-btn:hover {
    background: var(--panel-bg);
}

/* Dark mode */
body.dark .upgrade-btn {
    color: var(--text-primary);
}

/* ==================== Login Prompt (未登录引导) ==================== */

.login-prompt {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-prompt:hover {
    background: rgba(99, 102, 241, 0.12);
}

.login-prompt-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-prompt-icon svg {
    width: 20px;
    height: 20px;
    stroke: #6366f1;
    stroke-width: 2;
}

.login-prompt-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Dark mode */
body.dark .login-prompt {
    background: rgba(99, 102, 241, 0.12);
}

body.dark .login-prompt:hover {
    background: rgba(99, 102, 241, 0.18);
}

/* ==================== Auth Button / User Avatar ==================== */

#authBtn {
    padding: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 50%;
}

#authBtn:hover {
    background: var(--panel-bg);
}

/* Sign In button (未登录状态) */
#authBtn.sign-in-btn {
    padding: 8px 20px;
    background: var(--text-primary);
    color: var(--bg-color);
    border-radius: 24px;
    font-weight: 600;
    font-size: 14px;
}

#authBtn.sign-in-btn:hover {
    background: var(--text-primary);
    opacity: 0.9;
    transform: translateY(-1px);
}

/* User avatar (已登录状态) */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

/* Dark mode */
body.dark #authBtn.sign-in-btn {
    background: white;
    color: #1a1a1a;
}

/* ==================== Auth Dropdown Menu (MINIMAX style) ==================== */

.auth-dropdown {
    position: absolute;
    top: 56px;
    right: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0;
    min-width: 280px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    display: none;
    overflow: hidden;
}

/* User info section at top */
.auth-user-info {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.auth-user-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.auth-user-id {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.auth-user-id:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Menu items */
.auth-menu-items {
    padding: 8px;
}

.auth-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
}

.auth-menu-item:hover {
    background: var(--panel-bg);
}

.auth-menu-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 2;
}

/* Dark mode */
body.dark .auth-dropdown {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* ==================== Auth Modal (MINIMAX Style) ==================== */

.auth-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

/* Decorative background curves (MINIMAX style) */
.auth-modal-background {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.auth-modal-curve {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    opacity: 0.15;
    filter: blur(60px);
}

.auth-modal-curve-1 {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    top: -200px;
    right: -200px;
    animation: float 8s ease-in-out infinite;
}

.auth-modal-curve-2 {
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    bottom: -200px;
    left: -200px;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-30px) scale(1.05);
    }
}

.auth-modal-content {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 48px 40px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Close button (top-right X) */
.auth-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 24px;
    line-height: 32px;
    text-align: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.auth-modal-close:hover {
    background: var(--panel-bg);
    color: var(--text-primary);
}

/* Logo/Branding */
.auth-modal-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
}

.auth-modal-logo svg {
    width: 48px;
    height: 48px;
    margin-right: 12px;
}

.auth-modal-brand {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Header */
.auth-modal-content h2 {
    margin: 0 0 12px 0;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}

.auth-modal-content p {
    margin: 0 0 32px 0;
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    text-align: center;
}

/* Input fields */
.auth-modal-input-group {
    margin-bottom: 24px;
}

.auth-modal-input-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.auth-modal-content input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    color: var(--text-primary);
    background: var(--card-bg);
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.auth-modal-content input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.auth-modal-content input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Primary button (Continue/Send Code) */
.auth-modal-primary-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.auth-modal-primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.auth-modal-primary-btn:active:not(:disabled) {
    transform: translateY(0);
}

.auth-modal-primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Secondary button (Back) */
.auth-modal-secondary-btn {
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 12px;
}

.auth-modal-secondary-btn:hover {
    border-color: var(--text-primary);
    background: var(--panel-bg);
}

/* Divider (or) */
.auth-modal-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
}

.auth-modal-divider::before,
.auth-modal-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.auth-modal-divider span {
    padding: 0 16px;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Google Sign In Button */
.auth-modal-google-btn {
    width: 100%;
    padding: 14px 16px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-modal-google-btn:hover:not(:disabled) {
    border-color: #4285F4;
    background: rgba(66, 133, 244, 0.05);
    transform: translateY(-1px);
}

.auth-modal-google-btn:active:not(:disabled) {
    transform: translateY(0);
}

.auth-modal-google-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.auth-modal-google-btn svg {
    flex-shrink: 0;
}

/* Dark mode */
body.dark .auth-modal-google-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark .auth-modal-google-btn:hover:not(:disabled) {
    border-color: #4285F4;
    background: rgba(66, 133, 244, 0.1);
}

/* Footer links */
.auth-modal-footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.auth-modal-footer-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.auth-modal-footer a {
    color: #6366f1;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.auth-modal-footer a:hover {
    color: #a855f7;
    text-decoration: underline;
}

/* Loading state */
.auth-modal-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
}

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

/* Dark mode */
body.dark .auth-modal {
    background: rgba(0, 0, 0, 0.8);
}

body.dark .auth-modal-content {
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.05);
}

body.dark .auth-modal-curve {
    opacity: 0.08;
}

/* ==================== Subscription Info (User Menu) ==================== */

.auth-subscription-info {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.subscription-plan-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

.subscription-plan-badge.free {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.subscription-plan-badge.pro {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
    color: #6366f1;
}

.subscription-plan-badge.max {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(236, 72, 153, 0.15));
    color: #a855f7;
}

.subscription-expiry {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.subscription-expiry.warning {
    color: #f59e0b;
}

.subscription-expiry.expired {
    color: #ef4444;
}

.subscription-expiry .days-left {
    font-weight: 600;
    color: #f59e0b;
}

/* Dark mode */
body.dark .subscription-plan-badge.free {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

body.dark .subscription-plan-badge.pro {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(168, 85, 247, 0.25));
    color: #a78bfa;
}

body.dark .subscription-plan-badge.max {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(236, 72, 153, 0.25));
    color: #c084fc;
}

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

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

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

/* ==================== Responsive Design ==================== */

@media (max-width: 768px) {
    .auth-dropdown {
        right: 10px;
        min-width: 180px;
    }

    .auth-modal-content {
        padding: 24px;
        max-width: 90%;
    }

    #authBtn {
        padding: 6px 12px;
        font-size: 13px;
    }

    #quotaDisplay {
        padding: 4px 10px;
        font-size: 12px;
        min-width: 50px;
    }
}

@media (max-width: 480px) {
    /* Hide email text on very small screens, show icon only */
    #authBtn {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
