/* ====== 统一表单样式 ====== */

/* 表单容器 */
.form-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 2rem;
}

.auth-container {
    max-width: 500px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

/* 表单标题 */
.form-title {
    text-align: center;
    margin-bottom: 2rem;
}

.form-title i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: block;
}

.form-title h2 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-title p {
    color: var(--text-secondary);
    margin: 0;
}

/* 表单组 */
.form-group {
    margin-bottom: 1.5rem;
}

/* 表单字段包装器 - 包含输入框和错误提示 */
.form-field-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}

/* 输入框组包装器 */
.input-group-wrapper {
    position: relative;
    margin-bottom: 0.25rem; /* 为错误提示预留空间 */
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-label i {
    margin-right: 0.5rem;
    color: var(--primary-color);
}

/* 输入框统一样式 */
.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: #ffffff;
    color: var(--text-primary);
    transition: all 0.3s ease;
    min-height: 48px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background-color: #ffffff;
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* 手机号输入框 */
.form-control[type="tel"] {
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

/* 密码输入框组 */
.password-input {
    position: relative;
    width: 100%;
}

.password-input .form-control {
    padding-right: 3rem;
    width: 100%;
}

.toggle-password {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    z-index: 2;
}

.toggle-password:hover {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.1);
}

/* 输入框组 */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex: 1;
}

.input-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: none;
}

/* 验证码输入框 */
.verification-group {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 0.25rem; /* 为错误提示预留空间 */
}

.verification-group .form-control {
    flex: 1;
}

.verification-group .btn {
    white-space: nowrap;
    min-width: 120px;
}

/* 验证码字段包装器 */
.verification-field-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* 复选框样式 */
.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-check-label {
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

/* 表单操作区域 */
.form-actions {
    margin-top: 2rem;
}

.form-actions .btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    min-height: 48px;
}

/* 表单链接 */
.form-links {
    text-align: center;
    margin-top: 1.5rem;
}

.form-links a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.form-links a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* 社交登录 */
.social-login {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.social-login .text-center {
    margin-bottom: 1.5rem;
}

.social-login .text-center span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.social-login .btn {
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
    font-weight: 500;
}

/* 表单验证状态 */
.form-control.is-valid {
    border-color: var(--success-color);
}

.form-control.is-valid:focus {
    border-color: var(--success-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.form-control.is-invalid {
    border-color: var(--error-color);
}

.form-control.is-invalid:focus {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* 表单字段容器 */
.form-field-container {
    position: relative;
    margin-bottom: 1.5rem;
}

/* 错误提示区域 - 预留空间 */
.field-error {
    min-height: 1.5rem;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    padding: 0.25rem 0;
    display: flex; /* 始终显示，用opacity控制可见性 */
    align-items: center;
    transition: all 0.3s ease;
    opacity: 0; /* 默认透明 */
    visibility: hidden; /* 默认不可见 */
}

.field-error:not(:empty) {
    opacity: 1; /* 有内容时可见 */
    visibility: visible; /* 有内容时可见 */
}

.field-error:empty {
    min-height: 1.5rem;
    opacity: 0; /* 空内容时透明 */
    visibility: hidden; /* 空内容时不可见 */
}

.field-error.error {
    color: var(--error-color);
}

.field-error.success {
    color: var(--success-color);
}

.field-error.info {
    color: var(--info-color);
}

.field-error.warning {
    color: var(--warning-color);
}

/* 错误提示图标 */
.field-error::before {
    content: '';
    display: inline-block;
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.field-error.error::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ef4444'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z'/%3E%3C/svg%3E");
}

.field-error.success::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2310b981'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
}

.field-error.info::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233b82f6'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
}

.field-error.warning::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f59e0b'%3E%3Cpath d='M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z'/%3E%3C/svg%3E");
}

/* 兼容Bootstrap的反馈样式 */
.valid-feedback {
    display: block;
    color: var(--success-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    min-height: 1.5rem;
}

.invalid-feedback {
    display: block;
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    min-height: 1.5rem;
}

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

.strength-bar {
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

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

.strength-fill.weak {
    background-color: var(--error-color);
    width: 25%;
}

.strength-fill.medium {
    background-color: var(--warning-color);
    width: 50%;
}

.strength-fill.strong {
    background-color: var(--info-color);
    width: 75%;
}

.strength-fill.very-strong {
    background-color: var(--success-color);
    width: 100%;
}

.strength-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* 密码要求列表 */
.password-requirements {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.password-requirements h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.password-requirements ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.password-requirements li {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.password-requirements li:last-child {
    margin-bottom: 0;
}

.password-requirements li i {
    margin-right: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.password-requirements li.met {
    color: var(--success-color);
}

.password-requirements li.met i {
    color: var(--success-color);
}

/* 加载状态 */
.form-control:disabled {
    background-color: #f8f9fa;
    cursor: not-allowed;
    opacity: 0.7;
}

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

.btn .spinner-border {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .form-container {
        padding: 1rem;
    }
    
    .auth-container {
        margin: 1rem;
    }
    
    .verification-group {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .verification-group .btn {
        min-width: auto;
    }
    
    .form-control {
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    /* 移动端错误提示优化 */
    .field-error {
        font-size: 0.8rem;
        min-height: 1.25rem;
        opacity: 0;
        visibility: hidden;
    }
    
    .field-error:not(:empty) {
        opacity: 1;
        visibility: visible;
    }
    
    .field-error:empty {
        min-height: 1.25rem;
        opacity: 0;
        visibility: hidden;
    }
}

@media (max-width: 480px) {
    .form-title i {
        font-size: 2.5rem;
    }
    
    .form-title h2 {
        font-size: 1.5rem;
    }
    
    .form-control {
        padding: 0.75rem;
        min-height: 44px;
    }
    
    .form-actions .btn {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }
} 