/**
 * Carrosséis Elementor etheme_product_carousel (ex.: Destaques na página inicial).
 * Complementa theme.css — só layout (flex, alturas, margin-top nos botões).
 * Estilo visual dos botões (gradiente, hover): ver theme.css «BOTÕES GRID» — não duplicar
 * no CSS do Elementor para evitar conflitos.
 *
 * Altura automática (Elementor): com ela ativa, o Swiper pode não igualar alturas;
 * desactivar «Altura automática» no widget ajuda. O CSS abaixo:
 * — reserva 2 linhas para o título (como na grelha da loja);
 * — cola YITH / botões + form.cart ao fundo (margin-top: auto no primeiro CTA; quantidade junta do botão).
 */

.elementor-widget-etheme_product_carousel .swiper-wrapper {
	align-items: stretch !important;
}

.elementor-widget-etheme_product_carousel .swiper-slide {
	display: flex !important;
	flex-direction: column;
	min-height: 0;
	box-sizing: border-box;
}

.elementor-widget-etheme_product_carousel .swiper-slide > .etheme-product-grid-item {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	width: 100%;
	min-height: 100%;
	box-sizing: border-box;
}

.elementor-widget-etheme_product_carousel .etheme-product-grid-image {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 180px;
	margin-bottom: 14px !important;
	box-sizing: border-box;
}

.elementor-widget-etheme_product_carousel .etheme-product-grid-image img {
	max-height: 160px;
	width: auto;
	max-width: 100%;
	object-fit: contain;
	display: block;
	/*
	 * WordPress 6.7+ (wp-img-auto-sizes): img[sizes^="auto,"] recebe contain-intrinsic-size:3000px 1500px.
	 * Esse ratio 2:1 não corresponde às miniaturas quadradas do carrossel e pode distorcer a caixa
	 * de layout (efeito de “zoom”/recorte visual). Reverter para o tamanho natural da imagem.
	 */
	contain-intrinsic-size: auto;
}

.elementor-widget-etheme_product_carousel .etheme-product-grid-content {
	display: flex !important;
	flex-direction: column !important;
	flex: 1 1 auto;
	min-height: 0;
	padding-top: 2px !important;
	gap: 0;
	row-gap: 0;
	align-items: stretch !important;
	justify-content: flex-start !important;
	border-collapse: separate !important;
	border-spacing: 0 !important;
	table-layout: auto !important;
	box-sizing: border-box;
}

.elementor-widget-etheme_product_carousel .etheme-product-grid-content > * {
	display: block !important;
	float: none !important;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.elementor-widget-etheme_product_carousel .etheme-product-grid-content > a.add_to_cart_button,
.elementor-widget-etheme_product_carousel .etheme-product-grid-content > a.button,
.elementor-widget-etheme_product_carousel .etheme-product-grid-content > .ajax_add_to_cart {
	display: flex !important;
	align-items: center;
	justify-content: center;
}

.elementor-widget-etheme_product_carousel .etheme-product-grid-content .clear {
	display: none !important;
}

/* Título: 2 linhas + min-height = mesma «caixa» em todos os slides (como grelha /archive) */
.elementor-widget-etheme_product_carousel .etheme-product-grid-item h2.etheme-product-grid-title,
.elementor-widget-etheme_product_carousel .etheme-product-grid-item h2.woocommerce-loop-product__title {
	flex: 0 0 auto;
	line-height: 1.25;
	min-height: calc(1.25em * 2);
	max-height: calc(1.25em * 2);
	margin: 0;
	padding: 0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.elementor-widget-etheme_product_carousel .etheme-product-grid-content .price {
	flex: 0 0 auto;
	min-height: 0;
	margin-top: 0 !important;
	margin-bottom: 0 !important;
	padding: 0;
	line-height: 1.2;
	order: 98;
}

.elementor-widget-etheme_product_carousel .etheme-product-grid-item:not(:has(.price)) .etheme-product-grid-content::after {
	content: "";
	display: block;
	flex: 0 0 auto;
	min-height: 1.4em;
	margin-bottom: 0;
	order: 98;
}

.elementor-widget-etheme_product_carousel .etheme-product-grid-content .product-footer,
.elementor-widget-etheme_product_carousel .etheme-product-grid-content .yith-ywraq-add-to-quote,
.elementor-widget-etheme_product_carousel .etheme-product-grid-content > a.add_to_cart_button,
.elementor-widget-etheme_product_carousel .etheme-product-grid-content > a.button,
.elementor-widget-etheme_product_carousel .etheme-product-grid-content > .ajax_add_to_cart {
	margin-top: auto !important;
	padding-top: 0;
	width: 100%;
	order: 99;
	box-sizing: border-box;
}

/* form.cart: colado ao CTA anterior; só recebe margin-top:auto quando é o único bloco de acção */
.elementor-widget-etheme_product_carousel .etheme-product-grid-content > form.cart {
	display: flex !important;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: 0 !important;
	margin-bottom: 0 !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
	padding-top: 0 !important;
	width: 100%;
	order: 100;
	box-sizing: border-box;
	flex: 0 0 auto;
}

.elementor-widget-etheme_product_carousel .etheme-product-grid-content:not(:has(.yith-ywraq-add-to-quote)):not(:has(> a.add_to_cart_button)):not(:has(> .ajax_add_to_cart)):not(:has(> .etheme-product-grid-button)):not(:has(.product-footer)) > form.cart {
	margin-top: auto !important;
}

/* -----------------------------------------------------------------
   Grelha custom de relacionados no single
   Isolada da homepage: 4 cartões fixos, sem carrossel.
   XStore / etheme: woocommerce_product_loop_start() pode ser <div class="row products ...">
   em vez de <ul class="products"> — o filho direto do viewport cobre os dois casos.
   ----------------------------------------------------------------- */
.single-product .ag-related-products-grid .ag-related-products-strip__viewport > .products {
	display: flex !important;
	flex-wrap: nowrap !important;
	gap: 20px;
	margin: 0;
	padding: 0;
	list-style: none;
	width: auto !important;
	align-items: stretch;
}

.single-product .ag-related-products-grid {
	position: relative;
}

.single-product .ag-related-products-grid .ag-related-products-strip__viewport {
	overflow-x: auto;
	overflow-y: hidden;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.single-product .ag-related-products-grid .ag-related-products-strip__viewport::-webkit-scrollbar {
	display: none;
}

.single-product .ag-related-products-grid .ag-related-products-strip__viewport > .products > .product,
.single-product .ag-related-products-grid .ag-related-products-strip__viewport > .products > .product.etheme-product-grid-item {
	display: flex !important;
	flex-direction: column !important;
	height: 100%;
	margin: 0 !important;
	flex: 0 0 var(--ag-related-products-card-width, calc((100% - 60px) / 4)) !important;
	width: var(--ag-related-products-card-width, calc((100% - 60px) / 4)) !important;
	max-width: var(--ag-related-products-card-width, calc((100% - 60px) / 4)) !important;
	min-width: var(--ag-related-products-card-width, calc((100% - 60px) / 4)) !important;
	scroll-snap-align: start;
	float: none !important;
	clear: none !important;
}

.single-product .ag-related-products-grid .etheme-product-grid-image {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 180px;
	margin-bottom: 14px !important;
	box-sizing: border-box;
}

.single-product .ag-related-products-grid .etheme-product-grid-image img {
	width: 100%;
	height: 160px;
	max-width: 100%;
	object-fit: contain;
	object-position: center center;
	display: block;
	contain-intrinsic-size: auto;
}

.single-product .ag-related-products-grid .etheme-product-grid-item h2.etheme-product-grid-title,
.single-product .ag-related-products-grid .etheme-product-grid-item h2.woocommerce-loop-product__title {
	flex: 0 0 auto;
	line-height: 1.25;
	min-height: calc(1.25em * 2);
	max-height: calc(1.25em * 2);
	margin: 0;
	padding: 0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.single-product .ag-related-products-grid .etheme-product-grid-content {
	display: flex !important;
	flex-direction: column !important;
	flex: 1 1 auto;
	min-height: 0;
	padding-top: 2px !important;
	gap: 0;
	row-gap: 0;
	align-items: stretch !important;
	justify-content: flex-start !important;
	border-collapse: separate !important;
	border-spacing: 0 !important;
	table-layout: auto !important;
	box-sizing: border-box;
}

.single-product .ag-related-products-grid .etheme-product-grid-content > * {
	display: block !important;
	float: none !important;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.single-product .ag-related-products-grid .etheme-product-grid-content .price {
	display: block;
	flex: 0 0 auto;
	min-height: 0;
	margin-top: 0.2rem !important;
	margin-bottom: 0 !important;
	padding: 0;
	line-height: 1.3 !important;
	width: 100%;
	order: 98;
}

.single-product .ag-related-products-grid .etheme-product-grid-content .price.ag-related-products-price-placeholder {
	visibility: hidden;
	min-height: 1.4em;
}

.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart {
	display: flex !important;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: auto !important;
	margin-right: 0 !important;
	margin-bottom: 0 !important;
	margin-left: 0 !important;
	padding-top: 0 !important;
	width: 100%;
	order: 100;
	box-sizing: border-box;
}

.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart .quantity,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart .minus,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart .plus,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart .qty {
	display: none !important;
}

.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart .single_add_to_cart_button,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart button.single_add_to_cart_button,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart button.add_to_cart_button,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart .etheme-product-grid-button,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart a.button {
	display: flex !important;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 100% !important;
	max-width: 100%;
	min-height: 40px;
	height: 40px !important;
	padding: 0 20px !important;
	margin: 0 !important;
	border: none !important;
	border-radius: 6px !important;
	background: linear-gradient(180deg, #4aa6c7 0%, #3c94b6 100%) !important;
	color: #ffffff !important;
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08) !important;
	font-size: 13px !important;
	font-weight: 500 !important;
	line-height: 1 !important;
	text-transform: uppercase !important;
	letter-spacing: 0.4px !important;
	text-decoration: none !important;
	transition: all 0.2s ease;
}

.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart .single_add_to_cart_button:hover,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart button.single_add_to_cart_button:hover,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart button.add_to_cart_button:hover,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart .etheme-product-grid-button:hover,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart a.button:hover {
	background: linear-gradient(180deg, #3c94b6 0%, #317f9e 100%) !important;
	box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12) !important;
	color: #ffffff !important;
	transform: translateY(-1px);
}

.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart .single_add_to_cart_button:active,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart button.single_add_to_cart_button:active,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart button.add_to_cart_button:active,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart .etheme-product-grid-button:active,
.single-product .ag-related-products-grid .etheme-product-grid-content > form.cart a.button:active {
	background: linear-gradient(180deg, #317f9e 0%, #296d88 100%) !important;
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08) !important;
	transform: translateY(0);
}

.single-product .ag-related-products-grid .etheme-product-grid-content .yith-ywraq-add-to-quote,
.single-product .ag-related-products-grid .etheme-product-grid-content > a.add_to_cart_button,
.single-product .ag-related-products-grid .etheme-product-grid-content > a.ajax_add_to_cart,
.single-product .ag-related-products-grid .etheme-product-grid-content > a.button,
.single-product .ag-related-products-grid .etheme-product-grid-content > .etheme-product-grid-button,
.single-product .ag-related-products-grid .etheme-product-grid-content .product-footer {
	margin-top: auto !important;
	margin-bottom: 0 !important;
	padding-top: 0 !important;
	padding-bottom: 0 !important;
	width: 100%;
	order: 99;
	box-sizing: border-box;
}

.single-product .ag-related-products-grid .etheme-product-grid-content > a.add_to_cart_button,
.single-product .ag-related-products-grid .etheme-product-grid-content > a.button,
.single-product .ag-related-products-grid .etheme-product-grid-content > a.ajax_add_to_cart {
	display: flex !important;
	align-items: center;
	justify-content: center;
}

.single-product .ag-related-products-grid .etheme-product-grid-content .yith-ywraq-add-to-quote a {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 100%;
}

.single-product .ag-related-products-grid .ag-related-products-strip__nav {
	position: absolute;
	top: 50%;
	z-index: 3;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.94);
	color: #cfd8e3;
	box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
	transform: translateY(-50%);
	transition: all 0.2s ease;
}

.single-product .ag-related-products-grid .ag-related-products-strip__nav:hover:not(:disabled) {
	background: #ffffff;
	color: #9fb1c6;
	box-shadow: 0 14px 28px rgba(15, 23, 42, 0.14);
}

.single-product .ag-related-products-grid .ag-related-products-strip__nav:active:not(:disabled) {
	transform: translateY(-50%) scale(0.98);
}

.single-product .ag-related-products-grid .ag-related-products-strip__nav:disabled {
	opacity: 0.35;
	cursor: default;
	pointer-events: none;
}

.single-product .ag-related-products-grid[data-ag-no-overflow="1"] .ag-related-products-strip__nav {
	display: none;
}

.single-product .ag-related-products-grid .ag-related-products-strip__nav span {
	display: block;
	font-size: 28px;
	line-height: 1;
	transform: translateY(-1px);
}

.single-product .ag-related-products-grid .ag-related-products-strip__nav--prev {
	left: -8px;
}

.single-product .ag-related-products-grid .ag-related-products-strip__nav--next {
	right: -8px;
}

@media (max-width: 1024px) {
	.single-product .ag-related-products-grid .ag-related-products-strip__viewport > .products > .product,
	.single-product .ag-related-products-grid .ag-related-products-strip__viewport > .products > .product.etheme-product-grid-item {
		flex-basis: var(--ag-related-products-card-width, calc((100% - 20px) / 2)) !important;
		width: var(--ag-related-products-card-width, calc((100% - 20px) / 2)) !important;
		max-width: var(--ag-related-products-card-width, calc((100% - 20px) / 2)) !important;
		min-width: var(--ag-related-products-card-width, calc((100% - 20px) / 2)) !important;
	}
}

@media (max-width: 767px) {
	.single-product .ag-related-products-grid .ag-related-products-strip__viewport > .products > .product,
	.single-product .ag-related-products-grid .ag-related-products-strip__viewport > .products > .product.etheme-product-grid-item {
		flex-basis: var(--ag-related-products-card-width, 86%) !important;
		width: var(--ag-related-products-card-width, 86%) !important;
		max-width: var(--ag-related-products-card-width, 86%) !important;
		min-width: var(--ag-related-products-card-width, 86%) !important;
	}

	.single-product .ag-related-products-grid .ag-related-products-strip__nav {
		width: 38px;
		height: 38px;
	}

	.single-product .ag-related-products-grid .ag-related-products-strip__nav span {
		font-size: 24px;
	}

	.single-product .ag-related-products-grid .ag-related-products-strip__nav--prev {
		left: -2px;
	}

	.single-product .ag-related-products-grid .ag-related-products-strip__nav--next {
		right: -2px;
	}
}
