/* ==========================================================================
   Abastos Peruanos — Ficha de producto (woocommerce/single-product.php)
   Izquierda: galería, pestañas y relacionados (se desplaza).
   Derecha: resumen de compra fijo (position: sticky) mientras baja la izquierda.
   Variables --ap-* en ap-site.css.
   ========================================================================== */

body.nuda-product-page,
body.nuda-product-page .site,
body.nuda-product-page .site-main { max-width: none; margin: 0; background: #fff; }
/* sticky deja de funcionar si un ancestro recorta con overflow: hidden. */
body.nuda-product-page .site,
body.nuda-product-page .site-main { overflow: visible; }

.ap-pdp {
	--pdp-top: calc(24px + var(--wp-admin--admin-bar--height, 0px));
	padding: 0 0 clamp(56px, 6vw, 90px);
	color: var(--ap-ink);
	font-family: var(--ap-font);
}
.ap-pdp *,
.ap-pdp *::before,
.ap-pdp *::after { box-sizing: border-box; }
.ap-pdp p { margin: 0; }
html body .ap-pdp :is(h1, h2, h3) { letter-spacing: 0 !important; text-transform: none; }

/* ── Migas ──────────────────────────────────────────────────────────────── */

.ap-pdp__crumbs {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 8px;
	padding: 32px 0 36px;
	font: 400 1rem/1.4 var(--ap-font);
}
.ap-pdp__crumbs a { color: var(--ap-ink); text-decoration: none; transition: color .2s; }
.ap-pdp__crumbs a:hover { color: var(--ap-red); }
.ap-pdp__crumbs > span[aria-hidden] { color: var(--ap-ink); }
.ap-pdp__crumbs [aria-current] { color: var(--ap-red); text-transform: uppercase; }

/* ── Dos columnas ───────────────────────────────────────────────────────── */

.ap-pdp__layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(340px, 34%);
	grid-template-areas:
		"media   summary"
		"content summary";
	grid-template-rows: auto 1fr;
	column-gap: clamp(40px, 6vw, 110px);
}
.ap-pdp__media { grid-area: media; min-width: 0; }
.ap-pdp__content { grid-area: content; min-width: 0; }
.ap-pdp__summary { grid-area: summary; min-width: 0; }
/* El aside ocupa toda la altura de la izquierda; su contenido se queda pegado arriba. */
.ap-pdp__sticky { position: sticky; top: var(--pdp-top); padding-bottom: 24px; }

/* ── Galería ────────────────────────────────────────────────────────────── */

.ap-gallery { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: start; }
.ap-gallery.has-thumbs { grid-template-columns: 128px minmax(0, 1fr); }

.ap-gallery__rail { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ap-gallery__step {
	display: grid;
	place-items: center;
	width: 40px;
	height: 30px;
	padding: 0;
	border: 0;
	background: none;
	color: #c4c4c4;
	cursor: pointer;
	transition: color .2s, opacity .2s;
}
.ap-gallery__step:hover { color: var(--ap-ink); }
.ap-gallery__step:disabled { opacity: .35; cursor: default; }
.ap-gallery__rail.is-static .ap-gallery__step { visibility: hidden; }

.ap-gallery .nuda-gallery__thumbs {
	display: flex;
	flex-direction: column;
	gap: 14px;
	width: 100%;
	max-height: 430px;
	overflow: hidden;
	overscroll-behavior: contain;
	scroll-behavior: smooth;
}
.ap-gallery .nuda-gallery__thumb {
	display: block;
	flex: 0 0 auto;
	width: 100%;
	aspect-ratio: 1;
	padding: 6px;
	border: 1.5px solid transparent;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	transition: border-color .2s, opacity .2s, scale .12s ease-out;
}
.ap-gallery .nuda-gallery__thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ap-gallery .nuda-gallery__thumb:not(.is-active) { opacity: .7; }
.ap-gallery .nuda-gallery__thumb:hover { opacity: 1; }
.ap-gallery .nuda-gallery__thumb.is-active { border-color: var(--ap-line); }
.ap-gallery .nuda-gallery__thumb:active { scale: .96; }

.ap-gallery .nuda-gallery__main { position: relative; margin: 0; }
.ap-gallery .nuda-gallery__open {
	display: block;
	width: 100%;
	aspect-ratio: 1 / .82;
	padding: 0;
	border: 0;
	background: none;
	cursor: zoom-in;
}
.ap-gallery .nuda-gallery__img {
	display: block;
	width: 100%;
	height: 100% !important;
	object-fit: contain;
	transition: opacity .2s;
}
.ap-gallery .nuda-gallery__img.is-swapping { opacity: 0; }

/* ── Resumen (columna fija) ─────────────────────────────────────────────── */

.ap-pdp__brand { margin-bottom: 6px !important; color: var(--ap-ink); font: 500 1.25rem/1.2 var(--ap-font); }
html body .ap-pdp .ap-pdp__title {
	margin: 0;
	color: #3a3a3a;
	font: 700 clamp(1.75rem, 2.4vw, 2.5rem)/1.1 var(--ap-font);
	letter-spacing: -.01em !important;
	text-transform: uppercase;
}
.ap-pdp__sku { margin-top: 8px !important; color: #777; font-size: .9375rem; }

.ap-pdp__price { margin-top: 30px; }
.ap-pdp__price-label { display: block; color: var(--ap-ink); font: 400 1.125rem/1.2 var(--ap-font); }
.ap-pdp__price-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 22px; margin-top: 6px !important; }
.ap-pdp__amount { color: var(--ap-ink); font: 500 clamp(1.875rem, 2.4vw, 2.375rem)/1 var(--ap-font); letter-spacing: -.01em; }
.ap-pdp__amount :is(del, ins) { text-decoration-thickness: 1px; }
.ap-pdp__amount del { margin-right: 10px; color: #9a9a9a; font-size: .6em; }
.ap-pdp__amount ins { text-decoration: none; }
.ap-pdp__stock { color: #8a8a8a; font: 400 .9375rem/1 var(--ap-font); }
.ap-pdp__stock.is-out { color: var(--ap-red); }

/* Botones */
.ap-pdp__buy { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; margin-top: 44px; }
.ap-pdp__actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-top: 12px; }
.ap-pdp__buy + .ap-pdp__actions { margin-top: 12px; }
.ap-pdp__price + .ap-pdp__actions { margin-top: 44px; }

.ap-pdp__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-height: 54px;
	padding: 0 18px;
	border: 0;
	border-radius: 4px;
	color: #fff !important;
	font: 600 1.125rem/1.1 var(--ap-font);
	text-align: center;
	text-decoration: none !important;
	cursor: pointer;
	transition: background-color .2s, scale .1s ease-out;
}
.ap-pdp__btn:active { scale: .98; }
.ap-pdp__btn--cart { background: #c8161d; }
.ap-pdp__btn--cart:hover { background: var(--ap-red-dark); }
.ap-pdp__btn--wa { background: #5fae1f; }
.ap-pdp__btn--wa:hover { background: #4f9418; }
.ap-pdp__btn--sheet { background: #111; }
.ap-pdp__btn--sheet:hover { background: #333; }

/* Formulario estándar de WooCommerce (variables/agrupados). */
.ap-pdp__buy--wc { display: block; }
.ap-pdp__buy--wc .single_add_to_cart_button {
	min-height: 54px;
	padding: 0 28px;
	border: 0;
	border-radius: 4px;
	background: #c8161d;
	color: #fff;
	font: 600 1.0625rem/1 var(--ap-font);
}

/* Cantidad −/+ */
.ap-stepper {
	display: inline-flex;
	align-items: center;
	height: 54px;
	border: 1.5px solid var(--ap-ink);
	border-radius: 4px;
}
.ap-stepper button,
.ap-stepper input {
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--ap-ink);
	text-align: center;
}
.ap-stepper button { display: grid; place-items: center; width: 34px; color: #8a8a8a; cursor: pointer; transition: color .15s; }
.ap-stepper button:hover { color: var(--ap-ink); }
.ap-stepper button:active { scale: .9; }
html body .ap-pdp .ap-stepper input {
	width: 40px;
	height: 100%;
	padding: 0;
	border: 0;
	box-shadow: none;
	font: 500 1.375rem/1 var(--ap-font);
	-moz-appearance: textfield;
	appearance: textfield;
}
.ap-stepper input::-webkit-inner-spin-button,
.ap-stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ap-stepper input:focus-visible { outline: 2px solid var(--ap-red); outline-offset: -2px; border-radius: 2px; }

/* Envíos */
.ap-pdp__ship {
	display: flex;
	align-items: center;
	gap: 22px;
	margin-top: 40px;
	padding: 24px 22px;
	border-radius: 6px;
	background: var(--ap-soft);
}
.ap-pdp__ship svg { flex: 0 0 auto; color: var(--ap-ink); }
.ap-pdp__ship strong { display: block; color: var(--ap-ink); font: 500 1.0625rem/1.3 var(--ap-font); }
.ap-pdp__ship span { display: block; margin-top: 3px; color: #777; font: 400 .9375rem/1.3 var(--ap-font); }

.ap-pdp__delivery { display: grid; gap: 18px; margin: 26px 0 0; padding: 0; list-style: none; }
.ap-pdp__delivery li { margin: 0; }
.ap-pdp__delivery a {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	color: var(--ap-ink);
	font: 400 1rem/1.2 var(--ap-font);
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-thickness: 1px;
	transition: color .2s;
}
.ap-pdp__delivery a:hover { color: var(--ap-red); }

/* ── Pestañas ───────────────────────────────────────────────────────────── */

.ap-pdp__info { max-width: 900px; margin-top: clamp(48px, 5vw, 80px); }
.ap-tabs { display: flex; gap: 28px; border-bottom: 1px solid #c9ccd3; }
.ap-tabs__tab {
	margin: 0 0 -1px;
	padding: 0 2px 14px;
	border: 0;
	border-bottom: 4px solid transparent;
	background: none;
	color: #3a3a3a;
	font: 500 1.25rem/1.2 var(--ap-font);
	cursor: pointer;
	transition: color .2s, border-color .25s;
}
.ap-tabs__tab:hover { color: var(--ap-ink); }
.ap-tabs__tab[aria-selected="true"] { border-bottom-color: #0f2a4a; color: #0f2a4a; }
.ap-tabs__tab:focus-visible { outline: 2px solid var(--ap-red); outline-offset: 4px; }
/* Sin JS no hay pestañas: se ven los paneles seguidos. */
.ap-pdp__info:not(.is-ready) .ap-tabs { display: none; }

.ap-pdp__panel { padding-top: 28px; }
.ap-pdp__text { color: var(--ap-body-color); font: 400 var(--ap-fs-body)/var(--ap-lh-body) var(--ap-font); }
.ap-pdp__text > * + * { margin-top: 1em !important; }
.ap-pdp__text strong { color: var(--ap-ink); }

.ap-specs { margin: 0; border: 1px solid var(--ap-line); border-radius: 6px; overflow: hidden; }
.ap-specs > div { display: grid; grid-template-columns: minmax(140px, 32%) minmax(0, 1fr); gap: 16px; padding: 14px 18px; border-top: 1px solid #ececec; font-size: var(--ap-fs-body); line-height: 1.45; }
.ap-specs > div:first-child { border-top: 0; }
.ap-specs > div:nth-child(even) { background: #fafafa; }
.ap-specs dt { color: var(--ap-ink); font-weight: 600; }
.ap-specs dd { margin: 0; color: #555; }

/* ── Productos relacionados (OZ Sliders, tarjeta de OZ Cotizador) ───────── */

.ap-pdp__related { margin-top: clamp(56px, 6vw, 90px); }
html body .ap-pdp .ap-pdp__related-title {
	margin: 0 0 24px;
	color: var(--ap-ink);
	font: 700 clamp(2rem, 3.4vw, 3rem)/1.05 var(--ap-font);
	letter-spacing: -.035em !important;
}

.ap-pdp .ap-red { color: var(--ap-red); }
html body .ap-pdp .ozs.ap-related-slider { position: relative; padding-top: 0 !important; overflow: visible; }
html body .ap-pdp .ozs.ap-related-slider:is(.ozs, .oz-unified) .ozs__nav::before,
html body .ap-pdp .ozs.ap-related-slider:is(.ozs, .oz-unified) .ozs__nav::after { display: none !important; }
/* Tarjeta de producto: componente común en ap-site.css (.ozc-product-card). */

/* Flechas a los lados, cuadradas y grises, sin sombra. */
html body .ap-pdp .ozs.ap-related-slider:is(.ozs, .oz-unified) .ozs__nav {
	position: absolute !important;
	inset: 0 -26px !important;
	z-index: 5;
	display: flex !important;
	align-items: center;
	justify-content: space-between;
	width: auto !important;
	height: auto !important;
	margin: 0;
	padding: 0;
	pointer-events: none;
}
html body .ap-pdp .ozs.ap-related-slider:is(.ozs, .oz-unified) .ozs__nav .ozs__nav-btn {
	position: relative !important;
	inset: auto !important;
	display: grid;
	place-items: center;
	width: 48px !important;
	height: 48px !important;
	margin: 0 !important;
	border: 0 !important;
	border-radius: 8px !important;
	background: #ececec !important;
	box-shadow: none !important;
	opacity: 1;
	transform: none !important;
	pointer-events: auto;
	transition: background-color .2s, scale .1s ease-out !important;
}
html body .ap-pdp .ozs.ap-related-slider:is(.ozs, .oz-unified) .ozs__nav .ozs__nav-btn::before {
	width: 20px !important;
	height: 20px !important;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M5 12h14M13 5l7 7-7 7' stroke='%23141414' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
	background-size: 20px 20px !important;
	opacity: 1 !important;
}
html body .ap-pdp .ozs.ap-related-slider:is(.ozs, .oz-unified) .ozs__nav .ozs__nav-btn--prev::before { transform: rotate(180deg) !important; }
html body .ap-pdp .ozs.ap-related-slider:is(.ozs, .oz-unified) .ozs__nav .ozs__nav-btn:hover { background: #dedede !important; }
html body .ap-pdp .ozs.ap-related-slider:is(.ozs, .oz-unified) .ozs__nav .ozs__nav-btn:active { scale: .94; }

/* ── Visor de imagen ────────────────────────────────────────────────────── */

.nuda-zoom {
	width: min(1100px, 100vw - 32px);
	max-width: none;
	height: min(900px, 100dvh - 32px);
	max-height: none;
	padding: 24px;
	border: 0;
	border-radius: 8px;
	background: #fff;
}
.nuda-zoom[open] { display: grid; place-items: center; animation: ap-zoom-in .25s var(--ap-ease); }
.nuda-zoom::backdrop { background: rgba(0, 0, 0, .75); }
@keyframes ap-zoom-in { from { opacity: 0; scale: .97; } }
.nuda-zoom img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-out; }
.nuda-zoom__close,
.nuda-zoom__nav {
	position: absolute;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--ap-line);
	border-radius: 50%;
	background: #fff;
	color: var(--ap-ink);
	cursor: pointer;
	transition: border-color .2s, color .2s;
}
.nuda-zoom__close:hover,
.nuda-zoom__nav:hover { border-color: var(--ap-red); color: var(--ap-red); }
.nuda-zoom__close { top: 14px; right: 14px; }
.nuda-zoom__nav { top: 50%; translate: 0 -50%; }
.nuda-zoom__nav--prev { left: 14px; }
.nuda-zoom__nav--next { right: 14px; }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 1480px) {
	html body .ap-pdp .ozs.ap-related-slider:is(.ozs, .oz-unified) .ozs__nav { inset: 0 -14px !important; }
}

/* Una columna: galería, resumen (ya no fijo) y después el contenido. */
@media (max-width: 1024px) {
	.ap-pdp__layout {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas: "media" "summary" "content";
		grid-template-rows: auto;
	}
	.ap-pdp__sticky { position: static; padding-bottom: 0; }
	.ap-pdp__summary { margin-top: 32px; }
	.ap-gallery.has-thumbs { grid-template-columns: 96px minmax(0, 1fr); }
}

@media (max-width: 640px) {
	.ap-pdp__crumbs { padding: 20px 0 22px; font-size: .9375rem; }
	/* Miniaturas debajo, en fila deslizable con el dedo. */
	.ap-gallery.has-thumbs { grid-template-columns: minmax(0, 1fr); gap: 16px; }
	.ap-gallery__rail { order: 2; }
	.ap-gallery__step { display: none; }
	.ap-gallery .nuda-gallery__thumbs {
		flex-direction: row;
		max-height: none;
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		scrollbar-width: none;
	}
	.ap-gallery .nuda-gallery__thumbs::-webkit-scrollbar { display: none; }
	.ap-gallery .nuda-gallery__thumb { width: 72px; scroll-snap-align: start; }
	.ap-pdp__buy { grid-template-columns: minmax(0, 1fr); }
	.ap-stepper { justify-self: start; }
	.ap-pdp__actions { grid-template-columns: minmax(0, 1fr); }
	.ap-tabs { gap: 20px; }
	.ap-tabs__tab { font-size: 1.0625rem; }
	.ap-specs > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
	html body .ap-pdp .ozs.ap-related-slider:is(.ozs, .oz-unified) .ozs__nav { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
	.ap-gallery .nuda-gallery__thumbs { scroll-behavior: auto; }
	.nuda-zoom[open] { animation: none; }
	.ap-pdp__btn:active,
	.ap-stepper button:active,
	.ap-gallery .nuda-gallery__thumb:active { scale: none; }
}
