/**
 * ATS Consultation Requests — lead and contact form styles (REQ-003, REQ-013, REQ-021).
 * Reproduces the prototype booking form (.field, .field-row, .form-error,
 * .btn-primary.btn-block, .form-success) on the plugin's BEM classes.
 * Uses the American Tax Services theme.json presets with literal fallbacks so
 * the form stays usable under any theme (TECH-002, TECH-018).
 */

.ats-form {
	position: relative; /* Success overlay anchor outside the theme card; the theme sets static inside its card. */
	margin: 0;
	font-family: var(--wp--preset--font-family--inter, "Inter", system-ui, sans-serif);
	color: var(--wp--preset--color--contrast, #0c1e33);
}

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

/* ---- Fields (.field / .field-label / .field-row) ---- */

.ats-form__field {
	display: block;
	margin: 0 0 12px;
	min-width: 0;
}

.ats-form__label {
	display: block;
	margin-bottom: 6px;
	color: var(--wp--preset--color--navy, #0c2d4e);
	font-size: 0.78rem;
	font-weight: 600;
	line-height: 1.6;
}

/* Required-field marker (aria-hidden: the inputs carry `required` for assistive tech). */
.ats-form__req {
	margin-left: 2px;
	color: var(--wp--preset--color--accent, #c71c2c);
}

.ats-form__row {
	display: grid;
	grid-template-columns: 1.3fr 1fr;
	gap: 12px;
}

@media (max-width: 560px) {
	.ats-form__row {
		grid-template-columns: 1fr 1fr;
	}
}

.ats-form__input,
.ats-form__select {
	display: block;
	width: 100%;
	height: 48px;
	margin: 0;
	padding: 0 14px;
	border: 1px solid var(--wp--preset--color--border, #e3eaf5);
	border-radius: 10px;
	background-color: var(--wp--preset--color--surface, #f2f6fc);
	color: var(--wp--preset--color--contrast, #0c1e33);
	font-family: inherit;
	font-size: 0.88rem;
	line-height: normal;
	outline: none;
	box-shadow: none;
	transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.ats-form__input::placeholder {
	color: var(--wp--preset--color--muted, #5d6b84);
	opacity: 1;
}

/* Caret: Lucide chevron-down as an inline data URI (no external request). */
.ats-form__select {
	padding-right: 42px;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300488a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 16px center;
	background-size: 16px;
}

.ats-form__select::-ms-expand {
	display: none;
}

/* Disabled fields. */
.ats-form__input:disabled,
.ats-form__select:disabled {
	border-color: var(--wp--preset--color--border, #e3eaf5);
	background-color: var(--wp--preset--color--surface, #f2f6fc);
	color: var(--wp--preset--color--muted, #5d6b84);
	cursor: not-allowed;
	opacity: 0.7;
	box-shadow: none;
}

.ats-form__select option:disabled {
	color: var(--wp--preset--color--muted, #5d6b84);
}

.ats-form__input:focus,
.ats-form__select:focus {
	border-color: var(--wp--preset--color--blue-500, #1a62a8);
	background-color: var(--wp--preset--color--base, #fff);
	box-shadow: 0 0 0 4px rgba(26, 98, 168, 0.15);
}

/* The blue border + halo is the focus indicator: drop the theme's red :focus-visible outline,
 * which reads as an error on form fields. Checkboxes get a blue outline instead. */
.ats-form .ats-form__input:focus-visible,
.ats-form .ats-form__select:focus-visible {
	outline: none;
}

.ats-form .ats-form__checkbox:focus-visible {
	outline: 2px solid var(--wp--preset--color--blue-500, #1a62a8);
	outline-offset: 2px;
	border-radius: 3px;
}

/* Invalid: server-side (aria-invalid) or client-side (.invalid / .is-invalid). */
.ats-form__input[aria-invalid="true"],
.ats-form__select[aria-invalid="true"],
.ats-form__input.invalid,
.ats-form__select.invalid,
.ats-form__input.is-invalid,
.ats-form__select.is-invalid {
	border-color: #e5533a;
	background-color: #fff6f4;
}

/* Per-field error text (server-side). */
.ats-form__error {
	margin: 6px 0 0;
	color: #d1432b;
	font-size: 0.8rem;
	line-height: 1.4;
}

/* Form-level error (.form-error). */
.ats-form__notice {
	margin: 2px 0 12px;
	color: #d1432b;
	font-size: 0.8rem;
	line-height: 1.5;
}

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

/* ---- Submit (.btn.btn-primary.btn-block) ---- */

.ats-form__submit {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	min-height: 50px;
	margin: 6px 0 0;
	padding: 0 28px;
	border: 1.5px solid transparent;
	border-radius: 12px;
	background: var(--wp--preset--color--accent, #c71c2c);
	color: var(--wp--preset--color--base, #fff);
	font-family: var(--wp--preset--font-family--poppins, "Poppins", system-ui, sans-serif);
	font-size: 0.92rem;
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	box-shadow: 0 10px 24px rgba(199, 28, 44, 0.32);
	transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.ats-form__submit:hover {
	background: var(--wp--preset--color--accent-dark, #a51522);
	color: var(--wp--preset--color--base, #fff);
	transform: translateY(-2px);
	box-shadow: 0 14px 30px rgba(199, 28, 44, 0.42);
}

.ats-form__submit:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary, #00488a);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.ats-form__submit,
	.ats-form__input,
	.ats-form__select {
		transition: none;
	}

	.ats-form__submit:hover {
		transform: none;
	}
}

/* ---- Success overlay (.form-success) ---- */

.ats-form__success {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 30px;
	border-radius: inherit;
	background: var(--wp--preset--color--base, #fff);
	text-align: center;
}

.ats-form__success[hidden] {
	display: none;
}

.ats-form__success:focus {
	outline: none;
}

.ats-form__success-icon {
	display: grid;
	place-items: center;
	width: 60px;
	height: 60px;
	margin-bottom: 6px;
	border-radius: 50%;
	background: #e2f7e8;
	color: #22a356;
}

.ats-form__success-icon svg {
	width: 28px;
	height: 28px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.4;
}

.ats-form__success strong {
	font-family: var(--wp--preset--font-family--poppins, "Poppins", system-ui, sans-serif);
	font-size: 1.1rem;
	font-weight: 600;
	line-height: 1.3;
	color: var(--wp--preset--color--navy, #0c2d4e);
}

.ats-form__success small {
	color: var(--wp--preset--color--muted, #5d6b84);
	font-size: 0.875rem;
	line-height: 1.6;
}

/* ---- Contact form ---- */

.ats-form__row--even {
	grid-template-columns: 1fr 1fr;
}

@media (max-width: 560px) {
	.ats-form__row--even {
		grid-template-columns: 1fr;
	}
}

.ats-form__textarea {
	height: auto;
	min-height: 140px;
	padding: 12px 14px;
	line-height: 1.5;
	resize: vertical;
}

/* ---- Consent (GDPR) ---- */

.ats-form__consent {
	display: grid;
	grid-template-columns: auto 1fr;
	align-items: start;
	gap: 10px;
	margin: 4px 0 12px;
}

.ats-form__checkbox {
	width: 18px;
	height: 18px;
	margin: 2px 0 0;
	accent-color: var(--wp--preset--color--primary, #00488a);
	cursor: pointer;
}

.ats-form__checkbox[aria-invalid="true"],
.ats-form__checkbox.invalid {
	outline: 2px solid #e5533a;
	outline-offset: 2px;
}

.ats-form__consent-label {
	color: var(--wp--preset--color--muted, #5d6b84);
	font-size: 0.78rem;
	line-height: 1.5;
	cursor: pointer;
}

.ats-form__consent-label a,
.ats-form__recaptcha a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.ats-form__consent .ats-form__error {
	grid-column: 1 / -1;
	margin-top: 0;
}

/* ---- reCAPTCHA v3: Google's required notice replaces the floating badge ---- */

.ats-form__recaptcha {
	margin: 4px 0 8px;
	color: var(--wp--preset--color--muted, #5d6b84);
	font-size: 0.72rem;
	line-height: 1.5;
}

.grecaptcha-badge {
	visibility: hidden !important;
}

/* Honeypot: hidden from sighted users and assistive tech (TECH-007). */
.ats-form__hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	margin: 0;
}

/* ---- Services interested in: multi-select checkbox group (lead form) ---- */

.ats-form__services {
	min-width: 0;
	margin: 0 0 12px;
	padding: 0;
	border: 0;
}

.ats-form__services legend {
	padding: 0;
}

.ats-form__options {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}

@media (max-width: 400px) {
	.ats-form__options {
		grid-template-columns: 1fr;
	}
}

.ats-form__option {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 40px;
	padding: 8px 12px;
	border: 1px solid var(--wp--preset--color--border, #e3eaf5);
	border-radius: 10px;
	background-color: var(--wp--preset--color--surface, #f2f6fc);
	color: var(--wp--preset--color--contrast, #0c1e33);
	font-size: 0.82rem;
	line-height: 1.3;
	cursor: pointer;
	transition: border-color 0.2s, background-color 0.2s;
}

.ats-form__option .ats-form__checkbox {
	flex: none;
	margin: 0;
}

.ats-form__option:hover,
.ats-form__option:has(:checked) {
	border-color: var(--wp--preset--color--blue-500, #1a62a8);
	background-color: var(--wp--preset--color--base, #fff);
}

.ats-form__option:has(:focus-visible) {
	box-shadow: 0 0 0 4px rgba(26, 98, 168, 0.15);
}

.ats-form__services.invalid .ats-form__option,
.ats-form__option:has([aria-invalid="true"]) {
	border-color: #e5533a;
}

.ats-form__option .ats-form__checkbox[aria-invalid="true"] {
	outline: 0;
}

/* ---- Toasts for the AJAX submit (protect.js) ---- */

.ats-toast-region {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 100000;
	display: grid;
	gap: 10px;
	width: min(380px, calc(100vw - 32px));
	pointer-events: none;
}

@media (max-width: 560px) {
	.ats-toast-region {
		right: 16px;
		bottom: 16px;
	}
}

.ats-toast {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: start;
	gap: 12px;
	padding: 14px;
	border-radius: 12px;
	background: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--contrast, #0c1e33);
	font-family: var(--wp--preset--font-family--inter, "Inter", system-ui, sans-serif);
	box-shadow: 0 18px 40px rgba(7, 29, 51, 0.22);
	pointer-events: auto;
	animation: ats-toast-in 0.25s ease-out;
}

.ats-toast.is-leaving {
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.25s, transform 0.25s;
}

.ats-toast__icon {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: #e3f5ea;
	color: #1f9d55;
}

.ats-toast--error .ats-toast__icon {
	background: #fdeceb;
	color: #c2412b;
}

.ats-toast__icon svg,
.ats-toast__close svg {
	width: 16px;
	height: 16px;
}

.ats-toast__body {
	display: grid;
	gap: 2px;
	min-width: 0;
	padding-top: 3px;
	font-size: 0.85rem;
	line-height: 1.45;
}

.ats-toast__body strong {
	color: var(--wp--preset--color--navy, #0c2d4e);
	font-weight: 600;
}

.ats-toast__body span {
	color: var(--wp--preset--color--muted, #5d6b84);
}

.ats-toast__close {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--wp--preset--color--muted, #5d6b84);
	cursor: pointer;
}

.ats-toast__close:hover {
	background: var(--wp--preset--color--surface, #f2f6fc);
}

.ats-toast__close:focus-visible {
	outline: 2px solid var(--wp--preset--color--blue-500, #1a62a8);
	outline-offset: 2px;
}

.ats-form[aria-busy="true"] .ats-form__submit {
	cursor: progress;
	opacity: 0.7;
}

@keyframes ats-toast-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ats-toast {
		animation: none;
	}

	.ats-toast.is-leaving {
		transition: none;
	}
}

/* ---- Services as a searchable multi-select dropdown (assets/js/multiselect.js) ----
 * Without the script the checkbox grid above is shown as is; .is-enhanced turns it into a
 * dropdown: a select-like toggle and a floating panel with a search box and a one-column list. */

.ats-ms {
	position: relative;
}

.ats-ms__toggle,
.ats-ms__search {
	display: none;
}

.ats-form__option[hidden] {
	display: none;
}

.ats-form__services.is-enhanced .ats-ms__toggle {
	display: flex;
	align-items: center;
	width: 100%;
	height: 48px;
	margin: 0;
	padding: 0 42px 0 14px;
	border: 1px solid var(--wp--preset--color--border, #e3eaf5);
	border-radius: 10px;
	background-color: var(--wp--preset--color--surface, #f2f6fc);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300488a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 16px center;
	background-size: 16px;
	color: var(--wp--preset--color--contrast, #0c1e33);
	font-family: inherit;
	font-size: 0.88rem;
	text-align: left;
	cursor: pointer;
	transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.ats-form__services.is-enhanced .ats-ms__toggle:focus-visible,
.ats-form__services.is-open .ats-ms__toggle {
	border-color: var(--wp--preset--color--blue-500, #1a62a8);
	background-color: var(--wp--preset--color--base, #fff);
	box-shadow: 0 0 0 4px rgba(26, 98, 168, 0.15);
	outline: none;
}

.ats-ms__value {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ats-ms__placeholder {
	color: var(--wp--preset--color--muted, #5d6b84);
}

.ats-form__services.has-value .ats-ms__placeholder,
.ats-form__services:not(.has-value) .ats-ms__value {
	display: none;
}

/* Invalid (client check adds .invalid on the fieldset; the server marks the checkboxes). */
.ats-form__services.is-enhanced.invalid .ats-ms__toggle,
.ats-form__services.is-enhanced:has([aria-invalid="true"]) .ats-ms__toggle {
	border-color: #e5533a;
	background-color: #fff6f4;
}

.ats-form__services.is-enhanced .ats-ms__panel {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	left: 0;
	z-index: 30;
	padding: 8px;
	border: 1px solid var(--wp--preset--color--border, #e3eaf5);
	border-radius: 12px;
	background: var(--wp--preset--color--base, #fff);
	box-shadow: 0 18px 40px rgba(7, 29, 51, 0.18);
}

.ats-form__services.is-enhanced .ats-ms__panel[hidden] {
	display: none;
}

.ats-form__services.is-enhanced .ats-ms__search {
	display: block;
	width: 100%;
	height: 40px;
	margin: 0 0 6px;
	padding: 0 12px;
	border: 1px solid var(--wp--preset--color--border, #e3eaf5);
	border-radius: 8px;
	background: var(--wp--preset--color--surface, #f2f6fc);
	color: var(--wp--preset--color--contrast, #0c1e33);
	font-family: inherit;
	font-size: 0.86rem;
	outline: none;
}

.ats-form__services.is-enhanced .ats-ms__search:focus {
	border-color: var(--wp--preset--color--blue-500, #1a62a8);
	background: var(--wp--preset--color--base, #fff);
}

.ats-form__services.is-enhanced .ats-form__options {
	grid-template-columns: 1fr;
	gap: 2px;
	max-height: 264px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.ats-form__services.is-enhanced .ats-form__option {
	min-height: 40px;
	padding: 8px 10px;
	border: 0;
	border-radius: 8px;
	background: transparent;
}

.ats-form__services.is-enhanced .ats-form__option:hover,
.ats-form__services.is-enhanced .ats-form__option:has(:focus-visible) {
	background: var(--wp--preset--color--surface, #f2f6fc);
	box-shadow: none;
}

.ats-form__services.is-enhanced .ats-form__option:has(:checked) {
	background: #eaf2fc;
}

.ats-ms__empty {
	margin: 6px 4px;
	color: var(--wp--preset--color--muted, #5d6b84);
	font-size: 0.84rem;
}
