/**
 * 表单组件样式
 * 文件作用：为所有页面提供统一的表单样式
 * 影响文件：login.php, register.php, comment.php - 所有包含表单的页面
 * 创建时间：2025-02-01
 * 作者：Kaka工具箱
 */

/* ================================================
   通用表单样式
   ================================================ */

/**
 * 表单组间距
 * 作用：统一所有表单的字段间距
 */
.form-group {
    margin-bottom: 1.5rem;
}

/**
 * 表单标签样式
 * 作用：统一标签的字体和颜色
 */
.form-label {
    font-weight: 600;
    color: #364a63;
    margin-bottom: 0.5rem;
    display: inline-block;
}

/**
 * 必填字段标识
 * 作用：红色星号标识必填字段
 */
.form-label .required,
.form-label .text-danger {
    color: #ef4444;
    margin-left: 2px;
}

/* ================================================
   输入框样式
   ================================================ */

/**
 * 基础输入框样式
 * 作用：统一所有输入框的外观
 */
.form-control {
    border: 2px solid #e5e9f2;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.3s ease;
    background-color: #fff;
    color: #364a63;
}

/**
 * 大号输入框样式
 * 作用：用于登录注册等重要页面的输入框
 */
.form-control-lg {
    border-radius: 12px;
    padding: 16px 20px;
    font-size: 16px;
}

/**
 * 输入框焦点状态
 * 作用：用户点击输入框时的视觉反馈
 */
.form-control:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

/**
 * 输入框禁用状态
 */
.form-control:disabled {
    background-color: #f8f9fc;
    border-color: #e5e9f2;
    color: #8094ae;
    cursor: not-allowed;
}

/* ================================================
   验证状态样式
   ================================================ */

/**
 * 验证成功状态
 * 作用：实时验证通过时的绿色边框
 */
.form-control.is-valid {
    border-color: #10b981;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2310b981' d='m2.3 6.73.09-.02L4.25 4.5l2.5 2.5c.13.13.32.13.45 0s.13-.32 0-.45L4.5 4.25 6.75 2c.13-.13.13-.32 0-.45s-.32-.13-.45 0L4 3.75 1.75 1.5c-.13-.13-.32-.13-.45 0s-.13.32 0 .45L3.5 4.25 1.25 6.5c-.13.13-.13.32 0 .45s.32.13.45 0l.6-.22z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/**
 * 验证失败状态
 * 作用：实时验证失败时的红色边框
 */
.form-control.is-invalid {
    border-color: #ef4444;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23ef4444'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 4.6 1.4 1.4m0-1.4-1.4 1.4'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* ================================================
   文本域样式
   ================================================ */

/**
 * 文本域基础样式
 * 作用：多行文本输入框的样式
 */
.form-control[rows] {
    min-height: 100px;
    resize: vertical;
}

/**
 * 自动调整高度的文本域
 * 作用：根据内容自动调整高度
 */
.form-control.auto-resize {
    resize: none;
    overflow: hidden;
}

/* ================================================
   密码输入框样式
   ================================================ */

/**
 * 密码输入框容器
 * 作用：包含密码显示/隐藏按钮的容器
 */
.form-control-wrap {
    position: relative;
}

/**
 * 密码显示/隐藏按钮
 * 作用：切换密码可见性的按钮
 */
.passcode-switch {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #8094ae;
    cursor: pointer;
    padding: 4px;
    z-index: 2;
    transition: color 0.3s ease;
}

.passcode-switch:hover {
    color: #6366f1;
}

.passcode-switch .icon-hide {
    display: none;
}

/* ================================================
   按钮样式
   ================================================ */

/**
 * 主要按钮样式
 * 作用：主要操作按钮的渐变效果
 */
.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
}

/**
 * 大号主要按钮
 */
.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
    border-radius: 12px;
}

/**
 * 块级按钮（占满宽度）
 */
.btn-block {
    width: 100%;
    display: block;
    text-align: center;
}

/**
 * 按钮悬停效果
 */
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
    text-decoration: none;
    color: #fff;
}

/**
 * 按钮禁用状态
 */
.btn-primary:disabled {
    opacity: 0.6;
    transform: none;
    box-shadow: none;
    cursor: not-allowed;
}

/* ================================================
   表单帮助文本
   ================================================ */

/**
 * 表单帮助信息
 * 作用：字段下方的说明文字
 */
.form-help {
    font-size: 12px;
    color: #8094ae;
    margin-top: 4px;
    line-height: 1.4;
}

/**
 * 成功状态的帮助文本
 */
.text-success {
    color: #10b981 !important;
}

/**
 * 错误状态的帮助文本
 */
.text-danger {
    color: #ef4444 !important;
}

/**
 * 警告状态的帮助文本
 */
.text-warning {
    color: #f59e0b !important;
}

/* ================================================
   表单图标
   ================================================ */

/**
 * 表单图标容器
 * 作用：在输入框中显示图标
 */
.form-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #8094ae;
    pointer-events: none;
    z-index: 2;
}

.form-icon-left {
    left: 12px;
}

.form-icon-right {
    right: 12px;
    pointer-events: auto;
}

/**
 * 有图标的输入框内边距调整
 */
.form-control.has-icon-left {
    padding-left: 40px;
}

.form-control.has-icon-right {
    padding-right: 40px;
}

/* ================================================
   响应式设计
   ================================================ */

/**
 * 移动端表单优化
 */
@media (max-width: 768px) {

    .form-control,
    .form-control-lg {
        font-size: 16px;
        /* 防止iOS缩放 */
    }

    .btn-block {
        margin-top: 1rem;
    }
}