/**
 * Havenlytics V3 — Forms
 * Derived from design tokens and input patterns in havenlytics-homepage-v3.html
 * (browser URL bar, toggle switch, progress bar)
 *
 * @package Havenlytics_Theme
 */

.hvnly-form {
	display: flex;
	flex-direction: column;
	gap: var(--hvnly--space-7);
}

.hvnly-form-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--hvnly--space-7);
}

@media (max-width: 640px) {
	.hvnly-form-row {
		grid-template-columns: 1fr;
	}
}

.hvnly-field {
	display: flex;
	flex-direction: column;
	gap: var(--hvnly--space-3);
}

.hvnly-label {
	font-family: var(--hvnly--font-display);
	font-size: var(--hvnly--text-base);
	font-weight: var(--hvnly--weight-semibold);
	color: var(--hvnly--ink-900);
}

.hvnly-label--optional {
	font-weight: var(--hvnly--weight-medium);
	color: var(--hvnly--ink-400);
}

/* ── Global native form controls (WordPress defaults) ──────────── */
.hvnly-input,
.hvnly-textarea,
.hvnly-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input[type="file"],
textarea,
select {
	width: 100%;
	font-family: var(--hvnly--font-body);
	font-size: var(--hvnly-input-font-size, var(--hvnly--text-base));
	color: var(--hvnly--ink-900);
	background: var(--hvnly--surface-0);
	border: 1px solid var(--hvnly-input-border-color, var(--hvnly--border));
	border-radius: var(--hvnly-input-radius, var(--hvnly--radius-sm));
	padding: var(--hvnly-input-padding, var(--hvnly--space-5) var(--hvnly--space-7));
	transition: var(--hvnly--transition-border), var(--hvnly--transition-shadow), var(--hvnly--transition-bg);
}

input[type="file"] {
	padding: var(--hvnly--space-4);
}

input[type="search"] {
	-webkit-appearance: none;
	appearance: none;
}

.hvnly-input::placeholder,
.hvnly-textarea::placeholder,
input::placeholder,
textarea::placeholder {
	color: var(--hvnly--ink-400);
	opacity: 1;
}

.hvnly-input:hover,
.hvnly-textarea:hover,
.hvnly-select:hover,
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="url"]:hover,
input[type="number"]:hover,
input[type="search"]:hover,
input[type="tel"]:hover,
textarea:hover,
select:hover {
	border-color: var(--hvnly--ink-200);
}

.hvnly-input:focus,
.hvnly-textarea:focus,
.hvnly-select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
textarea:focus,
select:focus {
	outline: none;
	border-color: var(--hvnly-input-focus-color, var(--hvnly--core-primary));
	box-shadow: 0 0 0 3px rgba(var(--hvnly--core-primary-rgb), 0.12);
}

.hvnly-input:disabled,
.hvnly-textarea:disabled,
.hvnly-select:disabled,
input:disabled,
textarea:disabled,
select:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	background: var(--hvnly--surface-50);
}

.hvnly-input:invalid:not(:placeholder-shown),
.hvnly-textarea:invalid:not(:placeholder-shown),
input:invalid:not(:placeholder-shown):not(:focus),
textarea:invalid:not(:placeholder-shown):not(:focus) {
	border-color: #E05252;
}

label,
legend {
	font-family: var(--hvnly--font-display);
	font-size: var(--hvnly--text-base);
	font-weight: var(--hvnly--weight-semibold);
	color: var(--hvnly--ink-900);
}

fieldset {
	border: 1px solid var(--hvnly--border);
	border-radius: var(--hvnly--radius-md);
	padding: var(--hvnly--space-9);
	margin: 0 0 var(--hvnly--space-9);
}

fieldset legend {
	padding: 0 var(--hvnly--space-3);
}

/* Native checkbox & radio */
input[type="checkbox"],
input[type="radio"] {
	accent-color: var(--hvnly--core-primary);
	width: 1.05em;
	height: 1.05em;
	margin-right: var(--hvnly--space-3);
	vertical-align: middle;
	cursor: pointer;
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
	outline: 2px solid var(--hvnly--core-primary);
	outline-offset: 2px;
}

/* Unclassed submit buttons → primary */
.post-password-form input[type="submit"],
input[type="submit"]:not(.hvnly-btn):not(.button):not(.search-submit) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--hvnly--space-4);
	font-family: var(--hvnly--font-display);
	font-weight: var(--hvnly--weight-bold);
	font-size: var(--hvnly--text-md);
	padding: 15px 28px;
	border-radius: var(--hvnly--radius-pill);
	border: 1px solid transparent;
	background: var(--hvnly--core-gradient);
	color: var(--hvnly--on-primary);
	box-shadow: var(--hvnly--shadow-primary);
	cursor: pointer;
	transition: var(--hvnly--transition-lift);
}

.post-password-form input[type="submit"]:hover,
input[type="submit"]:not(.hvnly-btn):not(.button):not(.search-submit):hover {
	background: var(--hvnly--core-secondary);
	transform: translateY(-2px);
	box-shadow: var(--hvnly--shadow-primary-hover);
}

.hvnly-input--pill {
	border-radius: var(--hvnly--radius-pill);
	padding: var(--hvnly--space-2) var(--hvnly--space-6);
	font-size: 12.5px;
	color: var(--hvnly--ink-400);
}

.hvnly-textarea {
	min-height: 140px;
	resize: vertical;
	line-height: var(--hvnly--leading-normal);
}

.hvnly-select {
	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' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%237A7793' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right var(--hvnly--space-7) center;
	padding-right: var(--hvnly--space-18);
}

.hvnly-help-text {
	font-size: var(--hvnly--text-sm);
	color: var(--hvnly--ink-400);
}

.hvnly-field-error .hvnly-input,
.hvnly-field-error .hvnly-textarea,
.hvnly-field-error .hvnly-select {
	border-color: #E05252;
}

.hvnly-error-text {
	font-size: var(--hvnly--text-sm);
	color: #E05252;
}

/* ── Checkbox / radio ──────────────────────────────────────────── */
.hvnly-check {
	display: flex;
	align-items: flex-start;
	gap: var(--hvnly--space-5);
	font-size: var(--hvnly--text-md);
	color: var(--hvnly--ink-600);
	cursor: pointer;
}

.hvnly-check input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.hvnly-check-box {
	flex-shrink: 0;
	width: var(--hvnly--space-10);
	height: var(--hvnly--space-10);
	border-radius: var(--hvnly--space-2);
	border: 1px solid var(--hvnly--border);
	background: var(--hvnly--surface-0);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: var(--hvnly--transition-bg), var(--hvnly--transition-border);
}

.hvnly-check input:checked + .hvnly-check-box {
	background: var(--hvnly--core-gradient);
	border-color: transparent;
	color: var(--hvnly--on-primary);
}

.hvnly-check input:checked + .hvnly-check-box::after {
	content: "\f00c";
	font-family: "Font Awesome 6 Free";
	font-weight: 900;
	font-size: 11px;
	line-height: 1;
}

.hvnly-check input:focus-visible + .hvnly-check-box {
	outline: 2px solid var(--hvnly--core-primary);
	outline-offset: 2px;
}

.hvnly-form-feedback {
	margin: 0 0 var(--hvnly--space-8);
	padding: var(--hvnly--space-8) var(--hvnly--space-10);
	border-radius: var(--hvnly--radius-md);
	font-size: var(--hvnly--text-md);
	line-height: 1.5;
}

.hvnly-form-feedback--success {
	background: rgba(34, 168, 110, 0.1);
	color: #1a7a52;
	border: 1px solid rgba(34, 168, 110, 0.25);
}

.hvnly-form-feedback--error {
	background: rgba(224, 82, 82, 0.08);
	color: #b83232;
	border: 1px solid rgba(224, 82, 82, 0.25);
}

.hvnly-btn.is-loading {
	opacity: 0.88;
	cursor: wait;
	pointer-events: none;
}

.hvnly-btn.is-loading .hvnly-btn__text {
	display: none;
}

.hvnly-btn:not(.is-loading) .hvnly-btn__spinner,
.hvnly-btn:not(.is-loading) .hvnly-btn__sending {
	display: none;
}

.hvnly-btn.is-loading .hvnly-btn__spinner {
	display: inline-block;
	width: 1em;
	height: 1em;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: hvnly-spin 0.65s linear infinite;
	flex-shrink: 0;
}

.hvnly-btn.is-loading .hvnly-btn__sending {
	display: inline;
}

@keyframes hvnly-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ── Inline field validation ─────────────────────────────────── */
.hvnly-field-control {
	position: relative;
}

.hvnly-field-control .hvnly-input,
.hvnly-field-control .hvnly-textarea,
.hvnly-field-control .hvnly-select,
.hvnly-field-control input,
.hvnly-field-control textarea,
.hvnly-field-control select {
	padding-right: calc(var(--hvnly--space-7) + 1.5rem);
}

.hvnly-field-icon {
	position: absolute;
	top: 50%;
	right: var(--hvnly--space-7);
	transform: translateY(-50%);
	width: 1.125rem;
	height: 1.125rem;
	pointer-events: none;
	opacity: 0;
	transition: opacity var(--hvnly--duration-base) var(--hvnly--ease);
	font-size: 0.875rem;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
}

.hvnly-field-control:has(.hvnly-textarea) .hvnly-field-icon {
	top: var(--hvnly--space-7);
	transform: none;
}

.hvnly-field--valid .hvnly-field-control .hvnly-input,
.hvnly-field--valid .hvnly-field-control .hvnly-textarea,
.hvnly-field--valid .hvnly-field-control .hvnly-select {
	border-color: #22a86e;
	box-shadow: 0 0 0 3px rgba(34, 168, 110, 0.12);
}

.hvnly-field--error .hvnly-field-control .hvnly-input,
.hvnly-field--error .hvnly-field-control .hvnly-textarea,
.hvnly-field--error .hvnly-field-control .hvnly-select,
.hvnly-field--error > .hvnly-input,
.hvnly-field--error > .hvnly-textarea,
.hvnly-field--error > .hvnly-select {
	border-color: #e05252;
	box-shadow: 0 0 0 3px rgba(224, 82, 82, 0.1);
}

.hvnly-field--valid .hvnly-field-icon {
	opacity: 1;
	color: #22a86e;
}

.hvnly-field--valid .hvnly-field-icon::before {
	content: "\f00c";
	font-family: "Font Awesome 6 Free";
	font-weight: 900;
}

.hvnly-field--error .hvnly-field-icon {
	opacity: 1;
	color: #e05252;
}

.hvnly-field--error .hvnly-field-icon::before {
	content: "\f06a";
	font-family: "Font Awesome 6 Free";
	font-weight: 900;
}

.hvnly-field-message {
	display: block;
	font-size: var(--hvnly--text-sm);
	line-height: 1.45;
	margin-top: var(--hvnly--space-3);
	min-height: 0;
}

.hvnly-field-message:empty,
.hvnly-field-message[hidden] {
	display: none;
}

.hvnly-field--valid .hvnly-field-message {
	color: #1a7a52;
}

.hvnly-field--error .hvnly-field-message {
	color: #b83232;
}

.hvnly-check.hvnly-field--error .hvnly-check-box {
	border-color: #e05252;
	box-shadow: 0 0 0 3px rgba(224, 82, 82, 0.1);
}

.hvnly-check .hvnly-field-message {
	margin-top: var(--hvnly--space-2);
	margin-left: calc(var(--hvnly--space-10) + var(--hvnly--space-5));
}

/* ── Form status cards ───────────────────────────────────────── */
.hvnly-form-status-host {
	margin-bottom: var(--hvnly--space-8);
}

.hvnly-form-status-host:empty,
.hvnly-form-status-host[hidden] {
	display: none;
	margin: 0;
}

.hvnly-form-status {
	display: flex;
	gap: var(--hvnly--space-7);
	padding: var(--hvnly--space-9) var(--hvnly--space-10);
	border-radius: var(--hvnly--radius-md);
	border: 1px solid transparent;
	opacity: 0;
	transform: translateY(6px);
	animation: hvnly-form-status-in 0.35s var(--hvnly--ease) forwards;
}

.hvnly-form-status--visible {
	opacity: 1;
	transform: translateY(0);
}

@keyframes hvnly-form-status-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.hvnly-form-status--success {
	background: rgba(34, 168, 110, 0.1);
	border-color: rgba(34, 168, 110, 0.22);
	color: #145c3d;
}

.hvnly-form-status--error {
	background: rgba(224, 82, 82, 0.08);
	border-color: rgba(224, 82, 82, 0.22);
	color: #8f2a2a;
}

.hvnly-form-status__icon {
	flex-shrink: 0;
	font-size: 1.35rem;
	line-height: 1;
	margin-top: 2px;
}

.hvnly-form-status--success .hvnly-form-status__icon {
	color: #22a86e;
}

.hvnly-form-status--error .hvnly-form-status__icon {
	color: #e05252;
}

.hvnly-form-status__content {
	flex: 1;
	min-width: 0;
}

.hvnly-form-status__title {
	margin: 0 0 var(--hvnly--space-3);
	font-family: var(--hvnly--font-display);
	font-size: var(--hvnly--text-lg);
	font-weight: var(--hvnly--weight-bold);
	color: inherit;
}

.hvnly-form-status__body {
	margin: 0;
	font-size: var(--hvnly--text-md);
	line-height: 1.55;
	color: inherit;
}

.hvnly-form-status__meta {
	margin: var(--hvnly--space-5) 0 0;
	font-size: var(--hvnly--text-sm);
	line-height: 1.5;
	color: inherit;
	opacity: 0.92;
}

.hvnly-form-status__retry {
	appearance: none;
	border: 0;
	background: none;
	padding: 0;
	margin-right: var(--hvnly--space-3);
	font: inherit;
	font-weight: var(--hvnly--weight-semibold);
	color: inherit;
	text-decoration: underline;
	cursor: pointer;
}

.hvnly-form-status__retry:hover {
	opacity: 0.85;
}

.hvnly-form-status__meta a {
	color: inherit;
	font-weight: var(--hvnly--weight-semibold);
}

.hvnly-newsletter__field {
	flex: 1;
	min-width: 0;
}

.hvnly-newsletter__form .hvnly-form-status-host {
	flex-basis: 100%;
	width: 100%;
}

/* Font Awesome 6.0 local bundle: alias X/Twitter brand icon */
.fa-brands.fa-x-twitter::before {
	content: "\f099";
}

/* ── Toggle switch (billing) ───────────────────────────────────── */
.hvnly-switch {
	width: 52px;
	height: 30px;
	border-radius: var(--hvnly--radius-pill);
	background: var(--hvnly--ink-200);
	position: relative;
	transition: background var(--hvnly--duration-base);
}

.hvnly-switch[aria-checked="true"] {
	background: var(--hvnly--core-gradient);
}

.hvnly-switch::after {
	content: '';
	position: absolute;
	top: 3px;
	left: 3px;
	width: var(--hvnly--gutter);
	height: var(--hvnly--gutter);
	border-radius: var(--hvnly--radius-full);
	background: var(--hvnly--on-primary);
	transition: transform var(--hvnly--duration-base) var(--hvnly--ease);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.hvnly-switch[aria-checked="true"]::after {
	transform: translateX(22px);
}

.hvnly-toggle-label {
	font-size: var(--hvnly--text-base);
	font-weight: var(--hvnly--weight-semibold);
	color: var(--hvnly--ink-400);
	transition: var(--hvnly--transition-color);
}

.hvnly-toggle-label.is-active {
	color: var(--hvnly--ink-900);
}

/* ── Progress bar ──────────────────────────────────────────────── */
.hvnly-progress {
	background: rgba(255, 255, 255, 0.16);
	border-radius: var(--hvnly--radius-pill);
	height: var(--hvnly--space-4);
	overflow: hidden;
}

.hvnly-progress--surface {
	background: var(--hvnly--surface-100);
}

.hvnly-progress-bar {
	display: block;
	height: 100%;
	width: 0%;
	background: var(--hvnly--on-primary);
	border-radius: var(--hvnly--radius-pill);
	transition: width var(--hvnly--duration-import) var(--hvnly--ease);
}

.hvnly-progress--surface .hvnly-progress-bar {
	background: var(--hvnly--core-gradient);
}

.hvnly-progress.is-visible .hvnly-progress-bar,
.hvnly-import-progress.is-visible span {
	width: 100%;
}

/* Legacy alias from reference HTML */
.hvnly-import-progress {
	background: rgba(255, 255, 255, 0.16);
	border-radius: var(--hvnly--radius-pill);
	height: var(--hvnly--space-4);
	overflow: hidden;
	margin-bottom: var(--hvnly--space-4);
}

.hvnly-import-progress span {
	display: block;
	height: 100%;
	width: 0%;
	background: var(--hvnly--on-primary);
	border-radius: var(--hvnly--radius-pill);
	transition: width var(--hvnly--duration-import) var(--hvnly--ease);
}
