.lilac-aha-collection {
	text-align: center;
	padding: 32px 0;
}

.lilac-aha-collection__heading {
	margin: 0 0 20px;
}

.lilac-aha-collection__heading-highlight {
	color: #b08d57;
	border-bottom: 2px solid #b08d57;
}

/*
 * Tab nằm trên 1 hàng, tràn thì cuộn ngang. Không dùng justify-content: center
 * vì khi tràn, flex sẽ đẩy tab đầu ra ngoài mép trái, không cuộn tới được.
 * Căn giữa bằng margin auto ở tab đầu/cuối: margin auto tự về 0 khi tràn.
 */
.lilac-aha-collection__tabs {
	display: flex;
	flex-wrap: nowrap;
	gap: 10px;
	margin-bottom: 20px;
	overflow-x: auto;
	overflow-y: hidden;
}

.lilac-aha-collection__tab:first-child {
	margin-left: auto;
}

.lilac-aha-collection__tab:last-child {
	margin-right: auto;
}

.lilac-aha-collection__tab {
	flex: 0 0 auto;
	white-space: nowrap;
	background: none;
	border: 1px solid #ccc;
	border-radius: 20px;
	padding: 8px 20px;
	font-size: 13px;
	letter-spacing: 0.5px;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.lilac-aha-collection__tab.is-active {
	background: #222;
	color: #fff;
	border-color: #222;
}

.lilac-aha-collection__description {
	max-width: 640px;
	margin: 0 auto 28px;
	font-size: 14px;
	color: #666;
}

.lilac-aha-collection__products {
	--lilac-collection-image-height: clamp(180px, 18vw, 260px);
	position: relative;
	min-height: 120px;
	transition: opacity 0.15s ease;
}

.lilac-aha-collection__products.is-loading {
	opacity: 0.5;
	pointer-events: none;
}

/*
 * Widget này (dựng bằng Elementor) không bọc trong <div class="woocommerce">
 * nên CSS/Isotope của theme lilac (scope dưới ".woocommerce ul.products ...")
 * không áp dụng. Tự layout bằng CSS Grid, !important để thắng chắc chắn
 * display:list-item/bullet mặc định của trình duyệt cho <ul><li>.
 * Số cột cũng !important: ở trang có class "woocommerce" (Shop/danh mục, trang
 * sản phẩm) theme ép ".woocommerce ul.products[class*=columns-]" còn 4 cột ở
 * 1281-1540px (layout.css, selector mạnh hơn). Các rule 3/2 cột ở media query
 * bên dưới cũng !important và đứng sau nên vẫn thắng.
 */
.lilac-aha-collection__products ul.products {
	display: grid !important;
	grid-template-columns: repeat(5, 1fr) !important;
	gap: 20px;
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
	height: auto !important;
	text-align: left;
}

/*
 * "Sản phẩm tương tự" ở trang chi tiết sản phẩm (inc/class-lilac-related-products.php)
 * bọc lưới trong chính .lilac-aha-collection__products -> dùng y hệt CSS card ở
 * đây; chỉ thêm số cột theo cấu hình của theme (class columns-N) + tiêu đề.
 */
/* Không !important: phải thua rule 3/2 cột (!important) ở media query bên dưới
   trên màn hẹp. Hiện "Sản phẩm tương tự" cố định 5 cột (Lilac_Related_Products::COLUMNS)
   = đúng rule 5 cột gốc ở trên. */
.lilac-related-products ul.products.columns-2 { grid-template-columns: repeat(2, 1fr); }
.lilac-related-products ul.products.columns-3 { grid-template-columns: repeat(3, 1fr); }
.lilac-related-products ul.products.columns-4 { grid-template-columns: repeat(4, 1fr); }
.lilac-related-products ul.products.columns-5 { grid-template-columns: repeat(5, 1fr); }

.lilac-related-products__heading {
	text-align: center;
	margin: 0 0 28px;
}

.lilac-aha-collection__products ul.products li.product {
	display: block !important;
	float: none !important;
	min-width: 0;
	width: auto !important;
	margin: 0 !important;
	list-style: none !important;
	padding-bottom: 0;
}

.lilac-aha-collection__products ul.products li.product.isotope-grid-sizer {
	display: none !important;
}

/* Title/rating/price bị theme lilac gỡ khỏi content-product.php mặc định,
   widget-products.php add lại 3 hook gốc của WooCommerce (xem chú thích PHP) -
   style lại cho khớp ảnh tham khảo: canh giữa, sao vàng, giá đậm.
   Chú ý: title/rating/price nằm trong ".product-wrapper" (theme cha in ra ở
   loop-start-end.php), KHÔNG nằm trong thẻ <a> - <a class="image"> chỉ bọc
   ảnh thumbnail, nên phải canh giữa ở ".product-wrapper" chứ không phải "a". */
.woocommerce .lilac-aha-collection__products ul.products li.product .product-wrapper,
.lilac-aha-collection__products ul.products li.product .product-wrapper {
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	gap: 10px;
	height: 100%;
	align-items: center;
	text-align: center;
}

/* Khung ảnh đồng đều; giữ trọn sản phẩm dù ảnh gốc có tỉ lệ khác nhau. */
.lilac-aha-collection__products ul.products li.product .product-wrapper .product-thumb {
	position: relative;
	flex: 0 0 auto;
	width: 100%;
	height: var(--lilac-collection-image-height);
}

.lilac-aha-collection__products ul.products li.product .product-wrapper .product-thumb > a.image,
.lilac-aha-collection__products ul.products li.product .product-wrapper .product-thumb > a.image > :is(.primary-image, .secondary-image) {
	display: block;
	width: 100%;
	height: 100%;
}

.lilac-aha-collection__products ul.products li.product .product-wrapper .product-thumb > a.image,
.lilac-aha-collection__products ul.products li.product .product-wrapper .product-thumb > a.image > .primary-image {
	position: relative;
}

.lilac-aha-collection__products ul.products li.product .product-wrapper .product-thumb > a.image > :is(.secondary-image, .product-thumb-overlay) {
	position: absolute;
	inset: 0;
}

.lilac-aha-collection__products ul.products li.product .product-wrapper .product-thumb > a.image > :is(.primary-image, .secondary-image) img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center;
	transition: transform 0.4s ease;
}

/* Zoom ảnh khi hover item (giống Aha Kits). Cắt ở a.image vì nút giỏ hàng nằm ngoài thẻ này. */
.lilac-aha-collection__products ul.products li.product .product-wrapper .product-thumb > a.image {
	overflow: hidden;
}

.lilac-aha-collection__products ul.products li.product:hover .product-wrapper .product-thumb > a.image > :is(.primary-image, .secondary-image) img {
	transform: scale(1.08);
}

/* Nút nổi trên mép dưới khung ảnh, không chiếm hàng hoặc đẩy tên sản phẩm. */
.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__cart {
	position: absolute;
	left: 0;
	bottom: calc(100% - var(--lilac-collection-image-height) + 12px);
	z-index: 2;
	display: flex;
	justify-content: center;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
	width: 100%;
	min-height: 36px;
	padding: 0 8px;
	box-sizing: border-box;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__cart a.button,
.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__cart a.added_to_cart {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	position: relative;
	float: none;
	max-width: 100%;
	min-height: 36px;
	margin: 0;
	padding: 8px 14px;
	box-sizing: border-box;
	border: 1px solid #b08d57;
	border-radius: 0;
	background: #b08d57;
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: 0.3px;
	text-align: center;
	text-decoration: none;
	text-transform: uppercase;
	white-space: normal;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__cart a:hover {
	border-color: #222;
	background: #222;
	color: #fff;
}

.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__cart a:focus-visible {
	outline: 2px solid #222;
	outline-offset: 3px;
}

.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__cart a.button.added {
	display: none !important;
}

.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__cart a.loading {
	opacity: 0.7;
	pointer-events: none;
}

.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__cart a.loading::after {
	content: "";
	position: static;
	width: 12px;
	height: 12px;
	margin: 0;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	font-family: inherit;
	animation: lilac-collection-cart-spin 0.6s linear infinite;
}

@keyframes lilac-collection-cart-spin {
	to { transform: rotate(360deg); }
}

/* Chỉ ẩn trên thiết bị có chuột; bàn phím và màn hình cảm ứng vẫn dùng được. */
@media (hover: hover) and (pointer: fine) {
	.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__cart {
		opacity: 0;
		pointer-events: none;
		transform: translateY(6px);
	}

	.lilac-aha-collection__products ul.products li.product:hover .lilac-aha-collection__cart,
	.lilac-aha-collection__products ul.products li.product:focus-within .lilac-aha-collection__cart {
		opacity: 1;
		pointer-events: auto;
		transform: translateY(0);
	}
}

@media (prefers-reduced-motion: reduce) {
	.lilac-aha-collection__products ul.products li.product .product-wrapper .product-thumb > a.image > :is(.primary-image, .secondary-image) img,
	.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__cart {
		transition: none;
	}
}

/* Khối bọc chung tiêu đề + sao + số review + giá
   (lilac_collection_loop_product_info_open/close trong inc/collection-functions.php) */
.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__product-info {
	width: 100%;
	padding: 12px;
	box-sizing: border-box;
}

.lilac-aha-collection__products ul.products li.product .woocommerce-loop-product__title {
	margin: 16px 0 8px;
	font-size: 14px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: #111;
}

.lilac-aha-collection__products ul.products li.product .star-rating {
	margin: 0 0 6px;
	color: #b08d57;
	font-size: 13px;
}

/*
 * Vẽ ngôi sao: CSS gốc của WooCommerce + theme lilac đều viết dưới dạng
 * ".woocommerce .star-rating ..." nên KHÔNG áp dụng cho widget (không nằm trong
 * .woocommerce) -> chỉ hiện chữ "Rated 5.00 out of 5". Chép lại đúng các rule
 * đó (woocommerce.css + theme), scope theo lưới của widget. Font "WooCommerce"
 * do woocommerce.css khai báo @font-face (được nạp trên mọi trang frontend).
 */
.lilac-aha-collection__products ul.products li.product .star-rating {
	float: none;
	overflow: hidden;
	position: relative;
	height: 1em;
	line-height: 1;
	width: 5.6em;
	margin-left: auto;
	margin-right: auto;
	font-family: "WooCommerce";
}

.lilac-aha-collection__products ul.products li.product .star-rating::before,
.lilac-aha-collection__products ul.products li.product .star-rating > span::before {
	font-family: "WooCommerce";
	letter-spacing: 2px;
	text-align: left;
	text-indent: 0;
	position: absolute;
	top: 0;
	left: 0;
}

.lilac-aha-collection__products ul.products li.product .star-rating::before {
	content: "\e021\e021\e021\e021\e021";
	color: #cfc8d8;
	float: left;
}

.lilac-aha-collection__products ul.products li.product .star-rating > span {
	overflow: hidden;
	float: left;
	position: absolute;
	top: 0;
	left: 0;
	padding-top: 1.5em;
}

.lilac-aha-collection__products ul.products li.product .star-rating > span::before {
	content: "\e020\e020\e020\e020\e020";
}

.lilac-aha-collection__products ul.products li.product .lilac-aha-collection__rating-count {
	display: block;
	width: 100%;
	margin: 0 0 8px;
	font-size: 12px;
	color: #999;
}

.lilac-aha-collection__products ul.products li.product .price {
	font-size: 14px;
	font-weight: 600;
	color: #111;
}

@media (max-width: 992px) {
	.lilac-aha-collection__products ul.products {
		grid-template-columns: repeat(3, 1fr) !important;
	}
}

@media (max-width: 768px) {
	.lilac-aha-collection__products ul.products {
		grid-template-columns: repeat(2, 1fr) !important;
	}
}

/*
 * Riêng widget Aha Collection: sản phẩm nằm trên 1 hàng, tràn thì cuộn ngang
 * (giống thanh tab). Số card hiện vừa khung giữ nguyên 5 / 3 / 2 theo breakpoint
 * như lưới ở trên. Trang Collection (15 sp/trang, có phân trang) và "Sản phẩm
 * tương tự" dùng chung CSS card nhưng không nằm trong .lilac-aha-collection nên
 * vẫn là lưới nhiều hàng.
 * grid-template-columns phải !important để thắng !important của 2 media query trên.
 * Căn giữa bằng "safe center" (không phải "center"): khi tràn, "center" đẩy card
 * đầu ra ngoài mép trái, không cuộn tới được; "safe" tự về căn trái lúc tràn.
 * Không dùng margin auto như thanh tab được: đây là grid (margin auto chỉ căn
 * trong ô) và con đầu của <ul> là li.isotope-grid-sizer ẩn của theme.
 */
.lilac-aha-collection .lilac-aha-collection__products ul.products {
	grid-template-columns: none !important;
	grid-auto-flow: column;
	grid-auto-columns: calc((100% - 4 * 20px) / 5);
	justify-content: safe center;
	overflow-x: auto;
	overflow-y: hidden;
}

@media (max-width: 992px) {
	.lilac-aha-collection .lilac-aha-collection__products ul.products {
		grid-auto-columns: calc((100% - 2 * 20px) / 3);
	}
}

@media (max-width: 768px) {
	.lilac-aha-collection .lilac-aha-collection__products ul.products {
		grid-auto-columns: calc((100% - 20px) / 2);
	}
}

.lilac-aha-collection__footer {
	margin-top: 28px;
}

.lilac-aha-collection__button {
	display: inline-block;
	padding: 12px 32px;
	border: 1px solid #222;
	border-radius: 30px;
	text-decoration: none;
	color: inherit;
	font-size: 13px;
	letter-spacing: 0.5px;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.lilac-aha-collection__button:hover {
	background: #222;
	color: #fff;
}
