/* ==========================================================================
   WCGS - Product gallery base styles (Amazon / ShopLentor style rail)
   Thumbnail position, size and gap are added as inline CSS generated from
   WooCommerce > Gallery Layout settings - see class-wcgs-gallery.php.
   ========================================================================== */

.woocommerce-product-gallery {
	display: flex;
	align-items: flex-start;
	gap: 15px;
	max-width: 100%;
	position: relative;
}

/* Main image / slider area */
.woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	order: 2;
	position: relative;
	overflow: hidden;
}

.woocommerce-product-gallery .woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image img {
	width: 100%;
	height: auto;
	display: block;
	border-radius: 4px;
}

/* Never leave the gallery invisible, and avoid a flash of stacked images before JS runs */
.woocommerce-product-gallery {
	opacity: 1 !important;
}

.woocommerce-product-gallery:not(.wcgs-custom) .woocommerce-product-gallery__image:nth-child(n+2) {
	display: none;
}

/* Own slider (FlexSlider is disabled): only the active image is shown */
.woocommerce-product-gallery.wcgs-custom .woocommerce-product-gallery__image:not(.wcgs-active) {
	display: none !important;
}

/* Hover-zoom (lightweight, CSS-only fallback in addition to WC's native zoom) */
.woocommerce-product-gallery.wcgs-zoom-enabled .woocommerce-product-gallery__wrapper:hover img {
	cursor: zoom-in;
}

/* Vertical/horizontal thumbnail column */
.woocommerce-product-gallery .flex-control-thumbs {
	order: 1;
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 0;
	list-style: none;
	max-height: 500px;
	overflow-y: auto;
	scroll-behavior: smooth;
	scrollbar-width: thin;
}

.woocommerce-product-gallery .flex-control-thumbs li {
	list-style: none;
	margin: 0;
	flex-shrink: 0;
	/* Override WooCommerce's default 25% float width so each thumb fills the rail */
	width: 100% !important;
	float: none !important;
	aspect-ratio: 1 / 1;
	background: #fff;
}

.woocommerce-product-gallery .flex-control-thumbs li img {
	width: 100%;
	height: 100%;
	aspect-ratio: 1 / 1;
	/* contain = whole image visible inside the square, no cropping */
	object-fit: contain;
	background: #fff;
	box-sizing: border-box;
	display: block;
	cursor: pointer;
	border: 2px solid transparent;
	border-radius: 4px;
	opacity: 0.75;
	transition: border-color 0.15s ease, opacity 0.15s ease;
}

.woocommerce-product-gallery .flex-control-thumbs li img:hover {
	opacity: 1;
}

.woocommerce-product-gallery .flex-control-thumbs li img.flex-active {
	border-color: #333;
	opacity: 1;
}

/* Up/down scroll arrows for the thumbnail rail, shown by JS only when the
   thumbnails overflow the visible height. */
.wcgs-thumb-scroll {
	display: none;
	align-items: center;
	justify-content: center;
	width: 100%;
	background: #f5f5f5;
	border: 1px solid #e2e2e2;
	border-radius: 4px;
	cursor: pointer;
	padding: 4px 0;
	font-size: 12px;
	line-height: 1;
}

.wcgs-thumb-scroll:hover {
	background: #eaeaea;
}

.wcgs-thumb-scroll.wcgs-visible {
	display: flex;
}

.wcgs-thumb-scroll--up {
	order: 0;
	margin-bottom: 6px;
}

.wcgs-thumb-scroll--down {
	order: 2;
	margin-top: 6px;
}

/* "Click to see full view" link, centered below the gallery */
.wcgs-full-view-link {
	display: block;
	width: 100%;
	text-align: center;
	margin-top: 10px;
	font-size: 14px;
	text-decoration: none;
}

.wcgs-full-view-link:hover {
	text-decoration: underline;
}

/* Stack vertically on narrow screens regardless of the configured position */
@media (max-width: 600px) {
	.woocommerce-product-gallery {
		flex-direction: column !important;
	}

	.woocommerce-product-gallery .woocommerce-product-gallery__wrapper {
		order: 1;
	}

	.woocommerce-product-gallery .flex-control-thumbs {
		order: 2;
		flex-direction: row !important;
		width: 100% !important;
		flex: initial !important;
		max-height: none;
		overflow-x: auto;
		overflow-y: visible;
	}

	.woocommerce-product-gallery .flex-control-thumbs li {
		flex: 0 0 60px;
	}

	.wcgs-thumb-scroll {
		display: none !important;
	}
}
