/**
 * GrowProp Marketplace – Public lead capture form (vanilla CSS, gpm- prefix)
 * Mobile-first, a11y-ready. Typography hierarchy: title > legend > label > body > small.
 * Depends on auth.css for variables.
 *
 * @package GrowProp\Marketplace
 */

/* ==========================================================================
   Container & base typography
   ========================================================================== */

.gpm-lead-form-container,
.gpm-lead-form--step2 {
	width: 100%;
	max-width: 32rem;
	margin: 0 auto;
	padding: 1.5rem 1rem;
	font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 1rem;
	line-height: 1.5;
	color: var(--gpm-text);
}

.gpm-lead-form-container {
	box-sizing: border-box;
}

@media (min-width: 640px) {
	.gpm-lead-form-container,
	.gpm-lead-form--step2 {
		padding: 2rem 1.5rem;
	}
}

/* ==========================================================================
   Honeypot (hidden from users)
   ========================================================================== */

.gpm-hp-field {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ==========================================================================
   Form header – hierarchy level 1 (page/section title)
   ========================================================================== */

.gpm-lead-form__header {
	margin-bottom: 1.5rem;
	text-align: center;
}

.gpm-lead-form__title {
	margin: 0 0 0.5rem;
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: -0.02em;
	color: var(--gpm-text);
}

.gpm-lead-form__desc {
	margin: 0;
	font-size: 0.875rem;
	line-height: 1.45;
	color: var(--gpm-text-secondary);
}

/* ==========================================================================
   Sections and groups – hierarchy level 2 (section legend)
   ========================================================================== */

.gpm-form-section {
	margin: 0 0 1.5rem;
	padding: 1rem 0;
	border: 0;
	border-bottom: 1px solid var(--gpm-border);
}

.gpm-form-section:last-of-type {
	border-bottom: 0;
}

.gpm-form-section__legend {
	display: block;
	padding: 0 0 0.75rem;
	margin: 0;
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.4;
	color: var(--gpm-text);
}

.gpm-form-group {
	margin-bottom: 1rem;
}

.gpm-form-group:last-child {
	margin-bottom: 0;
}

.gpm-form-group--error .gpm-input,
.gpm-form-group--error .gpm-select {
	border-color: var(--gpm-error);
}

.gpm-form-group--error .gpm-input:focus,
.gpm-form-group--error .gpm-select:focus {
	outline: 2px solid var(--gpm-error);
	outline-offset: 2px;
}

.gpm-form-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	margin-bottom: 1rem;
}

.gpm-form-row .gpm-form-group {
	margin-bottom: 0;
}

@media (max-width: 479px) {
	.gpm-form-row {
		grid-template-columns: 1fr;
	}
}

/* ==========================================================================
   Labels and inputs – hierarchy level 3 (label), body (input)
   ========================================================================== */

.gpm-label {
	display: block;
	margin-bottom: 0.375rem;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.4;
	color: var(--gpm-text);
}

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

.gpm-input,
.gpm-select {
	display: block;
	width: 100%;
	padding: 0.5rem 0.75rem;
	font-size: 1rem;
	font-family: inherit;
	line-height: 1.5;
	color: var(--gpm-text);
	background: var(--gpm-bg-white);
	border: 1px solid var(--gpm-border);
	border-radius: var(--gpm-radius-md);
	transition: border-color var(--gpm-transition), box-shadow var(--gpm-transition);
}

.gpm-input::placeholder {
	color: var(--gpm-text-muted);
}

.gpm-input:focus,
.gpm-select:focus {
	outline: 0;
	border-color: var(--gpm-border-focus);
	box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.gpm-input:disabled,
.gpm-select:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Read-only field (e.g. logged-in email) – visually distinct, not editable */
.gpm-input--readonly,
.gpm-input[readonly] {
	background: var(--gpm-bg);
	color: var(--gpm-text-secondary);
	border-color: var(--gpm-border);
	cursor: default;
	opacity: 0.95;
}

.gpm-input--readonly:focus,
.gpm-input[readonly]:focus {
	outline: 0;
	box-shadow: none;
	border-color: var(--gpm-border);
}

/* ==========================================================================
   Phone input with country code & flags (intl-tel-input)
   ========================================================================== */

.gpm-lead-form-container .iti,
.gpm-lead-form--step2 .iti,
.gpm-iti-container.iti {
	--iti-path-flags-1x: url('https://cdn.jsdelivr.net/npm/intl-tel-input@23/build/img/flags.webp');
	--iti-path-flags-2x: url('https://cdn.jsdelivr.net/npm/intl-tel-input@23/build/img/flags@2x.webp');
	--iti-path-globe-1x: url('https://cdn.jsdelivr.net/npm/intl-tel-input@23/build/img/globe.webp');
	--iti-path-globe-2x: url('https://cdn.jsdelivr.net/npm/intl-tel-input@23/build/img/globe@2x.webp');
	display: block;
	width: 100%;
}

.gpm-iti-container .iti__input {
	font-size: 1rem;
	font-family: inherit;
	padding: 0.5rem 0.75rem;
	height: auto;
	min-height: 2.5rem;
	border: 1px solid var(--gpm-border);
	border-radius: var(--gpm-radius-md);
}

.gpm-iti-container.iti--allow-dropdown .iti__flag-container:hover .iti__selected-flag {
	background-color: rgba(0, 0, 0, 0.05);
}

.gpm-iti-container .iti__dial-code {
	font-size: 1rem;
	color: var(--gpm-text);
}

.gpm-select {
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	padding-right: 2rem;
}

.gpm-error-message {
	display: block;
	margin-top: 0.25rem;
	font-size: 0.8125rem;
	line-height: 1.4;
	color: var(--gpm-error);
}

/* Small / muted text – hierarchy level 5 */
.gpm-text-small,
.gpm-text-muted {
	font-size: 0.8125rem;
	line-height: 1.45;
	color: var(--gpm-text-secondary);
}

/* ==========================================================================
   Consent checkbox
   ========================================================================== */

.gpm-consent-group {
	margin-bottom: 1.25rem;
}

.gpm-checkbox-label {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	cursor: pointer;
	font-size: 0.875rem;
	color: var(--gpm-text);
}

.gpm-checkbox-label input[type="checkbox"] {
	width: 1.125rem;
	height: 1.125rem;
	margin-top: 0.125rem;
	flex-shrink: 0;
}

.gpm-checkbox-label a {
	color: var(--gpm-border-focus);
	text-decoration: underline;
}

.gpm-checkbox-label a:hover {
	text-decoration: none;
}

.gpm-checkbox-inline {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	cursor: pointer;
	font-size: 0.875rem;
	white-space: nowrap;
}

.gpm-checkbox-inline input[type="checkbox"] {
	width: 1rem;
	height: 1rem;
	flex-shrink: 0;
}

/* ==========================================================================
   Actions and buttons – primary only for main CTA; others dark gray
   ========================================================================== */

.gpm-form-actions {
	margin-top: 1.5rem;
}

.gpm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	width: 100%;
	padding: 0.75rem 1.25rem;
	font-size: 0.9375rem;
	font-weight: 600;
	font-family: inherit;
	line-height: 1.5;
	text-align: center;
	color: #fff;
	background: #374151;
	border: none;
	border-radius: var(--gpm-radius-md);
	cursor: pointer;
	transition: background var(--gpm-transition), color var(--gpm-transition), opacity var(--gpm-transition);
}

.gpm-btn:hover:not(:disabled) {
	background: #1f2937;
	color: #fff;
}

.gpm-btn:focus {
	outline: 0;
	box-shadow: 0 0 0 2px rgba(55, 65, 81, 0.3);
}

.gpm-btn:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

/* Main CTA only – primary color */
.gpm-btn--primary {
	color: var(--gpm-primary-hover);
	background: var(--gpm-primary);
}

.gpm-btn--primary:hover:not(:disabled) {
	background: var(--gpm-primary-hover);
	color: var(--gpm-primary);
}

.gpm-btn--primary:focus {
	box-shadow: 0 0 0 2px var(--gpm-primary-light);
}

/* Secondary / ghost – dark gray (default style, explicit for clarity) */
.gpm-btn--secondary,
.gpm-btn--ghost {
	color: #374151;
	background: transparent;
	border: 1px solid #d1d5db;
}

.gpm-btn--secondary:hover:not(:disabled),
.gpm-btn--ghost:hover:not(:disabled) {
	background: #f3f4f6;
	color: #1f2937;
	border-color: #9ca3af;
}

.gpm-btn--ghost {
	border-color: transparent;
}

.gpm-btn--ghost:hover:not(:disabled) {
	background: #f3f4f6;
	border-color: transparent;
}

.gpm-btn--block {
	display: flex;
}

.gpm-btn--sm {
	padding: 0.375rem 0.75rem;
	font-size: 0.8125rem;
}

.gpm-btn-loading {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
}

/* ==========================================================================
   Toast (error/success message)
   ========================================================================== */

.gpm-form-toast {
	padding: 0.75rem 1rem;
	margin-bottom: 1rem;
	font-size: 0.875rem;
	border-radius: var(--gpm-radius-md);
}

.gpm-form-toast--error {
	background: var(--gpm-error-light);
	color: var(--gpm-error);
}

.gpm-form-toast--success {
	background: var(--gpm-success-light);
	color: var(--gpm-success);
}

/* ==========================================================================
   Success state (after submit)
   ========================================================================== */

.gpm-success-message {
	padding: 2rem 1rem;
	text-align: center;
	background: var(--gpm-success-light);
	border-radius: var(--gpm-radius-lg);
}

.gpm-success-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	margin-bottom: 1rem;
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--gpm-success);
	background: var(--gpm-bg-white);
	border-radius: 50%;
}

.gpm-success-title {
	margin: 0 0 0.5rem;
	font-size: 1.125rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--gpm-text);
}

.gpm-success-desc {
	margin: 0;
	font-size: 0.875rem;
	line-height: 1.45;
	color: var(--gpm-text-secondary);
}

/* ==========================================================================
   Step 2 – amenity groups (consistent hierarchy)
   ========================================================================== */

.gpm-lead-form--step2 .gpm-form-section__legend,
.gpm-lead-form--step2 .gpm-form-section h3 {
	font-size: 0.9375rem;
	font-weight: 600;
}

.gpm-amenity-group__title {
	margin: 0 0 0.5rem;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.4;
	color: var(--gpm-text);
}

.gpm-amenity-group__items {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.gpm-checkbox-label--amenity {
	font-size: 0.875rem;
}

.gpm-step2-months-hint,
.gpm-form-section .gpm-text-muted {
	font-size: 0.8125rem;
	color: var(--gpm-text-secondary);
}

.gpm-step2-months-hint {
	margin: 0.25rem 0 0;
}

.gpm-months-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1rem;
	margin-bottom: 0.5rem;
	align-items: center;
}

.gpm-amenities-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1rem;
}

/* Hide Step 1b heading & subheading when Step 2 is open */
body.gpm-step2-open .gpm-lead-form-container #gpm-v2-step-1b .gpm-lead-form__header {
	display: none;
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.gpm-input,
	.gpm-select,
	.gpm-btn {
		transition: none;
	}
}
