/**
 * CT Forms — Frontend Styles
 *
 * Rendered form styles compatible with the RE7 theme.
 * Uses --ct-accent CSS variable with fallback for theming.
 *
 * @package CT Real Estate Core
 */

/* =========================================================================
   Variables
   ========================================================================= */
:root {
	--ct-accent:        #2271b1;
	--ct-accent-hover:  #135e96;
	--ct-error:         #cc0000;
	--ct-error-bg:      #fee2e2;
	--ct-success-bg:    #d1fae5;
	--ct-success-text:  #065f46;
	--ct-radius:        4px;
}

/* =========================================================================
   Form Wrapper
   ========================================================================= */
.ct-form {
	max-width: 600px;
	width: 100%;
}

/* =========================================================================
   Field Container & Rows
   ========================================================================= */
.ct-form-fields {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	width: 100%;
}

.ct-form-row {
	flex: 0 0 100%;
	min-width: 0;
	box-sizing: border-box;
}

.ct-form-row.ct-field-width-full {
	flex: 0 0 100%;
}

.ct-form-row.ct-field-width-half {
	flex: 0 0 calc(50% - 8px);
}

/* =========================================================================
   Labels
   ========================================================================= */
label.ct-form-label {
	display: block;
	font-weight: 600;
	font-size: 14px;
	margin-bottom: 4px;
	color: #1a1a1a;
	line-height: 1.4;
}

label.ct-form-label .ct-required-star {
	color: var(--ct-error);
	margin-left: 2px;
}

/* =========================================================================
   Fields
   ========================================================================= */
input.ct-form-field[type="text"],
input.ct-form-field[type="tel"],
input.ct-form-field[type="email"],
input.ct-form-field[type="number"],
input.ct-form-field[type="date"],
textarea.ct-form-field,
select.ct-form-field {
	display: block;
	width: 100%;
	padding: 10px 12px;
	margin: 0;
	border: 1px solid #ddd;
	border-radius: var(--ct-radius);
	font-size: 14px;
	font-family: inherit;
	color: #1a1a1a;
	background: #fff;
	box-sizing: border-box;
	line-height: 1.5;
	transition: border-color 0.15s, outline 0.15s;
	-webkit-appearance: none;
	appearance: none;
}

.ct-form-fields .nice-select,
.ct-form-step .nice-select {
	margin: 0;
}

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

select.ct-form-field {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 36px;
}

input.ct-form-field:focus,
textarea.ct-form-field:focus,
select.ct-form-field:focus {
	outline: 2px solid var(--ct-accent, #2271b1);
	outline-offset: 0;
	border-color: transparent;
}

/* Error state */
input.ct-form-field.ct-error,
textarea.ct-form-field.ct-error,
select.ct-form-field.ct-error {
	border-color: var(--ct-error);
	outline: none;
}

input.ct-form-field.ct-error:focus,
textarea.ct-form-field.ct-error:focus,
select.ct-form-field.ct-error:focus {
	outline: 2px solid var(--ct-error);
	border-color: transparent;
}

/* =========================================================================
   Inline Error Messages
   ========================================================================= */
.ct-form-field-error {
	display: block;
	font-size: 12px;
	color: var(--ct-error);
	margin-top: 4px;
	line-height: 1.4;
}

/* =========================================================================
   Checkbox / Radio
   ========================================================================= */
.ct-form-checkbox-label {
	display: flex;
	flex-direction: row;
	align-items: flex-start;
	gap: 8px;
	cursor: pointer;
	font-size: 14px;
	color: #1a1a1a;
	line-height: 1.5;
}

.ct-form-checkbox-label input[type="checkbox"],
.ct-form-checkbox-label input[type="radio"] {
	margin-top: 2px;
	width: 16px;
	height: 16px;
	cursor: pointer;
	flex-shrink: 0;
	accent-color: var(--ct-accent);
}

/* Stacked checkbox options */
.ct-form-checkbox-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

/* Radio group */
.ct-form-radio-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.ct-form-radio-label {
	display: flex;
	flex-direction: row;
	align-items: flex-start;
	gap: 8px;
	cursor: pointer;
	font-size: 14px;
	color: #1a1a1a;
	line-height: 1.5;
}

.ct-form-radio-label input[type="radio"] {
	margin-top: 2px;
	width: 16px;
	height: 16px;
	cursor: pointer;
	flex-shrink: 0;
	accent-color: var(--ct-accent);
}

/* =========================================================================
   Submit Row
   ========================================================================= */
.ct-form-submit-row {
	margin-top: 20px;
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 12px;
	clear: both;
}

/* =========================================================================
   Submit Button
   ========================================================================= */
.ct-form-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 24px;
	background: var(--ct-accent, #2271b1);
	color: #fff;
	border: none;
	border-radius: var(--ct-radius);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
	transition: background 0.15s, opacity 0.15s;
	font-family: inherit;
	line-height: 1.3;
}

.ct-form-submit:hover {
	background: var(--ct-accent-hover, #135e96);
}

.ct-form-submit:disabled,
.ct-form-submit[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
}

/* =========================================================================
   Spinner — rendered inside the submit button during submission
   ========================================================================= */
.ct-btn-spinner {
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ct-frontend-spin 0.65s linear infinite;
	vertical-align: middle;
	flex-shrink: 0;
}

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

/* =========================================================================
   Success / Error Message Area
   ========================================================================= */
.ct-form-message {
	padding: 12px 16px;
	border-radius: var(--ct-radius);
	font-size: 14px;
	line-height: 1.5;
	display: none;
}

.ct-form-message.ct-visible {
	display: block;
}

.ct-form-message.ct-success {
	background: var(--ct-success-bg, #d1fae5);
	color: var(--ct-success-text, #065f46);
	border: 1px solid #6ee7b7;
}

.ct-form-message.ct-error {
	background: var(--ct-error-bg, #fee2e2);
	color: var(--ct-error, #cc0000);
	border: 1px solid #fca5a5;
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 480px) {
	.ct-form-row.ct-field-width-half {
		flex: 0 0 100%;
	}

	.ct-form-submit {
		width: 100%;
	}
}

/* =========================================================================
   Conditional Logic — Hidden Fields
   ========================================================================= */

.ct-form-row[data-ct-hidden="1"] {
	display: none !important;
}

@keyframes ct-field-reveal {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.ct-form-row[data-ct-revealing] {
	animation: ct-field-reveal 0.2s ease;
}

/* =========================================================================
   Multi-Step Forms
   ========================================================================= */

/* Progress bar */
.ct-form-progress {
	width: 100%;
	height: 4px;
	background: #e5e7eb;
	border-radius: 2px;
	margin-bottom: 24px;
	overflow: hidden;
}

.ct-form-progress-bar {
	height: 100%;
	background: var(--ct-accent, #2271b1);
	border-radius: 2px;
	transition: width 0.35s ease;
}

/* Steps wrapper — holds min-height so the page never shifts between steps */
.ct-form--multi-step .ct-form-steps-wrap {
	position: relative;
	transition: min-height 0.2s ease;
	padding: 1%;
}

/* Step containers */
.ct-form-step {
	display: none;
}

.ct-form-step.ct-step-active {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	animation: ct-step-in 0.25s ease;
}

.ct-form-step-label {
	flex: 0 0 100%;
	font-size: 16px;
	font-weight: 600;
	color: #111827;
	margin-bottom: 4px;
}

@keyframes ct-step-in {
	from {
		opacity: 0;
		transform: translateX(16px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

/* Step navigation */
.ct-form-step-nav {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 20px;
}

/* When the nav is moved inside a step's flex container it must stretch
   to the full row so it sits flush below the last field. */
.ct-form-step .ct-form-step-nav {
	flex: 0 0 100%;
	margin-top: 8px;
}

.ct-step-prev,
.ct-step-next {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 42px;
	padding: 0 20px;
	border-radius: var(--ct-radius);
	font-size: 14px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
	border: 1px solid #d1d5db;
}

.ct-step-next {
	background: var(--ct-accent, #2271b1);
	color: #fff;
	border-color: transparent;
}

.ct-step-next:hover {
	background: var(--ct-accent-hover, #135e96);
}

.ct-step-prev {
	background: #fff;
	color: #374151 !important;
}

.ct-step-prev:hover {
	background: #f9fafb;
}

/* =========================================================================
   Conversational Form
   ========================================================================= */

.ct-form--conversational .ct-conv-slides {
	position: relative;
	overflow: hidden;
}

.ct-conv-slide {
	display: none;
	flex-direction: column;
	gap: 16px;
}

.ct-conv-slide.ct-conv-active {
	display: flex;
	animation: ct-conv-in 0.3s ease;
}

@keyframes ct-conv-in {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.ct-conv-slide label {
	font-size: 18px;
	font-weight: 600;
	color: #111827;
}

.ct-conv-next {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	align-self: flex-start;
	height: 40px;
	padding: 0 20px;
	background: var(--ct-accent, #2271b1);
	color: #fff;
	border: none;
	border-radius: var(--ct-radius);
	font-size: 14px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s;
}

.ct-conv-next:hover {
	background: var(--ct-accent-hover, #135e96);
}

.ct-conv-counter {
	font-size: 12px;
	color: #9ca3af;
	margin-top: 12px;
	text-align: right;
}

/* =========================================================================
   New Field Types — Frontend Styles
   ========================================================================= */

/* Multiselect checkbox-group */
.ct-form-multiselect-group {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 4px;
}

.ct-form-multiselect-label {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border: 1px solid #ddd;
	border-radius: 4px;
	cursor: pointer;
	font-size: 13px;
	background: #fff;
	transition: border-color 0.12s, background 0.12s;
	user-select: none;
}

.ct-form-multiselect-label:hover {
	border-color: #999;
	background: #f9f9f9;
}

.ct-form-multiselect-label input[type="checkbox"] {
	margin: 0;
	cursor: pointer;
}

.ct-form-multiselect-label input[type="checkbox"]:checked + span,
.ct-form-multiselect-label:has(input:checked) {
	font-weight: 500;
}

/* Price field */
.ct-price-display-input {
	font-size: 15px;
}

/* File upload field */
.ct-file-upload-wrap {
	position: relative;
}

.ct-file-drop-zone {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 24px 16px;
	border: 2px dashed #ccc;
	border-radius: 6px;
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s;
	background: #fafafa;
	text-align: center;
}

.ct-file-drop-zone:hover,
.ct-file-drop-zone.ct-drag-over {
	border-color: #0073aa;
	background: #f0f8ff;
}

.ct-file-drop-zone input[type="file"] {
	position: absolute;
	inset: 0;
	opacity: 0;
	cursor: pointer;
	width: 100%;
	height: 100%;
}

.ct-file-drop-label {
	font-size: 13px;
	color: #555;
	pointer-events: none;
}

.ct-file-drop-hint {
	font-size: 11px;
	color: #999;
	pointer-events: none;
}

.ct-file-selected-name {
	margin-top: 6px;
	font-size: 12px;
	color: #333;
	word-break: break-all;
}

/* Slider field */
.ct-field-slider-wrap {
	width: 100%;
	padding: 4px 0;
}

.ct-field-slider-header {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 10px;
}

.ct-field-slider-value {
	font-size: 14px;
	font-weight: 600;
	color: #333;
}

.ct-field-slider .slider-range-wrap {
	padding: 6px 0;
}

/* Number field */
.ct-form-row input[type="number"] {
	appearance: textfield;
	-moz-appearance: textfield;
}

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

/* =========================================================================
   Divider field
   ========================================================================= */
.ct-form-divider { margin: 8px 0 16px; }
.ct-divider-line  { border-top: 1px solid var(--ct-accent, #ddd); }
.ct-divider-heading h4 { margin: 0 0 4px; font-size: 16px; font-weight: 600; line-height: 1.3; }
.ct-divider-heading p  { margin: 0; font-size: 13px; color: #666; }
.ct-divider-spacing    { margin: 24px 0; }

/* =========================================================================
   Content Block field
   ========================================================================= */
.ct-form-content-block {
	margin-bottom: 16px;
	line-height: 1.6;
}
.ct-form-content-block a { color: var(--ct-accent, #2d7dd2); }
.ct-form-content-block p { margin: 0 0 0.75em; }
.ct-form-content-block h2,
.ct-form-content-block h3,
.ct-form-content-block h4 { margin: 0 0 0.4em; }
.ct-form-content-block ul,
.ct-form-content-block ol { padding-left: 1.4em; margin: 0 0 0.75em; }

/* =========================================================================
   Signature field
   ========================================================================= */
.ct-sig-wrap   { position: relative; }
.ct-sig-canvas {
	display: block;
	border: 1px solid #ddd;
	border-radius: 4px;
	cursor: crosshair;
	touch-action: none;
	width: 100%;
}
.ct-sig-clear {
	margin-top: 6px;
	background: none;
	border: 1px solid #ccc;
	border-radius: 4px;
	padding: 4px 12px;
	cursor: pointer;
	font-size: 12px;
	color: #555;
}
.ct-sig-clear:hover { border-color: #999; color: #222; }
.ct-sig-error {
	color: var(--ct-error, #c00);
	font-size: 12px;
	margin-top: 4px;
	display: none;
}
