/* 通用样式和重置 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', 'Microsoft YaHei', 'Segoe UI', Arial, sans-serif; /* 确保中文字体优先 */
    color: #333;
    line-height: 1.6;
}

/* 登录页面特定样式 */
body.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center; /* 垂直居中 */
    justify-content: center; /* 水平居中 */
    overflow: hidden; /* 防止滚动条出现 */
    padding: 20px; /* 控制上下边距，防止容器紧贴边缘 */
}

.login-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px; /* 控制容器最大宽度 */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.6s ease forwards; /* forwards 保持动画结束状态 */
    opacity: 0; /* 初始隐藏，等待动画 */
    /* margin: auto 0; /* 垂直方向的居中由 body 的 flex 属性控制 */
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 15px;
    color: #8a2be2; /* 奖杯图标的颜色，使其与主题色统一 */
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.login-header h1 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 2.2em;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text; /* 标准属性 */
}

.subtitle {
    margin: 0;
    color: #666;
    font-size: 1.1em;
    opacity: 0.8;
}

/* 消息提示样式 */
.flash-messages {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.flash-message {
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid;
    font-size: 14px;
    animation: slideIn 0.3s ease forwards; /* forwards 保持动画结束状态 */
    opacity: 0;
    display: flex; /* 便于图标和文字对齐 */
    align-items: center;
    cursor: pointer; /* 提示可点击关闭 */
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: transform 0.2s ease;
}
.flash-message:hover {
    transform: translateY(-2px);
}


/* 消息类型颜色 */
.flash-message.success {
    background-color: #d4edda;
    border-color: #28a745;
    color: #155724;
}
.flash-message.error {
    background-color: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}
.flash-message.warning {
    background-color: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}
.flash-message.info {
    background-color: #d1ecf1;
    border-color: #17a2b8;
    color: #0c5460;
}

.flash-message i { /* Font Awesome 图标样式 */
    margin-right: 8px;
    font-size: 16px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* 表单样式 */
#loginForm {
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 25px;
    transition: all 0.3s ease;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: 15px 50px 15px 16px; /* 留出右侧空间给图标 */
    border: 2px solid #e1e1e1;
    border-radius: 12px;
    font-size: 16px;
    background: #fafafa;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.input-wrapper input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.input-wrapper input::placeholder {
    color: #999;
}

.input-wrapper .input-icon { /* Font Awesome 图标样式 */
    position: absolute;
    right: 16px;
    top: 50%; /* 垂直居中 */
    transform: translateY(-50%); /* 垂直居中修正 */
    font-size: 16px;
    color: #999;
    pointer-events: none;
    transition: color 0.3s ease;
}

.input-wrapper input:focus + .input-icon {
    color: #667eea;
}

/* 登录按钮样式 */
.login-button {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex; /* flex布局以便居中加载动画 */
    justify-content: center;
    align-items: center;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.login-button:active {
    transform: translateY(0);
}

.login-button.loading {
    pointer-events: none; /* 禁用点击 */
    opacity: 0.8;
    cursor: default; /* 改变鼠标样式 */
}

.login-button span {
    transition: opacity 0.3s ease;
}

.login-button.loading span {
    opacity: 0;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute; /* 相对于button定位 */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* 居中 */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.login-button.loading .loading-spinner {
    opacity: 1;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 页脚样式 */
.footer-text {
    text-align: center;
    color: #666;
    font-size: 13px;
    line-height: 1.6;
}

.footer-text p {
    margin: 5px 0;
}

.tips {
    opacity: 0.7;
    font-style: italic;
}

/* 响应式设计 */
@media (max-width: 480px) {
    body.login-page {
        padding: 15px; /* 更小的边距 */
    }
    .login-container {
        padding: 30px 25px;
        max-width: none;
        width: 100%; /* 确保小屏幕上充满宽度 */
    }
    
    .login-header h1 {
        font-size: 1.8em;
    }
    
    .input-wrapper input {
        padding: 12px 45px 12px 14px;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    .input-wrapper .input-icon {
        font-size: 15px; /* 稍微小一点 */
        right: 14px;
    }
    
    .login-button {
        padding: 14px;
        font-size: 15px;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    body.login-page {
        background: linear-gradient(135deg, #4b5f8c 0%, #5f4a7c 100%); /* 更深的暗色渐变 */
    }
    .login-container {
        background: rgba(30, 30, 30, 0.95);
        color: #e0e0e0;
    }
    
    .login-header h1 {
        color: #e0e0e0;
        background: linear-gradient(135deg, #4b5f8c 0%, #5f4a7c 100%); /* 暗色模式标题渐变 */
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }
    
    .subtitle {
        color: #b0b0b0;
    }
    
    .login-icon {
        color: #b08dcf; /* 暗色模式下图标颜色微调 */
    }

    .form-group label {
        color: #e0e0e0;
    }
    
    .input-wrapper input {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .input-wrapper input:focus {
        background: #333;
        border-color: #667eea;
    }
    
    .input-wrapper input::placeholder {
        color: #888;
    }
    
    .input-wrapper .input-icon {
        color: #888;
    }
    .input-wrapper input:focus + .input-icon {
        color: #667eea;
    }

    .login-button {
        background: linear-gradient(135deg, #4b5f8c 0%, #5f4a7c 100%);
    }
    .login-button:hover {
         box-shadow: 0 8px 25px rgba(75, 95, 140, 0.3);
    }

    .footer-text {
        color: #b0b0b0;
    }

    /* 消息提示在暗色模式下的颜色 */
    .flash-message.success {
        background-color: #2a6a3b;
        border-color: #4CAF50;
        color: #c8e6c9;
    }
    .flash-message.error {
        background-color: #7c2d36;
        border-color: #f44336;
        color: #ffcdd2;
    }
    .flash-message.warning {
        background-color: #7b6e2d;
        border-color: #ffeb3b;
        color: #fffde7;
    }
    .flash-message.info {
        background-color: #215d68;
        border-color: #00bcd4;
        color: #b2ebf2;
    }
}

/* 无障碍支持 - 减少动画 */
@media (prefers-reduced-motion: reduce) {
    .login-container,
    .login-icon,
    .flash-message,
    .form-group,
    .login-button,
    .loading-spinner {
        transition: none !important; /* 强制禁用所有过渡 */
    }
}

/* 无障碍支持 - 高对比度模式 */
@media (prefers-contrast: high) {
    .form-group input {
        border-width: 3px;
        border-color: currentcolor; /* 使用当前文本颜色 */
    }
    
    .login-button {
        border: 2px solid ButtonText; /* 使用系统按钮文本颜色 */
        background: ButtonFace; /* 使用系统按钮背景色 */
        color: ButtonText; /* 使用系统按钮文本颜色 */
        box-shadow: none; /* 移除阴影 */
    }
    .login-button:hover {
        background: Highlight; /* 高亮背景 */
        color: HighlightText; /* 高亮文本 */
        transform: none; /* 移除形变 */
    }
    .login-button.loading .loading-spinner {
        border-top-color: ButtonText;
    }
    .flash-message {
        border-width: 2px;
        box-shadow: none;
        transform: none;
    }
    .flash-message:hover {
        transform: none;
    }
}


/* 请将这些新样式追加到 denglu_styles.css 文件末尾 */

/* 注册表单的特定样式 */
#registerForm {
    width: 100%;
}

/* 表单切换链接容器 */
.toggle-form-container {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.toggle-link {
    color: #667eea;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
    transition: color 0.2s ease-in-out;
}

.toggle-link:hover {
    color: #5a67d8;
    text-decoration: underline;
}

/* 确保注册按钮与登录按钮样式一致 */
#registerButton {
    background: linear-gradient(135deg, #38b2ac 0%, #319795 100%);
}

#registerButton:hover:not(:disabled) {
    background: linear-gradient(135deg, #4fd1c5 0%, #38b2ac 100%);
}


/* 细微调整，使表单切换更平滑 */
.login-container {
    transition: all 0.3s ease-in-out;
}

.form-group {
    /* 确保 form-group 有一个固定的底部边距 */
    margin-bottom: 1.25rem;
}

/* 错误提示的动画效果 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.input-wrapper.error input {
    border-color: #e53e3e;
    animation: shake 0.5s ease-in-out;
}

.input-wrapper.error .input-icon {
    color: #e53e3e;
}