/* "Você também pode gostar" — Painel Sofisticado para WooCommerce
 * Seção isolada em namespace próprio (.psw-*) para não herdar regras
 * antigas do tema que estavam "esmagando" os produtos relacionados. */

:root {
	--psw-rw-primary: #e11d2e;
	--psw-rw-primary-dark: #b91c1c;
	--psw-rw-text: #171717;
	--psw-rw-text-muted: #6b6f80;
	--psw-rw-border: #ececec;
	--psw-rw-bg: #ffffff;
	--psw-rw-bg-soft: #fafafa;
	--psw-rw-radius: 16px;
	--psw-rw-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}

.psw-related-wines,
.psw-related-wines * ,
.psw-related-wines *::before,
.psw-related-wines *::after {
	box-sizing: border-box;
}

/* ===== Container: força largura própria, ignorando qualquer coluna/sidebar
   estreita que estivesse espremendo a seção antiga ===== */
.psw-related-wines {
	width: 100% !important;
	max-width: 100% !important;
	float: none !important;
	clear: both;
	margin: 56px 0 24px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--psw-rw-text);
}

.psw-related-wines-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 20px;
}

.psw-related-wines-head h2 {
	margin: 0;
	font-size: 22px;
	font-weight: 800;
	letter-spacing: -0.01em;
	color: var(--psw-rw-text);
}

.psw-carousel-nav {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

.psw-carousel-btn {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 1px solid var(--psw-rw-border);
	background: #fff;
	color: var(--psw-rw-text);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.psw-carousel-btn:hover {
	background: var(--psw-rw-primary);
	border-color: var(--psw-rw-primary);
	color: #fff;
}

.psw-carousel-btn .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
}

/* ===== Trilho do carrossel: scroll nativo (funciona com touch/trackpad
   mesmo sem JS) + scroll-snap para parar sempre alinhado num card ===== */
.psw-carousel-track {
	display: flex;
	gap: 20px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	padding: 6px 4px 14px;
	margin: 0 -4px;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
}

.psw-carousel-track::-webkit-scrollbar {
	height: 6px;
}

.psw-carousel-track::-webkit-scrollbar-thumb {
	background: var(--psw-rw-border);
	border-radius: 999px;
}

/* ===== Card do vinho: compacto e premium ===== */
.psw-wine-card {
	scroll-snap-align: start;
	flex: 0 0 calc( (100% - 3 * 20px) / 4 ); /* 4 cards visíveis no desktop */
	min-width: 220px;
	max-width: 280px;
	background: var(--psw-rw-bg);
	border: 1px solid var(--psw-rw-border);
	border-radius: var(--psw-rw-radius);
	box-shadow: var(--psw-rw-shadow);
	padding: 16px;
	display: flex;
	flex-direction: column;
	position: relative;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.psw-wine-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.psw-wine-card-media {
	width: 100%;
	aspect-ratio: 3 / 4;
	border-radius: 12px;
	overflow: hidden;
	background: var(--psw-rw-bg-soft);
	margin-bottom: 14px;
}

.psw-wine-card-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.psw-wine-card-body {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 14px;
}

.psw-wine-card-title {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.35;
	color: var(--psw-rw-text);
	/* Trunca em 2 linhas para manter os cards alinhados entre si */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.psw-wine-card-desc {
	margin: 0;
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--psw-rw-text-muted);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.psw-wine-card-price {
	margin-top: auto;
	font-size: 16px;
	font-weight: 800;
	color: var(--psw-rw-text);
}

.psw-wine-card-price ins {
	text-decoration: none;
	color: var(--psw-rw-primary);
}

.psw-wine-card-price del {
	color: var(--psw-rw-text-muted);
	font-weight: 500;
	font-size: 13px;
	margin-right: 4px;
}

/* ===== Botão nativo do WooCommerce, "skinado" para ficar premium ===== */
.psw-wine-card-action {
	position: relative;
}

.psw-wine-card-action .button,
.psw-wine-card-action .add_to_cart_button {
	display: flex !important;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	padding: 11px 14px;
	background: var(--psw-rw-primary);
	color: #fff !important;
	border: none;
	border-radius: 10px;
	font-weight: 700;
	font-size: 13.5px;
	text-decoration: none;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.1s ease;
}

.psw-wine-card-action .button:hover,
.psw-wine-card-action .add_to_cart_button:hover {
	background: var(--psw-rw-primary-dark);
}

.psw-wine-card-action .button:active,
.psw-wine-card-action .add_to_cart_button:active {
	transform: scale(0.98);
}

/* Estado "fora de estoque" / não comprável (fallback nativo do WooCommerce) */
.psw-wine-card-action .button.disabled,
.psw-wine-card-action .button[aria-disabled="true"] {
	background: #d1d5db !important;
	color: #6b7280 !important;
	cursor: not-allowed;
}

/* Ícone de "carregando" nativo do WooCommerce durante a requisição AJAX */
.psw-wine-card-action .add_to_cart_button.loading {
	opacity: 0.75;
	pointer-events: none;
}

.psw-wine-card-action .add_to_cart_button.loading::after {
	content: "";
	width: 14px;
	height: 14px;
	border: 2px solid rgba(255, 255, 255, 0.5);
	border-top-color: #fff;
	border-radius: 50%;
	animation: psw-spin 0.6s linear infinite;
}

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

/* Esconde o link "Ver carrinho" que o WooCommerce insere sozinho depois
   do botão — o feedback aqui já é dado pelo selo + toast + carrinho lateral. */
.psw-wine-card-action .added_to_cart {
	display: none !important;
}

/* Selo "Adicionado", aparece por 1.8s ao adicionar (ver related-wines.js) */
.psw-added-badge {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	background: #15803d;
	color: #fff;
	border-radius: 10px;
	font-weight: 700;
	font-size: 13px;
	opacity: 0;
	transform: translateY(4px);
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.psw-wine-card.is-added .psw-added-badge {
	opacity: 1;
	transform: translateY(0);
}

.psw-wine-card.is-added .psw-wine-card-action .button {
	visibility: hidden;
}

.psw-wine-card.is-adding {
	opacity: 0.9;
}

/* ===== Botão flutuante do carrinho ===== */
.psw-cart-fab {
	position: fixed;
	right: 24px;
	bottom: 24px;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--psw-rw-text);
	color: #fff;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
	cursor: pointer;
	z-index: 9998;
	transition: transform 0.15s ease;
}

.psw-cart-fab:hover {
	transform: scale(1.06);
}

.psw-cart-fab .dashicons {
	font-size: 22px;
	width: 22px;
	height: 22px;
}

.psw-cart-fab-count {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 999px;
	background: var(--psw-rw-primary);
	color: #fff;
	font-size: 11px;
	font-weight: 800;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

/* ===== Carrinho lateral (drawer) ===== */
.psw-mini-cart-drawer {
	position: fixed;
	inset: 0;
	z-index: 9999;
	visibility: hidden;
	pointer-events: none;
}

.psw-mini-cart-drawer.is-open {
	visibility: visible;
	pointer-events: auto;
}

.psw-mini-cart-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.4);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.psw-mini-cart-drawer.is-open .psw-mini-cart-overlay {
	opacity: 1;
}

.psw-mini-cart-panel {
	position: absolute;
	top: 0;
	right: 0;
	height: 100%;
	width: min(400px, 92vw);
	background: #fff;
	box-shadow: -12px 0 32px rgba(0, 0, 0, 0.15);
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform 0.3s ease;
}

.psw-mini-cart-drawer.is-open .psw-mini-cart-panel {
	transform: translateX(0);
}

.psw-mini-cart-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 20px;
	border-bottom: 1px solid var(--psw-rw-border);
}

.psw-mini-cart-header h3 {
	margin: 0;
	font-size: 17px;
	font-weight: 800;
}

.psw-mini-cart-close {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: none;
	background: var(--psw-rw-bg-soft);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	color: var(--psw-rw-text);
}

.psw-mini-cart-body {
	flex: 1;
	overflow-y: auto;
	padding: 18px 20px;
}

/* Skin leve sobre a marcação nativa do WooCommerce (cart/mini-cart.php) */
.psw-mini-cart-body .woocommerce-mini-cart {
	list-style: none;
	margin: 0 0 16px;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.psw-mini-cart-body .woocommerce-mini-cart-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--psw-rw-border);
	position: relative;
}

.psw-mini-cart-body .woocommerce-mini-cart-item img {
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: 8px;
}

.psw-mini-cart-body .woocommerce-mini-cart-item a.remove {
	position: absolute;
	top: 0;
	right: 0;
	color: var(--psw-rw-text-muted) !important;
}

.psw-mini-cart-body .total {
	font-size: 15px;
	font-weight: 800;
	padding-top: 10px;
	border-top: 1px solid var(--psw-rw-border);
}

.psw-mini-cart-body .woocommerce-mini-cart__buttons {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: 14px;
}

.psw-mini-cart-body .woocommerce-mini-cart__buttons a.button {
	display: block;
	text-align: center;
	padding: 12px;
	border-radius: 10px;
	font-weight: 700;
	text-decoration: none;
}

.psw-mini-cart-body .woocommerce-mini-cart__buttons a.wc-forward {
	background: var(--psw-rw-bg-soft);
	color: var(--psw-rw-text) !important;
	border: 1px solid var(--psw-rw-border);
}

.psw-mini-cart-body .woocommerce-mini-cart__buttons a.checkout {
	background: var(--psw-rw-primary);
	color: #fff !important;
}

.psw-mini-cart-body .woocommerce-mini-cart__empty-message {
	color: var(--psw-rw-text-muted);
	font-size: 14px;
}

/* ===== Toast "Adicionado ao carrinho" ===== */
.psw-toast {
	position: fixed;
	left: 50%;
	bottom: 28px;
	transform: translate(-50%, 16px);
	background: var(--psw-rw-text);
	color: #fff;
	padding: 12px 20px;
	border-radius: 999px;
	font-size: 13.5px;
	font-weight: 600;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease, transform 0.25s ease;
	z-index: 10000;
}

.psw-toast.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* ===== Desktop: garante exatamente ~4 e depois ~3 cards visíveis,
   nunca "esmagados" ===== */
@media (max-width: 1200px) {
	.psw-wine-card {
		flex: 0 0 calc( (100% - 2 * 20px) / 3 ); /* 3 cards */
	}
}

@media (max-width: 900px) {
	.psw-wine-card {
		flex: 0 0 calc( (100% - 20px) / 2.2 ); /* ~2 cards */
		min-width: 190px;
	}

	.psw-mini-cart-panel {
		width: 100vw;
	}
}

/* ===== Mobile: 1,5–2 cards por vez, touch-friendly ===== */
@media (max-width: 560px) {
	.psw-related-wines {
		margin: 40px 0 16px;
	}

	.psw-related-wines-head h2 {
		font-size: 19px;
	}

	.psw-wine-card {
		flex: 0 0 62%; /* ~1,6 cards visíveis, indicando que há mais */
		min-width: 0;
		max-width: none;
		padding: 12px;
	}

	.psw-cart-fab {
		right: 16px;
		bottom: 16px;
		width: 52px;
		height: 52px;
	}
}

body.psw-drawer-open {
	overflow: hidden;
}
