/**
 * EZWP Product Gallery — estructura.
 * Colores / radios / tamaños: controles Elementor + defaults de referencia.
 */

.ezwp-gallery {
	--ezwp-gallery-bg: #f2f2f2;
	--ezwp-gallery-radius: 24px;
	--ezwp-gallery-gap: 12px;
	--ezwp-thumb-size: 72px;
	--ezwp-thumb-radius: 12px;
	--ezwp-thumb-active: #111;
	--ezwp-img-fit: contain;
	--ezwp-img-position: center center;
	--ezwp-zoom: 1.06;
	--ezwp-fade-ms: 450ms;

	position: relative;
	display: block;
	width: 100%;
	max-width: 100%;
}

/* Flex solo cuando hay thumbs (layout lateral / inferior) */
.ezwp-gallery--thumbs-left,
.ezwp-gallery--thumbs-right,
.ezwp-gallery--thumbs-bottom {
	display: flex;
	align-items: stretch;
	gap: var(--ezwp-gallery-gap);
}

.ezwp-gallery--thumbs-left {
	flex-direction: row;
}

.ezwp-gallery--thumbs-right {
	flex-direction: row-reverse;
}

.ezwp-gallery--thumbs-bottom {
	flex-direction: column;
}

.ezwp-gallery__stage {
	position: relative;
	display: block;
	flex: 1 1 auto;
	width: 100%;
	height: auto;
	min-width: 0;
	min-height: 0;
	overflow: hidden;
	border-radius: var(--ezwp-gallery-radius);
	background: var(--ezwp-gallery-bg);
}

/*
 * Grid stack (no position:absolute en slides): el alto queda en el flujo
 * y no colapsa en mobile / loops de Elementor.
 */
.ezwp-gallery__viewport {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: minmax(0, 1fr);
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	min-height: 12.5rem;
	overflow: hidden;
	isolation: isolate;
}

.ezwp-gallery__product-link {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: block;
	cursor: pointer;
	text-indent: -9999px;
	overflow: hidden;
}

.ezwp-gallery__slide {
	grid-area: 1 / 1;
	position: relative;
	z-index: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	align-self: stretch;
	justify-self: stretch;
	width: 100%;
	height: auto;
	min-width: 0;
	min-height: 100%;
	margin: 0;
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--ezwp-fade-ms) ease, visibility var(--ezwp-fade-ms) ease;
	pointer-events: none;
}

.ezwp-gallery__slide.is-active {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	z-index: 1;
}

.ezwp-gallery__slide img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: var(--ezwp-img-fit);
	object-position: var(--ezwp-img-position);
	transition: transform 0.45s ease;
	transform-origin: center center;
}

/* Cover / fill: la imagen ocupa todo el viewport */
.ezwp-gallery--fit-cover .ezwp-gallery__slide img,
.ezwp-gallery--fit-fill .ezwp-gallery__slide img {
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
}

.ezwp-gallery--fit-cover .ezwp-gallery__slide img {
	object-fit: cover;
}

.ezwp-gallery--fit-fill .ezwp-gallery__slide img {
	object-fit: fill;
}

.ezwp-gallery--fit-contain .ezwp-gallery__slide img {
	object-fit: contain;
}

.ezwp-gallery--fit-none .ezwp-gallery__slide img {
	object-fit: none;
}

.ezwp-gallery--fit-scale-down .ezwp-gallery__slide img {
	object-fit: scale-down;
}

/* Hover: zoom suave */
.ezwp-gallery--hover-zoom:hover .ezwp-gallery__slide.is-active img {
	transform: scale(var(--ezwp-zoom));
}

/* Badges overlay */
.ezwp-gallery__badges {
	position: absolute;
	z-index: 3;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 6px;
	pointer-events: none;
}

.ezwp-gallery__badges--top-right {
	top: 16px;
	right: 0;
}

.ezwp-gallery__badges--top-left {
	top: 16px;
	left: 0;
	align-items: flex-start;
}

.ezwp-gallery__badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.35em 0.85em;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	line-height: 1.2;
	color: #fff;
	white-space: nowrap;
}

.ezwp-gallery__badge--sale {
	background: #ff4d1a;
	border-radius: 8px 0 0 8px;
}

.ezwp-gallery__badges--top-left .ezwp-gallery__badge--sale {
	border-radius: 0 8px 8px 0;
}

.ezwp-gallery__badge--sold-out {
	background: #111;
	border-radius: 999px;
	margin-right: 12px;
}

.ezwp-gallery__badges--top-left .ezwp-gallery__badge--sold-out {
	margin-right: 0;
	margin-left: 12px;
}

.ezwp-gallery__badge--tag {
	background: #6b8e23;
	border-radius: 999px;
	margin-right: 12px;
}

.ezwp-gallery__badges--top-left .ezwp-gallery__badge--tag {
	margin-right: 0;
	margin-left: 12px;
}

.ezwp-gallery__badge--origin {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	background: rgba(255, 255, 255, 0.92);
	color: #111;
	border-radius: 999px;
	margin-right: 12px;
	text-transform: none;
	font-weight: 600;
}

.ezwp-gallery__badges--top-left .ezwp-gallery__badge--origin {
	margin-right: 0;
	margin-left: 12px;
}

.ezwp-gallery__badge-flag {
	width: 1.25em;
	height: auto;
	border-radius: 2px;
}

/* Thumbs */
.ezwp-gallery__thumbs {
	display: flex;
	flex-shrink: 0;
	gap: 10px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.ezwp-gallery--thumbs-left .ezwp-gallery__thumbs,
.ezwp-gallery--thumbs-right .ezwp-gallery__thumbs {
	flex-direction: column;
	max-height: 100%;
	overflow-y: auto;
	scrollbar-width: thin;
}

.ezwp-gallery--thumbs-bottom .ezwp-gallery__thumbs {
	flex-direction: row;
	overflow-x: auto;
	justify-content: center;
}

.ezwp-gallery__thumb {
	flex: 0 0 auto;
	width: var(--ezwp-thumb-size);
	height: var(--ezwp-thumb-size);
	padding: 0;
	border: 2px solid transparent;
	border-radius: var(--ezwp-thumb-radius);
	background: var(--ezwp-gallery-bg);
	cursor: pointer;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: border-color 0.2s ease;
}

.ezwp-gallery__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center center;
	pointer-events: none;
}

.ezwp-gallery__thumb.is-active {
	border-color: var(--ezwp-thumb-active);
}

.ezwp-gallery__thumb:focus-visible {
	outline: 2px solid var(--ezwp-thumb-active);
	outline-offset: 2px;
}

/* Arrows — por encima del link al producto */
.ezwp-gallery__arrow {
	position: absolute;
	top: 50%;
	z-index: 4;
	transform: translateY(-50%);
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	color: #111;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.ezwp-gallery__stage:hover .ezwp-gallery__arrow,
.ezwp-gallery__arrow:focus-visible {
	opacity: 1;
}

.ezwp-gallery__arrow--prev {
	left: 12px;
}

.ezwp-gallery__arrow--next {
	right: 12px;
}

.ezwp-gallery__arrow svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

/* Dots — por encima del link al producto */
.ezwp-gallery__dots {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 14px;
	z-index: 4;
	display: flex;
	justify-content: center;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ezwp-gallery__dot {
	width: 8px;
	height: 8px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.25);
	cursor: pointer;
}

.ezwp-gallery__dot.is-active {
	background: #111;
	transform: scale(1.15);
}

/* Single image: hide nav chrome via modifier */
.ezwp-gallery--main-only {
	display: block;
}

.ezwp-gallery--main-only .ezwp-gallery__thumbs,
.ezwp-gallery--main-only .ezwp-gallery__arrow,
.ezwp-gallery--main-only .ezwp-gallery__dots {
	display: none !important;
}

@media (max-width: 767px) {
	.ezwp-gallery--thumbs-left,
	.ezwp-gallery--thumbs-right,
	.ezwp-gallery--thumbs-bottom {
		flex-direction: column;
		align-items: stretch;
	}

	.ezwp-gallery__stage {
		flex: 0 0 auto;
		width: 100%;
	}

	.ezwp-gallery__viewport {
		width: 100%;
		/* Fallback si el tema anula aspect-ratio */
		min-height: clamp(12.5rem, 70vw, 28rem);
	}

	.ezwp-gallery--thumbs-left .ezwp-gallery__thumbs,
	.ezwp-gallery--thumbs-right .ezwp-gallery__thumbs {
		flex-direction: row;
		order: 2;
		width: 100%;
		overflow-x: auto;
	}
}
