/**
 * Front-end form styles. Loaded only when a form is on the page.
 */

.tse-form {
	max-width: 640px;
	margin: 0 auto;
	padding: 32px;
	border: 1px solid #d0d5dd;
	border-radius: 8px;
	background: #fff;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: #1d2327;
	box-sizing: border-box;
	display: flex;
	flex-wrap: wrap;
	column-gap: 16px;
}

/* -- Field widths ----------------------------------------------------- */

.tse-field {
	width: 100%;
	margin-bottom: 20px;
	box-sizing: border-box;
}

.tse-field-width-75 { width: calc(75% - 4px); }
.tse-field-width-50 { width: calc(50% - 8px); }
.tse-field-width-33 { width: calc(33.333% - 10.667px); }
.tse-field-width-25 { width: calc(25% - 12px); }

/* Full-width form children that are not fields */
.tse-form > .tse-form-progress,
.tse-form > .tse-form-banner {
	width: 100%;
}

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

.tse-field label,
.tse-field-label {
	display: block;
	margin-bottom: 6px;
	font-weight: 600;
	font-size: 14px;
	color: #1d2327;
}

.tse-required {
	color: #CC0F05;
}

.tse-field input[type="text"],
.tse-field input[type="email"],
.tse-field input[type="tel"],
.tse-field input[type="number"],
.tse-field input[type="date"],
.tse-field input[type="url"],
.tse-field input[type="file"],
.tse-field textarea,
.tse-field select {
	display: block;
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #d0d5dd;
	border-radius: 6px;
	background: #fff;
	font-size: 15px;
	line-height: 1.5;
	color: #1d2327;
	box-sizing: border-box;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tse-field input:focus,
.tse-field textarea:focus,
.tse-field select:focus {
	outline: none;
	border-color: #092669;
	box-shadow: 0 0 0 3px rgba(9, 38, 105, 0.12);
}

.tse-field textarea {
	min-height: 100px;
	resize: vertical;
}

.tse-field select {
	appearance: auto;
}

.tse-field input[type="number"] {
	-moz-appearance: textfield;
	appearance: textfield;
}

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

.tse-field-help {
	margin: 6px 0 0;
	font-size: 13px;
	color: #667085;
}

/* -- Choices (radio, checkbox) ----------------------------------------- */

.tse-choice-group {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 4px;
}

.tse-choice {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 400;
	font-size: 15px;
	cursor: pointer;
}

.tse-choice input[type="radio"],
.tse-choice input[type="checkbox"] {
	width: 18px;
	height: 18px;
	margin: 0;
	accent-color: #092669;
	flex-shrink: 0;
}

.tse-other-input {
	margin-top: 6px;
	margin-left: 26px;
}

/* -- Progress indicator ------------------------------------------------ */

.tse-form-progress {
	margin: 0 0 24px;
}

.tse-form-progress-label {
	margin: 0 0 8px;
	font-size: 13px;
	font-weight: 600;
	color: #667085;
	text-align: center;
}

.tse-form-progress-bar {
	width: 100%;
	height: 8px;
	background: #e9ecef;
	border-radius: 999px;
	overflow: hidden;
}

.tse-form-progress-bar-fill {
	height: 100%;
	background: #2271b1;
	border-radius: 999px;
	transition: width 0.3s ease;
}

/* -- Button row ------------------------------------------------------- */

.tse-form-actions {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 4px;
}

.tse-form button[type="submit"] {
	display: inline-block;
	margin-left: auto;
	padding: 12px 28px;
	border: none;
	border-radius: 6px;
	background: #CC0F05;
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.tse-form button[type="submit"]:hover {
	background: #a30c04;
}

.tse-form button[type="submit"]:focus-visible {
	outline: 2px solid #CC0F05;
	outline-offset: 2px;
}

.tse-form button[type="submit"].tse-form-loading {
	position: relative;
	color: transparent;
	cursor: default;
}

.tse-form button[type="submit"].tse-form-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 16px;
	height: 16px;
	margin: -8px 0 0 -8px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: tse-forms-spin 0.6s linear infinite;
}

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

.tse-form-back {
	display: inline-block;
	padding: 12px 28px;
	border: none;
	border-radius: 6px;
	background: #092669;
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.tse-form-back:hover {
	background: #061a4a;
	color: #fff;
}

.tse-form-back:focus-visible {
	outline: 2px solid #092669;
	outline-offset: 2px;
}

/* -- Status banners ---------------------------------------------------- */

.tse-form-banner {
	max-width: 640px;
	margin: 0 auto 16px;
	padding: 14px 20px;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 500;
	box-sizing: border-box;
}

.tse-form-banner-success {
	background: #ecfdf3;
	border: 1px solid #a6f4c5;
	color: #065f46;
}

.tse-form-banner-error {
	background: #fef3f2;
	border: 1px solid #fecdca;
	color: #991b1b;
}

/* -- Custom text / HTML fields ----------------------------------------- */

.tse-field-custom_text {
	color: #475467;
}

/* -- Field errors ------------------------------------------------------ */

.tse-field-error {
	margin: 6px 0 0;
	padding: 0;
	font-size: 13px;
	font-weight: 500;
	color: #CC0F05;
	line-height: 1.4;
}

.tse-field input[aria-invalid="true"],
.tse-field textarea[aria-invalid="true"],
.tse-field select[aria-invalid="true"] {
	border-color: #CC0F05;
}

.tse-field input[aria-invalid="true"]:focus,
.tse-field textarea[aria-invalid="true"]:focus,
.tse-field select[aria-invalid="true"]:focus {
	border-color: #CC0F05;
	box-shadow: 0 0 0 3px rgba(204, 15, 5, 0.12);
}

/* -- Captcha ----------------------------------------------------------- */

.tse-field-captcha {
	margin-bottom: 20px;
}

/* -- Accessibility utilities --------------------------------------------- */

/* Standard clip-based visually-hidden pattern (matches WP core's own
   .screen-reader-text, reimplemented here since this stylesheet can't
   depend on the active theme/admin defining that class on the front end). */
.tse-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

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

@media (max-width: 480px) {
	.tse-form {
		padding: 20px 16px;
		border-left: none;
		border-right: none;
		border-radius: 0;
	}

	.tse-field-width-75,
	.tse-field-width-50,
	.tse-field-width-33,
	.tse-field-width-25 {
		width: 100%;
	}

	.tse-form-actions {
		flex-direction: column;
	}

	.tse-form-actions button[type="submit"],
	.tse-form-actions .tse-form-back {
		width: 100%;
		text-align: center;
	}
}
