/**
 * Product grids — Samsung / Xiaomi / CellphoneS premium minimal
 * Flatsome: .product-small, .ux-relay, .section-title, .onsale
 *
 * Badge giảm giá: sửa --phonez-sale-* bên dưới (hoặc khối "5. Sale badge")
 */

:root {
	/* Badge sản phẩm — LikeNew + Giảm giá dùng chung kích thước */
	--phonez-badge-offset: 12px;
	--phonez-badge-min-h: 28px;
	--phonez-badge-py: 6px;
	--phonez-badge-px: 12px;
	--phonez-badge-font: 0.6875rem;
	--phonez-badge-fw: 700;
	--phonez-badge-lh: 1.2;
	--phonez-badge-tracking: 0.02em;
	--phonez-badge-radius: 999px;
	--phonez-sale-bg: linear-gradient(135deg, #e53935 0%, #c62828 100%);
	--phonez-sale-shadow: 0 3px 10px rgba(198, 40, 40, 0.32);
	--phonez-likenew-bg: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);
	--phonez-likenew-shadow: 0 3px 10px rgba(21, 101, 192, 0.32);
}

/* ─── 1. Section header (product blocks) ─── */
.section-title-container {
	margin-bottom: 1.75rem;
}

.section-title {
	padding-bottom: 0 !important;
	border-bottom: none !important;
}

.section-title .section-title-main {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 0 0 0 16px !important;
	margin: 0 !important;
	border: none !important;
	background: none !important;
	font-size: clamp(1rem, 2.2vw, 1.125rem) !important;
	font-weight: 800 !important;
	letter-spacing: 0.06em;
	line-height: 1.3;
	text-transform: uppercase;
	color: var(--phonez-text, #1a1a1a) !important;
}

/* Accent line xanh — không gạch vàng */
.section-title .section-title-main::before {
	content: "";
	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	width: 4px;
	height: 22px;
	border-radius: 4px;
	background: linear-gradient(180deg, #1e73be 0%, #4a9ad4 100%);
	box-shadow: 0 0 12px rgba(30, 115, 190, 0.35);
}

/* Icon tech nhỏ */
.section-title .section-title-main::after {
	content: "";
	display: inline-block;
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	margin-left: 2px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e73be' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M13 2L3 14h9l-1 8 10-12h-9l1-8z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-size: contain;
	opacity: 0.85;
}

.section-title a {
	font-size: 0.8125rem;
	font-weight: 600;
	text-transform: none;
	letter-spacing: 0;
}

/* Subline mảnh dưới header */
.section-title-container::after {
	content: "";
	display: block;
	width: 100%;
	max-width: 120px;
	height: 2px;
	margin-top: 12px;
	background: linear-gradient(90deg, rgba(30, 115, 190, 0.5), transparent);
	border-radius: 2px;
}

/* ─── 2. Grid spacing ─── */
.products:not(.ux-products-grid) .product-small,
.ux-relay .products .product-small,
.row.products .product-small {
	padding-left: 10px;
	padding-right: 10px;
	margin-bottom: 20px;
}

@media (min-width: 850px) {
	.products .product-small,
	.ux-relay .products .product-small {
		padding-left: 12px;
		padding-right: 12px;
		margin-bottom: 24px;
	}
}

/* ─── 3. Product card ─── */
.products .product-small .col-inner,
.ux-relay .product-small .col-inner {
	height: 100%;
}

.products .product-small .box,
.ux-relay .product-small .box,
.products .product-small .product-small.box {
	display: flex;
	flex-direction: column;
	height: 100%;
	background: #fff;
	border: 1px solid #eef1f5;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
	transition:
		transform 0.28s cubic-bezier(0.25, 0.8, 0.25, 1),
		box-shadow 0.28s cubic-bezier(0.25, 0.8, 0.25, 1),
		border-color 0.28s ease;
}

.products .product-small:hover .box,
.ux-relay .product-small:hover .box {
	transform: translateY(-6px);
	border-color: rgba(30, 115, 190, 0.18);
	box-shadow: 0 16px 40px rgba(30, 115, 190, 0.12);
}

/* ─── 4. Image zone (giữ hover Flatsome: .back-image / .show-on-hover) ─── */
.products .product-small .box-image,
.ux-relay .product-small .box-image {
	position: relative;
	background: #f8fafc;
	border-radius: 18px 18px 0 0;
	padding: 0;
	overflow: hidden;
}

/* Vùng ảnh bên trong — không padding trực tiếp lên .box-image */
.products .product-small .box-image > div:not(.image-tools):not(.out-of-stock-label),
.ux-relay .product-small .box-image > div:not(.image-tools):not(.out-of-stock-label) {
	position: relative;
	padding: 16px 12px;
	background: #f8fafc;
	overflow: hidden;
}

/* Ảnh chính — zoom nhẹ */
.products .product-small .box-image img:not(.back-image),
.ux-relay .product-small .box-image img:not(.back-image) {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 12px;
	transition: transform 0.45s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.45s ease;
}

.products .product-small.has-hover:hover .box-image img:not(.back-image),
.ux-relay .product-small.has-hover:hover .box-image img:not(.back-image) {
	transform: scale(1.04);
}

/* Ảnh gallery hover (fade in back) — Flatsome */
.products .product-small .box-image img.back-image,
.ux-relay .product-small .box-image img.back-image {
	opacity: 0 !important;
	border-radius: 12px;
	transform: none !important;
	will-change: opacity;
	transition: opacity 0.45s ease !important;
	z-index: 2;
}

.products .product-small.has-hover:hover .box-image img.back-image,
.ux-relay .product-small.has-hover:hover .box-image img.back-image,
.products .has-hover:hover .box-image .show-on-hover.back-image {
	opacity: 1 !important;
	transform: scale(1) translateZ(0) !important;
}

/* Fade in back: ẩn ảnh chính khi hover (tránh 2 ảnh chồng) */
.products .has-hover:hover .image-fade_in_back img:not(.back-image),
.ux-relay .has-hover:hover .image-fade_in_back img:not(.back-image),
.products .product-small.has-hover:hover .box-image:has(.back-image) img:not(.back-image),
.ux-relay .product-small.has-hover:hover .box-image:has(.back-image) img:not(.back-image) {
	opacity: 0;
}

.products .product-small.has-hover:hover .box-image img.back-image,
.ux-relay .product-small.has-hover:hover .box-image img.back-image {
	transform: none !important;
}

/* ─── 5. Sale badge — premium pill ─── */
.products .product-small .badge-container,
.ux-relay .product-small .badge-container,
.products .badge-container {
	top: var(--phonez-badge-offset) !important;
	right: var(--phonez-badge-offset) !important;
	left: auto !important;
	margin: 0 !important;
	z-index: 5;
}

/* Gỡ khung badge-circle legacy (style.css) — chỉ giữ pill .onsale */
.products .callout.badge,
.ux-relay .callout.badge,
.product-main .callout.badge {
	display: block;
	height: auto !important;
	width: auto !important;
	min-height: 0;
	top: 0 !important;
	margin: 0;
	padding: 0;
	border: none;
	border-radius: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	pointer-events: none;
}

.products .callout.badge .badge-inner,
.ux-relay .callout.badge .badge-inner,
.product-main .callout.badge .badge-inner {
	width: auto !important;
	height: auto !important;
	min-height: 0;
	transform: none;
	border: none;
	background: transparent !important;
}

.products .badge-inner.on-sale,
.products .onsale,
.ux-relay .badge-inner.on-sale,
.ux-relay .onsale,
.product-main .badge-inner.on-sale,
.product-main .onsale,
.badge-container .badge-inner.on-sale,
.badge-container .onsale {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	gap: 4px;
	box-sizing: border-box;
	min-width: auto !important;
	width: auto !important;
	height: auto !important;
	min-height: var(--phonez-badge-min-h) !important;
	padding: var(--phonez-badge-py) var(--phonez-badge-px) var(--phonez-badge-py) 28px !important;
	border: none !important;
	border-radius: var(--phonez-badge-radius) !important;
	background: var(--phonez-sale-bg) !important;
	background-image: var(--phonez-sale-bg) !important;
	color: #fff !important;
	font-size: var(--phonez-badge-font) !important;
	font-weight: var(--phonez-badge-fw) !important;
	line-height: var(--phonez-badge-lh) !important;
	letter-spacing: var(--phonez-badge-tracking);
	box-shadow: var(--phonez-sale-shadow);
	left: auto !important;
	bottom: auto !important;
}

.products .badge-inner.on-sale::before,
.products .onsale::before,
.ux-relay .badge-inner.on-sale::before,
.ux-relay .onsale::before,
.product-main .badge-inner.on-sale::before,
.product-main .onsale::before,
.badge-container .badge-inner.on-sale::before,
.badge-container .onsale::before {
	content: "" !important;
	position: absolute;
	left: 8px;
	top: 50%;
	transform: translateY(-50%);
	width: 14px !important;
	height: 14px !important;
	margin: 0 !important;
	border-radius: 0 !important;
	background-color: transparent !important;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23fff'%3E%3Cpath d='M7 2l12 10h-8l1 10-12-10h8z'/%3E%3C/svg%3E") !important;
	background-repeat: no-repeat !important;
	background-position: center !important;
	background-size: 12px !important;
}

.products .onsale span.amount,
.ux-relay .onsale span.amount,
.product-main .onsale span.amount,
.badge-container .onsale span.amount {
	color: #fff !important;
	font-size: inherit !important;
}

/* Ẩn badge % frame cũ nếu còn */
.products .badge-circle .badge-inner.on-sale,
.products .callout.badge .badge-inner.on-sale {
	border-radius: 999px !important;
}

/* ─── 5b. LikeNew — góc trái, đồng bộ pill với badge Giảm ─── */
.products .product-small .box-image,
.ux-relay .product-small .box-image {
	position: relative;
}

.phonez-likenew-badge {
	position: absolute;
	top: var(--phonez-badge-offset);
	left: var(--phonez-badge-offset);
	z-index: 6;
	pointer-events: none;
	line-height: 0;
}

.phonez-likenew-badge__text {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: var(--phonez-badge-min-h);
	padding: var(--phonez-badge-py) var(--phonez-badge-px);
	border: none;
	border-radius: var(--phonez-badge-radius);
	background: var(--phonez-likenew-bg);
	background-image: var(--phonez-likenew-bg);
	color: #fff;
	font-size: var(--phonez-badge-font);
	font-weight: var(--phonez-badge-fw);
	line-height: var(--phonez-badge-lh);
	letter-spacing: var(--phonez-badge-tracking);
	white-space: nowrap;
	box-shadow: var(--phonez-likenew-shadow);
}

/* Trang chi tiết — .product-images có class relative (Flatsome) */
.product-main .product-images,
.product-main .product-gallery {
	position: relative;
}

.product-main .badge-container.is-larger {
	top: var(--phonez-badge-offset) !important;
	right: var(--phonez-badge-offset) !important;
}

.product-main .phonez-likenew-badge {
	top: var(--phonez-badge-offset);
	left: var(--phonez-badge-offset);
	z-index: 12;
}

/* ─── 6. Product title (tối đa 4 dòng — không cắt sớm như 2 dòng cũ) ─── */
.products .product-small .box-text,
.ux-relay .product-small .box-text {
	padding: 14px 14px 16px !important;
	text-align: left !important;
	flex: 1;
	display: flex;
	flex-direction: column;
}

.products .product-small .title-wrapper,
.ux-relay .product-small .title-wrapper {
	/* Cùng chiều cao vùng tên → card thẳng hàng */
	min-height: 5.8em;
	margin-bottom: 4px;
}

.products .product-small .product-title,
.ux-relay .product-small .product-title {
	margin: 0;
	line-height: 1.45;
}

.products .product-small .product-cat,
.ux-relay .product-small .product-cat {
	display: block;
	margin-bottom: 6px;
	overflow: visible;
	text-overflow: unset;
	white-space: normal;
	font-size: 0.6875rem;
	letter-spacing: 0.06em;
	opacity: 0.65;
}

.products .product-small .product-title a,
.ux-relay .product-small .product-title a {
	display: -webkit-box;
	-webkit-line-clamp: 4;
	line-clamp: 4;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 0.875rem !important;
	font-weight: 600 !important;
	line-height: 1.45 !important;
	color: #2a2a2a !important;
	transition: color 0.2s ease;
	word-break: break-word;
}

.products .product-small:hover .product-title a,
.ux-relay .product-small:hover .product-title a {
	color: #1e73be !important;
}

/* ─── 7. Price ─── */
.products .product-small .price-wrapper,
.ux-relay .product-small .price-wrapper {
	margin-top: auto;
	padding-top: 8px;
}

.products .product-small .price,
.ux-relay .product-small .price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 6px 8px;
	line-height: 1.3;
}

.products .product-small .price ins,
.ux-relay .product-small .price ins {
	order: 1;
	text-decoration: none;
}

.products .product-small .price ins .amount,
.ux-relay .product-small .price ins .amount,
.products .product-small .price > .amount:not(del .amount),
.ux-relay .product-small .price > .woocommerce-Price-amount {
	font-size: 1.0625rem !important;
	font-weight: 700 !important;
	color: #c62828 !important;
}

.products .product-small .price del,
.ux-relay .product-small .price del {
	order: 2;
	opacity: 1;
}

.products .product-small .price del .amount,
.ux-relay .product-small .price del .amount {
	font-size: 0.8125rem !important;
	font-weight: 500 !important;
	color: #9ca3af !important;
	text-decoration: line-through;
}

/* Liên hệ / giá custom */
.products .product-small .price .amount:empty,
.products .product-small .price {
	font-size: 0.9375rem;
}

/* Rating */
.products .product-small .phakerate,
.ux-relay .product-small .phakerate {
	margin-top: 6px;
	font-size: 0.75rem;
}

.products .product-small .phakerate .point,
.ux-relay .product-small .phakerate .point {
	color: #f59e0b;
}

/* ─── 8. UX Relay / pagination trong section SP ─── */
.ux-relay__control--bottom {
	margin-top: 1.5rem;
	padding-top: 0.5rem;
}

/* ─── 9. Mobile ─── */
@media (max-width: 549px) {
	.section-title .section-title-main {
		font-size: 0.9375rem !important;
		letter-spacing: 0.04em;
	}

	.products .product-small,
	.ux-relay .products .product-small {
		padding-left: 6px;
		padding-right: 6px;
		margin-bottom: 14px;
	}

	.products .product-small .box,
	.ux-relay .product-small .box {
		border-radius: 16px;
	}

	.products .product-small .box-image > div:not(.image-tools),
	.ux-relay .product-small .box-image > div:not(.image-tools) {
		padding: 12px 10px;
	}

	.products .product-small .title-wrapper,
	.ux-relay .product-small .title-wrapper {
		min-height: 5.4em;
	}

	.products .product-small .product-title a,
	.ux-relay .product-small .product-title a {
		font-size: 0.8125rem !important;
		-webkit-line-clamp: 4;
		line-clamp: 4;
	}

	.products .product-small .price ins .amount {
		font-size: 1rem !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.products .product-small .box,
	.products .product-small .box-image img:not(.back-image),
	.products .product-small .box-image img.back-image {
		transition-duration: 0.15s;
	}

	.products .product-small.has-hover:hover .box-image img:not(.back-image) {
		transform: none;
	}

	.products .product-small:hover .box {
		transform: translateY(-2px);
	}
}
