/* ==========================================================================
   WooCommerce Independent Product Images – Frontend Styles
   ========================================================================== */

/* ── Editor placeholder ─────────────────────────────────────────────────── */
.wcipi-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	background: #f8f8fb;
	border: 2px dashed #c5c9d4;
	border-radius: 6px;
	padding: 48px 24px;
	text-align: center;
	color: #a0a5b0;
	min-height: 160px;
}

.wcipi-placeholder-icon { opacity: 0.5; }
.wcipi-placeholder p    { margin: 0; font-size: 13px; line-height: 1.5; }

/* ── Gallery root ───────────────────────────────────────────────────────── */
/*
 * width: 100% + align-self: stretch are critical when the widget lives inside
 * an Elementor Flexbox or Grid Container.  Without them the gallery shrinks to
 * its intrinsic content width instead of filling the column.
 */
.wcipi-gallery {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: stretch; /* children (main image, thumbnails) fill full width */
	width: 100%;          /* fill the Elementor widget-container / flex cell  */
	align-self: stretch;  /* stretch inside any flex/grid parent               */
	box-sizing: border-box;
}

/* ── Flex layout (left / right thumbnails) ──────────────────────────────── */
.wcipi-gallery-flex {
	display: flex;
	align-items: flex-start;
	width: 100%;
}

/* Left:  thumbnails are first in DOM → appear on the left naturally  */
/* Right: thumbnails are second in DOM → appear on the right naturally */
.wcipi-flex-left  { flex-direction: row; }
.wcipi-flex-right { flex-direction: row; }

/* ── Main image outer (flex child) ──────────────────────────────────────── */
/*
 * In a row context (left/right thumbs): flex:1 1 auto fills remaining width.
 * In a column context (bottom thumbs):  width:100% ensures it fills the gallery.
 */
.wcipi-main-image-outer-wrap {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
}

/* ── Main image wrapper (positions sale badge + arrows) ─────────────────── */
.wcipi-main-image-wrapper {
	position: relative;
	width: 100%;
	box-sizing: border-box;
}

/* ── Track + individual slides ──────────────────────────────────────────── */
.wcipi-main-image-track {
	position: relative;
	overflow: hidden;
	width: 100%;
}

.wcipi-main-image {
	display: none;
}

.wcipi-main-image.wcipi-active {
	display: block;
}

/* Fade animation */
.wcipi-gallery[data-animation="fade"] .wcipi-main-image.wcipi-active {
	animation: wcipi-fade-in 0.35s ease both;
}

@keyframes wcipi-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

/* Slide animation */
.wcipi-gallery[data-animation="slide"] .wcipi-main-image.wcipi-active {
	animation: wcipi-slide-in 0.3s ease both;
}

@keyframes wcipi-slide-in {
	from { transform: translateX(30px); opacity: 0; }
	to   { transform: translateX(0);   opacity: 1; }
}

.wcipi-main-image img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	transition: transform 0.4s ease, opacity 0.3s ease, filter 0.3s ease;
}

/* Hover zoom on main image */
.wcipi-gallery[data-zoom="yes"] .wcipi-main-image-wrapper:hover .wcipi-main-image.wcipi-active img {
	transform: scale(1.05);
}

/* Anchor/span wrapper inside the slide */
.wcipi-lightbox-trigger,
.wcipi-image-wrap {
	display: block;
	position: relative;
	overflow: hidden;
}

/* ── Sale flash badge ───────────────────────────────────────────────────── */
.wcipi-onsale {
	position: absolute;
	top: 10px;
	left: 0;
	right: auto;
	z-index: 4;
	background-color: #e2401c;
	color: #fff;
	font-size: 0.85em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 0 12px;
	min-width: 50px;
	min-height: 28px;
	line-height: 28px;
	display: inline-block;
	text-align: center;
	border-radius: 2px;
	pointer-events: none;
}

/* ── Zoom icon overlay ──────────────────────────────────────────────────── */
.wcipi-zoom-icon {
	position: absolute;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: rgba(0, 0, 0, 0.5);
	color: #fff;
	font-size: 18px;
	padding: 10px;
	border-radius: 50%;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease;
}

.wcipi-main-image-wrapper:hover .wcipi-zoom-icon { opacity: 1; }

/* Zoom icon position variants */
.wcipi-zoom-pos-center       { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.wcipi-zoom-pos-top-left     { top: 12px; left: 12px; }
.wcipi-zoom-pos-top-right    { top: 12px; right: 12px; }
.wcipi-zoom-pos-bottom-left  { bottom: 12px; left: 12px; }
.wcipi-zoom-pos-bottom-right { bottom: 12px; right: 12px; }

/* ── Navigation arrows ──────────────────────────────────────────────────── */
.wcipi-arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 5;
	border: none;
	outline: none;
	cursor: pointer;
	background-color: rgba(0, 0, 0, 0.5);
	color: #fff;
	padding: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	border-radius: 4px;
	transition: background-color 0.2s ease, color 0.2s ease, opacity 0.3s ease;
}

.wcipi-arrow-prev { left: 10px; }
.wcipi-arrow-next { right: 10px; }

/* Arrows hidden on single-image galleries */
.wcipi-single-image .wcipi-arrow { display: none !important; }

/* On-hover arrows */
.wcipi-arrows-on-hover .wcipi-arrow {
	opacity: 0;
	pointer-events: none;
}

.wcipi-arrows-on-hover:hover .wcipi-arrow,
.wcipi-arrows-on-hover:focus-within .wcipi-arrow {
	opacity: 1;
	pointer-events: auto;
}

/* ── Thumbnails ─────────────────────────────────────────────────────────── */
.wcipi-thumbnails {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-top: 10px;
}

/* Vertical thumbnails (left / right) */
.wcipi-flex-left  .wcipi-thumbnails,
.wcipi-flex-right .wcipi-thumbnails {
	flex-direction: column;
	flex-wrap: nowrap;
	flex-shrink: 0;
	width: 80px;
	margin-top: 0;
}

/* Column widths (bottom layout) */
.wcipi-thumbs-cols-1  > .wcipi-thumbnail { width: calc(100% / 1  - 4px); }
.wcipi-thumbs-cols-2  > .wcipi-thumbnail { width: calc(100% / 2  - 4px); }
.wcipi-thumbs-cols-3  > .wcipi-thumbnail { width: calc(100% / 3  - 4px); }
.wcipi-thumbs-cols-4  > .wcipi-thumbnail { width: calc(100% / 4  - 4px); }
.wcipi-thumbs-cols-5  > .wcipi-thumbnail { width: calc(100% / 5  - 4px); }
.wcipi-thumbs-cols-6  > .wcipi-thumbnail { width: calc(100% / 6  - 4px); }
.wcipi-thumbs-cols-7  > .wcipi-thumbnail { width: calc(100% / 7  - 4px); }
.wcipi-thumbs-cols-8  > .wcipi-thumbnail { width: calc(100% / 8  - 4px); }
.wcipi-thumbs-cols-9  > .wcipi-thumbnail { width: calc(100% / 9  - 4px); }
.wcipi-thumbs-cols-10 > .wcipi-thumbnail { width: calc(100% / 10 - 4px); }

/* Left/right thumbnails always fill the column */
.wcipi-flex-left  .wcipi-thumbnail,
.wcipi-flex-right .wcipi-thumbnail { width: 100%; }

.wcipi-thumbnail {
	cursor: pointer;
	flex-shrink: 0;
	box-sizing: border-box;
}

.wcipi-thumbnail img {
	display: block;
	width: 100%;
	height: auto;
	opacity: 0.7;
	border: 2px solid transparent;
	transition: opacity 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
}

.wcipi-thumbnail.wcipi-active img,
.wcipi-thumbnail:hover img {
	opacity: 1;
	border-color: #333;
}

/* ── Lightbox ───────────────────────────────────────────────────────────── */
.wcipi-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wcipi-lightbox-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.92);
	cursor: pointer;
}

.wcipi-lightbox-stage {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 94vw;
	max-height: 94vh;
}

.wcipi-lightbox-img-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 90vw;
	max-height: 88vh;
}

.wcipi-lightbox-img {
	display: block;
	max-width: 90vw;
	max-height: 88vh;
	object-fit: contain;
	user-select: none;
	transition: opacity 0.2s ease;
}

.wcipi-lightbox-img.wcipi-lb-loading { opacity: 0.4; }

/* Lightbox buttons (close, prev, next) */
.wcipi-lightbox-close,
.wcipi-lightbox-prev,
.wcipi-lightbox-next {
	position: fixed;
	border: none;
	cursor: pointer;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: background-color 0.2s ease;
	z-index: 2;
}

.wcipi-lightbox-close:hover,
.wcipi-lightbox-prev:hover,
.wcipi-lightbox-next:hover {
	background: rgba(255, 255, 255, 0.28);
}

.wcipi-lightbox-close     { top: 18px; right: 18px; width: 42px; height: 42px; }
.wcipi-lightbox-prev      { top: 50%; left: 18px;  transform: translateY(-50%); width: 48px; height: 48px; }
.wcipi-lightbox-next      { top: 50%; right: 18px; transform: translateY(-50%); width: 48px; height: 48px; }

.wcipi-lightbox-close svg,
.wcipi-lightbox-prev svg,
.wcipi-lightbox-next svg {
	width: 22px;
	height: 22px;
	pointer-events: none;
}

.wcipi-lightbox-counter {
	position: fixed;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	color: rgba(255, 255, 255, 0.65);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 13px;
	letter-spacing: 0.03em;
	pointer-events: none;
	z-index: 2;
}
