/* ==========================================================================
   WP Recesso — stili form, modal, step, stati
   Prefisso .wpr- su tutto. Nessun conflitto con WooCommerce / temi comuni.

   Colori: si usano i CSS System Colors del browser (Canvas, CanvasText,
   ButtonFace, ButtonText, ButtonBorder, Field, FieldText, Highlight…).
   Questo garantisce compatibilità automatica con qualsiasi tema WordPress,
   compreso il dark mode dell'OS, senza sovrascrivere i colori del tema.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Proprietà non cromatiche
   --------------------------------------------------------------------------- */
:root {
	--wpr-radius:   6px;
	--wpr-z-modal:  99999;
	--wpr-font:     inherit;

	/* Colori semantici mantenuti (feedback UX, non decorativi) */
	--wpr-color-error:   #b91c1c;
	--wpr-bg-error:      #fef2f2;
	--wpr-border-error:  #fca5a5;
	--wpr-color-success: #15803d;
	--wpr-bg-success:    #f0fdf4;
	--wpr-border-success:#86efac;
}

/* ---------------------------------------------------------------------------
   Form wrapper — eredita tutto dal tema
   --------------------------------------------------------------------------- */
.wpr-form-wrap {
	font-family: var(--wpr-font);
	line-height: 1.6;
	max-width: 560px;
}

.wpr-form__title {
	margin: 0 0 8px;
	font-size: 1.4em;
	font-weight: 700;
}

.wpr-form__intro {
	margin: 0 0 24px;
	font-size: .9em;
	opacity: .75;
}

/* ---------------------------------------------------------------------------
   Step (navigazione tramite attributo hidden)
   --------------------------------------------------------------------------- */
.wpr-step {
	display: block;
}

.wpr-step[hidden] {
	display: none !important;
}

/* ---------------------------------------------------------------------------
   Campi
   --------------------------------------------------------------------------- */
.wpr-field {
	margin-bottom: 18px;
}

.wpr-fieldset {
	margin-bottom: 18px;
}

.wpr-label,
.wpr-field > .wpr-label {
	display: block;
	margin-bottom: 6px;
	font-size: .88em;
	font-weight: 600;
}

.wpr-input,
.wpr-textarea {
	display: block;
	width: 100%;
	padding: 10px 12px;
	font-size: 16px;        /* evita zoom automatico su iOS */
	font-family: var(--wpr-font);
	color: FieldText;
	background: Field;
	border: 1px solid ButtonBorder;
	border-radius: var(--wpr-radius);
	box-sizing: border-box;
	-webkit-appearance: none;
	appearance: none;
	transition: outline-offset .1s ease;
}

.wpr-input:focus,
.wpr-textarea:focus {
	outline: 2px solid Highlight;
	outline-offset: 1px;
}

.wpr-textarea {
	resize: vertical;
	min-height: 90px;
}

/* ---------------------------------------------------------------------------
   Lista articoli (checkbox)
   --------------------------------------------------------------------------- */
.wpr-items-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 12px;
	background: transparent;
	border: 1px solid ButtonBorder;
	border-radius: var(--wpr-radius);
}

.wpr-checkbox-label {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: .93em;
	line-height: 1.4;
}

.wpr-checkbox-label input[type="checkbox"] {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	margin: 0;
	cursor: pointer;
	accent-color: Highlight;
}

.wpr-item__thumb {
	flex-shrink: 0;
	width: 48px;
	height: 48px;
	object-fit: cover;
	border-radius: 4px;
	border: 1px solid ButtonBorder;
}

.wpr-item__info {
	display: flex;
	flex-direction: column;
}

.wpr-item__name {
	font-weight: 600;
}

.wpr-item__qty {
	font-size: .83em;
	opacity: .65;
}

/* ---------------------------------------------------------------------------
   Messaggi di stato inline — colori semantici mantenuti
   --------------------------------------------------------------------------- */
.wpr-message {
	padding: 10px 14px;
	border-radius: var(--wpr-radius);
	font-size: .9em;
	margin-top: 12px;
}

.wpr-message[hidden] {
	display: none !important;
}

.wpr-message.is-error {
	color: var(--wpr-color-error);
	background: var(--wpr-bg-error);
	border: 1px solid var(--wpr-border-error);
}

.wpr-message.is-success {
	color: var(--wpr-color-success);
	background: var(--wpr-bg-success);
	border: 1px solid var(--wpr-border-success);
}

/* ---------------------------------------------------------------------------
   Bottoni — struttura senza colori imposti
   --------------------------------------------------------------------------- */
.wpr-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	margin-top: 20px;
}

.wpr-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 11px 22px;
	font-size: .95em;
	font-family: var(--wpr-font);
	font-weight: 600;
	line-height: 1.2;
	border-radius: var(--wpr-radius);
	cursor: pointer;
	text-decoration: none;
	-webkit-appearance: none;
	appearance: none;
	transition: opacity .15s ease, outline-offset .1s ease;
}

/*
 * .wpr-btn--primary: usa i CSS system colors per adattarsi a qualsiasi tema.
 * CanvasText come sfondo = colore del testo corrente (scuro su temi chiari,
 * chiaro su temi scuri). Canvas come colore testo = contrasto garantito.
 */
.wpr-btn--primary {
	background: CanvasText;
	color: Canvas;
	border: 2px solid CanvasText;
}

.wpr-btn--primary:hover,
.wpr-btn--primary:focus-visible {
	opacity: .82;
	outline: 2px solid Highlight;
	outline-offset: 2px;
}

/*
 * .wpr-btn--secondary: contorno sottile, sfondo trasparente.
 * Eredita il colore del testo dal tema (ButtonText).
 */
.wpr-btn--secondary {
	background: transparent;
	color: ButtonText;
	border: 2px solid ButtonBorder;
}

.wpr-btn--secondary:hover,
.wpr-btn--secondary:focus-visible {
	outline: 2px solid Highlight;
	outline-offset: 2px;
}

/* Loading state */
.wpr-btn.is-loading {
	opacity: .55;
	cursor: not-allowed;
	pointer-events: none;
}

.wpr-btn.is-loading::after {
	content: '';
	display: inline-block;
	width: 13px;
	height: 13px;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: wpr-spin .6s linear infinite;
	margin-left: 6px;
}

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

/* ---------------------------------------------------------------------------
   Step 3 — Conferma successo (colori semantici mantenuti)
   --------------------------------------------------------------------------- */
.wpr-success {
	text-align: center;
	padding: 20px 0;
}

.wpr-success__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	background: var(--wpr-color-success);
	color: #fff;
	border-radius: 50%;
	font-size: 2em;
	margin: 0 auto 16px;
}

.wpr-success__title {
	margin: 0 0 10px;
	font-size: 1.2em;
	font-weight: 700;
	color: var(--wpr-color-success);
}

.wpr-success__detail {
	margin: 0 0 12px;
	font-size: .95em;
	font-weight: 600;
}

.wpr-success__legal {
	font-size: .83em;
	opacity: .65;
	margin: 0;
}

/* ---------------------------------------------------------------------------
   Status badges
   --------------------------------------------------------------------------- */
.wpr-status {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 20px;
	font-size: .8em;
	font-weight: 600;
	text-transform: capitalize;
}

.wpr-status--ricevuto      { background: #d6eaf8; color: #1a5276; }
.wpr-status--in_lavorazione{ background: #fef9e7; color: #7d6608; }
.wpr-status--completato    { background: #eafaf1; color: #1e8449; }
.wpr-status--rifiutato     { background: #fdecea; color: #922b21; }

/* ---------------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------------- */
.wpr-modal {
	position: fixed;
	inset: 0;
	z-index: var(--wpr-z-modal);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	box-sizing: border-box;
}

.wpr-modal[hidden] {
	display: none !important;
}

.wpr-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .5);
	cursor: pointer;
}

.wpr-modal__box {
	position: relative;
	z-index: 1;
	background: Canvas;
	color: CanvasText;
	border-radius: calc(var(--wpr-radius) * 2);
	box-shadow: 0 8px 40px rgba(0, 0, 0, .28);
	width: 100%;
	max-width: 620px;
	max-height: 90vh;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.wpr-modal__content {
	padding: 32px 32px 28px;
}

.wpr-modal__close {
	position: absolute;
	top: 12px;
	right: 14px;
	z-index: 2;
	background: transparent;
	border: none;
	cursor: pointer;
	font-size: 1.5em;
	line-height: 1;
	color: inherit;
	opacity: .5;
	padding: 4px 8px;
	border-radius: var(--wpr-radius);
	transition: opacity .15s ease;
}

.wpr-modal__close:hover,
.wpr-modal__close:focus-visible {
	opacity: 1;
	outline: 2px solid Highlight;
	outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   Link trigger
   --------------------------------------------------------------------------- */
.wpr-modal-trigger,
.wpr-link {
	cursor: pointer;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 480px) {
	.wpr-modal__content {
		padding: 24px 18px 20px;
	}

	.wpr-modal__box {
		border-radius: var(--wpr-radius);
	}

	.wpr-actions {
		flex-direction: column;
	}

	.wpr-btn {
		width: 100%;
		justify-content: center;
	}
}
