/**
 * DS Elements — Ảnh sản phẩm
 *
 * Cột thumbnail bên trái có bề rộng cố định, khung ảnh lớn ăn hết phần còn lại.
 * Chiều cao cột thumbnail tính từ SỐ thumbnail muốn thấy chứ không kéo cho bằng
 * khung lớn: kéo cho bằng thì mỗi lần đổi tỉ lệ khung là tỉ lệ thumbnail méo
 * theo, mà thumbnail méo thì không còn nhận ra ảnh nào với ảnh nào.
 */

.elementor-widget-ds-product-gallery {
	width: 100%;
	min-width: 0;
}

.ds-pgal {
	--ds-pgal-thumbs: 4;
	--ds-pgal-thumb-w: 84px;
	--ds-pgal-thumb-gap: var(--ds-space-2);
	--ds-pgal-thumb-ratio: .95;
	--ds-pgal-ratio: 1.06;
	--ds-pgal-nav-size: 24px;

	width: 100%;
	min-width: 0;
}

.ds-pgal *,
.ds-pgal *::before,
.ds-pgal *::after {
	box-sizing: border-box;
}

/* --- Bố cục hai cột ----------------------------------------------------- */

.ds-pgal__stage {
	display: flex;
	align-items: flex-start;
	gap: var(--ds-space-3);
	min-width: 0;
}

.ds-pgal__rail {
	flex: 0 0 var(--ds-pgal-thumb-w);
	width: var(--ds-pgal-thumb-w);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--ds-space-1);
	min-width: 0;
}

.ds-pgal__main {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
}

/* --- Khung ảnh lớn ------------------------------------------------------ */

.ds-pgal__frame {
	display: block;
	aspect-ratio: var(--ds-pgal-ratio);
	overflow: hidden;
	background: var(--ds-pgal-frame-bg, var(--ds-color-surface));
	border-radius: var(--ds-pgal-radius, var(--ds-radius-md));
}

.ds-pgal__frame img {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: cover;
}

.ds-pgal__video {
	position: absolute;
	inset: 0;
	overflow: hidden;
	border-radius: var(--ds-pgal-radius, var(--ds-radius-md));
	background: var(--ds-color-heading);
}

.ds-pgal__video[hidden] {
	display: none;
}

.ds-pgal__video iframe {
	width: 100%;
	height: 100%;
	display: block;
	border: 0;
}

/* --- Cột thumbnail ------------------------------------------------------ */

.ds-pgal__thumbs {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: var(--ds-pgal-thumb-gap);
	overflow-y: auto;
	overscroll-behavior: contain;
	scroll-snap-type: y mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-ms-overflow-style: none;

	/* Cao đúng bằng n thumbnail cộng (n−1) khe. Viết ra bằng công thức chứ không
	   đặt số cứng, vì cả ba biến đều là control. */
	max-height: calc(
		var(--ds-pgal-thumbs) * (var(--ds-pgal-thumb-w) / var(--ds-pgal-thumb-ratio))
		+ (var(--ds-pgal-thumbs) - 1) * var(--ds-pgal-thumb-gap)
	);
}

.ds-pgal__thumbs::-webkit-scrollbar {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.ds-pgal__thumbs {
		scroll-behavior: auto;
	}
}

.ds-pgal__thumb {
	position: relative;
	flex: 0 0 auto;
	width: 100%;
	aspect-ratio: var(--ds-pgal-thumb-ratio);
	padding: 0;
	overflow: hidden;
	scroll-snap-align: start;

	background: var(--ds-color-surface);
	border: 2px solid transparent;
	border-radius: var(--ds-radius-md);
	cursor: pointer;
	transition: border-color var(--ds-transition), opacity var(--ds-transition);
}

.ds-pgal__thumb img {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: cover;
}

.ds-pgal__thumb:hover {
	border-color: var(--ds-color-line-soft);
}

.ds-pgal__thumb.is-active {
	border-color: var(--ds-pgal-thumb-active, var(--ds-color-brand));
}

/* Nhãn play trên thumbnail video: tam giác trắng trong đĩa tối mờ. */
.ds-pgal__play {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 28px;
	height: 28px;
	display: block;
	background: rgba(0, 29, 73, .55);
	border-radius: var(--ds-radius-pill);
}

.ds-pgal__play::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 0;
	height: 0;
	border-left: 9px solid var(--ds-color-white);
	border-top: 6px solid transparent;
	border-bottom: 6px solid transparent;
	transform: translateX(2px);
}

/* --- Nút cuộn lên / xuống ----------------------------------------------- */

.ds-pgal__nav {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	width: var(--ds-pgal-nav-size);
	height: var(--ds-pgal-nav-size);
	padding: 0;

	background: transparent;
	color: var(--ds-color-brand);
	border: 0;
	cursor: pointer;
	transition: opacity var(--ds-transition), color var(--ds-transition);
}

.ds-pgal__nav:hover:not(:disabled) {
	color: var(--ds-color-brand-light);
}

.ds-pgal__nav:disabled {
	opacity: .3;
	cursor: default;
}

.ds-pgal__chev {
	width: 9px;
	height: 9px;
	border-top: 2px solid currentColor;
	border-right: 2px solid currentColor;
}

.ds-pgal__chev--up {
	transform: translateY(2px) rotate(-45deg);
}

.ds-pgal__chev--down {
	transform: translateY(-2px) rotate(135deg);
}

/* --- Dải hành động ------------------------------------------------------ */

.ds-pgal__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--ds-space-2) var(--ds-space-6);
	margin: var(--ds-pgal-action-gap, var(--ds-space-4)) 0 0;
	padding: 0;
	list-style: none;
}

.ds-pgal__action {
	min-width: 0;
}

.ds-pgal__action-btn {
	display: inline-flex;
	align-items: center;
	gap: var(--ds-space-2);
	padding: 0;

	background: transparent;
	border: 0;
	color: var(--ds-pgal-action-color, var(--ds-color-body));
	font-size: var(--ds-fs-small);
	line-height: var(--ds-lh-small);
	text-decoration: none;
	cursor: pointer;
	transition: color var(--ds-transition);
}

.ds-pgal__action-btn:hover {
	color: var(--ds-color-brand-light);
}

.ds-pgal__action-icon {
	display: grid;
	place-items: center;
	color: var(--ds-pgal-action-icon, var(--ds-color-brand));
}

.ds-pgal__action-icon i {
	font-size: 15px;
	line-height: 1;
}

/* SVG không kế thừa màu chữ — không có dòng này thì icon đen kịt. */
.ds-pgal__action-icon svg {
	width: 15px;
	height: 15px;
	display: block;
	fill: currentColor;
}

/* --- Màn nhỏ ------------------------------------------------------------ */

/* Từ tablet trở xuống cột ảnh chạy hết bề ngang, mà bề ngang đó là 772px: khung
   ảnh phình lên 680×642, đẩy phần tóm tắt xuống dưới màn hình và chừa một khoảng
   trống 280px cạnh cột thumbnail. Chặn lại ở 560 rồi căn giữa — ảnh sản phẩm to
   hơn mức này không cho thêm thông tin gì. */
@media (max-width: 1024px) {
	.ds-pgal__stage {
		max-width: 560px;
		margin-inline: auto;
	}
}

/* Dưới 768 cột thumbnail nằm dọc thì chiếm mất 1/4 bề ngang màn hình, ảnh lớn
   còn không đủ chỗ. Lật thành hàng ngang dưới ảnh và bỏ hai nút — vuốt ngang là
   thao tác sẵn có trên điện thoại. */
@media (max-width: 767px) {
	.ds-pgal__stage {
		flex-direction: column-reverse;
		gap: var(--ds-space-2);
	}

	.ds-pgal__rail {
		flex: 0 0 auto;
		width: 100%;
	}

	.ds-pgal__nav {
		display: none;
	}

	.ds-pgal__thumbs {
		flex-direction: row;
		max-height: none;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
	}

	.ds-pgal__thumb {
		width: var(--ds-pgal-thumb-w);
	}

	.ds-pgal__actions {
		justify-content: flex-start;
		gap: var(--ds-space-2) var(--ds-space-4);
	}
}
