/**
 * UZ Forms Builder — frontend styles.
 *
 * Every selector is scoped under .uzfb-form-wrap / .uzfb-form so nothing
 * leaks into the theme, and no bare element selectors (input, button,
 * select, label) are styled globally.
 */

.uzfb-form-wrap {
	--uzfb-accent: #2b6cb0;
	--uzfb-accent-hover: #24598f;
	--uzfb-border: #d5d8dd;
	--uzfb-border-focus: #2b6cb0;
	--uzfb-text: #1f2328;
	--uzfb-muted: #6a7280;
	--uzfb-error: #b32d2e;
	--uzfb-success: #1e7b34;
	--uzfb-radius: 6px;
	--uzfb-gap: 20px;

	max-width: 100%;
	box-sizing: border-box;
	color: var(--uzfb-text);
}

.uzfb-form-wrap *,
.uzfb-form-wrap *::before,
.uzfb-form-wrap *::after {
	box-sizing: inherit;
}

.uzfb-form-title {
	margin: 0 0 6px;
	font-size: 1.5em;
	line-height: 1.3;
}

.uzfb-form-description {
	margin: 0 0 var(--uzfb-gap);
	color: var(--uzfb-muted);
}

/* ---------------------------------------------------------------
 * Fields
 * --------------------------------------------------------------- */

.uzfb-form .uzfb-field {
	margin-bottom: var(--uzfb-gap);
}

.uzfb-form .uzfb-label {
	display: block;
	margin-bottom: 6px;
	font-weight: 600;
	font-size: 0.95em;
	line-height: 1.4;
}

.uzfb-form .uzfb-required-mark {
	color: var(--uzfb-error);
	margin-left: 2px;
}

.uzfb-form .uzfb-description {
	margin: 0 0 8px;
	font-size: 0.85em;
	color: var(--uzfb-muted);
	line-height: 1.5;
}

.uzfb-form .uzfb-input {
	display: block;
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--uzfb-border);
	border-radius: var(--uzfb-radius);
	background: #fff;
	color: var(--uzfb-text);
	font-size: 1em;
	font-family: inherit;
	line-height: 1.5;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.uzfb-form textarea.uzfb-input {
	resize: vertical;
	min-height: 110px;
}

/* Visible focus state — never rely on color alone. */
.uzfb-form .uzfb-input:focus,
.uzfb-form .uzfb-radio:focus,
.uzfb-form .uzfb-checkbox:focus,
.uzfb-form .uzfb-button:focus {
	outline: 2px solid var(--uzfb-border-focus);
	outline-offset: 1px;
	border-color: var(--uzfb-border-focus);
	box-shadow: 0 0 0 3px rgba(43, 108, 176, .15);
}

.uzfb-form .uzfb-input:disabled {
	background: #f4f5f7;
	color: var(--uzfb-muted);
	cursor: not-allowed;
}

/* Input sizes */
.uzfb-form .uzfb-size-small .uzfb-input { max-width: 240px; }
.uzfb-form .uzfb-size-medium .uzfb-input { max-width: 100%; }
.uzfb-form .uzfb-size-large .uzfb-input { max-width: 100%; }

/* Left-aligned labels (desktop only) */
@media (min-width: 640px) {
	.uzfb-form .uzfb-label-left {
		display: grid;
		grid-template-columns: 30% 1fr;
		gap: 12px;
		align-items: start;
	}
	.uzfb-form .uzfb-label-left .uzfb-label { margin-bottom: 0; padding-top: 10px; }
	.uzfb-form .uzfb-label-left .uzfb-error,
	.uzfb-form .uzfb-label-left .uzfb-description { grid-column: 2; }
}

.uzfb-form .uzfb-label-hidden .uzfb-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

/* ---------------------------------------------------------------
 * Choices
 * --------------------------------------------------------------- */

.uzfb-form .uzfb-fieldset {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
}

.uzfb-form .uzfb-choices {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.uzfb-form .uzfb-choices-inline {
	flex-direction: row;
	flex-wrap: wrap;
	gap: 16px;
}

.uzfb-form .uzfb-choice {
	display: flex;
	align-items: flex-start;
	gap: 8px;
}

.uzfb-form .uzfb-choice label {
	font-weight: 400;
	line-height: 1.5;
	cursor: pointer;
}

.uzfb-form .uzfb-radio,
.uzfb-form .uzfb-checkbox {
	margin: 3px 0 0;
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	cursor: pointer;
}

/* Name subfields */
.uzfb-form .uzfb-subfields {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
}

.uzfb-form .uzfb-subfield {
	flex: 1 1 160px;
	display: flex;
	flex-direction: column;
}

.uzfb-form .uzfb-sublabel {
	margin-top: 4px;
	font-size: 0.8em;
	color: var(--uzfb-muted);
}

.uzfb-form .uzfb-divider {
	border: 0;
	border-top: 1px solid var(--uzfb-border);
	margin: 28px 0;
}

/* ---------------------------------------------------------------
 * Errors & messages
 * --------------------------------------------------------------- */

.uzfb-form .uzfb-error {
	margin: 6px 0 0;
	min-height: 0;
	font-size: 0.85em;
	color: var(--uzfb-error);
	line-height: 1.4;
}

.uzfb-form .uzfb-error:empty {
	display: none;
}

/* Error state uses a border change + icon-free text, not color alone. */
.uzfb-form .uzfb-has-error .uzfb-input {
	border-color: var(--uzfb-error);
	border-width: 2px;
}

.uzfb-form .uzfb-has-error .uzfb-label::after {
	content: " \26A0";
	color: var(--uzfb-error);
}

.uzfb-form-message {
	margin-bottom: 16px;
	line-height: 1.6;
}

.uzfb-form-message:empty {
	display: none;
}

.uzfb-form-message.uzfb-message-success {
	padding: 14px 16px;
	background: #edf7ee;
	border-left: 4px solid var(--uzfb-success);
	border-radius: var(--uzfb-radius);
	color: #14532d;
}

.uzfb-form-message.uzfb-message-error {
	padding: 14px 16px;
	background: #fdecec;
	border-left: 4px solid var(--uzfb-error);
	border-radius: var(--uzfb-radius);
	color: #7f1d1d;
}

/* ---------------------------------------------------------------
 * Submit button
 * --------------------------------------------------------------- */

.uzfb-form .uzfb-form-footer {
	margin-top: 8px;
}

.uzfb-form .uzfb-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 26px;
	border: 0;
	border-radius: var(--uzfb-radius);
	background: var(--uzfb-accent);
	color: #fff;
	font-size: 1em;
	font-family: inherit;
	font-weight: 600;
	line-height: 1.4;
	cursor: pointer;
	transition: background-color .15s ease;
}

.uzfb-form .uzfb-button:hover:not(:disabled) {
	background: var(--uzfb-accent-hover);
}

.uzfb-form .uzfb-button:disabled {
	opacity: .65;
	cursor: not-allowed;
}

.uzfb-form .uzfb-spinner {
	display: none;
	width: 15px;
	height: 15px;
	border: 2px solid rgba(255, 255, 255, .4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: uzfb-spin .7s linear infinite;
}

.uzfb-form .uzfb-button.uzfb-loading .uzfb-spinner {
	display: inline-block;
}

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

@media (prefers-reduced-motion: reduce) {
	.uzfb-form .uzfb-spinner { animation: none; }
	.uzfb-form .uzfb-input,
	.uzfb-form .uzfb-button { transition: none; }
}

/* ---------------------------------------------------------------
 * Honeypot & utilities
 * --------------------------------------------------------------- */

.uzfb-form .uzfb-hp-wrap {
	position: absolute !important;
	left: -9999px !important;
	top: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.uzfb-form-wrap .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.uzfb-notice {
	padding: 12px 16px;
	border-radius: var(--uzfb-radius, 6px);
	font-size: 0.9em;
}

.uzfb-notice-warning {
	background: #fff8e5;
	border-left: 4px solid #dba617;
	color: #664d03;
}

/* ---------------------------------------------------------------
 * Mobile
 * --------------------------------------------------------------- */

@media (max-width: 600px) {
	.uzfb-form-wrap { --uzfb-gap: 16px; }

	.uzfb-form .uzfb-input {
		/* 16px prevents iOS Safari from zooming on focus. */
		font-size: 16px;
	}

	.uzfb-form .uzfb-button {
		width: 100%;
	}

	.uzfb-form .uzfb-subfields {
		flex-direction: column;
	}
}
