/* ============================================================
 * Serre in Posa Form — stili frontend
 * Palette LivinGrancia
 * ============================================================ */

.sipf-wrap {
	--sipf-green-dark: #1B4332;
	--sipf-green-mid:  #2D6A4F;
	--sipf-green-soft: #95D5B2;
	--sipf-green-pale: #D8F3DC;
	--sipf-bg:         #FAF6F0;
	--sipf-white:      #FFFFFF;
	--sipf-text:       #1B4332;
	--sipf-muted:      #555555;
	--sipf-error:      #C53030;

	box-sizing: border-box;
	max-width: 820px;
	margin: 0 auto;
	padding: 60px 20px;
	background: var(--sipf-bg);
	color: var(--sipf-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 16px;
	line-height: 1.55;
}

.sipf-wrap *,
.sipf-wrap *::before,
.sipf-wrap *::after {
	box-sizing: border-box;
}

/* --- Header --------------------------------------------------- */
.sipf-header {
	text-align: center;
	margin-bottom: 36px;
}

.sipf-title {
	font-family: "Playfair Display", Georgia, "Times New Roman", serif;
	font-size: 32px;
	line-height: 1.2;
	color: var(--sipf-green-dark);
	margin: 0 0 14px;
}

.sipf-intro {
	max-width: 680px;
	margin: 0 auto;
	color: var(--sipf-muted);
	font-size: 16px;
}

.sipf-intro p {
	margin: 0 0 10px;
}

/* --- Progress bar -------------------------------------------- */
.sipf-progress {
	margin: 0 0 36px;
}

.sipf-progress-list {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	list-style: none;
	margin: 0;
	padding: 0;
	counter-reset: none;
}

.sipf-progress-item {
	position: relative;
	flex: 1 1 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	min-width: 0;
}

/* Linea che collega i cerchi */
.sipf-progress-item::before {
	content: "";
	position: absolute;
	top: 17px;
	left: -50%;
	width: 100%;
	height: 2px;
	background: var(--sipf-green-soft);
	z-index: 0;
}

.sipf-progress-item:first-child::before {
	display: none;
}

.sipf-progress-dot {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: 2px solid var(--sipf-green-soft);
	background: var(--sipf-white);
	color: var(--sipf-green-mid);
	font-weight: 700;
	font-size: 15px;
	transition: background-color .25s ease, border-color .25s ease, color .25s ease, transform .25s ease;
}

.sipf-progress-label {
	margin-top: 8px;
	font-size: 13px;
	color: var(--sipf-muted);
	line-height: 1.25;
	transition: color .25s ease;
}

/* Stato: completato */
.sipf-progress-item.is-done .sipf-progress-dot {
	background: var(--sipf-green-soft);
	border-color: var(--sipf-green-mid);
	color: var(--sipf-green-dark);
}

/* Stato: attivo */
.sipf-progress-item.is-current .sipf-progress-dot {
	background: var(--sipf-green-dark);
	border-color: var(--sipf-green-dark);
	color: var(--sipf-white);
	transform: scale(1.08);
}

.sipf-progress-item.is-current .sipf-progress-label {
	color: var(--sipf-green-dark);
	font-weight: 600;
}

/* Stato: nascosto dalla conditional logic (es. step 3) */
.sipf-progress-item.is-skipped {
	display: none;
}

/* --- Step ----------------------------------------------------- */
.sipf-steps {
	background: var(--sipf-white);
	border: 1px solid var(--sipf-green-pale);
	border-radius: 12px;
	padding: 32px 28px;
}

.sipf-step {
	display: none;
}

.sipf-step.is-active {
	display: block;
	animation: sipfFadeSlide .4s ease;
}

@keyframes sipfFadeSlide {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: translateY(0); }
}

.sipf-step-title {
	font-family: "Playfair Display", Georgia, "Times New Roman", serif;
	font-size: 24px;
	color: var(--sipf-green-dark);
	margin: 0 0 6px;
}

.sipf-step-intro {
	color: var(--sipf-muted);
	font-size: 15px;
	margin-bottom: 22px;
}

.sipf-step-intro p {
	margin: 0 0 10px;
}

/* --- Campi ---------------------------------------------------- */
.sipf-field {
	margin: 0 0 20px;
	border: 0;
	padding: 0;
}

.sipf-label,
.sipf-legend {
	display: block;
	font-size: 14px;
	font-weight: 500;
	color: var(--sipf-green-dark);
	margin-bottom: 6px;
}

.sipf-legend {
	padding: 0;
}

.sipf-req {
	color: var(--sipf-error);
	font-weight: 700;
}

.sipf-input {
	display: block;
	width: 100%;
	padding: 12px 16px;
	font-size: 16px;
	color: var(--sipf-text);
	background: var(--sipf-white);
	border: 1px solid var(--sipf-green-pale);
	border-radius: 8px;
	transition: border-color .2s ease, box-shadow .2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.sipf-input:focus {
	outline: none;
	border-color: var(--sipf-green-mid);
	box-shadow: 0 0 0 3px rgba(45, 106, 79, .18);
}

.sipf-input::placeholder {
	color: #9aa39c;
}

.sipf-textarea {
	min-height: 100px;
	resize: vertical;
	line-height: 1.5;
}

.sipf-select {
	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 fill='%232D6A4F' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 16px center;
	padding-right: 40px;
}

.sipf-uppercase {
	text-transform: uppercase;
}

.sipf-narrow {
	max-width: 200px;
}

.sipf-input.sipf-uppercase::placeholder {
	text-transform: none;
}

/* Stato di errore sul campo */
.sipf-field.has-error .sipf-input,
.sipf-field.has-error .sipf-select {
	border-color: var(--sipf-error);
	box-shadow: 0 0 0 3px rgba(197, 48, 48, .14);
}

.sipf-field.has-error .sipf-label,
.sipf-field.has-error .sipf-legend {
	color: var(--sipf-error);
}

.sipf-help {
	display: block;
	margin-top: 6px;
	font-size: 13px;
	color: var(--sipf-muted);
}

.sipf-error {
	display: none;
	margin-top: 6px;
	font-size: 13px;
	color: var(--sipf-error);
	font-weight: 500;
}

.sipf-field.has-error .sipf-error {
	display: block;
}

/* --- Radio --------------------------------------------------- */
.sipf-radio-group {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.sipf-radio-option {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 14px 16px;
	border: 1px solid var(--sipf-green-pale);
	border-radius: 8px;
	cursor: pointer;
	transition: border-color .2s ease, background-color .2s ease;
}

.sipf-radio-option:hover {
	border-color: var(--sipf-green-soft);
	background: var(--sipf-bg);
}

.sipf-radio-option input[type="radio"] {
	margin: 3px 0 0;
	width: 18px;
	height: 18px;
	accent-color: var(--sipf-green-mid);
	flex: 0 0 auto;
}

.sipf-radio-text {
	font-size: 15px;
}

/* --- Checkbox ------------------------------------------------ */
.sipf-checkbox-label {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	cursor: pointer;
	font-size: 14.5px;
	line-height: 1.5;
	color: var(--sipf-text);
}

.sipf-field-checkbox {
	padding: 14px 16px;
	border: 1px solid var(--sipf-green-pale);
	border-radius: 8px;
	background: var(--sipf-bg);
}

.sipf-field-checkbox.has-error {
	border-color: var(--sipf-error);
	background: rgba(197, 48, 48, .04);
}

.sipf-checkbox {
	margin: 2px 0 0;
	width: 20px;
	height: 20px;
	flex: 0 0 auto;
	accent-color: var(--sipf-green-mid);
}

.sipf-checkbox-text a {
	color: var(--sipf-green-mid);
	text-decoration: underline;
}

/* --- Visibilità (override di display:flex ecc. quando [hidden]) -- */
.sipf-conditional-wrap[hidden],
.sipf-steps[hidden],
.sipf-progress[hidden],
.sipf-nav[hidden],
.sipf-recap[hidden] {
	display: none !important;
}

/* --- Honeypot ------------------------------------------------ */
.sipf-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* --- Navigazione --------------------------------------------- */
.sipf-nav {
	display: flex;
	gap: 12px;
	justify-content: space-between;
	margin-top: 28px;
	flex-wrap: wrap;
}

.sipf-btn {
	font: inherit;
	font-size: 16px;
	font-weight: 600;
	padding: 14px 32px;
	border-radius: 8px;
	border: 2px solid transparent;
	cursor: pointer;
	transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease, color .2s ease;
	-webkit-appearance: none;
	appearance: none;
	line-height: 1.2;
}

.sipf-btn:focus-visible {
	outline: 3px solid rgba(45, 106, 79, .4);
	outline-offset: 2px;
}

.sipf-btn-primary {
	background: var(--sipf-green-dark);
	color: var(--sipf-white);
	margin-left: auto;
}

.sipf-btn-primary:hover {
	transform: translateY(-2px);
	box-shadow: 0 8px 18px rgba(27, 67, 50, .25);
}

.sipf-btn-secondary {
	background: transparent;
	color: var(--sipf-green-mid);
	border-color: var(--sipf-green-mid);
}

.sipf-btn-secondary:hover {
	background: var(--sipf-green-mid);
	color: var(--sipf-white);
	transform: translateY(-2px);
}

.sipf-btn[disabled],
.sipf-btn.is-loading {
	opacity: .65;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

/* Visibilità bottoni gestita via JS aggiungendo questa classe */
.sipf-btn[hidden] {
	display: none !important;
}

/* --- Errore generale form ----------------------------------- */
.sipf-form-error {
	margin-top: 18px;
	padding: 14px 18px;
	border-radius: 8px;
	background: rgba(197, 48, 48, .08);
	border: 1px solid rgba(197, 48, 48, .35);
	color: var(--sipf-error);
	font-size: 14.5px;
	font-weight: 500;
}

.sipf-form-error[hidden] {
	display: none;
}

/* --- Messaggio di successo ---------------------------------- */
.sipf-success[hidden] {
	display: none;
}

.sipf-success-inner {
	text-align: center;
	background: var(--sipf-green-pale);
	border: 1px solid var(--sipf-green-soft);
	border-radius: 12px;
	padding: 30px;
	font-size: 18px;
	color: var(--sipf-green-dark);
}

.sipf-success-inner p {
	margin: 0 0 10px;
}

.sipf-success-inner p:last-child {
	margin-bottom: 0;
}

/* --- Scheda di riepilogo ------------------------------------- */
.sipf-recap {
	background: var(--sipf-white);
	border: 1px solid var(--sipf-green-pale);
	border-radius: 12px;
	padding: 32px 28px;
	animation: sipfFadeSlide .4s ease;
}

.sipf-recap > .sipf-step-title {
	margin-bottom: 6px;
}

.sipf-recap-body {
	margin-top: 14px;
}

.sipf-recap-section {
	margin: 0 0 18px;
	border: 1px solid var(--sipf-green-pale);
	border-radius: 8px;
	overflow: hidden;
}

.sipf-recap-section-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	background: var(--sipf-bg);
	padding: 10px 14px;
	border-bottom: 1px solid var(--sipf-green-pale);
}

.sipf-recap-section-head h3 {
	margin: 0;
	font-family: "Playfair Display", Georgia, "Times New Roman", serif;
	font-size: 17px;
	color: var(--sipf-green-dark);
}

.sipf-recap-edit {
	flex: 0 0 auto;
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	color: var(--sipf-green-mid);
	background: transparent;
	border: 1px solid var(--sipf-green-soft);
	border-radius: 6px;
	padding: 5px 12px;
	cursor: pointer;
	transition: background-color .2s ease, color .2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.sipf-recap-edit:hover {
	background: var(--sipf-green-mid);
	color: var(--sipf-white);
}

.sipf-recap-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

.sipf-recap-table th {
	text-align: left;
	width: 38%;
	padding: 8px 14px;
	font-weight: 600;
	color: var(--sipf-green-dark);
	vertical-align: top;
	border-bottom: 1px solid var(--sipf-green-pale);
}

.sipf-recap-table td {
	padding: 8px 14px;
	vertical-align: top;
	border-bottom: 1px solid var(--sipf-green-pale);
	word-break: break-word;
	color: var(--sipf-text);
}

.sipf-recap-table tr:last-child th,
.sipf-recap-table tr:last-child td {
	border-bottom: 0;
}

.sipf-recap-empty {
	color: var(--sipf-muted);
	font-style: italic;
}

.sipf-recap-nav {
	margin-top: 24px;
}

/* ============================================================
 * Mobile (max-width: 767px)
 * ============================================================ */
@media (max-width: 767px) {
	.sipf-wrap {
		padding: 32px 14px;
		font-size: 16px;
	}

	.sipf-title {
		font-size: 25px;
	}

	.sipf-steps {
		padding: 22px 16px;
	}

	.sipf-step-title {
		font-size: 21px;
	}

	/* Progress bar: solo numeri, niente label */
	.sipf-progress-label {
		display: none;
	}

	.sipf-progress-dot {
		width: 30px;
		height: 30px;
		font-size: 13px;
	}

	.sipf-progress-item::before {
		top: 14px;
	}

	.sipf-nav {
		gap: 10px;
	}

	.sipf-btn {
		padding: 13px 20px;
		font-size: 15px;
		flex: 1 1 auto;
		text-align: center;
	}

	.sipf-btn-primary {
		margin-left: 0;
	}

	.sipf-narrow {
		max-width: 100%;
	}

	/* Su iOS evita lo zoom automatico al focus: font >= 16px (già impostato) */
	.sipf-input {
		font-size: 16px;
	}

	/* Riepilogo: layout a blocchi su mobile */
	.sipf-recap {
		padding: 22px 16px;
	}

	.sipf-recap-section-head {
		flex-wrap: wrap;
	}

	.sipf-recap-table,
	.sipf-recap-table tbody,
	.sipf-recap-table tr {
		display: block;
		width: 100%;
	}

	.sipf-recap-table tr {
		border-bottom: 1px solid var(--sipf-green-pale);
		padding: 8px 0;
	}

	.sipf-recap-table tr:last-child {
		border-bottom: 0;
	}

	.sipf-recap-table th {
		display: block;
		width: auto;
		padding: 0 14px 2px;
		border-bottom: 0;
		font-size: 13px;
	}

	.sipf-recap-table td {
		display: block;
		padding: 0 14px;
		border-bottom: 0;
	}
}

/* Riduci animazioni se richiesto dall'utente */
@media (prefers-reduced-motion: reduce) {
	.sipf-step.is-active {
		animation: none;
	}
	.sipf-btn,
	.sipf-progress-dot {
		transition: none;
	}
}
