/* 移动端优化样式 */
body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 10px 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

.login-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 0 15px;
}

.login-card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
    background: white;
}

.login-header {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    border-radius: 15px 15px 0 0;
    padding: 25px 20px;
    text-align: center;
}

.login-header h2 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.login-header p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
}

.card-body {
    padding: 25px 20px;
}

.form-control {
    height: 45px;
    font-size: 16px; /* 防止iOS缩放 */
    border-radius: 8px;
}

.form-control:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.input-group-text {
    background-color: #f8f9fa;
    border-color: #ced4da;
    min-width: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn {
    height: 45px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 错误提示样式 */
.error-message {
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 5px;
    display: none;
}

.error-message.show {
    display: block;
}

/* 移动端提示样式 */
.mobile-alert {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 15px;
    font-size: 0.85rem;
    display: none;
}

.mobile-alert.show {
    display: block;
}

/* 新设备信任提示样式 */
.new-device-alert {
    background: linear-gradient(45deg, #f39c12, #e67e22);
    color: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    display: none;
}

.new-device-alert.show {
    display: block;
}

.new-device-alert .device-input-group {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.new-device-alert .device-input {
    flex: 1;
}

.new-device-alert .btn-group {
    display: flex;
    gap: 5px;
}

.new-device-alert .btn {
    height: 38px;
    font-size: 0.85rem;
    padding: 5px 10px;
}

/* 生物识别选项样式 */
.biometric-option {
    margin-bottom: 20px;
    display: none;
}

.biometric-option.show {
    display: block;
}

.biometric-btn {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    border: none;
    color: white;
    height: 50px;
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 10px;
}

.biometric-btn:hover {
    background: linear-gradient(45deg, #219653, #27ae60);
    color: white;
}

/* ==================== 验证码相关样式优化 ==================== */
.captcha-container {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    background: #f8f9fa;
    transition: all 0.3s ease;
}

.captcha-container.loading {
    opacity: 0.7;
    pointer-events: none;
}

.captcha-container.error {
    border-color: #e74c3c;
    background: #fdf2f2;
}

.captcha-container.success {
    border-color: #27ae60;
    background: #f2fdf2;
}

.captcha-display-area {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 6px;
    padding: 10px;
    border: 1px solid #dee2e6;
    margin-bottom: 10px;
    position: relative;
}

.captcha-display-area.loading::after {
    content: '加载中...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
    z-index: 10;
}

/* 数学题验证码样式 */
.captcha-math {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 0;
}

/* 图片验证码样式 */
.captcha-image-container {
    text-align: center;
    width: 100%;
}

.captcha-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid #ddd;
    cursor: pointer;
    transition: all 0.3s ease;
}

.captcha-image:hover {
    opacity: 0.8;
    transform: scale(1.02);
}

.captcha-image.loading {
    opacity: 0.5;
    filter: blur(1px);
}

/* 验证码控制区域 */
.captcha-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.85rem;
}

.captcha-refresh-btn {
    background: #6c757d;
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.captcha-refresh-btn:hover {
    background: #5a6268;
    color: white;
    text-decoration: none;
}

.captcha-refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.captcha-hint {
    color: #6c757d;
    font-size: 0.8rem;
}

/* 验证码输入区域 */
.captcha-input-group {
    margin-top: 10px;
}

.captcha-input-group .input-group-text {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    border-color: #3498db;
}

.captcha-input-group .form-control {
    border-left: none;
}

.captcha-input-group .form-control:focus {
    border-color: #3498db;
    box-shadow: none;
}

.captcha-input-group .form-control:focus + .input-group-text {
    border-color: #3498db;
}

/* 验证码状态指示器 */
.captcha-status {
    font-size: 0.75rem;
    margin-top: 5px;
    padding: 3px 8px;
    border-radius: 3px;
    display: inline-block;
}

.captcha-status.valid {
    background: #d4edda;
    color: #155724;
}

.captcha-status.invalid {
    background: #f8d7da;
    color: #721c24;
}

.captcha-status.expired {
    background: #fff3cd;
    color: #856404;
}

/* 按钮加载状态 */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 吐司提示样式 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1055;
}

.toast {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 10px;
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.toast.show {
    display: block;
}

.toast.success {
    background: rgba(39, 174, 96, 0.9);
}

.toast.error {
    background: rgba(231, 76, 60, 0.9);
}

.toast.warning {
    background: rgba(243, 156, 18, 0.9);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 移动端调试面板样式 */
.mobile-debug-panel {
    background: linear-gradient(45deg, #2c3e50, #34495e);
    color: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    font-size: 0.85rem;
    display: none;
}

.mobile-debug-panel.show {
    display: block;
}

.mobile-debug-panel h6 {
    margin-bottom: 10px;
    font-weight: 600;
}

.debug-item {
    margin-bottom: 5px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    display: flex;
    align-items: center;
}

.debug-item strong {
    min-width: 80px;
    margin-right: 10px;
}

.debug-details {
    margin-top: 10px;
    display: none;
}

.debug-details.show {
    display: block;
}

.debug-log {
    background: #1a1a1a;
    color: #00ff00;
    border-radius: 5px;
    padding: 10px;
    font-size: 11px;
    line-height: 1.2;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
}

.debug-toggle-btn {
    font-size: 0.8rem;
    padding: 3px 8px;
}

/* ==================== 移动端特定优化 ==================== */
@media (max-width: 576px) {
    .login-container {
        padding: 0 10px;
    }

    .login-header {
        padding: 20px 15px;
    }

    .login-header h2 {
        font-size: 1.3rem;
    }

    .card-body {
        padding: 20px 15px;
    }

    .form-control {
        font-size: 16px;
    }

    /* 移动端触摸优化 */
    .btn, .form-control, .form-select {
        min-height: 44px; /* 苹果推荐的最小触摸目标尺寸 */
    }

    /* 移动端验证码优化 */
    .captcha-container {
        padding: 10px;
        margin: 10px 0;
    }

    .captcha-display-area {
        min-height: 60px;
        padding: 8px;
    }

    .captcha-math {
        font-size: 1.2rem;
        padding: 8px;
        min-height: 44px;
    }

    .captcha-image {
        max-width: 100%;
        height: auto;
    }

    .captcha-controls {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .captcha-refresh-btn {
        order: 2;
        justify-content: center;
    }

    .captcha-hint {
        order: 1;
        text-align: center;
    }

    .captcha-input-group .input-group-text {
        min-width: 44px;
    }

    .new-device-alert .device-input-group {
        flex-direction: column;
        gap: 8px;
    }

    .new-device-alert .btn-group {
        flex-direction: row;
    }

    .new-device-alert .btn {
        flex: 1;
        min-height: 44px;
    }

    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        margin-bottom: 5px;
        padding: 10px 12px;
    }

    /* 移动端调试面板优化 */
    .mobile-debug-panel {
        padding: 10px;
    }

    .debug-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .debug-item strong {
        min-width: auto;
        margin-right: 0;
        margin-bottom: 2px;
    }

    .debug-log {
        font-size: 10px;
        max-height: 150px;
    }
}

/* 防止iOS输入框样式覆盖 */
input, select, textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 8px;
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .captcha-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .captcha-container {
        background: #2d3748;
        border-color: #4a5568;
    }

    .captcha-display-area {
        background: #1a202c;
        border-color: #4a5568;
    }

    .captcha-math {
        background: #2d3748;
        color: #e2e8f0;
    }
}

/* 打印样式优化 */
@media print {
    .captcha-container {
        border: 1px solid #000;
        background: white;
        break-inside: avoid;
    }

    .captcha-image {
        filter: none !important;
    }
}