/* ==========================================================================
   Forms — lead form #dang-ky (.c-lead-form) = Fluent Forms markup, themed here.
   The plugin's default skin is off (inc/contact-form.php); its small structural CSS stays.
   docs/02 §4 lỗi #8: visible boxes, radius 14px, 1.5px border, blue focus ring, large tap targets.
   Behaviour (validation, sending state, success card): assets/js/form-handler.js.
   ========================================================================== */

.c-lead-form {
	padding: clamp(20px, 0.9rem + 1.6vw, 40px);
	background: var(--c-surface);
	border-radius: var(--radius-lg);
	box-shadow: 0 10px 30px rgba(19, 61, 115, 0.06);
}

.c-lead-form__off {
	padding: var(--space-5);
	background: var(--c-pastel-ice);
	border-radius: var(--radius-md);
	color: var(--c-primary-dark);
	text-align: center;
}

.c-lead-form[data-lead-form] .fluentform,
.c-lead-form fieldset {
	margin: 0;
}

/* --- Layout: name + phone side by side from 600px ------------------------ */
.c-lead-form[data-lead-form] .ff-t-container {
	display: grid;
	gap: 0 var(--space-4);
	margin: 0;
}

.c-lead-form[data-lead-form] .ff-t-cell {
	width: auto;
	padding: 0 !important;      /* plugin adds gutters inline / via its CSS */
}

@media (min-width: 600px) {
	.c-lead-form[data-lead-form] .ff-t-container {
		grid-template-columns: 1fr 1fr;
	}
}

.c-lead-form[data-lead-form] .ff-el-group {
	margin: 0 0 var(--space-4);
}

/* --- Labels ------------------------------------------------------------- */
.c-lead-form[data-lead-form] .ff-el-input--label {
	display: block;
	margin-bottom: var(--space-2);
	padding: 0;
}

.c-lead-form[data-lead-form] .ff-el-input--label label {
	margin: 0;
	font-family: var(--font-eyebrow);
	font-size: var(--fs-sm);
	font-weight: var(--fw-medium);
	color: var(--c-text-eyebrow);
}

.c-lead-form[data-lead-form] .ff-el-input--label.ff-el-is-required.asterisk-right label::after {
	content: "*";
	margin-left: 3px;
	color: var(--c-danger);            /* red "required" mark (only the phone, 18/11) */
}

/* --- Inputs ------------------------------------------------------------- */
.c-lead-form[data-lead-form] .ff-el-form-control {
	display: block;
	width: 100%;
	min-height: 52px;
	padding: var(--space-3) var(--space-4);
	background: var(--c-surface);
	border: 1.5px solid var(--c-field-border);
	border-radius: 14px;
	box-shadow: none;
	color: var(--c-text-strong);
	font: inherit;
	font-size: var(--fs-base);
	line-height: 1.4;
	transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.c-lead-form[data-lead-form] .ff-el-form-control::placeholder {
	color: #9AA6B5;
	opacity: 1;
}

.c-lead-form[data-lead-form] .ff-el-form-control:hover {
	border-color: #A9C6EE;
}

.c-lead-form[data-lead-form] .ff-el-form-control:focus {
	border-color: var(--c-primary);
	outline: none;
	box-shadow: 0 0 0 4px rgba(var(--c-primary-rgb), 0.15);
}

/* --- Error state (same markup for browser + server errors) ----------------- */
.c-lead-form[data-lead-form] .ff-el-is-error .ff-el-form-control {
	background: #FFF8F8;
	border-color: var(--c-danger);
}

.c-lead-form[data-lead-form] .ff-el-is-error .ff-el-form-control:focus {
	box-shadow: 0 0 0 4px rgba(217, 56, 58, 0.14);
}

.c-lead-form[data-lead-form] .error.text-danger {
	display: block;
	margin-top: var(--space-2);
	color: var(--c-danger);
	font-size: var(--fs-xs);
	font-weight: var(--fw-medium);
	line-height: 1.45;
	text-wrap: balance;                /* if a message must wrap, no lone last word */
	animation: sk-error-in 0.22s ease-out;
}

@keyframes sk-error-in {
	from { opacity: 0; transform: translateY(-4px); }
	to { opacity: 1; transform: none; }
}

/* --- Consent checkbox ------------------------------------------------------ */
.c-lead-form[data-lead-form] .c-ff-consent {
	margin-top: var(--space-5);
}

/* plugin lays this out as a table (display: table / table-row / table-cell) — back to a simple flex row */
.c-lead-form[data-lead-form] .ff-el-tc {
	display: block;
}

.c-lead-form[data-lead-form] .ff-el-tc label.ff_tc_label {
	display: flex;
	gap: var(--space-3);
	align-items: flex-start;
	margin: 0;
	color: var(--c-text);
	font-size: var(--fs-sm);
	font-weight: var(--fw-regular);
	line-height: 1.5;
	cursor: pointer;
}

.c-lead-form[data-lead-form] .ff-el-tc label.ff_tc_label > span,
.c-lead-form[data-lead-form] .ff-el-tc label.ff_tc_label > div {
	display: block;
}

.c-lead-form[data-lead-form] .ff-el-tc label.ff_tc_label > .ff_tc_checkbox {
	flex: none;
	width: auto;
	padding-top: 1px !important;      /* plugin: 8px !important */
}

.c-lead-form[data-lead-form] .ff-el-form-check-input {
	width: 20px;
	height: 20px;
	margin: 0;
	accent-color: var(--c-primary);
	cursor: pointer;
	top: 0;
	vertical-align: top;
}

.c-lead-form[data-lead-form] .ff-el-is-error .ff-el-form-check-input {
	outline: 2px solid var(--c-danger);
	outline-offset: 1px;
}

.c-lead-form[data-lead-form] .ff_t_c {
	margin: 0;
}

/* --- Submit + sending state ------------------------------------------------ */
.c-lead-form[data-lead-form] .ff_submit_btn_wrapper {
	margin: var(--space-5) 0 0;
}

.c-lead-form[data-lead-form] .ff-btn-submit {
	position: relative;
	display: flex;
	gap: var(--space-3);
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 54px;
	padding: var(--space-3) var(--space-6);
	background: var(--c-primary);
	border: 0;
	border-radius: var(--radius-pill);
	box-shadow: var(--shadow-btn);
	color: var(--c-on-primary);
	font-family: var(--font-sans);
	font-size: var(--fs-base);
	font-weight: var(--fw-bold);
	line-height: 1.25;
	text-wrap: balance;
	cursor: pointer;
	transition: background var(--transition-fast), transform var(--transition-fast);
}

.c-lead-form[data-lead-form] .ff-btn-submit::after {
	content: "";
	flex: none;
	width: 14px;
	height: 14px;
	background: currentColor;
	-webkit-mask: url("../img/icons/arrow-right.svg") center / contain no-repeat;
	mask: url("../img/icons/arrow-right.svg") center / contain no-repeat;
	transition: transform var(--transition-fast);
}

.c-lead-form[data-lead-form] .ff-btn-submit:hover {
	background: var(--c-primary-dark);
}

.c-lead-form[data-lead-form] .ff-btn-submit:hover::after {
	transform: translateX(3px);
}

.c-lead-form[data-lead-form] .ff-btn-submit:active {
	transform: translateY(1px);
}

.c-lead-form[data-lead-form] .ff-btn-submit:focus-visible {
	outline: 3px solid rgba(var(--c-primary-rgb), 0.35);
	outline-offset: 3px;
}

/* Fluent adds .ff-working + disabled while sending → spinner + "Đang gửi…" */
.c-lead-form[data-lead-form] .ff-btn-submit.ff-working {
	font-size: 0;                     /* hide the label text node */
	opacity: 0.92;
	cursor: progress;
}

.c-lead-form[data-lead-form] .ff-btn-submit.ff-working::before {
	content: attr(data-sending);
	order: 2;
	font-size: var(--fs-base);
}

.c-lead-form[data-lead-form] .ff-btn-submit.ff-working::after {
	position: static;                 /* plugin draws a progress bar here (absolute, full width) */
	order: 1;
	width: 18px;
	height: 18px;
	background: none;
	border: 2.5px solid rgba(255, 255, 255, 0.35);
	border-top-color: #FFF;
	border-radius: 50%;
	-webkit-mask: none;
	mask: none;
	animation: sk-spin 0.7s linear infinite;
}

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

/* Error list Fluent may show under the form (network / global errors) */
.c-lead-form[data-lead-form] .ff-errors-in-stack:not(:empty) {
	margin-top: var(--space-4);
}

.c-lead-form[data-lead-form] .ff-errors-in-stack .error-clear {
	margin-left: auto;
	cursor: pointer;
}

/* --- Success card (built by form-handler.js around Fluent's confirmation text) */
.c-lead-form[data-lead-form] .ff-message-success {
	margin: 0;
	padding: 0;
	border: 0;
	box-shadow: none;
}

.c-lead-form[data-lead-form] .c-form-success {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: var(--space-7) var(--space-4);
	text-align: center;
}

.c-lead-form[data-lead-form] .c-form-success:focus,
.c-lead-form[data-lead-form] .c-form-success__title:focus {
	outline: none;
}

.c-lead-form[data-lead-form] .c-form-success__icon {
	position: relative;
	width: 88px;
	height: 88px;
	margin-bottom: var(--space-5);
}

/* soft halo that spreads once the tick is drawn */
.c-lead-form[data-lead-form] .c-form-success__icon::before {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(var(--c-primary-rgb), 0.18);
	border-radius: 50%;
	opacity: 0;
}

.c-lead-form[data-lead-form] .c-form-success__svg {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	overflow: visible;
}

.c-lead-form[data-lead-form] .c-form-success__ring {
	fill: var(--c-primary);
	fill-opacity: 0;
	stroke: var(--c-primary);
	stroke-width: 3;
	stroke-dasharray: 183;
	stroke-dashoffset: 183;
	transform: rotate(-90deg);
	transform-origin: center;
}

.c-lead-form[data-lead-form] .c-form-success__tick {
	fill: none;
	stroke: #FFF;
	stroke-width: 5;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-dasharray: 40;
	stroke-dashoffset: 40;
}

.c-lead-form[data-lead-form] .c-form-success > :not(.c-form-success__icon) {
	opacity: 0;
	transform: translateY(10px);
}

.c-lead-form[data-lead-form] .c-form-success__title,
.c-lead-form[data-lead-form] .c-form-success h3 {
	margin: 0 0 var(--space-3);
	color: var(--c-primary-dark);
	font-family: var(--font-display);
	font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.625rem);
	font-weight: var(--fw-bold);
	line-height: 1.3;
}

.c-lead-form[data-lead-form] .c-form-success p {
	max-width: 30em;
	margin: 0;
	color: var(--c-text);
	font-size: var(--fs-base);
	line-height: 1.65;
}

.c-lead-form[data-lead-form] .c-form-success__again {
	display: inline-flex;
	align-items: center;
	min-height: var(--tap-min);
	margin-top: var(--space-6);
	padding: var(--space-2) var(--space-5);
	background: var(--c-surface);
	border: 1px solid var(--c-primary);
	border-radius: var(--radius-pill);
	color: var(--c-primary);
	font: inherit;
	font-size: var(--fs-sm);
	font-weight: var(--fw-bold);
	cursor: pointer;
	transition: background var(--transition-fast);
}

.c-lead-form[data-lead-form] .c-form-success__again:hover {
	background: var(--c-pastel-ice);
}

/* Sequence: ring draws (0–0.6s) → fills → tick draws → pop + halo → texts rise */
.c-lead-form[data-lead-form] .c-form-success.is-shown .c-form-success__ring {
	animation:
		sk-draw 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards,
		sk-fill 0.3s 0.5s ease-out forwards;
}

.c-lead-form[data-lead-form] .c-form-success.is-shown .c-form-success__tick {
	animation: sk-draw 0.35s 0.75s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.c-lead-form[data-lead-form] .c-form-success.is-shown .c-form-success__icon {
	animation: sk-pop 0.5s 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.c-lead-form[data-lead-form] .c-form-success.is-shown .c-form-success__icon::before {
	animation: sk-halo 1.1s 0.95s ease-out forwards;
}

.c-lead-form[data-lead-form] .c-form-success.is-shown > :not(.c-form-success__icon) {
	animation: sk-rise 0.5s ease-out forwards;
}

.c-lead-form[data-lead-form] .c-form-success.is-shown > :nth-child(2) { animation-delay: 0.85s; }
.c-lead-form[data-lead-form] .c-form-success.is-shown > :nth-child(3) { animation-delay: 0.95s; }
.c-lead-form[data-lead-form] .c-form-success.is-shown > :nth-child(n + 4) { animation-delay: 1.05s; }

@keyframes sk-draw {
	to { stroke-dashoffset: 0; }
}

@keyframes sk-fill {
	to { fill-opacity: 1; }
}

@keyframes sk-pop {
	0% { transform: scale(1); }
	45% { transform: scale(1.1); }
	100% { transform: scale(1); }
}

@keyframes sk-halo {
	0% { opacity: 0.9; transform: scale(0.9); }
	100% { opacity: 0; transform: scale(1.8); }
}

@keyframes sk-rise {
	to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.c-lead-form[data-lead-form] .error.text-danger,
	.c-lead-form[data-lead-form] .c-form-success.is-shown .c-form-success__ring,
	.c-lead-form[data-lead-form] .c-form-success.is-shown .c-form-success__tick,
	.c-lead-form[data-lead-form] .c-form-success.is-shown .c-form-success__icon,
	.c-lead-form[data-lead-form] .c-form-success.is-shown .c-form-success__icon::before,
	.c-lead-form[data-lead-form] .c-form-success.is-shown > :not(.c-form-success__icon) {
		animation: none;
	}

	.c-lead-form[data-lead-form] .c-form-success__ring {
		fill-opacity: 1;
		stroke-dashoffset: 0;
	}

	.c-lead-form[data-lead-form] .c-form-success__tick {
		stroke-dashoffset: 0;
	}

	.c-lead-form[data-lead-form] .c-form-success > :not(.c-form-success__icon) {
		opacity: 1;
		transform: none;
	}

	.c-lead-form[data-lead-form] .ff-btn-submit.ff-working::after {
		animation-duration: 1.5s;
	}
}
