/**
 * DhishaAI — Elementor atomic form submission UX.
 *
 * Every rule is scoped to .dh-form--submitting, a class this plugin adds only while
 * a request is in flight. Nothing here restyles a form in its normal state, so the
 * existing Elementor design is untouched.
 */

/* The form as a whole reads as busy. */
[data-element_type="e-form"].dh-form--submitting {
	position: relative;
	cursor: progress;
}

/* Blocked controls: visibly inert, but values still readable and still on screen. */
[data-element_type="e-form"].dh-form--submitting input,
[data-element_type="e-form"].dh-form--submitting select,
[data-element_type="e-form"].dh-form--submitting textarea {
	opacity: .55;
	cursor: not-allowed;
}

/* Nothing in the form should respond to the pointer while submitting, except that
   the submit button keeps its spinner visible. */
[data-element_type="e-form"].dh-form--submitting input,
[data-element_type="e-form"].dh-form--submitting select,
[data-element_type="e-form"].dh-form--submitting textarea,
[data-element_type="e-form"].dh-form--submitting label {
	pointer-events: none;
}

/* --- Submit button: spinner + busy treatment ------------------------------ */

[data-element_type="e-form"].dh-form--submitting button[type="submit"],
[data-element_type="e-form"].dh-form--submitting input[type="submit"] {
	position: relative;
	cursor: progress;
	opacity: .85;
	/* Room for the spinner so the label does not jump. */
	padding-inline-start: 2.6em;
	pointer-events: none;
}

[data-element_type="e-form"].dh-form--submitting button[type="submit"]::before,
[data-element_type="e-form"].dh-form--submitting input[type="submit"]::before {
	content: "";
	position: absolute;
	inset-inline-start: 1em;
	top: 50%;
	width: 1em;
	height: 1em;
	margin-top: -.5em;
	border: 2px solid currentColor;
	border-inline-end-color: transparent;
	border-radius: 50%;
	opacity: .9;
	animation: dh-form-spin .7s linear infinite;
}

/* input[type=submit] cannot host a pseudo-element; fall back to a border pulse. */
[data-element_type="e-form"].dh-form--submitting input[type="submit"] {
	padding-inline-start: 1em;
	animation: dh-form-pulse 1s ease-in-out infinite;
}

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

@keyframes dh-form-pulse {
	50% { opacity: .6; }
}

/* Honour a reduced-motion preference: keep the state legible, drop the animation. */
@media (prefers-reduced-motion: reduce) {
	[data-element_type="e-form"].dh-form--submitting button[type="submit"]::before,
	[data-element_type="e-form"].dh-form--submitting input[type="submit"]::before {
		animation: none;
		border-inline-end-color: currentColor;
		opacity: .5;
	}
	[data-element_type="e-form"].dh-form--submitting input[type="submit"] {
		animation: none;
	}
}
