/* 移除全局html,body样式，避免影响主页面 */
/* html, body {
    overflow: hidden;
} */

/* 模态框容器样式 - 用于嵌入模式 */
#login-modal-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    overflow-y: hidden; /* 弹窗模式禁用整体纵向滚动 */
}

/* 当模态框隐藏时，确保不阻挡其他元素 */
#login-modal-container.hidden {
    pointer-events: none;
}

/* 独立页面样式 - 仅当login.html作为独立页面时使用 */
body.login-page:not(.modal-open) {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    margin: 0;
    padding: 0;
    padding-top: 0 !important; /* 登录页面不需要导航栏空间 */
    overflow: hidden;
}

/* 模态框场景下的login-page类不影响页面布局 */
body.login-page.modal-open {
    /* 保持原有的modal-open样式，不添加额外的布局影响 */
}

/* 通用隐藏类 */
.hidden {
    display: none !important;
}

/* 成功提示样式 */
.success-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background-color: #d4edda;
    color: #155724;
    padding: 1.5rem 2rem;
    border-radius: 12px;
    border-left: 4px solid #27ae60;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    z-index: 1000000;
    font-size: 16px;
    font-weight: 500;
    max-width: 320px;
    text-align: center;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-toast.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.success-toast.hide {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
}

/* 眼睛图标显示样式 */
.eye-icon {
    display: inline-block;
}

/* 登录框过渡动画 */
.login-box {
    transition: all 0.3s ease;
}

/* 输入框验证状态样式 */
.input-group input.invalid {
    border-color: #e74c3c !important;
    background-color: #fdf2f2 !important;
}

.input-group input.valid {
    border-color: #27ae60 !important;
}

/* 滑入动画 */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.login-container {
    position: relative;
    animation: fadeIn 0.3s ease-out;
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 移除min-height，避免与父容器冲突 */
    width: 100%;
    height: 100%;
}

/* 弹窗模式：居中显示，内部内容超高时在白框内滚动 */
#login-modal-container .login-container {
    align-items: center;
    padding: 24px 16px;
}

#login-modal-container .login-box {
    max-width: 95vw;
    max-height: calc(100vh - 96px);
    overflow-y: auto; /* 关键：在白色框内产生滚动，避免底部按钮溢出 */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.login-box {
    background-color: white;
    padding: 1.75rem;
    border-radius: 12px;
    width: 440px;
    height: 650px; /* 增加高度确保OAuth按钮和所有内容完全可见 */
    /* 确保width和height包含padding和border */
    box-sizing: border-box;
    /* 在MacBook Air 13寸及以上屏幕保持固定尺寸440*650px */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    overflow: hidden; /* 确保内容在容器内 */
}

/* 注册表单需要更大的高度，但内容必须完全适配不可滚动的固定高度 */
#register-form {
    height: 700px; /* 注册表单相应增加高度，确保所有内容完整展示 */
    overflow: hidden; /* 确保内容在容器内 */
}

/* CSS变量系统 - 适中间距标准，确保内容完整展示且不过于紧凑 */
:root {
    --form-spacing-unit: 8px; /* 增加基础间距单位，避免过于紧凑 */
    --form-logo-height: 48px; /* 恢复logo高度 */
    --form-title-height: 32px; /* 增加标题高度 */
    --form-subtitle-height: 20px; /* 增加副标题高度 */
    --form-input-height: 44px; /* 保持合适的输入框高度 */
    --form-btn-height: 46px; /* 增加按钮高度 */
    
    /* 适中间距定义 */
    --form-logo-margin-top: calc(var(--form-spacing-unit) * 0.5); /* 4px */
    --form-logo-margin-bottom: calc(var(--form-spacing-unit) * 1.5); /* 12px */
    --form-title-margin-bottom: calc(var(--form-spacing-unit) * 0.5); /* 4px */
    --form-subtitle-margin-bottom: calc(var(--form-spacing-unit) * 2); /* 16px */
    --form-input-group-margin: calc(var(--form-spacing-unit) * 2); /* 16px */
    --form-btn-margin-top: calc(var(--form-spacing-unit) * 1); /* 8px */
    --form-switch-margin-top: calc(var(--form-spacing-unit) * 1.5); /* 12px */
}

/* 统一表单布局框架 */
.login-box {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* 登录表单和注册表单共享样式 */
#login-form .logo-container,
#register-form .logo-container {
    margin-top: var(--form-logo-margin-top);
    margin-bottom: var(--form-logo-margin-bottom);
    height: var(--form-logo-height);
    display: flex;
    align-items: center;
    justify-content: center;
}

#login-form h2,
#register-form h2 {
    margin-bottom: var(--form-title-margin-bottom);
    height: var(--form-title-height);
    line-height: var(--form-title-height);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 登录表单副标题 - 占位与注册表单第一个输入组对齐 */
#login-form .login-subtitle {
    margin-top: 0;
    margin-bottom: var(--form-subtitle-margin-bottom);
    height: var(--form-subtitle-height);
    line-height: var(--form-subtitle-height);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 输入组统一间距 */
#login-form .input-group,
#register-form .input-group {
    margin-bottom: var(--form-input-group-margin);
}

/* 输入框统一高度 */
#login-form .input-group input,
#register-form .input-group input {
    height: var(--form-input-height);
    box-sizing: border-box;
}

/* 按钮统一样式和位置 */
#login-form .login-btn,
#register-form .login-btn {
    margin-top: var(--form-btn-margin-top);
    height: var(--form-btn-height);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 底部切换链接统一位置 */
#login-form .switch-form,
#register-form .switch-form {
    margin-top: var(--form-switch-margin-top);
    height: 20px;
    line-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 登录表单特殊处理 - 补偿缺少的确认密码输入组 */
#login-form {
    /* 通过padding-bottom补偿高度差，确保底部对齐，OAuth按钮在容器内显示 */
    padding-bottom: 12px; /* 增加底部间距为OAuth按钮留出空间 */
    box-sizing: border-box;
}


/* 响应式CSS变量调整 */
/* 中等屏幕优化 - 避免固定宽度问题 */
@media (max-width: 768px) and (min-width: 481px) {
    .login-box {
        width: 90vw;
        max-width: 500px;
        height: auto;
        min-height: 580px; /* 增加最小高度确保内容完整 */
        max-height: 90vh;
    }
    
    #register-form {
        min-height: 630px; /* 注册表单需要更大的最小高度 */
    }
}

/* 手机竖屏模式 - 适中间距 */
@media (max-width: 480px) {
    :root {
        --form-spacing-unit: 7px; /* 保持适中的间距 */
        --form-logo-height: 42px;
        --form-title-height: 30px;
        --form-subtitle-height: 20px;
        --form-input-height: 44px; /* 保持触摸友好的高度 */
        --form-btn-height: 46px;
    }
    
    .login-box {
        width: 95vw;
        height: auto;
        min-height: 550px; /* 增加最小高度确保内容完整 */
        max-height: 85vh;
        padding: 1.5rem;
    }
    
    #register-form {
        min-height: 600px; /* 注册表单需要更大的最小高度 */
    }
    
    #login-form {
        padding-bottom: calc(var(--form-input-height) + var(--form-input-group-margin) + 24px);
    }
}

/* 极低高度屏幕（如手机横屏） */
@media (max-height: 600px) and (max-width: 900px) {
    :root {
        --form-spacing-unit: 6px; /* 保持最小可用间距 */
        --form-logo-height: 38px;
        --form-title-height: 26px;
        --form-subtitle-height: 18px;
        --form-input-height: 44px; /* 保持触摸友好的高度 */
        --form-btn-height: 44px;
    }
    
    .login-box {
        height: auto;
        max-height: 90vh; /* 增加最大高度利用更多空间 */
        min-height: 450px; /* 确保最小高度 */
        padding: 1.2rem; /* 减少padding节省空间 */
    }
    
    #register-form {
        min-height: 500px; /* 注册表单最小高度 */
    }
    
    #login-form {
        padding-bottom: calc(var(--form-input-height) + var(--form-input-group-margin) + 20px);
    }
}

/* 小屏幕设备组合条件 */
@media (max-width: 480px) and (max-height: 600px) {
    :root {
        --form-spacing-unit: 5px; /* 保持最小可用间距 */
        --form-logo-height: 36px;
        --form-title-height: 24px;
        --form-subtitle-height: 18px;
        --form-input-height: 44px; /* 保持触摸友好的高度 */
        --form-btn-height: 44px;
    }
    
    .login-box {
        width: 95vw;
        height: auto;
        min-height: 420px; /* 增加最小高度 */
        max-height: 85vh; /* 增加最大高度利用更多空间 */
        padding: 1rem;
    }
    
    #register-form {
        min-height: 470px; /* 注册表单最小高度 */
    }
    
    #login-form {
        padding-bottom: calc(var(--form-input-height) + var(--form-input-group-margin) + 16px);
    }
}

/* 确保MacBook Air 13寸及以上屏幕始终显示440*650px */
@media (min-width: 1200px) and (min-height: 800px) {
    .login-box {
        width: 440px;
        height: 650px; /* 增加高度确保OAuth按钮完全可见 */
        max-width: none;
        max-height: none;
    }
    
    #register-form {
        height: 700px; /* 相应增加注册表单高度 */
    }
}

.login-header {
    position: relative;
    margin-bottom: 0;
}

.logo-container {
    text-align: center;
    /* margin值由CSS变量系统统一管理 */
}

.logo {
    max-height: 48px;
    width: auto;
    display: inline-block;
    /* 移除border-radius，保持logo原始形状 */
}

.close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
    z-index: 1001;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    line-height: 1;
}

.close-btn:hover {
    color: #666;
}



h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: #1a1a1a;
    text-align: center;
    /* margin值由CSS变量系统统一管理 */
}

.login-subtitle {
    color: #888;
    font-size: 1rem;
    text-align: center;
    font-weight: 400;
    /* margin和line-height由CSS变量系统统一管理 */
}

p {
    color: #666;
    margin-bottom: 32px;
    font-size: 1rem;
    line-height: 1.4;
    text-align: center;
}

.input-group {
    position: relative;
    /* margin值由CSS变量系统统一管理 */
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 1rem;
}

.input-group label .required {
    color: #e74c3c;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: #fafafa;
}

.input-group input:focus {
    outline: none;
    border-color: #2c3e50;
    background-color: white;
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.08);
}

.input-group input:invalid {
    border-color: #e74c3c;
}

.input-group input:valid {
    border-color: #27ae60;
}

.input-icon {
    position: absolute;
    right: 1rem;
    color: #999;
    pointer-events: none;
}

.toggle-password {
    position: absolute;
    right: 1rem;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.toggle-password:hover {
    color: #2c3e50;
}

.eye-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    transition: opacity 0.3s ease;
}

.eye-icon path {
    fill: currentColor;
}

/* 默认状态：密码不可见，显示eye-hidden图标 */
.eye-hidden {
    display: inline-block;
}

.eye-visible {
    display: inline-block;
}

/* 通过.hidden类控制图标显示隐藏 */
.eye-icon.hidden {
    display: none !important;
}

.field-error {
    display: block;
    color: #e74c3c;
    font-size: 1rem;
    margin-top: 4px;
    min-height: 16px;
}

.field-hint {
    display: block;
    color: #666;
    font-size: 1rem;
    margin-top: 4px;
}

/* 错误提示样式 */
.error-message {
    background-color: #fee;
    color: #e74c3c;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 4px solid #e74c3c;
    font-size: 1rem;
}



/* 密码强度指示器 */
.password-strength {
    margin-top: 8px;
}

.strength-bar {
    width: 100%;
    height: 4px;
    background-color: #e1e5e9;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

.strength-fill {
    height: 100%;
    width: 0%;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.strength-text {
    font-size: 1rem;
    color: #666;
}

.password-requirements {
    margin-top: 8px;
}

.requirement {
    font-size: 0.8rem;
    color: #999;
    margin-bottom: 2px;
    transition: color 0.3s ease;
}

.requirement.valid {
    color: #27ae60;
}

.requirement.valid::before {
    content: '✓';
    margin-right: 4px;
}

.requirement:not(.valid)::before {
    content: '✗';
    margin-right: 4px;
}

/* 记住我复选框样式 */
.checkbox-group {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    user-select: none;
}

.checkbox-input {
    display: none;
}

.checkbox-custom {
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-radius: 3px;
    margin-right: 8px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.checkbox-input:checked + .checkbox-custom {
    background-color: #2c3e50;
    border-color: #2c3e50;
}

.checkbox-input:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-text {
    color: #666;
    font-size: 1rem;
}

/* 用户协议样式 */
.form-agreement {
    margin-bottom: 24px;
}

.agreement-checkbox {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

.agreement-checkbox input[type="checkbox"] {
    display: none;
}

.agreement-checkbox .checkmark {
    margin-top: 2px;
    flex-shrink: 0;
}

.link {
    color: #1a1a1a;
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

/* 登录按钮样式 */
.login-btn {
    width: 100%;
    padding: 0.9rem;
    background: #2c3e50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    /* margin和height由CSS变量系统统一管理 */
}

.login-btn:hover {
    background: #34495e;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(44, 62, 80, 0.2);
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-loading {
    display: none;
}

.login-btn.loading .btn-text {
    display: none;
}

.login-btn.loading .btn-loading {
    display: inline;
}





/* 切换表单样式 */
.switch-form {
    color: #666;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 400;
    transition: color 0.3s ease;
    /* display、text-align、margin由CSS变量系统统一管理 */
}

.switch-form:hover {
    color: #2c3e50;
    text-decoration: underline;
}

/* OAuth登录区域样式 */
.oauth-section {
    margin: 1.2rem 0 1rem 0; /* 适中的上下边距，确保按钮可见 */
}

.divider {
    position: relative;
    text-align: center;
    margin: 0.8rem 0; /* 适中的分割线间距 */
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: #e1e5e9;
    z-index: 1;
}

.divider-text {
    background-color: #fff;
    color: #6c757d;
    font-size: 12px; /* 减少字体大小 */
    padding: 0 0.75rem; /* 减少文字左右间距 */
    position: relative;
    z-index: 2;
}

.oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    height: 40px; /* 明确设置高度 */
    padding: 0.625rem 0.75rem;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    background-color: #fff;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box; /* 确保尺寸计算准确 */
    text-decoration: none;
}

.oauth-btn:hover {
    background-color: #f8f9fa;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.oauth-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.oauth-btn:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.oauth-icon {
    flex-shrink: 0;
}

.google-btn:hover {
    border-color: #4285f4;
}

/* 确保OAuth区域在所有设备上都正常显示 */
.oauth-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 1rem 0 0.8rem 0; /* 适中的上下边距，确保完整可见 */
}

.oauth-buttons {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.oauth-btn {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* PC端OAuth样式优化 */
@media (min-width: 769px) {
    .oauth-section {
        margin: 1rem 0 0.8rem 0; /* PC端使用适中间距 */
    }
    
    .divider {
        margin: 0.8rem 0; /* 适中的分割线间距 */
    }
    
    .divider-text {
        font-size: 14px;
        padding: 0 1rem;
    }
    
    .oauth-btn {
        padding: 0.875rem 1rem;
        font-size: 14px;
        min-height: 44px;
    }
}

/* 移动端OAuth样式优化 */
@media (max-width: 768px) {
    .oauth-section {
        margin: 1.2rem 0; /* 适中的移动端间距 */
    }
    
    .divider {
        margin: 1rem 0; /* 适中的分割线间距 */
    }
    
    .divider-text {
        font-size: 13px;
        padding: 0 0.75rem;
    }
    
    .oauth-btn {
        padding: 1rem;
        font-size: 15px;
        min-height: 48px; /* 确保移动端触摸友好 */
    }
    
    .oauth-icon {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .oauth-btn {
        padding: 1.125rem 1rem;
        min-height: 52px;
    }
}