/* =========================================================================
 * ShopCraft Theme — Layout fixes (v1.7.1+)
 *
 * Patch mirate per problemi visuali emersi dal testing. Caricato DOPO
 * shopify-style.css e responsive.css per vincere la cascade.
 * ========================================================================= */

/* =========================================================================
 * SHOP ARCHIVE: prodotti allineati a SINISTRA
 *
 * Cause possibili: float residui WC (.product), .summary float:right, oppure
 * grid-template-columns non applicato. Forziamo grid pulito + neutralizziamo
 * tutti i float WC sui .product nella loop.
 * ========================================================================= */

.sc-archive ul.products,
.sc-archive .sc-product-grid,
.sc-product-grid--responsive {
	display: grid !important;
	justify-content: start !important;
	justify-items: stretch !important;
	align-content: start !important;
	margin: 0 0 24px !important;
	padding: 0 !important;
	list-style: none !important;
	float: none !important;
	width: 100% !important;
	text-align: left !important;
}

/* Fallback grid-template-columns se non specificato inline.
   Solo per archive default (non il widget --responsive che già le ha). */
.sc-archive .sc-product-grid:not(.sc-product-grid--responsive) {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 1024px) {
	.sc-archive .sc-product-grid:not(.sc-product-grid--responsive) {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}
}
@media (max-width: 560px) {
	.sc-archive .sc-product-grid:not(.sc-product-grid--responsive) {
		grid-template-columns: 1fr !important;
	}
}

/* Neutralizza float/width residui WC su ogni prodotto nel loop archive. */
.sc-archive ul.products li,
.sc-archive ul.products li.product,
.sc-archive .sc-product-grid > li,
.sc-product-grid--responsive > li,
ul.products li.product.first,
ul.products li.product.last {
	float: none !important;
	clear: none !important;
	width: auto !important;
	max-width: 100% !important;
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
	justify-self: stretch !important;
	text-align: left !important;
}

/* WooCommerce a volte stampa .product .summary { float:right }
   che si propaga ai blocchi card per via di selettori globali.
   Lo annulliamo nel contesto archive. */
.sc-archive .sc-product-card,
.sc-archive .product .summary,
.sc-product-grid--responsive .sc-product-card {
	float: none !important;
	width: 100% !important;
}

/* Card grid: forza display flex column anche se WC mette block. */
.sc-product-card {
	display: flex !important;
	flex-direction: column !important;
}

/* =========================================================================
 * MY ACCOUNT: content non schiacciato
 *
 * Su mobile/tablet, il content principale veniva renderizzato in una colonna
 * stretta perché il flex parent non passava abbastanza spazio o il col2-set
 * WC default applicava float.
 * ========================================================================= */

.sc-account__layout {
	width: 100%;
}

/* NON forziamo width:100% sul content su desktop, sennò rompe il flex side-by-side.
   Solo box-sizing + min-width:0 per evitare overflow del contenuto WC interno. */
.sc-account__content {
	min-width: 0;
	box-sizing: border-box;
}

.sc-account__content .sc-account-card {
	min-width: 0;
	max-width: 100%;
	box-sizing: border-box;
}

.sc-account__content .woocommerce,
.sc-account__content .woocommerce-MyAccount-content,
.sc-account__content .woocommerce-Address,
.sc-account__content .woocommerce-Addresses,
.sc-account__content .woocommerce-EditAccountForm {
	width: 100% !important;
	max-width: 100% !important;
}

/* ---- WC My Account → ADDRESSES (Indirizzi) ----
   Markup WC default:
     <div class="u-columns woocommerce-Addresses col2-set addresses">
       <div class="u-column1 col-1 woocommerce-Address">
         <header class="woocommerce-Address-title title">
           <h3>Indirizzo di fatturazione</h3>
           <a class="edit">Aggiungi...</a>
         </header>
         <address>Non hai ancora impostato...</address>
       </div>
       <div class="u-column2 col-2 woocommerce-Address"> ... </div>
     </div>
*/

/* Container indirizzi: STACK VERTICALE (più pulito del 2-col su content stretto).
   Override molto specifico per battere i float WC default. */
body .sc-account__content .woocommerce-Addresses,
body .sc-account__content .u-columns,
body .sc-account__content .col2-set,
body .sc-account__content .col2-set.addresses {
	display: flex !important;
	flex-direction: column !important;
	gap: 20px !important;
	width: 100% !important;
	max-width: 100% !important;
	margin: 18px 0 0 !important;
	padding: 0 !important;
	float: none !important;
	clear: both !important;
}

/* Box singolo indirizzo: 100% width, padding ampio, bordo */
body .sc-account__content .woocommerce-Address,
body .sc-account__content .u-column1,
body .sc-account__content .u-column2,
body .sc-account__content .col2-set > .col-1,
body .sc-account__content .col2-set > .col-2 {
	background: #fff !important;
	border: 1px solid var(--sc-border, #e9e6e1) !important;
	border-radius: var(--sc-radius-lg, 14px) !important;
	padding: 26px 28px !important;
	margin: 0 !important;
	width: 100% !important;
	max-width: 100% !important;
	float: none !important;
	clear: both !important;
	text-align: left !important;
	box-sizing: border-box !important;
	display: block !important;
}

/* Header del box: titolo SOPRA, link "Aggiungi" SOTTO il titolo
   (stack verticale = leggibile sempre, niente schiacciamenti). */
.sc-account__content .woocommerce-Address-title,
.sc-account__content .woocommerce-Address .title {
	display: block !important;
	margin: 0 0 16px !important;
	padding: 0 0 14px !important;
	border-bottom: 1px solid var(--sc-border, #e9e6e1) !important;
	text-align: left !important;
}

.sc-account__content .woocommerce-Address-title h2,
.sc-account__content .woocommerce-Address-title h3,
.sc-account__content .woocommerce-Address .title h2,
.sc-account__content .woocommerce-Address .title h3 {
	display: block !important;
	margin: 0 0 6px !important;
	padding: 0 !important;
	font-size: 20px !important;
	font-weight: 600 !important;
	color: var(--sc-primary, #B8902F) !important;
	text-align: left !important;
	line-height: 1.3 !important;
	word-break: keep-all !important;
	overflow-wrap: normal !important;
	hyphens: manual !important;
	white-space: normal !important;
}

.sc-account__content .woocommerce-Address-title .edit,
.sc-account__content .woocommerce-Address .title .edit {
	display: inline-block !important;
	font-size: 13px !important;
	color: var(--sc-primary, #B8902F) !important;
	text-decoration: none !important;
	font-weight: 500;
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
}
.sc-account__content .woocommerce-Address-title .edit:hover {
	text-decoration: underline !important;
}

/* Contenuto indirizzo (<address>) */
.sc-account__content .woocommerce-Address address,
.sc-account__content .woocommerce-Address-title + p,
.sc-account__content .woocommerce-Address p {
	font-style: normal !important;
	margin: 0 !important;
	padding: 0 !important;
	line-height: 1.6 !important;
	color: var(--sc-text, #1f1f1f) !important;
	text-align: left !important;
	font-size: 14px !important;
	word-break: normal !important;
	overflow-wrap: break-word !important;
}

/* Paragrafo introduttivo sopra gli indirizzi */
.sc-account__content > p:first-of-type,
.sc-account__content .sc-account-card > p:first-of-type {
	margin: 0 0 18px !important;
	color: #555 !important;
	font-size: 14px !important;
	text-align: left !important;
	line-height: 1.5 !important;
}

/* My Account layout: side-by-side da tablet/desktop (>=820px),
   stack mobile (<820px). Uso flexbox (più robusto del grid contro override). */
@media (min-width: 820px) {
	.sc-account__layout {
		display: flex !important;
		flex-direction: row !important;
		flex-wrap: nowrap !important;
		align-items: flex-start !important;
		gap: 36px !important;
		grid-template-columns: none !important;
	}
	.sc-account__nav {
		flex: 0 0 240px !important;
		width: 240px !important;
		max-width: 240px !important;
		min-width: 240px !important;
		position: sticky;
		top: 30px;
	}
	.sc-account__content {
		flex: 1 1 auto !important;
		min-width: 0 !important;
		width: auto !important;
		max-width: none !important;
	}
	.sc-account-menu {
		display: block !important;
		grid-template-columns: none !important;
	}
	.sc-account-menu__item {
		display: block !important;
		width: 100% !important;
	}
}

/* Mobile / tablet stretto: menu in griglia 2 colonne sopra il content. */
@media (max-width: 819px) {
	.sc-account__layout {
		display: grid !important;
		grid-template-columns: 1fr !important;
		gap: 20px;
	}
	.sc-account__nav {
		position: static !important;
	}
	.sc-account-menu {
		display: grid !important;
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		gap: 8px !important;
		width: 100%;
	}
	.sc-account-menu__item {
		flex: none !important;
		width: 100%;
		margin: 0 !important;
	}
}

@media (max-width: 480px) {
	.sc-account-menu {
		grid-template-columns: 1fr !important;
	}
}

/* =========================================================================
 * FIX PREVENTIVI ALTRE PAGINE
 * ========================================================================= */

/* Cart table su tablet (768-1024): può rompere — forza max-width 100%. */
.sc-cart-page,
.sc-cart-page__wrap,
.sc-cart-table,
.sc-cart-summary-card {
	max-width: 100% !important;
	box-sizing: border-box;
}

.sc-cart-table {
	width: 100% !important;
	table-layout: auto;
}

/* Checkout: form fields full-width sempre, no float WC */
.sc-checkout-form .form-row {
	float: none !important;
	width: 100% !important;
	margin-bottom: 14px;
}
.sc-checkout-form .form-row-first,
.sc-checkout-form .form-row-last {
	float: none !important;
	width: 100% !important;
}
@media (min-width: 768px) {
	.sc-checkout-form .form-row-first {
		width: calc(50% - 8px) !important;
		float: left !important;
		margin-right: 16px;
	}
	.sc-checkout-form .form-row-last {
		width: calc(50% - 8px) !important;
		float: left !important;
	}
}
.sc-checkout-form input[type="text"],
.sc-checkout-form input[type="email"],
.sc-checkout-form input[type="tel"],
.sc-checkout-form input[type="password"],
.sc-checkout-form textarea,
.sc-checkout-form select,
.sc-checkout-form .select2-container {
	width: 100% !important;
	max-width: 100% !important;
	box-sizing: border-box !important;
}

/* Single product: galleria può sforare su mobile — forza max-width */
.sc-product__gallery,
.sc-product__gallery img,
.sc-product__gallery .woocommerce-product-gallery {
	max-width: 100% !important;
}
.sc-product__gallery .woocommerce-product-gallery__image img {
	width: 100% !important;
	height: auto !important;
}

/* Thankyou cards full-width mobile */
.sc-thankyou,
.sc-thankyou__wrap,
.sc-thankyou-card {
	max-width: 100% !important;
	box-sizing: border-box;
}

/* =========================================================================
 * BOXED CONTAINER per tutte le pagine WooCommerce
 *
 * Stesso comportamento di Elementor "Boxed": max-width + padding laterale
 * costante, no full-width.
 * ========================================================================= */

.sc-container,
.sc-product__wrap,
.sc-cart-page__wrap,
.sc-checkout-page__wrap,
.sc-account__wrap,
.sc-thankyou__wrap,
.sc-archive__wrap {
	max-width: 1280px !important;
	width: 100%;
	margin-left: auto !important;
	margin-right: auto !important;
	padding-left: 32px !important;
	padding-right: 32px !important;
	box-sizing: border-box;
	overflow-x: visible; /* permettiamo dropdown / popover di sforare */
}

@media (max-width: 768px) {
	.sc-container,
	.sc-product__wrap,
	.sc-cart-page__wrap,
	.sc-checkout-page__wrap,
	.sc-account__wrap,
	.sc-thankyou__wrap,
	.sc-archive__wrap {
		padding-left: 18px !important;
		padding-right: 18px !important;
	}
}

/* Body safety net: nessuno scroll orizzontale globale */
body { overflow-x: hidden; }

/* Inputs su mobile: 16px font-size impedisce iOS zoom-on-focus */
@media (max-width: 768px) {
	input[type="text"],
	input[type="email"],
	input[type="tel"],
	input[type="password"],
	input[type="number"],
	input[type="search"],
	select,
	textarea {
		font-size: 16px !important;
	}
}

/* =========================================================================
 * UTILITY
 * ========================================================================= */

/* Anti orphan text wraps. NIENTE hyphens (rompe "Indi-rizzo" e simili). */
.sc-account__content,
.sc-account__content * {
	overflow-wrap: break-word;
	word-wrap: break-word;
	hyphens: manual !important;
	-webkit-hyphens: manual !important;
	-ms-hyphens: manual !important;
}

/* I titoli WC non vanno mai spezzati */
.sc-account__content h1,
.sc-account__content h2,
.sc-account__content h3,
.sc-account__content h4,
.sc-account__content .woocommerce-Address-title h3,
.sc-account__content .woocommerce-Address-title h2 {
	word-break: keep-all !important;
	overflow-wrap: normal !important;
}

/* Force LTR text direction (preventivo, alcuni plugin settano RTL erroneo) */
.sc-archive,
.sc-product-grid,
.sc-product-card,
.sc-cart-page,
.sc-checkout-page,
.sc-account,
.sc-thankyou {
	direction: ltr;
	text-align: left;
}
