/*
 * Cheetah Forms frontend foundation and default presentation.
 *
 * These styles provide structural defaults for the runtime, field types,
 * responsive layout, validation feedback, and submission messages. Theme
 * variables remain the preferred integration point for site-specific styling.
 */
.chf-form,
.chf-form * {
	box-sizing: border-box;
}

.chf-form {
	--chf-primary: var(--cheetah-primary, #0D76B8);
	--chf-primary-hover: var(--cheetah-primary-hover, #0096DC);
	--chf-text: inherit;
	--chf-border: #d9dfe5;
	--chf-error: #b42318;
	--chf-success: #067647;
	--chf-radius: 4px;
	--chf-field-height: 44px;
	--chf-field-spacing: 20px;
	color: var(--chf-text);
}

.chf-form__title {
	margin-bottom: 0.75rem;
	font-size: 1.5rem;
	line-height: 1.3;
}

.chf-form__description {
	margin-bottom: 1.25rem;
}

.chf-form__fields {
	min-width: 0;
}

.chf-field {
	position: relative;
	margin-bottom: var(--chf-field-spacing);
}

.chf-field__label {
	display: block;
	margin-bottom: 0.45rem;
}

.chf-field__required {
	margin-left: 0.2em;
	color: var(--chf-error);
}

.chf-field__description {
	margin-top: 0.35rem;
	font-size: 0.9em;
}

.chf-field__error {
	margin-top: 0.35rem;
	color: var(--chf-error);
}

@media (max-width: 767px) {
	.chf-form {
		--chf-field-spacing: 16px;
	}
}

/*
 * ------------------------------------------------------------------
 * Form controls
 * ------------------------------------------------------------------
 */

.chf-form {
	--chf-input-bg: #fff;
	--chf-input-padding-x: 12px;
	--chf-input-padding-y: 10px;
	--chf-select-arrow-inset: 14px;
	--chf-font-family: inherit;
	--chf-font-size: 15px;
	--chf-label-weight: 600;
	--chf-button-bg: var(--chf-primary);
	--chf-button-color: #fff;
	--chf-button-radius: var(--chf-radius);
}

.chf-field__label {
	font-weight: var(--chf-label-weight);
	font-size: 0.92em;
}

.chf-field__input,
.chf-field input[type="text"],
.chf-field input[type="email"],
.chf-field input[type="url"],
.chf-field input[type="tel"],
.chf-field input[type="number"],
.chf-field input[type="date"],
.chf-field input[type="password"],
.chf-field input[type="search"],
.chf-field input[type="file"],
.chf-field select,
.chf-field textarea {
	display: block;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	min-height: var(--chf-field-height);
	padding: var(--chf-input-padding-y) var(--chf-input-padding-x);
	border: 1px solid var(--chf-border);
	border-radius: var(--chf-radius);
	background: var(--chf-input-bg);
	color: inherit;
	font: inherit;
	font-size: var(--chf-font-size);
	line-height: 1.4;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.chf-field textarea {
	min-height: 110px;
	resize: vertical;
}

.chf-field input:focus,
.chf-field select:focus,
.chf-field textarea:focus {
	outline: none;
	border-color: var(--chf-primary);
	box-shadow: 0 0 0 3px rgba(13, 118, 184, 0.15);
}

/* Select: room for the native arrow */
.chf-field select,
.chf-field__input--select {
	padding-right: calc(var(--chf-select-arrow-inset) + 18px);
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	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='%23566672' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right var(--chf-select-arrow-inset) center;
	background-size: 12px 8px;
}

.chf-field select::-ms-expand {
	display: none;
}

/* Searchable select (country / state) */
.chf-searchable {
	position: relative;
}

.chf-searchable__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	width: 100%;
	min-height: var(--chf-field-height);
	padding: var(--chf-input-padding-y) var(--chf-input-padding-x);
	padding-right: calc(var(--chf-select-arrow-inset) + 18px);
	border: 1px solid var(--chf-border);
	border-radius: var(--chf-radius);
	background: var(--chf-input-bg) 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='%23566672' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E") no-repeat right var(--chf-select-arrow-inset) center / 12px 8px;
	color: inherit;
	font: inherit;
	font-size: var(--chf-font-size);
	text-align: left;
	cursor: pointer;
}

.chf-searchable__toggle:focus {
	outline: none;
	border-color: var(--chf-primary);
	box-shadow: 0 0 0 3px rgba(13, 118, 184, 0.15);
}

.chf-searchable__panel {
	position: absolute;
	z-index: 40;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	display: none;
	overflow: hidden;
	border: 1px solid var(--chf-border);
	border-radius: var(--chf-radius);
	background: #fff;
	box-shadow: 0 12px 28px rgba(18, 32, 45, 0.12);
}

.chf-searchable.is-open .chf-searchable__panel {
	display: block;
}

.chf-searchable__search {
	display: block;
	width: 100%;
	box-sizing: border-box;
	padding: 10px 12px;
	border: 0;
	border-bottom: 1px solid #edf0f2;
	font: inherit;
	font-size: 14px;
}

.chf-searchable__search:focus {
	outline: none;
}

.chf-searchable__list {
	max-height: 220px;
	margin: 0;
	padding: 4px 0;
	overflow-y: auto;
	list-style: none;
}

.chf-searchable__option {
	display: block;
	width: 100%;
	padding: 8px 12px;
	border: 0;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 14px;
	text-align: left;
	cursor: pointer;
}

.chf-searchable__option:hover,
.chf-searchable__option.is-active,
.chf-searchable__option[aria-selected="true"] {
	background: #f0f7fc;
	color: var(--chf-primary);
}

.chf-searchable__empty {
	padding: 12px;
	color: #6b7785;
	font-size: 13px;
}

/* Number field with custom spinner */
.chf-number-input {
	position: relative;
	display: flex;
	align-items: stretch;
}

.chf-number-input input[type="number"] {
	-moz-appearance: textfield;
	padding-right: 42px;
}

.chf-number-input input[type="number"]::-webkit-outer-spin-button,
.chf-number-input input[type="number"]::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.chf-number-spinner {
	position: absolute;
	top: 1px;
	right: 1px;
	bottom: 1px;
	display: flex;
	flex-direction: column;
	width: 32px;
	overflow: hidden;
	border-left: 1px solid var(--chf-border);
	border-radius: 0 var(--chf-radius) var(--chf-radius) 0;
	background: #f6f8fa;
}

.chf-number-spinner__btn {
	display: flex;
	flex: 1 1 50%;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: #4a5560;
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	user-select: none;
}

.chf-number-spinner__btn:hover,
.chf-number-spinner__btn:focus-visible {
	background: #e8eef4;
	color: var(--chf-primary);
	outline: none;
}

.chf-number-spinner__btn--up {
	border-bottom: 1px solid var(--chf-border);
}

.chf-field--has-error .chf-field__input,
.chf-field--has-error input,
.chf-field--has-error select,
.chf-field--has-error textarea,
.chf-field--has-error .chf-searchable__toggle {
	border-color: var(--chf-error);
}

/* Submit button */
.chf-field--submit .chf-field__input,
.chf-form button[type="submit"],
.chf-form .chf-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--chf-field-height);
	padding: 0 18px;
	border: 1px solid var(--chf-button-bg);
	border-radius: var(--chf-button-radius);
	background: var(--chf-button-bg);
	color: var(--chf-button-color);
	font-weight: 700;
	cursor: pointer;
}

.chf-form button[type="submit"]:hover,
.chf-form .chf-submit:hover {
	background: var(--chf-primary-hover);
	border-color: var(--chf-primary-hover);
}

/* Structured layout grid. `layout_html` is compiled from the builder's
 * canonical `layout_schema`; responsive spans are carried by the generated
 * column's CSS custom properties. */
.chf-layout {
	display: flex;
	flex-direction: column;
	gap: var(--chf-field-spacing);
}

.chf-layout__row {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	gap: var(--chf-field-spacing);
}

.chf-layout__col {
	min-width: 0;
	grid-column: span var(--chf-col-desktop, 12);
}

.chf-layout__col .chf-field {
	margin-bottom: 0;
}

@media (max-width: 1023px) {
	.chf-layout__col {
		grid-column: span var(--chf-col-tablet, 12);
	}
}

@media (max-width: 781px) {
	.chf-layout__row {
		grid-template-columns: repeat(12, minmax(0, 1fr));
	}

	.chf-layout__col {
		grid-column: span var(--chf-col-mobile, 12);
	}
}

/* File input -------------------------------------------------------- */

.chf-field input[type="file"],
.chf-field__input--file {
	padding: 8px;
	border: 1px dashed var(--chf-border);
	border-radius: var(--chf-radius);
	background: #f8fafc;
	cursor: pointer;
}

.chf-field input[type="file"]::file-selector-button,
.chf-field input[type="file"]::-webkit-file-upload-button {
	margin-right: 12px;
	padding: 8px 14px;
	border: 1px solid var(--chf-border);
	border-radius: calc(var(--chf-radius) - 1px);
	background: #fff;
	color: inherit;
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.chf-field input[type="file"]:hover::file-selector-button,
.chf-field input[type="file"]:hover::-webkit-file-upload-button {
	border-color: var(--chf-primary);
	background: #f0f7fc;
	color: var(--chf-primary);
}

.chf-field input[type="file"]:focus {
	border-style: solid;
}

/*
 * ------------------------------------------------------------------
 * Submission feedback and validation states
 * ------------------------------------------------------------------
 * The frontend runtime uses accessible inline feedback rather than browser
 * popups. The message region is a sibling immediately before its form, so theme
 * rules targeting form descendants cannot clip its success/error state. The
 * same semantic classes and `hidden` attribute drive both display and a11y.
 */
.chf-form__messages {
	box-sizing: border-box;
	display: block;
	position: relative;
	clear: both;
	grid-column: 1 / -1;
	isolation: isolate;
	width: 100%;
	min-width: 0;
	height: auto;
	max-height: none;
	overflow: visible;
	margin: 0 0 1rem;
	padding: 0;
	font-family: inherit;
	line-height: 1.5;
}

.chf-form__messages:not([hidden]):not(:empty) {
	display: flex !important;
	align-items: center !important;
	justify-content: space-between;
	gap: 0.75rem;
	box-sizing: border-box;
	width: 100%;
	padding: 0.75rem 0.8rem 0.75rem 1rem;
	border: 1px solid #d0d5dd;
	border-radius: 8px;
	background: #f8fafc;
	color: #344054;
	visibility: visible !important;
	opacity: 1 !important;
}

.chf-form__messages:empty,
.chf-form__messages[hidden] {
	display: none !important;
}

.chf-form__messages:not([hidden]):not(:empty) > .chf-form__message,
.chf-form__message {
	box-sizing: border-box;
	display: block !important;
	flex: 1 1 auto;
	min-width: 0;
	width: auto;
	min-height: 0;
	height: auto;
	max-height: none;
	overflow: visible;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: inherit;
	-webkit-text-fill-color: currentColor;
	font-family: inherit;
	font-size: 0.9rem;
	font-weight: 400;
	line-height: 1.5;
	text-align: left;
	white-space: normal;
	overflow-wrap: anywhere;
	transform: none;
}

.chf-form__messages.chf-form__messages--success:not(:empty) {
	border-color: #a6f4c5;
	background: #ecfdf3;
	color: #05603a;
}

.chf-form__messages.chf-form__messages--error:not(:empty),
.chf-form__messages.chf-form__messages--validation:not(:empty) {
	border-color: #fecdca;
	background: #fef3f2;
	color: #912018;
}

/* Older/server-rendered message modifiers keep inheriting the region palette. */
.chf-form__message--success,
.chf-form__message--error,
.chf-form__message--validation,
.chf-form__message--spam,
.chf-form__message--limit,
.chf-form__message--duplicate {
	border: 0;
	background: transparent;
	color: inherit;
	-webkit-text-fill-color: currentColor;
}

.chf-form .chf-field__errors:not([hidden]),
.chf-form [data-chf-field-key] .chf-field__errors:not([hidden]) {
	/*
	 * Keep field-level feedback compact, readable, and in normal document flow.
	 * Some themes and saved form styles use transparent text-fill, absolute
	 * positioning, or high-specificity text rules. Reset the relevant visual
	 * properties without using relative positioning: `top`/`right`/`bottom`/
	 * `left` offsets still apply to a relatively positioned box and can move
	 * the message away from its field while its original layout space remains.
	 * Static positioning ignores those offsets and keeps the message in flow.
	 */
	box-sizing: border-box;
	display: block !important;
	visibility: visible !important;
	opacity: 1 !important;
	position: static !important;
	float: none !important;
	clear: both !important;
	width: 100%;
	min-width: 0;
	height: auto !important;
	min-height: 0 !important;
	max-height: none !important;
	overflow: visible !important;
	clip: auto !important;
	clip-path: none !important;
	filter: none !important;
	transform: none !important;
	margin: 0.3rem 0 0 !important;
	padding: 0.4rem !important;
	border: 0 !important;
	border-radius: 3px !important;
	background: #fff5f4 !important;
	color: #912018 !important;
	-webkit-text-fill-color: #912018 !important;
	font-family: inherit !important;
	font-size: 0.78rem !important;
	font-weight: 500 !important;
	line-height: 1.35 !important;
	text-align: left !important;
	text-indent: 0 !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	white-space: normal !important;
	overflow-wrap: anywhere !important;
}

.chf-form .chf-field__errors[hidden] {
	display: none !important;
}

.chf-form .chf-field__errors > p {
	margin: 0;
}

.chf-form .chf-field__errors > p + p {
	margin-top: 0.25rem;
}

.chf-form .chf-field input[aria-invalid="true"],
.chf-form .chf-field select[aria-invalid="true"],
.chf-form .chf-field textarea[aria-invalid="true"],
.chf-form .chf-field .chf-searchable__toggle[aria-invalid="true"] {
	border-color: var(--chf-error);
	box-shadow: 0 0 0 1px rgba(180, 35, 24, 0.08);
}

.chf-form .chf-field input[aria-invalid="true"]:focus,
.chf-form .chf-field select[aria-invalid="true"]:focus,
.chf-form .chf-field textarea[aria-invalid="true"]:focus {
	border-color: var(--chf-error);
	box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.16);
	outline: none;
}

.chf-form .chf-form__fields[hidden] {
	display: none !important;
}

/*
 * ------------------------------------------------------------------
 * Floating (escaped) message region
 * ------------------------------------------------------------------
 *
 * When the runtime detects that a theme ancestor is clipping the
 * message region — a block wrapper with `overflow: hidden`, a fixed
 * height, or `contain: paint` — it relocates the region to
 * `document.body` and marks it with `data-chf-message-floating="1"`.
 * The rules below pin it as a prominent card at the top of the
 * viewport so the visitor sees it regardless of what the theme does.
 *
 * The `animation` is a short, unobtrusive entrance. Floating notices are
 * dismissed after 20 seconds; their timer pauses during hover, keyboard focus,
 * and hidden-tab states. The animation is disabled for reduced-motion users.
 */

.chf-form__messages[data-chf-message-floating="1"] {
	display: flex !important;
	align-items: center !important;
	justify-content: space-between !important;
	gap: 0.75rem !important;
	position: fixed !important;
	top: 24px !important;
	left: 50% !important;
	right: auto !important;
	bottom: auto !important;
	width: calc(100vw - 32px) !important;
	min-width: min(320px, calc(100vw - 32px)) !important;
	max-width: min(640px, calc(100vw - 32px)) !important;
	margin: 0 !important;
	padding: 0.8rem 0.85rem 0.8rem 1rem !important;
	border-radius: 10px !important;
	box-shadow: 0 12px 32px rgba(18, 32, 45, 0.18), 0 2px 8px rgba(18, 32, 45, 0.1) !important;
	transform: translateX(-50%) !important;
	z-index: 2147483000 !important;
	animation: chf-form-message-enter 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.chf-form__messages[data-chf-message-floating="1"] > .chf-form__message {
	flex: 1 1 auto !important;
	min-width: 0 !important;
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	color: inherit !important;
	-webkit-text-fill-color: currentColor !important;
}

@keyframes chf-form-message-enter {
	from {
		opacity: 0;
		transform: translateX(-50%) translateY(-16px);
	}
	to {
		opacity: 1;
		transform: translateX(-50%) translateY(0);
	}
}

@media (prefers-reduced-motion: reduce) {
	.chf-form__messages[data-chf-message-floating="1"] {
		animation: none;
	}
}

/*
 * ------------------------------------------------------------------
 * Message close control
 * ------------------------------------------------------------------
 *
 * Every message region — inline or floating — carries a close button.
 * The message region uses flex layout, so the close control stays centred
 * vertically beside short and multi-line messages without absolute offsets.
 *
 * The button inherits the message's own colour so it reads as part of
 * the message on both the success and error palettes.
 */

.chf-form__messages .chf-form__message-close {
	position: relative !important;
	top: auto !important;
	right: auto !important;
	transform: none !important;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 1.75rem;
	width: 1.75rem;
	min-width: 1.75rem;
	height: 1.75rem;
	align-self: center;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: currentColor;
	font-family: inherit;
	font-size: 1.25rem;
	font-weight: 400;
	line-height: 1;
	text-align: center;
	cursor: pointer;
	opacity: 0.55;
	transition: opacity 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.chf-form__messages .chf-form__message-close:hover,
.chf-form__messages .chf-form__message-close:focus-visible {
	opacity: 1;
	background: rgba(0, 0, 0, 0.08);
	outline: none;
}

.chf-form__messages .chf-form__message-close:focus-visible {
	box-shadow: 0 0 0 2px currentColor;
}

.chf-form__messages.chf-form__messages--success .chf-form__message-close:hover {
	background: rgba(5, 96, 58, 0.12);
}

.chf-form__messages.chf-form__messages--error .chf-form__message-close:hover,
.chf-form__messages.chf-form__messages--validation .chf-form__message-close:hover {
	background: rgba(145, 32, 24, 0.12);
}



