/**
 * Carrello laterale e stepper quantità - Azienda Agricola Urso
 *
 * I colori seguono la palette Elementor del sito (kit ID 9).
 */

:root {
	--urso-orange: #f86c2c; /* "In risalto" */
	--urso-green: #044c24;  /* "Principale" */
	--urso-text: #222222;   /* "Testo" */
	--urso-badge: #f9b233;  /* badge quantità giallo/ambra */
	--urso-cta: #333333;    /* pulsante checkout */
	--urso-border: #e8e8e8;
	--urso-muted: #8c8c8c;
}

/* ---------------------------------------------------------------- Drawer */

.urso-cart-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	opacity: 0;
	transition: opacity 0.3s ease;
	z-index: 99998;
}

.urso-cart-overlay.is-open {
	opacity: 1;
}

.urso-cart {
	position: fixed;
	top: 0;
	right: 0;
	width: 450px;
	max-width: 100%;
	height: 100%;
	background: #fff;
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform 0.3s ease;
	z-index: 99999;
	box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
	font-family: "Poppins", sans-serif;
}

.urso-cart.is-open {
	transform: translateX(0);
}

.urso-cart[hidden],
.urso-cart-overlay[hidden] {
	display: none;
}

body.urso-cart-open {
	overflow: hidden;
}

/* ---------------------------------------------------------------- Header */

.urso-cart__header {
	display: flex;
	align-items: center;
	border-bottom: 1px solid var(--urso-border);
	flex: none;
}

.urso-cart .urso-cart__close {
	width: 58px;
	height: 58px;
	flex: none;
	padding: 0;
	background: #333;
	background-color: #333;
	color: #fff;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	font-size: 26px;
	font-weight: 300;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.urso-cart .urso-cart__close:hover {
	background-color: #000;
}

.urso-cart__heading {
	flex: 1;
	margin: 0;
	padding-right: 58px; /* bilancia il pulsante di chiusura */
	text-align: center;
	font-size: 15px;
	font-weight: 400;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #555;
}

/* ----------------------------------------------------------------- Corpo */

.urso-cart__body {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.urso-cart__empty {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--urso-muted);
	font-size: 15px;
	padding: 40px 20px;
	text-align: center;
}

.urso-cart__items {
	flex: 1;
	overflow-y: auto;
	list-style: none;
	margin: 0;
	padding: 0;
}

.urso-cart__item {
	display: grid;
	grid-template-columns: 100px 1fr auto;
	gap: 16px;
	padding: 22px 20px;
	border-bottom: 1px solid #f4f4f4;
	position: relative;
	align-items: start;
}

/* Immagine e badge quantità */

.urso-cart__thumb {
	position: relative;
	width: 100px;
}

.urso-cart__thumb img {
	display: block;
	width: 100px;
	height: 80px;
	object-fit: cover;
	border-radius: 3px;
}

.urso-cart__thumb-badge {
	position: absolute;
	top: -9px;
	right: -9px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	background: var(--urso-orange);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
}

/* Testi */

.urso-cart__details {
	min-width: 0;
	padding-right: 10px;
}

.urso-cart__category {
	display: block;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #a0a0a0;
	margin-bottom: 3px;
}

.urso-cart__title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	color: var(--urso-orange);
	font-weight: 700;
	font-size: 15px;
	line-height: 1.3;
	text-decoration: none;
	margin-bottom: 10px;
}

.urso-cart__title:hover {
	text-decoration: underline;
}

.urso-cart__price {
	font-weight: 700;
	font-size: 15px;
	color: var(--urso-text);
	white-space: nowrap;
	padding-top: 18px;
}

.urso-cart__remove {
	position: absolute;
	top: 12px;
	right: 14px;
	background: none;
	border: 0;
	color: #cfcfcf;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 4px;
	transition: color 0.2s ease;
}

.urso-cart__remove:hover {
	color: var(--urso-text);
}

/* ---------------------------------------------------------------- Footer */

.urso-cart__footer {
	flex: none;
	border-top: 1px solid var(--urso-border);
	padding: 18px 20px 20px;
	background: #fafafa;
}

.urso-cart__totals {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 16px;
}

.urso-cart__count strong {
	font-size: 22px;
	font-weight: 700;
	color: var(--urso-text);
	margin-right: 6px;
}

.urso-cart__count span {
	font-size: 12px;
	color: var(--urso-muted);
	max-width: 70px;
	display: inline-block;
	line-height: 1.2;
	vertical-align: middle;
}

.urso-cart__subtotal span {
	font-size: 14px;
	color: #666;
	margin-right: 6px;
}

.urso-cart__subtotal strong {
	font-size: 20px;
	font-weight: 700;
	color: var(--urso-text);
}

.urso-cart .urso-cart__checkout {
	display: block;
	width: 100%;
	background: var(--urso-cta);
	background-color: var(--urso-cta);
	color: #fff;
	text-align: center;
	padding: 17px 16px;
	font-size: 14px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	text-decoration: none;
	border: 0;
	border-radius: 3px;
	box-sizing: border-box;
	transition: background-color 0.2s ease;
}

.urso-cart .urso-cart__checkout:hover,
.urso-cart .urso-cart__checkout:focus {
	background-color: #1f1f1f;
	color: #fff;
	text-decoration: none;
}

/* Stato di caricamento durante le chiamate AJAX */

.urso-cart.is-loading .urso-cart__body {
	opacity: 0.5;
	pointer-events: none;
}

/* -------------------------------------------------------- Stepper quantità */

.urso-qty {
	display: inline-flex;
	align-items: center;
	border: 1px solid #ddd;
	border-radius: 4px;
	overflow: hidden;
	background: #fff;
}

/*
 * Il kit Elementor colora tutti i `button` con un selettore più specifico
 * della singola classe, quindi qui serve `.urso-qty button.urso-qty__btn`
 * e un azzeramento esplicito di sfondo, bordi e raggio.
 */
.urso-qty button.urso-qty__btn {
	width: 32px;
	height: 32px;
	padding: 0;
	background: #fff;
	background-color: #fff;
	background-image: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	color: #8c8c8c;
	font-size: 16px;
	font-weight: 400;
	line-height: 1;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.urso-qty button.urso-qty__btn:hover,
.urso-qty button.urso-qty__btn:focus {
	background-color: #f5f5f5;
	color: var(--urso-text);
}

/*
 * Il kit Elementor impone `padding: 8px 16px` agli input con un selettore più
 * specifico di `.urso-qty__input`. Su un campo largo 32px in box-sizing
 * border-box i 16px per lato azzerano lo spazio del contenuto: il numero
 * esisteva nel DOM ma non aveva un pixel in cui essere disegnato, e fra - e +
 * non si vedeva nulla. Serve `.urso-qty input.urso-qty__input` e l'azzeramento
 * esplicito di padding, con line-height pari all'altezza.
 */
.urso-qty input.urso-qty__input {
	width: 44px;
	height: 32px;
	line-height: 32px;
	text-align: center;
	border: 0;
	border-left: 1px solid #ddd;
	border-right: 1px solid #ddd;
	font-size: 14px;
	color: var(--urso-text);
	background: #fff;
	border-radius: 0;
	padding: 0;
	-moz-appearance: textfield;
}

.urso-qty input.urso-qty__input::-webkit-outer-spin-button,
.urso-qty input.urso-qty__input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.urso-qty input.urso-qty__input:focus {
	outline: none;
	box-shadow: none;
}

/*
 * Dentro il drawer lo stepper è senza riquadro: solo i segni e il numero,
 * come nel riferimento approvato.
 */
.urso-qty--cart {
	border: 0;
	border-radius: 0;
	background: transparent;
	overflow: visible;
	gap: 8px;
}

/* Segni grigi su fondo trasparente, più grandi di prima. */
.urso-qty--cart button.urso-qty__btn {
	width: 28px;
	height: 28px;
	border-radius: 0;
	background: transparent;
	background-color: transparent;
	color: #9a9a9a;
	font-size: 19px;
	font-weight: 400;
}

.urso-qty--cart button.urso-qty__btn:hover,
.urso-qty--cart button.urso-qty__btn:focus {
	background-color: transparent;
	color: var(--urso-text);
}

.urso-qty--cart input.urso-qty__input {
	width: 30px;
	height: 22px;
	line-height: 22px;
	padding: 0;
	border: 0;
	background: transparent;
	font-size: 14px;
	font-weight: 700;
	color: var(--urso-text);
}

/* Scheda prodotto: stepper più grande e centrato, come da design */

.woocommerce div.product form.cart .urso-qty--product {
	height: 44px;
	margin: 0 auto 16px;
	display: flex;
}

.urso-qty--product button.urso-qty__btn {
	width: 42px;
	height: 42px;
	font-size: 18px;
}

/* Stepper dentro le schede del listato prodotti */

.urso-qty--loop {
	display: flex;
	margin: 0 auto 10px;
	width: max-content;
}

.urso-qty--loop button.urso-qty__btn {
	width: 34px;
	height: 34px;
	font-size: 17px;
}

.urso-qty--loop input.urso-qty__input {
	width: 46px;
	height: 34px;
	line-height: 34px;
	padding: 0;
	font-size: 15px;
	font-weight: 700;
}

/*
 * Nel listato il pulsante di aggiunta sta sotto lo stepper e occupa la riga,
 * così la scheda resta leggibile anche su mobile.
 */
.urso-qty--loop + .add_to_cart_button,
.urso-qty--loop ~ .add_to_cart_button {
	display: block;
	width: 100%;
	text-align: center;
}

/* Il campo quantità di WooCommerce dentro il nostro stepper */

.urso-qty .quantity {
	margin: 0 !important;
	display: flex;
}

.urso-qty .quantity input.qty {
	width: 56px;
	height: 42px;
	line-height: 42px;
	padding: 0;
	text-align: center;
	border: 0;
	border-left: 1px solid #ddd;
	border-right: 1px solid #ddd;
	border-radius: 0;
	font-size: 16px;
	color: var(--urso-text);
	-moz-appearance: textfield;
}

.urso-qty .quantity input.qty::-webkit-outer-spin-button,
.urso-qty .quantity input.qty::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* Pulsante "Aggiungi al carrello" in arancione brand */

.woocommerce div.product form.cart .single_add_to_cart_button {
	background: var(--urso-orange);
	color: #fff;
	text-transform: uppercase;
	font-weight: 700;
	letter-spacing: 0.04em;
	border-radius: 4px;
	padding: 16px 28px;
	border: 0;
	transition: background 0.2s ease;
}

.woocommerce div.product form.cart .single_add_to_cart_button:hover {
	background: #e35a1c;
	color: #fff;
}

.woocommerce div.product form.cart .single_add_to_cart_button.loading {
	opacity: 0.7;
}

/* --------------------------------------------- Icona carrello nell'header */

.urso-header-cart {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--urso-text);
	text-decoration: none;
	line-height: 1;
}

.urso-header-cart:hover {
	color: var(--urso-orange);
}

/*
 * Il kit Elementor colora i link dell'header con specificità maggiore, e l'SVG
 * eredita quel colore tramite stroke="currentColor". Fissiamo lo stroke in CSS:
 * una proprietà CSS batte sempre l'attributo di presentazione dell'SVG.
 * La pastiglia del contatore resta arancione: è un background, non uno stroke.
 */
.urso-header-cart svg {
	stroke: var(--urso-text);
}

.urso-header-cart:hover svg,
.urso-header-cart:focus svg {
	stroke: var(--urso-orange);
}

/* ------------------------------------------------------ Pulsante flottante */

.urso-cart-toggle {
	position: fixed;
	right: 20px;
	bottom: 20px;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: #fff;
	color: var(--urso-text);
	border: 0;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 99990;
	transition: transform 0.2s ease;
}

.urso-cart-toggle:hover {
	transform: scale(1.06);
}

/*
 * Stesso motivo dell'icona nell'header, aggravato dal fatto che questo è un
 * <button>: il kit Elementor lo colora con specificità maggiore e l'SVG
 * eredita l'arancione da currentColor. Lo stroke va fissato qui.
 * La pastiglia del contatore resta arancione.
 */
.urso-cart-toggle,
.urso-cart-toggle:hover,
.urso-cart-toggle:focus {
	color: var(--urso-text);
}

.urso-cart-toggle svg {
	stroke: var(--urso-text);
}

/*
 * Pastiglia con il numero di articoli: cerchio arancione, numero bianco,
 * agganciata in alto a destra dell'icona.
 */
.urso-cart-count {
	position: absolute;
	top: -6px;
	right: -8px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 10px;
	background: var(--urso-orange);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
}

/* ------------------------------------------------------------ Responsive */

@media (max-width: 480px) {
	/* Su mobile il pannello copre l'80% della larghezza, non tutto lo schermo:
	   resta visibile una fascia di pagina sotto l'overlay. */
	.urso-cart {
		width: 80%;
	}

	/*
	 * Su schermo stretto la colonna del prezzo veniva tagliata: miniatura e
	 * spaziature si restringono, e il prezzo non va mai a capo.
	 */
	.urso-cart__item {
		grid-template-columns: 64px minmax(0, 1fr) auto;
		gap: 12px;
		padding: 16px 14px;
	}

	.urso-cart__thumb,
	.urso-cart__thumb img {
		width: 64px;
	}

	.urso-cart__thumb img {
		height: 58px;
	}

	.urso-cart__details {
		padding-right: 0;
	}

	.urso-cart__title {
		font-size: 14px;
	}

	.urso-cart__price {
		font-size: 14px;
		padding-top: 16px;
	}

	.urso-cart__remove {
		top: 8px;
		right: 8px;
	}
}

/* Rispetta le preferenze di movimento ridotto */

@media (prefers-reduced-motion: reduce) {
	.urso-cart,
	.urso-cart-overlay,
	.urso-cart-toggle {
		transition: none;
	}
}
