/**
 * login.css - 登录页面专用样式（跨浏览器兼容版）
 * 支持：Chrome, Firefox, Safari (macOS/iOS), Edge, IE11+
 */

/* ========== 页面主体 ========== */
body {
    /* 渐变背景 - 全浏览器兼容 */
    background: #667eea; /* 回退色 */
    background: -webkit-linear-gradient(315deg, #667eea 0%, #764ba2 100%);
    background: -moz-linear-gradient(315deg, #667eea 0%, #764ba2 100%);
    background: -o-linear-gradient(315deg, #667eea 0%, #764ba2 100%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Flexbox 居中 - 全浏览器兼容 */
    display: -webkit-box;
    display: -webkit-flex;
    display: -moz-box;
    display: -ms-flexbox;
    display: flex;
    
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -moz-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    
    -webkit-box-align: center;
    -webkit-align-items: center;
    -moz-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    
    /* 高度兼容性 - Safari/iOS 特殊处理 */
    min-height: 100vh;
    min-height: -webkit-fill-available;
    min-height: calc(var(--vh, 1vh) * 100);
    
    /* 字体 */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    margin: 0;
    padding: 15px;
    
    /* 确保背景覆盖全屏 */
    background-attachment: fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

/* ========== 登录框容器 ========== */
.login-box {
    background: white;
    background: rgba(255, 255, 255, 1);
    padding: 30px 28px;
    
    /* 圆角 - 全浏览器兼容 */
    -webkit-border-radius: 12px;
    -moz-border-radius: 12px;
    border-radius: 12px;
    
    /* 阴影 - 全浏览器兼容 */
    -webkit-box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25);
    -moz-box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25);
    
    width: 340px;
    max-width: 100%;
    
    /* 确保在Safari上正确显示 */
    position: relative;
    z-index: 1;
    
    /* 动画 */
    -webkit-animation: fadeInUp 0.5s ease-out;
    -moz-animation: fadeInUp 0.5s ease-out;
    -o-animation: fadeInUp 0.5s ease-out;
    animation: fadeInUp 0.5s ease-out;
    
    /* 防止Safari上元素消失 */
    -webkit-transform: translateZ(0);
    -moz-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* ========== 动画关键帧 - 全浏览器兼容 ========== */
@-webkit-keyframes fadeInUp {
    from {
        opacity: 0;
        -webkit-transform: translateY(25px);
        transform: translateY(25px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}

@-moz-keyframes fadeInUp {
    from {
        opacity: 0;
        -moz-transform: translateY(25px);
        transform: translateY(25px);
    }
    to {
        opacity: 1;
        -moz-transform: translateY(0);
        transform: translateY(0);
    }
}

@-o-keyframes fadeInUp {
    from {
        opacity: 0;
        -o-transform: translateY(25px);
        transform: translateY(25px);
    }
    to {
        opacity: 1;
        -o-transform: translateY(0);
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        -webkit-transform: translateY(25px);
        -moz-transform: translateY(25px);
        -ms-transform: translateY(25px);
        -o-transform: translateY(25px);
        transform: translateY(25px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0);
        -moz-transform: translateY(0);
        -ms-transform: translateY(0);
        -o-transform: translateY(0);
        transform: translateY(0);
    }
}

/* ========== 标题样式 ========== */
.login-box h2 {
    text-align: center;
    color: #333;
    margin-bottom: 25px;
    font-weight: 600;
    font-size: 20px;
    position: relative;
    padding-bottom: 12px;
}

.login-box h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    
    /* Transform 兼容 */
    -webkit-transform: translateX(-50%);
    -moz-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    -o-transform: translateX(-50%);
    transform: translateX(-50%);
    
    width: 50px;
    height: 3px;
    
    /* 渐变兼容 */
    background: #667eea;
    background: -webkit-linear-gradient(left, #667eea, #764ba2);
    background: -moz-linear-gradient(left, #667eea, #764ba2);
    background: -o-linear-gradient(left, #667eea, #764ba2);
    background: linear-gradient(90deg, #667eea, #764ba2);
    
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    border-radius: 2px;
}

/* ========== 表单组 ========== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #555;
    font-size: 13px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    
    /* Safari 盒模型修复 */
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    
    outline: none;
    
    /* 过渡动画兼容 */
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
    
    font-size: 14px;
    font-family: inherit;
    
    /* Safari 表单元素修复 */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #fff;
}

.form-group input:focus {
    border-color: #667eea;
    
    /* 阴影兼容 */
    -webkit-box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    -moz-box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ========== 验证码组 ========== */
.captcha-group {
    display: -webkit-box;
    display: -webkit-flex;
    display: -moz-box;
    display: -ms-flexbox;
    display: flex;
    
    /* Gap 兼容性处理 */
    gap: 8px;
    
    -webkit-box-align: center;
    -webkit-align-items: center;
    -moz-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

/* Gap 不支持时的后备方案 */
@supports not (gap: 8px) {
    .captcha-group > *:not(:last-child) {
        margin-right: 8px;
    }
}

.captcha-group input {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -moz-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    
    outline: none;
    
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
    
    font-size: 14px;
    
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #fff;
}

.captcha-group input:focus {
    border-color: #667eea;
    
    -webkit-box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    -moz-box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.captcha-img {
    width: 90px;
    height: 32px;
    border: 2px solid #e0e0e0;
    
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    
    cursor: pointer;
    
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
    
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    
    /* 防止Safari图片拖拽 */
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
}

.captcha-img:hover {
    border-color: #667eea;
    
    -webkit-transform: scale(1.03);
    -moz-transform: scale(1.03);
    -ms-transform: scale(1.03);
    -o-transform: scale(1.03);
    transform: scale(1.03);
}

/* ========== 记住我复选框 ========== */
.remember-me {
    display: -webkit-box;
    display: -webkit-flex;
    display: -moz-box;
    display: -ms-flexbox;
    display: flex;
    
    -webkit-box-align: center;
    -webkit-align-items: center;
    -moz-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    
    margin-bottom: 16px;
    
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.remember-me input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    cursor: pointer;
    
    /* 恢复checkbox默认样式 */
    -webkit-appearance: checkbox;
    -moz-appearance: checkbox;
    appearance: auto;
    
    /* accent-color 兼容性 - Safari 15+ */
    accent-color: #667eea;
}

/* Safari < 15 不支持 accent-color 的后备方案 */
@supports not (accent-color: auto) {
    .remember-me input[type="checkbox"] {
        position: relative;
    }
}

.remember-me label {
    color: #666;
    font-size: 13px;
    cursor: pointer;
    margin: 0;
}

/* ========== 提交按钮 ========== */
.login-box button {
    width: 100%;
    padding: 11px;
    
    /* 渐变背景兼容 */
    background: #667eea;
    background: -webkit-linear-gradient(left, #667eea, #764ba2);
    background: -moz-linear-gradient(left, #667eea, #764ba2);
    background: -o-linear-gradient(left, #667eea, #764ba2);
    background: linear-gradient(90deg, #667eea, #764ba2);
    
    color: white;
    border: none;
    
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
    
    margin-top: 8px;
    
    /* Safari 按钮修复 */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    /* 防止Safari点击闪烁 */
    -webkit-tap-highlight-color: transparent;
}

.login-box button:hover {
    -webkit-transform: translateY(-2px);
    -moz-transform: translateY(-2px);
    -ms-transform: translateY(-2px);
    -o-transform: translateY(-2px);
    transform: translateY(-2px);
    
    -webkit-box-shadow: 0 5px 15px rgba(102, 126, 234, 0.35);
    -moz-box-shadow: 0 5px 15px rgba(102, 126, 234, 0.35);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.35);
}

.login-box button:active {
    -webkit-transform: translateY(0);
    -moz-transform: translateY(0);
    -ms-transform: translateY(0);
    -o-transform: translateY(0);
    transform: translateY(0);
}

.login-box button:disabled {
    background: #ccc;
    cursor: not-allowed;
    
    -webkit-transform: none;
    -moz-transform: none;
    -ms-transform: none;
    -o-transform: none;
    transform: none;
    
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
}

/* ========== 错误提示 ========== */
.error {
    background: #fff2f0;
    border-left: 3px solid #ff4d4f;
    color: #ff4d4f;
    padding: 10px 12px;
    
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    
    margin-bottom: 16px;
    font-size: 13px;
    
    -webkit-animation: shake 0.5s ease;
    -moz-animation: shake 0.5s ease;
    -o-animation: shake 0.5s ease;
    animation: shake 0.5s ease;
}

/* 抖动动画 - 全浏览器兼容 */
@-webkit-keyframes shake {
    0%, 100% { -webkit-transform: translateX(0); transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { -webkit-transform: translateX(-4px); transform: translateX(-4px); }
    20%, 40%, 60%, 80% { -webkit-transform: translateX(4px); transform: translateX(4px); }
}

@-moz-keyframes shake {
    0%, 100% { -moz-transform: translateX(0); transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { -moz-transform: translateX(-4px); transform: translateX(-4px); }
    20%, 40%, 60%, 80% { -moz-transform: translateX(4px); transform: translateX(4px); }
}

@-o-keyframes shake {
    0%, 100% { -o-transform: translateX(0); transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { -o-transform: translateX(-4px); transform: translateX(-4px); }
    20%, 40%, 60%, 80% { -o-transform: translateX(4px); transform: translateX(4px); }
}

@keyframes shake {
    0%, 100% { 
        -webkit-transform: translateX(0);
        -moz-transform: translateX(0);
        -ms-transform: translateX(0);
        -o-transform: translateX(0);
        transform: translateX(0); 
    }
    10%, 30%, 50%, 70%, 90% { 
        -webkit-transform: translateX(-4px);
        -moz-transform: translateX(-4px);
        -ms-transform: translateX(-4px);
        -o-transform: translateX(-4px);
        transform: translateX(-4px); 
    }
    20%, 40%, 60%, 80% { 
        -webkit-transform: translateX(4px);
        -moz-transform: translateX(4px);
        -ms-transform: translateX(4px);
        -o-transform: translateX(4px);
        transform: translateX(4px); 
    }
}

/* ========== 警告提示 ========== */
.warning {
    background: #fff7e6;
    border-left: 3px solid #fa8c16;
    color: #d46b08;
    padding: 10px 12px;
    
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    
    margin-bottom: 16px;
    font-size: 12px;
}

/* ========== 页脚文字 ========== */
.footer-text {
    text-align: center;
    margin-top: 20px;
    color: #999;
    font-size: 12px;
}

/* ========== 响应式适配 ========== */
@media screen and (max-width: 400px) {
    .login-box {
        padding: 25px 20px;
        width: 100%;
        margin: 10px;
    }
    
    .login-box h2 {
        font-size: 18px;
    }
    
    .captcha-img {
        width: 80px;
        height: 28px;
    }
}

/* ========== Safari/iOS 特殊修复 ========== */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari 特定样式 */
    body {
        /* 修复iOS Safari 100vh问题 */
        min-height: -webkit-fill-available;
    }
    
    .login-box {
        /* 确保在iOS上正确显示 */
        -webkit-overflow-scrolling: touch;
    }
    
    input, button {
        /* 修复iOS Safari字体大小调整 */
        font-size: 16px;
    }
}

/* ========== macOS Safari 特殊修复 ========== */
@media not all and (min-resolution:.001dpcm) { 
    @supports (-webkit-appearance:none) {
        /* Safari only */
        .login-box {
            /* 确保macOS Safari正确渲染 */
            -webkit-transform: translate3d(0, 0, 0);
            transform: translate3d(0, 0, 0);
        }
        
        .form-group input,
        .captcha-group input {
            /* 修复Safari输入框渲染 */
            -webkit-text-fill-color: inherit;
        }
    }
}

/* ========== 高对比度模式支持 ========== */
@media (prefers-contrast: high) {
    .login-box {
        border: 2px solid #333;
    }
    
    .form-group input,
    .captcha-group input {
        border-width: 2px;
    }
}

/* ========== 减少动画模式支持 ========== */
@media (prefers-reduced-motion: reduce) {
    .login-box,
    .error {
        -webkit-animation: none;
        -moz-animation: none;
        -o-animation: none;
        animation: none;
    }
    
    .login-box button:hover,
    .captcha-img:hover {
        -webkit-transform: none;
        -moz-transform: none;
        -ms-transform: none;
        -o-transform: none;
        transform: none;
    }
}

/* ========== 暗色模式支持 ========== */
@media (prefers-color-scheme: dark) {
    /* 可选：如果需要支持暗色模式，取消注释以下样式 */
    /*
    .login-box {
        background: #1e1e1e;
        color: #e0e0e0;
    }
    
    .login-box h2 {
        color: #e0e0e0;
    }
    
    .form-group label {
        color: #b0b0b0;
    }
    
    .form-group input,
    .captcha-group input {
        background-color: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }
    */
}
