/**
 * Perfect Forms – front-end styles.
 * Accent colour is set per form via the --pf-accent custom property.
 */

.pf-wrap {
	--pf-accent: #2563eb;
	--pf-text: #1f2937;
	--pf-muted: #6b7280;
	--pf-border: #d1d5db;
	--pf-bg: #fff;
	--pf-error: #dc2626;
	--pf-success: #15803d;
	--pf-radius: 8px;
	box-sizing: border-box;
	max-width: 760px;
	margin: 0 auto 1.5em;
	color: var(--pf-text);
	font-size: 16px;
	line-height: 1.5;
}

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

.pf-wrap [hidden] {
	display: none !important;
}

.pf-title {
	margin: 0 0 0.75em;
}

/* ---------- Layout ---------- */

.pf-fields {
	display: flex;
	flex-wrap: wrap;
	gap: 0 20px;
}

.pf-field {
	flex: 0 0 100%;
	max-width: 100%;
	margin: 0 0 20px;
	min-width: 0;
}

.pf-width--half {
	flex-basis: calc(50% - 10px);
	max-width: calc(50% - 10px);
}

.pf-width--third {
	flex-basis: calc(33.333% - 13.34px);
	max-width: calc(33.333% - 13.34px);
}

.pf-field.pf-cond-hidden,
.pf-hp {
	display: none !important;
}

/* ---------- Labels & inputs ---------- */

.pf-label {
	display: block;
	margin: 0 0 6px;
	font-weight: 600;
	font-size: 0.95em;
	padding: 0;
}

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

.pf-required {
	color: var(--pf-error);
}

.pf-wrap input[type="text"],
.pf-wrap input[type="email"],
.pf-wrap input[type="tel"],
.pf-wrap input[type="url"],
.pf-wrap input[type="number"],
.pf-wrap input[type="date"],
.pf-wrap input[type="time"],
.pf-wrap input[type="file"],
.pf-wrap select,
.pf-wrap textarea {
	display: block;
	width: 100%;
	max-width: 100%;
	padding: 10px 12px;
	font: inherit;
	color: inherit;
	background: var(--pf-bg);
	border: 1px solid var(--pf-border);
	border-radius: var(--pf-radius);
	box-shadow: none;
	transition: border-color 0.15s, box-shadow 0.15s;
	min-height: 44px;
}

.pf-wrap textarea {
	min-height: 120px;
	resize: vertical;
}

.pf-wrap select[multiple] {
	min-height: 120px;
}

.pf-wrap input:focus,
.pf-wrap select:focus,
.pf-wrap textarea:focus {
	outline: none;
	border-color: var(--pf-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--pf-accent) 25%, transparent);
}

.pf-description {
	margin-top: 6px;
	font-size: 0.875em;
	color: var(--pf-muted);
}

.pf-section-title {
	margin: 10px 0 4px;
	padding-bottom: 6px;
	border-bottom: 1px solid var(--pf-border);
	font-size: 1.2em;
}

/* Choices */

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

.pf-choice {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	cursor: pointer;
	font-weight: 400;
}

.pf-choice input {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	margin: 3px 0 0;
	accent-color: var(--pf-accent);
}

.pf-choice-key {
	display: none;
}

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

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

.pf-error {
	margin: 6px 0 0;
	color: var(--pf-error);
	font-size: 0.875em;
}

.pf-form-error,
.pf-success {
	margin: 0 0 20px;
	padding: 14px 16px;
	border-radius: var(--pf-radius);
	border-left: 4px solid;
}

.pf-form-error {
	background: #fef2f2;
	border-color: var(--pf-error);
	color: #991b1b;
}

.pf-success {
	background: #f0fdf4;
	border-color: var(--pf-success);
	color: #14532d;
}

.pf-success p:last-child {
	margin-bottom: 0;
}

/* ---------- Buttons ---------- */

.pf-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
}

.pf-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 44px;
	padding: 10px 24px;
	font: inherit;
	font-weight: 600;
	color: #fff;
	background: var(--pf-accent);
	border: 1px solid var(--pf-accent);
	border-radius: var(--pf-radius);
	cursor: pointer;
	transition: filter 0.15s, transform 0.05s;
	text-decoration: none;
}

.pf-btn:hover {
	filter: brightness(1.08);
}

.pf-btn:active {
	transform: translateY(1px);
}

.pf-btn:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--pf-accent) 40%, transparent);
	outline-offset: 2px;
}

.pf-btn[disabled] {
	opacity: 0.65;
	cursor: wait;
}

.pf-btn-secondary {
	color: var(--pf-accent);
	background: transparent;
}

.pf-wrap:not(.pf-js) .pf-js-only {
	display: none !important;
}

/* ---------- Multi-page ---------- */

.pf-multipage .pf-page {
	display: none;
}

.pf-multipage .pf-page.is-active {
	display: block;
}

.pf-steps {
	display: flex;
	list-style: none;
	margin: 0 0 24px;
	padding: 0;
	gap: 8px;
}

.pf-step-dot {
	flex: 1;
	position: relative;
	height: 6px;
	border-radius: 3px;
	background: var(--pf-border);
	margin: 0;
}

.pf-step-dot span {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
}

.pf-step-dot.is-active,
.pf-step-dot.is-done {
	background: var(--pf-accent);
}

/* ---------- Conversational mode ---------- */

.pf-conv .pf-form {
	position: relative;
	min-height: 320px;
	padding: 32px;
	background: var(--pf-bg);
	border: 1px solid #e5e7eb;
	border-radius: 16px;
	box-shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

.pf-conv .pf-field {
	display: none;
	flex-basis: 100%;
	max-width: 100%;
	margin: 0;
}

.pf-conv .pf-field.pf-active {
	display: block;
}

.pf-conv .pf-page > .pf-actions {
	display: none;
}

.pf-conv .pf-label,
.pf-conv .pf-section-title {
	font-size: 1.4em;
	font-weight: 600;
	line-height: 1.3;
	margin-bottom: 16px;
	border: 0;
}

.pf-q-num {
	color: var(--pf-accent);
	font-size: 0.75em;
	margin-right: 4px;
	white-space: nowrap;
}

.pf-conv input[type="text"],
.pf-conv input[type="email"],
.pf-conv input[type="tel"],
.pf-conv input[type="url"],
.pf-conv input[type="number"],
.pf-conv input[type="date"],
.pf-conv input[type="time"],
.pf-conv textarea {
	font-size: 1.25em;
	padding: 10px 2px;
	border: 0;
	border-bottom: 2px solid var(--pf-border);
	border-radius: 0;
	background: transparent;
}

.pf-conv input:focus,
.pf-conv textarea:focus {
	box-shadow: none;
	border-bottom-color: var(--pf-accent);
}

.pf-conv .pf-choice {
	position: relative;
	padding: 10px 14px;
	border: 1px solid color-mix(in srgb, var(--pf-accent) 45%, transparent);
	border-radius: var(--pf-radius);
	background: color-mix(in srgb, var(--pf-accent) 6%, transparent);
	max-width: 420px;
	align-items: center;
}

.pf-conv .pf-choice:has(input:checked) {
	background: color-mix(in srgb, var(--pf-accent) 18%, transparent);
	border-color: var(--pf-accent);
}

.pf-conv .pf-choice-key {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	font-size: 0.75em;
	font-weight: 700;
	border: 1px solid var(--pf-accent);
	border-radius: 4px;
	color: var(--pf-accent);
	background: var(--pf-bg);
}

.pf-conv .pf-choice input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
}

.pf-conv .pf-choice:focus-within {
	outline: 2px solid var(--pf-accent);
	outline-offset: 2px;
}

.pf-conv .pf-consent .pf-choice-key {
	display: none;
}

.pf-conv .pf-consent input {
	position: static;
	opacity: 1;
	width: 18px;
	height: 18px;
}

.pf-conv-nav {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	margin-top: 24px;
}

.pf-conv-hint {
	font-size: 0.8em;
	color: var(--pf-muted);
}

.pf-progress {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 28px;
}

.pf-progress-bar {
	flex: 1;
	height: 6px;
	border-radius: 3px;
	background: #e5e7eb;
	overflow: hidden;
}

.pf-progress-bar span {
	display: block;
	width: 0;
	height: 100%;
	background: var(--pf-accent);
	transition: width 0.3s ease;
}

.pf-progress-text {
	font-size: 0.8em;
	color: var(--pf-muted);
	white-space: nowrap;
}

.pf-welcome {
	display: none;
	text-align: center;
	padding: 24px 0;
}

.pf-show-welcome .pf-welcome {
	display: block;
}

.pf-show-welcome .pf-field,
.pf-show-welcome .pf-progress {
	display: none !important;
}

.pf-welcome-title {
	margin: 0 0 12px;
}

.pf-welcome-text {
	color: var(--pf-muted);
	margin-bottom: 24px;
}

.pf-enter-up {
	animation: pf-enter-up 0.35s ease both;
}

.pf-enter-down {
	animation: pf-enter-down 0.35s ease both;
}

.pf-shake {
	animation: pf-shake 0.35s ease;
}

@keyframes pf-enter-up {
	from {
		opacity: 0;
		transform: translateY(24px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes pf-enter-down {
	from {
		opacity: 0;
		transform: translateY(-24px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

@keyframes pf-shake {
	0%,
	100% {
		transform: translateX(0);
	}
	25% {
		transform: translateX(-6px);
	}
	75% {
		transform: translateX(6px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.pf-enter-up,
	.pf-enter-down,
	.pf-shake {
		animation: none;
	}
}

.pf-wrap.is-busy .pf-form {
	opacity: 0.85;
}

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
	.pf-width--half,
	.pf-width--third {
		flex-basis: 100%;
		max-width: 100%;
	}

	.pf-actions .pf-btn {
		flex: 1 1 auto;
	}

	.pf-conv .pf-form {
		padding: 20px 16px;
		border-radius: 12px;
	}

	.pf-conv .pf-label,
	.pf-conv .pf-section-title {
		font-size: 1.15em;
	}

	.pf-conv-hint {
		display: none;
	}
}
