/* addons-prodotti-woocommerce - front-end
 *
 * Si adatta al tema: eredita font e colore del testo, usa il colore di accento delle impostazioni (--apw-accent)
 * e variabili con valori di riserva, così un tema può ridefinirle senza toccare questo file.
 */
.apw-wrap {
	--apw-accent: #2271b1;
	--apw-border: rgba(0, 0, 0, .18);
	--apw-border-strong: rgba(0, 0, 0, .42);
	--apw-radius: 8px;
	--apw-surface: #fff;
	--apw-tint: rgba(34, 113, 177, .08); /* riserva per i browser senza color-mix */
	--apw-danger: #b32d2e;
	/* Colori personalizzabili da Impostazioni (--apw-text, --apw-summary-bg, --apw-on-accent): senza valore valgono i predefiniti sotto. */
	color: var(--apw-text, inherit);
	margin: 0 0 1.25em;
	width: 100%;
	flex: 1 0 100%;
}
@supports (background: color-mix(in srgb, red 10%, white)) {
	.apw-wrap { --apw-tint: color-mix(in srgb, var(--apw-accent) 9%, #fff); }
}

.apw-form + .apw-form { margin-top: 1.25em; }
.apw-form__title { margin: 0 0 .6em; font-size: 1.15em; }
.apw-section + .apw-section { margin-top: 1.4em; }
.apw-section__title {
	margin: 0 0 .7em;
	padding-bottom: .4em;
	border-bottom: 2px solid var(--apw-accent);
	font-size: 1.05em;
}
.apw-section__desc { margin: 0 0 .6em; font-size: .92em; opacity: .85; }

.apw-wrap [hidden] { display: none !important; }

.apw-fields {
	display: flex;
	flex-wrap: wrap;
	gap: 1.1em 1.25em;
}

.apw-field { box-sizing: border-box; min-width: 0; }
.apw-w-100 { flex: 1 1 100%; }
.apw-w-75 { flex: 1 1 calc(75% - 1.25em); }
.apw-w-66 { flex: 1 1 calc(66% - 1.25em); }
.apw-w-50 { flex: 1 1 calc(50% - 1.25em); }
.apw-w-33 { flex: 1 1 calc(33% - 1.25em); }
.apw-w-25 { flex: 1 1 calc(25% - 1.25em); }

@media (max-width: 600px) {
	.apw-field[class*="apw-w-"] { flex-basis: 100%; }
}

/* un campo che compare per una condizione si fa notare con una dissolvenza breve */
@keyframes apw-reveal {
	from { opacity: 0; transform: translateY(-6px); }
	to { opacity: 1; transform: none; }
}
.apw-reveal { animation: apw-reveal .22s ease-out; }
@media (prefers-reduced-motion: reduce) {
	.apw-reveal { animation: none; }
	.apw-wrap * { transition: none !important; }
}

.apw-label {
	display: block;
	margin: 0 0 .45em;
	font-weight: 600;
	line-height: 1.35;
}
.apw-req { color: var(--apw-danger); margin-left: .15em; }

.apw-input {
	display: block;
	width: 100%;
	box-sizing: border-box;
	min-height: 2.75em;
	padding: .55em .75em;
	border: 1.5px solid var(--apw-border);
	border-radius: var(--apw-radius);
	background-color: var(--apw-surface);
	color: inherit;
	font: inherit;
	transition: border-color .15s ease, box-shadow .15s ease;
}
textarea.apw-input { min-height: 5.5em; resize: vertical; }
.apw-input:hover { border-color: var(--apw-border-strong); }
.apw-input:focus-visible,
.apw-file__input:focus-visible + .apw-file__btn,
.apw-swatch__input:focus-visible + .apw-swatch__dot {
	outline: 2px solid var(--apw-accent);
	outline-offset: 2px;
}
.apw-input:focus { border-color: var(--apw-accent); }

.apw-desc { margin-top: .35em; font-size: .88em; opacity: .8; }
.apw-content { line-height: 1.5; }
.apw-content hr, hr.apw-separator { border: 0; border-top: 1px solid var(--apw-border); margin: .4em 0; }
.apw-label--content { font-weight: 600; margin-bottom: .2em; }

/* prezzo accanto a una scelta */
.apw-price-tag {
	display: inline-block;
	margin-left: .4em;
	font-size: .86em;
	font-weight: 500;
	opacity: .8;
	white-space: nowrap;
}

/* ---------------------------------------------------------------------
 * Scelte (radio / checkbox) — stile "Schede" (predefinito)
 * ------------------------------------------------------------------ */
.apw-style-cards .apw-choices:not(.apw-choices--swatches) {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.75rem), 1fr));
	gap: .6em;
}
.apw-style-cards .apw-choice {
	position: relative;
	display: flex;
	flex-wrap: wrap; /* se prezzo ed etichetta non stanno insieme, il prezzo va sotto invece di spezzare la parola */
	align-items: flex-start;
	justify-content: space-between;
	gap: .3em .5em;
	box-sizing: border-box;
	min-height: 2.9em;
	padding: .65em .8em;
	border: 1.5px solid var(--apw-border);
	border-radius: var(--apw-radius);
	background: var(--apw-surface);
	cursor: pointer;
	line-height: 1.3;
	transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.apw-style-cards .apw-choice:hover { border-color: var(--apw-border-strong); }
.apw-style-cards .apw-choice input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0;
}
.apw-style-cards .apw-choice__label {
	position: relative;
	flex: 1 1 5em;
	min-width: 0;
	padding-left: 1.75em;
	overflow-wrap: break-word;
}
/* indicatore (cerchio per le scelte singole, quadrato per le multiple) */
.apw-style-cards .apw-choice__label::before {
	content: "";
	position: absolute;
	left: 0;
	top: .08em;
	box-sizing: border-box;
	width: 1.2em;
	height: 1.2em;
	border: 2px solid var(--apw-border-strong);
	border-radius: 50%;
	background: var(--apw-surface);
	transition: border-color .15s ease, background-color .15s ease;
}
.apw-style-cards .apw-choice input[type="checkbox"] + .apw-choice__label::before { border-radius: 4px; }
.apw-style-cards .apw-choice__label::after {
	content: "";
	position: absolute;
	opacity: 0;
	transition: opacity .12s ease, transform .12s ease;
}
.apw-style-cards .apw-choice input[type="radio"] + .apw-choice__label::after {
	left: .38em;
	top: .46em;
	width: .44em;
	height: .44em;
	border-radius: 50%;
	background: var(--apw-accent);
	transform: scale(.4);
}
.apw-style-cards .apw-choice input[type="checkbox"] + .apw-choice__label::after {
	left: .42em;
	top: .16em;
	width: .3em;
	height: .62em;
	border: solid var(--apw-on-accent, #fff);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg) scale(.6);
}
.apw-style-cards .apw-choice input:checked + .apw-choice__label::before { border-color: var(--apw-accent); }
.apw-style-cards .apw-choice input[type="checkbox"]:checked + .apw-choice__label::before { background: var(--apw-accent); }
.apw-style-cards .apw-choice input[type="radio"]:checked + .apw-choice__label::after { opacity: 1; transform: scale(1); }
.apw-style-cards .apw-choice input[type="checkbox"]:checked + .apw-choice__label::after { opacity: 1; transform: rotate(45deg) scale(1); }
.apw-style-cards .apw-choice:has(input:checked) {
	border-color: var(--apw-accent);
	background: var(--apw-tint);
	box-shadow: 0 0 0 1px var(--apw-accent);
}
.apw-style-cards .apw-choice:has(input:focus-visible) { outline: 2px solid var(--apw-accent); outline-offset: 2px; }
.apw-style-cards .apw-choice:has(input:disabled) { opacity: .5; cursor: not-allowed; }
/* il prezzo è un'etichetta a destra della scheda */
.apw-style-cards .apw-choice .apw-price-tag {
	flex: none;
	margin: 0 0 0 auto;
	padding: .12em .55em;
	border-radius: 999px;
	background: rgba(0, 0, 0, .06);
	font-size: .8em;
	font-weight: 600;
	line-height: 1.5;
	opacity: 1;
	font-variant-numeric: tabular-nums;
}
.apw-style-cards .apw-choice:has(input:checked) .apw-price-tag { background: var(--apw-accent); color: var(--apw-on-accent, #fff); }

/* ---------------------------------------------------------------------
 * Scelte — stile "Classico" (pallini e caselle in riga)
 * ------------------------------------------------------------------ */
.apw-style-classic .apw-choices { display: flex; flex-wrap: wrap; gap: .5em 1.1em; }
.apw-style-classic .apw-choice { display: inline-flex; align-items: center; gap: .45em; cursor: pointer; }
.apw-style-classic .apw-choice input { margin: 0; accent-color: var(--apw-accent); }
.apw-style-classic .apw-choice input:focus-visible { outline: 2px solid var(--apw-accent); outline-offset: 2px; }

/* ---------------------------------------------------------------------
 * Campioni colore (uguali nei due stili)
 * ------------------------------------------------------------------ */
.apw-choices--swatches { display: flex; flex-wrap: wrap; gap: .8em; }
.apw-swatch {
	position: relative;
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: .3em;
	min-width: 3.2em;
	cursor: pointer;
	text-align: center;
}
.apw-swatch__input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0;
}
.apw-swatch__dot {
	display: block;
	width: 2.6em;
	height: 2.6em;
	border: 3px solid var(--apw-surface);
	box-shadow: 0 0 0 1px var(--apw-border-strong);
	transition: box-shadow .12s ease, transform .12s ease;
}
.apw-swatch--circle .apw-swatch__dot { border-radius: 50%; }
.apw-swatch--rounded .apw-swatch__dot { border-radius: 28%; }
.apw-swatch--square .apw-swatch__dot { border-radius: 0; }
.apw-swatch:hover .apw-swatch__dot { transform: scale(1.06); }
.apw-swatch__input:checked + .apw-swatch__dot { box-shadow: 0 0 0 3px var(--apw-accent); }
.apw-swatch__label { font-size: .85em; line-height: 1.2; max-width: 6em; }
.apw-swatch__input:checked ~ .apw-swatch__label { font-weight: 600; }
.apw-swatch .apw-price-tag { margin: 0; font-size: .78em; }
.apw-swatch:has(input:disabled) { opacity: .45; cursor: not-allowed; }

/* ---------------------------------------------------------------------
 * Caricamento file
 * ------------------------------------------------------------------ */
.apw-file {
	padding: .8em;
	border: 1.5px dashed var(--apw-border-strong);
	border-radius: var(--apw-radius);
	background: var(--apw-surface);
}
.apw-file__input { display: block; max-width: 100%; font: inherit; }
.apw-file__input::file-selector-button {
	margin-right: .8em;
	padding: .5em .9em;
	border: 1.5px solid var(--apw-accent);
	border-radius: var(--apw-radius);
	background: var(--apw-surface);
	color: var(--apw-accent);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.apw-file__input::file-selector-button:hover { background: var(--apw-tint); }
.apw-file__hint { margin-top: .5em; font-size: .85em; opacity: .75; }
.apw-file__list { list-style: none; margin: .5em 0 0; padding: 0; }
.apw-file__item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .75em;
	padding: .45em .7em;
	margin-bottom: .35em;
	border: 1px solid var(--apw-border);
	border-radius: var(--apw-radius);
	background: var(--apw-tint);
	font-size: .92em;
}
.apw-file__item--busy { opacity: .7; }
.apw-file__item--error { border-color: var(--apw-danger); color: var(--apw-danger); background: transparent; }
.apw-file__name { overflow-wrap: anywhere; }
.apw-file__remove {
	flex: none;
	background: none;
	border: 0;
	padding: 0;
	color: var(--apw-accent);
	text-decoration: underline;
	cursor: pointer;
	font: inherit;
}

/* ---------------------------------------------------------------------
 * Menu a tendina con ricerca (il <select> originale resta nel form, nascosto)
 * ------------------------------------------------------------------ */
.apw-combo { position: relative; }
.apw-combo__native {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: 0 !important;
	padding: 0 !important;
	opacity: 0;
	pointer-events: none;
	clip-path: inset(50%);
}
/* .apw-wrap davanti: i temi danno stile a input[type="text"] (es. Hello Elementor) e qui padding e dimensioni contano */
.apw-wrap .apw-combo__input {
	display: block;
	width: 100%;
	box-sizing: border-box;
	min-height: 2.75em;
	margin: 0;
	padding: .55em 2.4em .55em .75em;
	border: 1.5px solid var(--apw-border);
	border-radius: var(--apw-radius);
	background-color: var(--apw-surface);
	color: inherit;
	font: inherit;
	font-size: max(16px, 1em); /* sotto i 16px il telefono ingrandisce la pagina quando si scrive */
	text-overflow: ellipsis;
	cursor: pointer;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.apw-wrap .apw-combo__input:hover { border-color: var(--apw-border-strong); }
.apw-wrap .apw-combo__input:focus { border-color: var(--apw-accent); cursor: text; }
.apw-wrap .apw-combo__input:focus-visible { outline: 2px solid var(--apw-accent); outline-offset: 2px; }
.apw-wrap .apw-combo__input:disabled { opacity: .6; cursor: default; }
.apw-wrap .apw-combo__input::placeholder { color: inherit; opacity: .6; }
.apw-combo::after {
	content: "";
	position: absolute;
	top: 50%;
	right: .95em;
	width: .5em;
	height: .5em;
	margin-top: -.35em;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	opacity: .6;
	pointer-events: none;
}
.apw-combo--open::after { margin-top: -.05em; transform: rotate(-135deg); }
.apw-combo__list {
	position: absolute;
	z-index: 1000;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	max-height: 320px;
	margin: 0;
	padding: .3em 0;
	list-style: none;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	background: var(--apw-surface);
	color: var(--apw-text, inherit);
	border: 1.5px solid var(--apw-border-strong);
	border-radius: var(--apw-radius);
	box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
}
.apw-combo--up .apw-combo__list { top: auto; bottom: calc(100% + 4px); }
.apw-wrap .apw-combo__list li { margin: 0; }
.apw-combo__option {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1em;
	min-height: 2.75em; /* bersaglio comodo per il dito */
	box-sizing: border-box;
	padding: .45em .8em;
	line-height: 1.3;
	cursor: pointer;
}
.apw-combo__option:hover,
.apw-combo__option.is-active { background: var(--apw-tint); }
.apw-combo__option[aria-selected="true"] { font-weight: 600; box-shadow: inset 3px 0 0 var(--apw-accent); }
.apw-combo__option--none { opacity: .7; font-style: italic; }
.apw-combo__text { min-width: 0; overflow-wrap: anywhere; }
.apw-combo__tag { flex: none; font-size: .9em; opacity: .8; white-space: nowrap; }
.apw-combo__empty { padding: .6em .8em; opacity: .7; }

/* ---------------------------------------------------------------------
 * Errori
 * ------------------------------------------------------------------ */
.apw-error { margin-top: .35em; color: var(--apw-danger); font-size: .9em; font-weight: 500; min-height: 0; }
.apw-error:empty { display: none; }
.apw-field--invalid .apw-input,
.apw-wrap .apw-field--invalid .apw-combo__input,
.apw-field--invalid .apw-file { border-color: var(--apw-danger); }
.apw-style-cards .apw-field--invalid .apw-choice { border-color: var(--apw-danger); }

/* ---------------------------------------------------------------------
 * Prezzo di listino (fuori dal form, nella pagina prodotto)
 * ------------------------------------------------------------------ */
/* Con Elementor: lo stile predefinito del widget "Prezzo prodotto" di Elementor Pro (colore e tipografia globali "Primario").
   Il prezzo della variazione compare dentro il widget "Aggiungi al carrello", che non ha controlli per il prezzo: senza questa
   regola resterebbe il verde-oliva di WooCommerce. Le proprietà non impostate nel kit di Elementor restano quelle di prima. */
body[class*="elementor-kit-"] .woocommerce-variation-price .price.apw-list-price {
	color: var(--e-global-color-primary, inherit);
	font-family: var(--e-global-typography-primary-font-family), sans-serif;
	font-size: var(--e-global-typography-primary-font-size, 1.25em);
	font-weight: var(--e-global-typography-primary-font-weight, inherit);
	font-style: var(--e-global-typography-primary-font-style, normal);
	line-height: var(--e-global-typography-primary-line-height, inherit);
	letter-spacing: var(--e-global-typography-primary-letter-spacing, normal);
	text-transform: var(--e-global-typography-primary-text-transform, none);
}

/* Scelte a pagamento: il riepilogo del form diventa il prezzo e quello di listino sparisce (prezzo della variazione, widget
   "Prezzo prodotto" di Elementor, prezzo sotto il titolo dei temi classici). Torna appena le scelte non costano più nulla. */
.apw-price-replaced .woocommerce-variation-price,
.apw-price-replaced .elementor-widget-woocommerce-product-price,
.apw-price-replaced .summary > .price { display: none !important; }

/* ---------------------------------------------------------------------
 * Riepilogo prezzi
 * ------------------------------------------------------------------ */
.apw-summary {
	margin-top: 1.1em;
	padding: .9em 1.1em;
	border: 1.5px solid var(--apw-border);
	border-radius: var(--apw-radius);
	background: var(--apw-summary-bg, var(--apw-tint));
	font-variant-numeric: tabular-nums;
}
.apw-summary__lines { list-style: none; margin: 0 0 .5em; padding: 0 0 .5em; border-bottom: 1px dashed var(--apw-border-strong); }
.apw-summary__lines li {
	display: flex;
	justify-content: space-between;
	gap: 1em;
	padding: .2em 0;
	font-size: .93em;
	line-height: 1.35;
}
.apw-summary__name { min-width: 0; overflow-wrap: anywhere; }
.apw-summary__amt { flex: none; font-weight: 600; white-space: nowrap; }
.apw-summary__row { display: flex; justify-content: space-between; gap: 1em; padding: .15em 0; }
.apw-summary__row--total {
	font-size: 1.12em;
	font-weight: 700;
	border-top: 1.5px solid var(--apw-border-strong);
	margin-top: .4em;
	padding-top: .5em;
}
.apw-summary__note { text-align: right; font-size: .85em; opacity: .75; }
.apw-summary__note:empty { display: none; }

.apw-wrap .screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}
