/* 登录认证模块样式 - 高级设计 */

/* 登录按钮 - 右上角 */
.auth-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 25px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.auth-btn:hover {
    background: var(--primary);
    color: var(--bg);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(94, 234, 212, 0.3);
}

.auth-btn svg {
    width: 18px;
    height: 18px;
}

/* 已登录状态的用户头像 - 美化版 */
.auth-btn .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(94, 234, 212, 0.3);
    border: 2px solid rgba(94, 234, 212, 0.3);
    transition: all 0.3s ease;
    position: relative;
}

.auth-btn:hover .user-avatar {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(94, 234, 212, 0.5);
    border-color: var(--primary);
}

.auth-btn .user-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

/* 移动端登录按钮 */
.auth-btn-mobile {
    display: none;
}

/* 登录弹窗 - 高级设计 */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-modal.active {
    opacity: 1;
    visibility: visible;
}

.login-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    transition: all 0.4s ease;
}

.login-modal-content {
    position: relative;
    width: 90%;
    max-width: 420px;
    max-height: 90vh;
    background: linear-gradient(145deg, var(--card) 0%, rgba(31, 46, 45, 0.95) 100%);
    border-radius: 24px;
    border: 1px solid rgba(94, 234, 212, 0.15);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(94, 234, 212, 0.1),
        0 0 60px rgba(94, 234, 212, 0.1);
    transform: scale(0.9) translateY(30px);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.login-modal.active .login-modal-content {
    transform: scale(1) translateY(0);
}

/* 弹窗头部 - 高级设计 */
.login-modal-header {
    position: relative;
    text-align: center;
    padding: 40px 30px 20px;
    background: linear-gradient(180deg, rgba(94, 234, 212, 0.05) 0%, transparent 100%);
}

.modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 10px 30px rgba(94, 234, 212, 0.3),
        0 0 0 4px rgba(94, 234, 212, 0.1);
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.modal-icon svg {
    width: 32px;
    height: 32px;
    color: var(--bg);
}

.login-modal-header h3 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.modal-subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    opacity: 0.8;
}

.login-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: none;
    background: rgba(94, 234, 212, 0.1);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.login-modal-close:hover {
    background: rgba(94, 234, 212, 0.2);
    color: var(--primary);
    transform: rotate(90deg);
}

.login-modal-close svg {
    width: 18px;
    height: 18px;
}

/* 弹窗内容 */
.login-modal-body {
    padding: 20px 30px 40px;
    overflow-y: auto;
    max-height: calc(90vh - 180px);
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.login-modal-body::-webkit-scrollbar {
    width: 6px;
}

.login-modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.login-modal-body::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

/* 登录表单 */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 表单组 */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-left: 4px;
}

.form-label .optional {
    color: var(--text-muted);
    font-weight: 400;
}

/* 输入框包装器 */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transition: color 0.3s ease;
    z-index: 1;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px 14px 46px;
    border-radius: 12px;
    border: 1.5px solid rgba(94, 234, 212, 0.15);
    background: rgba(17, 28, 27, 0.6);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.input-wrapper input:hover {
    border-color: rgba(94, 234, 212, 0.3);
    background: rgba(17, 28, 27, 0.8);
}

.input-wrapper input:focus {
    border-color: var(--primary);
    background: rgba(17, 28, 27, 0.9);
    box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.1);
}

.input-wrapper input:focus + .input-icon,
.input-wrapper:focus-within .input-icon {
    color: var(--primary);
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

/* 验证码输入组 */
.code-wrapper input {
    padding-right: 110px;
}

.send-code-btn {
    position: absolute;
    right: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--bg);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.send-code-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(94, 234, 212, 0.3);
}

.send-code-btn:disabled,
.send-code-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--text-muted);
}

/* 密码可见性切换 */
.toggle-password {
    position: absolute;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.toggle-password:hover {
    background: rgba(94, 234, 212, 0.1);
    color: var(--primary);
}

.toggle-password svg {
    width: 18px;
    height: 18px;
}

/* 错误提示 */
.login-error {
    color: #f87171;
    font-size: 13px;
    text-align: center;
    padding: 0;
    background: rgba(248, 113, 113, 0.1);
    border-radius: 8px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.login-error.show {
    padding: 10px 12px;
    max-height: 50px;
}

/* 提交按钮 */
.login-submit-btn {
    position: relative;
    padding: 16px 24px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--bg);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
    overflow: hidden;
}

.login-submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.login-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(94, 234, 212, 0.4);
}

.login-submit-btn:hover:not(:disabled)::before {
    left: 100%;
}

.login-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loading {
    width: 20px;
    height: 20px;
    margin: 0 auto;
}

/* 登录/注册切换 */
.login-switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.login-switch a:hover {
    color: var(--primary-light);
    text-decoration: underline;
}

/* Turnstile 容器 */
.turnstile-container {
    display: flex;
    justify-content: center;
    padding: 10px 0;
}

#turnstileWidget {
    min-height: 65px;
}

/* Turnstile iframe 层级修复 */
#turnstileWidget iframe {
    z-index: 1 !important;
}

/* Turnstile 弹窗层级 */
.cf-turnstile {
    position: relative;
    z-index: 100;
}

/* Turnstile 验证弹窗 */
.cf-turnstile .challenge {
    z-index: 1000 !important;
}

/* Turnstile 错误状态 */
.turnstile-error {
    border: 1px solid #f87171;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    color: #f87171;
    font-size: 14px;
}

.switch-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.switch-btn:hover {
    color: var(--primary-light);
    transform: translateX(3px);
}

.switch-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.switch-btn:hover svg {
    transform: translateX(3px);
}

/* Toast 提示 */
.auth-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--card);
    color: var(--text);
    padding: 14px 28px;
    border-radius: 12px;
    border: 1px solid rgba(94, 234, 212, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    font-size: 14px;
    font-weight: 500;
    z-index: 1001;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.auth-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 响应式适配 */
@media (max-width: 800px) {
    .auth-btn {
        display: none;
    }

    .auth-btn-mobile {
        display: flex;
        position: fixed;
        top: 15px;
        right: 15px;
        height: 40px;
        padding: 0 16px;
        border-radius: 20px;
        background: var(--card);
        border: 1px solid var(--border);
        color: var(--primary);
        align-items: center;
        justify-content: center;
        gap: 6px;
        cursor: pointer;
        transition: all 0.3s ease;
        z-index: 1000;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        font-size: 13px;
        font-weight: 500;
    }

    .auth-btn-mobile:hover {
        background: var(--primary);
        color: var(--bg);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(94, 234, 212, 0.3);
    }

    .auth-btn-mobile svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    .auth-btn-mobile .user-avatar {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
        color: var(--bg);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        font-weight: 700;
        flex-shrink: 0;
        box-shadow: 0 2px 6px rgba(94, 234, 212, 0.3);
        border: 1.5px solid rgba(94, 234, 212, 0.3);
        position: relative;
    }

    .login-modal-content {
        width: 95%;
        max-width: 380px;
        border-radius: 20px;
    }

    .login-modal-header {
        padding: 30px 24px 16px;
    }

    .modal-icon {
        width: 56px;
        height: 56px;
        border-radius: 16px;
    }

    .modal-icon svg {
        width: 28px;
        height: 28px;
    }

    .login-modal-header h3 {
        font-size: 22px;
    }

    .login-modal-body {
        padding: 16px 24px 32px;
    }
}

@media (max-width: 480px) {
    .login-modal-header {
        padding: 24px 20px 16px;
    }

    .login-modal-body {
        padding: 16px 20px 28px;
    }

    .input-wrapper input {
        padding: 12px 14px 12px 44px;
        font-size: 16px; /* 防止 iOS 缩放 */
    }

    .login-submit-btn {
        padding: 14px 20px;
    }
}
