/**
 * HC Custom Forms — 前端基础样式
 */

:root {
    --hc-primary-color: #0f172a;      /* 提交按钮/焦点主色调 */
    --hc-primary-hover: #1e293b;      /* 按钮悬停色 */
    --hc-border-color: #cbd5e1;       /* 边框颜色 */
    --hc-bg-color: #ffffff;           /* 输入框背景色 */
    --hc-text-color: #334155;         /* 文本颜色 */
    --hc-error-color: #ef4444;        /* 错误提示色 */
    --hc-border-radius: 4px;          /* 圆角 */
    --hc-spacing-sm: 8px;             /* 小间距 */
    --hc-spacing-md: 16px;            /* 中间距 */
    --hc-spacing-lg: 24px;            /* 大间距 */
    --hc-transition: all 0.3s ease;   /* 过渡动画 */
}

/* 容器与基础重置 */
.hc-form-wrap {
    max-width: 100%;
    margin: 0 auto;
    font-family: inherit;
    color: var(--hc-text-color);
    box-sizing: border-box;
}

.hc-form-wrap * {
    box-sizing: border-box;
}

/* 字段组与布局 */
.hc-field-group {
    margin-bottom: var(--hc-spacing-md);
    width: 100%;
}

.hc-field-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--hc-spacing-md);
    margin-bottom: var(--hc-spacing-md);
}

.hc-field-row .hc-field-group {
    margin-bottom: 0; /* 在 row 内部由 gap 控制间距 */
}

/* Flex 辅助类（匹配你后台模板中的设定） */
.hc-flex-1 {
    flex: 1 1 0%;
    min-width: 0; /* 防止内容撑破 Flex 容器 */
}

.hc-w-auto {
    flex: 0 0 auto;
    width: auto;
}

/* 响应式：在小屏幕上让并排字段垂直排列 */
@media (max-width: 600px) {
    .hc-field-row {
        flex-direction: column;
        gap: var(--hc-spacing-md);
    }
    .hc-flex-1, .hc-w-auto {
        width: 100%;
        flex: none;
    }
}

/* 输入框、下拉框、文本域 */
.hc-form input[type="text"],
.hc-form input[type="email"],
.hc-form input[type="tel"],
.hc-form input[type="url"],
.hc-form input[type="number"],
.hc-form select,
.hc-form textarea {
    width: 100%;
    padding: 6px 14px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--hc-text-color);
    background-color: var(--hc-bg-color);
    border: 2px solid var(--hc-border-color);
    border-radius: var(--hc-border-radius);
    transition: var(--hc-transition);
    appearance: none; /* 移除浏览器原生样式，特别是 select */
}

/* 下拉框自定义右侧箭头 */
.hc-form select {
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23334155%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 14px top 50%;
    background-size: 10px auto;
    padding-right: 32px;
}

/* 焦点状态 var(--hc-primary-color); */
.hc-form input:focus,
.hc-form select:focus,
.hc-form textarea:focus {
    outline: none !important;
    border-color: var(--ast-global-color-0);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1) !important; /* 优雅的焦点环 */
}

/* 禁用与只读状态 */
.hc-form input:disabled,
.hc-form select:disabled,
.hc-form textarea:disabled {
    background-color: #e2e8f0;
    cursor: not-allowed;
    opacity: 0.7;
}

/* 占位符颜色 */
.hc-form ::placeholder {
    color: #94a3b8;
    opacity: 1;
}

/* 提交按钮 */
.hc-form button[type="submit"],
.hc-form-submit {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    /* color: #ffffff;
    background-color: var(--hc-primary-color); */
    border: none;
    /* border-radius: var(--hc-border-radius); */
    cursor: pointer;
    transition: var(--hc-transition);
    margin-top: var(--hc-spacing-sm);
}

.hc-form button[type="submit"]:hover:not(:disabled) {
    /* background-color: var(--hc-primary-hover); */
    transform: translateY(-1px);
}

.hc-form button[type="submit"]:active:not(:disabled) {
    transform: translateY(0);
}

/* 按钮加载/禁用状态 */
.hc-form button[type="submit"]:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* Turnstile 未验证时按钮禁用（cursor 用 not-allowed 区分"等待验证"和"提交中"） */
.hc-form button[type="submit"][disabled]:not(.hc-submitting) {
    cursor: not-allowed;
}

/* 隐私条款文字 */
.hc-form-privacy {
    font-size: 13px;
    color: #64748b;
    margin-top: var(--hc-spacing-md);
    text-align: center;
}

/* 文件上传区域 */
.jt-form-upload {
    margin-bottom: 1rem;
}

.jt-btn-upload {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--hc-text-color);
    background-color: var(--hc-bg-color);
    border: 1px dashed var(--hc-border-color);
    border-radius: var(--hc-border-radius);
    cursor: pointer;
    transition: var(--hc-transition);
    user-select: none;
}

.jt-btn-upload:hover {
    border-color: var(--hc-primary-color);
    background-color: #f1f5f9;
    color: var(--hc-primary-color);
}

.jt-btn-upload .material-icons {
    font-size: 18px;
    line-height: 1;
}

.jt-btn-upload input[type="file"] {
    display: none;
}

/* 已选文件名提示（可选，JS 动态添加时生效） */
.jt-upload-filename {
    margin-left: 8px;
    font-size: 13px;
    color: #64748b;
}

/* 表单整体纵向排列，用 order 控制 Turnstile 出现在按钮之前 */
.hc-form {
    display: flex;
    flex-direction: column;
}

/* Turnstile 验证码容器间距（全宽模式，适用大多数表单） */
.cf-turnstile {
    margin: var(--hc-spacing-md) 0 !important;
    width: 100%;
    order: 98;
}

/* 产品表单：隐私条款文字在 Turnstile 之后、按钮之前 */
.hc-form > .hc-form-privacy {
    order: 99;
}

/* 提交按钮排在 Turnstile（98）之后，order 100（兼容直接子元素和包裹层） */
.hc-form > button[type="submit"],
.hc-form > input[type="submit"],
.hc-form > .hc-form-submit,
.hc-form > *:has([type="submit"]) {
    order: 100;
}

/* Popup 表单：带 material-icons 的提示文字排在按钮之后 */
.hc-form > p:has(.material-icons) {
    order: 101;
}

/* Contact 表单：按钮有内联 style（width:auto），恢复自适应宽度并设最小宽等于 Turnstile */
.hc-form > button[type="submit"][style] {
    align-self: flex-start;
    min-width: 300px;
}

/* Contact 表单：Turnstile 退出 stretch 并收缩至与按钮等宽（~300px） */
.hc-form:has(> button[type="submit"][style]) .cf-turnstile {
    align-self: flex-start;
    width: auto;
}

/* 若需居中，取消注释以下两行：
.cf-turnstile {
    display: flex;
    justify-content: center;
} */