/* ==========================================================================
 * HBC Contact Form — 联系/询盘表单
 *
 * 结构:
 *   .hbc-contact-form-wrap
 *     └─ form.hbc-contact-form
 *           ├─ .header (title + subtitle)
 *           ├─ .fields (CSS Grid,字段宽度由 --hbc-field-width 控制)
 *           │     └─ .field--{type}
 *           │           ├─ .label
 *           │           ├─ .input / textarea / select / .choices
 *           │           └─ .error  (前端校验失败时显示)
 *           ├─ .consent (隐私同意复选框)
 *           ├─ .actions (按钮容器)
 *           │     └─ .submit
 *           ├─ .notice  (提交结果提示)
 *           └─ .hp      (honeypot,视觉隐藏)
 * ========================================================================== */

.hbc-contact-form-wrap {
	width: 100%;
}

.hbc-contact-form {
	display: flex;
	flex-direction: column;
	gap: 18px;
	box-sizing: border-box;
}

.hbc-contact-form *,
.hbc-contact-form *::before,
.hbc-contact-form *::after {
	box-sizing: border-box;
}

/* ==========================================================================
 *  标题区
 * ========================================================================== */
.hbc-contact-form__header {
	margin: 0 0 6px;
}

.hbc-contact-form__title {
	margin: 0 0 6px;
	font-size: 24px;
	line-height: 1.3;
	font-weight: 600;
	color: #1D2D5C;
}

.hbc-contact-form__subtitle {
	margin: 0;
	font-size: 14px;
	line-height: 1.6;
	color: #6B7280;
}

/* ==========================================================================
 *  字段网格
 *
 *  每个字段是一个 12 列网格中占 (--hbc-field-width / 100 * 12) 列的网格项。
 *  我们直接用 CSS Grid + flex-basis 模拟,避免复杂 grid-column-start 计算。
 *  实现方式:网格容器是 flex,字段 flex-basis 由百分比决定。
 * ========================================================================== */
.hbc-contact-form__fields {
	display: flex;
	flex-wrap: wrap;
	row-gap: 16px;
	column-gap: 16px;
}

.hbc-contact-form__field {
	--hbc-field-width: 100%;
	flex: 0 0 calc(var(--hbc-field-width) - var(--hbc-col-gap, 0px));
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

/* 因为 flex column-gap 已经处理列间距,这里不需要再减 */
.hbc-contact-form__field {
	flex-basis: var(--hbc-field-width);
}

/* 但当宽度 < 100% 时,需要从可用宽度里减去 column-gap 占的份额。
   利用 calc:100% 时不减,< 100% 时统一减 16px(默认 gap)。
   稳妥起见,使用兜底公式: */
.hbc-contact-form__field {
	flex-basis: calc(var(--hbc-field-width) - 16px * ((100% - var(--hbc-field-width)) / 100%));
}

/* fallback — 老浏览器不支持嵌套 calc 时,直接给个百分比近似 */
@supports not (flex-basis: calc(50% - 16px * 0.5)) {
	.hbc-contact-form__field {
		flex-basis: var(--hbc-field-width);
	}
}

/* ==========================================================================
 *  标签
 * ========================================================================== */
.hbc-contact-form__label {
	display: inline-block;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.4;
	color: #1F2937;
}

.hbc-contact-form__required {
	color: #1F2937;
	margin-left: 1px;
}

/* ==========================================================================
 *  输入框 / textarea / select 通用样式
 * ========================================================================== */
.hbc-contact-form__input {
	display: block;
	width: 100%;
	padding: 12px 14px;
	font-size: 14px;
	line-height: 1.4;
	color: #1F2937;
	background-color: #FFFFFF;
	border: 2px solid #3D1B6B;
	border-radius: 8px;
	outline: none;
	appearance: none;
	-webkit-appearance: none;
	font-family: inherit;
	transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.hbc-contact-form__input::placeholder {
	color: #9CA3AF;
	opacity: 1;
}

.hbc-contact-form__input:hover {
	border-color: #5A2D9B;
}

.hbc-contact-form__input:focus {
	border-color: #6B2FBF;
	box-shadow: 0 0 0 3px rgba(61, 27, 107, 0.15);
}

.hbc-contact-form__input--textarea {
	resize: vertical;
	min-height: 120px;
}

/* select 自定义箭头 */
.hbc-contact-form__input--select {
	padding-right: 36px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	background-size: 12px 8px;
	cursor: pointer;
}

/* 错误状态 */
.hbc-contact-form__field.has-error .hbc-contact-form__input {
	border-color: #DC2626;
	background-color: #FEF2F2;
}

.hbc-contact-form__field.has-error .hbc-contact-form__input:focus {
	border-color: #DC2626;
	box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.13);
}

.hbc-contact-form__error {
	display: none;
	font-size: 12px;
	line-height: 1.4;
	color: #DC2626;
	margin-top: 2px;
}

.hbc-contact-form__field.has-error .hbc-contact-form__error {
	display: block;
}

/* ==========================================================================
 *  Radio / Checkbox 选项组
 * ========================================================================== */
.hbc-contact-form__choices {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 18px;
	padding-top: 4px;
}

.hbc-contact-form__choice {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	line-height: 1.4;
	color: #1F2937;
	cursor: pointer;
	user-select: none;
}

.hbc-contact-form__choice input[type="radio"],
.hbc-contact-form__choice input[type="checkbox"] {
	width: 16px;
	height: 16px;
	margin: 0;
	accent-color: #1D2D5C;
	cursor: pointer;
}

/* ==========================================================================
 *  隐私同意
 * ========================================================================== */
.hbc-contact-form__consent {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	font-size: 13px;
	line-height: 1.6;
	color: #4B5563;
	cursor: pointer;
	user-select: none;
}

.hbc-contact-form__consent input[type="checkbox"] {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	margin: 3px 0 0;
	accent-color: #1D2D5C;
	cursor: pointer;
}

.hbc-contact-form__consent-text a {
	color: #1D2D5C;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.hbc-contact-form__consent-text a:hover,
.hbc-contact-form__consent-text a:focus {
	color: #142046;
}

.hbc-contact-form__consent.has-error {
	color: #DC2626;
}

.hbc-contact-form__consent.has-error input[type="checkbox"] {
	outline: 2px solid #DC2626;
	outline-offset: 2px;
}

/* ==========================================================================
 *  操作按钮区
 * ========================================================================== */
.hbc-contact-form__actions {
	display: flex;
	justify-content: flex-start;
	margin-top: 4px;
}

.hbc-contact-form__submit {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 14px 32px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.02em;
	color: #FFFFFF;
	background-color: #1D2D5C;
	border: 0;
	border-radius: 4px;
	cursor: pointer;
	font-family: inherit;
	white-space: nowrap;
	transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.hbc-contact-form__submit:hover,
.hbc-contact-form__submit:focus {
	background-color: #142046;
	color: #FFFFFF;
}

.hbc-contact-form__submit:focus-visible {
	outline: 2px solid #1D2D5C;
	outline-offset: 2px;
}

.hbc-contact-form__submit:active {
	transform: translateY(1px);
}

.hbc-contact-form__submit-content {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.hbc-contact-form__submit-icon {
	display: inline-flex;
	align-items: center;
	font-size: 0.95em;
}

.hbc-contact-form__submit-icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

/* 提交中状态 */
.hbc-contact-form__submit-spinner {
	display: none;
	width: 16px;
	height: 16px;
	margin-left: 0;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: hbc-cf-spin 0.7s linear infinite;
}

.hbc-contact-form.is-submitting .hbc-contact-form__submit {
	pointer-events: none;
	opacity: 0.85;
}

.hbc-contact-form.is-submitting .hbc-contact-form__submit-content {
	display: none;
}

.hbc-contact-form.is-submitting .hbc-contact-form__submit-spinner {
	display: inline-block;
}

.hbc-contact-form.is-submitting .hbc-contact-form__submit::after {
	content: attr(data-loading-text);
	margin-left: 8px;
}

@keyframes hbc-cf-spin {
	to { transform: rotate(360deg); }
}

/* ==========================================================================
 *  提交结果提示
 * ========================================================================== */
.hbc-contact-form__notice {
	padding: 14px 18px;
	font-size: 14px;
	line-height: 1.5;
	border: 1px solid transparent;
	border-radius: 4px;
}

.hbc-contact-form__notice[hidden] {
	display: none;
}

.hbc-contact-form__notice--success {
	color: #065F46;
	background-color: #ECFDF5;
	border-color: rgba(6, 95, 70, 0.2);
}

.hbc-contact-form__notice--error {
	color: #991B1B;
	background-color: #FEF2F2;
	border-color: rgba(153, 27, 27, 0.2);
}

/* ==========================================================================
 *  Honeypot — 视觉隐藏但可访问
 * ========================================================================== */
.hbc-contact-form__hp {
	position: absolute !important;
	left: -10000px !important;
	top: auto;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ==========================================================================
 *  响应式 — 平板及以下,字段全宽
 * ========================================================================== */
@media (max-width: 767px) {
	.hbc-contact-form__field {
		--hbc-field-width: 100%;
		flex-basis: 100%;
	}
	.hbc-contact-form__title {
		font-size: 20px;
	}
	.hbc-contact-form__submit {
		width: 100%;
	}
	.hbc-contact-form__actions {
		justify-content: stretch;
	}
}

/* ==========================================================================
 *  减少动效偏好
 * ========================================================================== */
@media (prefers-reduced-motion: reduce) {
	.hbc-contact-form__input,
	.hbc-contact-form__submit {
		transition: none;
	}
	.hbc-contact-form__submit-spinner {
		animation-duration: 1.4s;
	}
}
