/*
 * News "Sản phẩm hot" — list ngang gói sản phẩm trên trang news.
 *
 * Layout 100vw breakout giống .iw-news-featured: outer container full-width,
 * inner __inner cap về container-max + padding.
 *
 * <=4 gói: hiển thị flex tĩnh (no slider).
 * >4 gói:  Swiper init (markup .swiper/.swiper-wrapper/.swiper-slide), nav prev/next.
 *
 * Mobile (<=991px): vertical stack, mỗi card = row (image trái + title/detail phải),
 * KHÔNG dùng Swiper (CSS column override Swiper width tính sẵn → see iw-news-product.js).
 *
 * Design: Figma 407:50131 (desktop), 407:51702 (mobile).
 */

.iw-news-product {
	width: 100vw;
	max-width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
	background: #ffffff;
	font-family: inherit;
	color: #3d3d3d;
	-webkit-font-smoothing: antialiased;
}

.iw-news-product__inner {
	max-width: var(--iw-container-max);
	margin: 0 auto;
	padding: 0px var(--iw-container-pad-x);
	box-sizing: border-box;
}

/* Archive variant: block ở category page có padding dọc 40px (Figma category). */
.iw-news-product--archive .iw-news-product__inner {
	padding-top: 40px;
	padding-bottom: 40px;
}

/* ─── Single variant: shortcode nhúng giữa nội dung bài viết (.iw-article__inner
   max 700px). Bỏ 100vw breakout, fit parent column. >3 gói → slider (JS đọc
   modifier `--single`, set slidesPerView=3 desktop). Sidebar related products
   render qua article-sidebar.php (markup khác, dùng key meta `limit_sidebar`).
   Figma 407:51236 (desktop), 407:51305 (mobile).
*/
.iw-news-product--single {
	/* width: 100%;
	max-width: 100%;
	margin-left: 0;
	margin-right: 0; */
}
.iw-news-product--single .iw-news-product__inner {
	/* max-width: 100%;
	padding: 24px 0; */
}
.iw-news-product--single .iw-news-product__heading {
	font-size: 20px;
	line-height: 28px;
	margin: 16px 0;
}
/* Pre-init flex card width nhỏ để không tràn 700px column. */
.iw-news-product--single .iw-news-product__slider:not(.swiper-initialized) .swiper-wrapper {
	gap: 16px;
}
.iw-news-product--single .iw-news-product__slider:not(.swiper-initialized) .swiper-slide,
.iw-news-product--single .iw-news-product__list {
	gap: 16px;
}
.iw-news-product--single .iw-news-product__slider:not(.swiper-initialized) .swiper-slide {
	flex: 0 0 calc((100% - 32px) / 3);
	width: calc((100% - 32px) / 3);
}
.iw-news-product--single .iw-news-product__card {
	width: 100%;
	gap: 12px;
}
.iw-news-product--single .iw-news-product__img {
	margin: 0;
	width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.iw-news-product--single .iw-news-product__title {
	font-size: 15px;
	line-height: 20px;
	margin: 0;
}
.iw-news-product--single .iw-news-product__price {
	font-size: 13px;
	line-height: 18px;
}
.iw-news-product--single .iw-news-product__cta {
	padding: 10px 16px;
	font-size: 14px;
	line-height: 20px;
	color: #fff;
	margin: 0;
	margin-top: auto;
	text-decoration: none;
	text-underline-offset: 0;
}
/* Nav buttons: card nhỏ hơn → kích thước nút giảm. Vị trí top đã được JS
   tính runtime qua var --iw-news-product-nav-top (xem rule chính bên dưới). */
.iw-news-product--single .iw-news-product__nav {
	width: 32px;
	height: 32px;
	min-height: auto;
}
.iw-news-product--single .iw-news-product__nav--prev { left: -12px; }
.iw-news-product--single .iw-news-product__nav--next { right: -12px; }

/* `--single` variant @media overrides ─── gộp xuống cuối file cùng với
   `@media (max-width: 991px)` chính (xem section Responsive). */

.iw-news-product__heading {
	margin: 0 0 16px;
	color: #181d27;
	font-family: inherit;
	font-size: 32px;
	font-weight: 700;
	line-height: 44px;
}

/* ─── Slider wrap ─── */
.iw-news-product__slider-wrap {
	position: relative;
}

/* Pre-init layout (chưa có .swiper-initialized) — flex tĩnh để tránh FOUC card
   phình to. Swiper init xong sẽ set width inline → override gap/flex của ta. */
.iw-news-product__slider:not(.swiper-initialized) .swiper-wrapper {
	display: flex;
	flex-direction: row;
	gap: 32px;
}
.iw-news-product__slider:not(.swiper-initialized) .swiper-slide {
	flex: 0 0 336px;
	width: 336px;
}

/* Static (no slider, ≤4 gói): direct flex, no Swiper class. */
.iw-news-product__list {
	display: flex;
	flex-direction: row;
	gap: 32px;
}

/* ─── Card ─── */
.iw-news-product__card {
	flex: 0 0 auto;
	width: 336px;
	display: flex;
	flex-direction: column;
	gap: 20px;
	height: 100%;
}

/* Equal-height (Swiper):
   - swiper-wrapper align-items: stretch → các slide cùng height = tallest
   - swiper-slide display:flex + height:auto → slide thành flex container, card
     bên trong stretch dọc tự nhiên
   - __body flex:1 + __cta margin-top:auto → CTA luôn align bottom card.
   Apply cho mọi variant (--single, --archive, default). */
.iw-news-product__slider .swiper-wrapper {
	align-items: stretch;
}
.iw-news-product__slider .swiper-slide {
	height: auto;
	display: flex;
}
.iw-news-product__body {
	flex: 1;
}


.iw-news-product__media {
	display: block;
	width: 100%;
	aspect-ratio: 500 / 361;
	border-radius: 8px;
	overflow: hidden;
	background: #f7f7f8;
}
.iw-news-product__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.iw-news-product__body {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.iw-news-product__title {
	margin: 0;
	font-family: inherit;
	font-size: 18px;
	font-weight: 590;
	line-height: 22px;
	color: #3d3d3d;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.iw-news-product__title a {
	color: inherit;
	text-decoration: none;
}
.iw-news-product__title a:hover {
	color: var(--iw-accent, #4564ed);
}

/* ─── Price row ─── */
.iw-news-product__price {
	display: flex;
	align-items: baseline;
	gap: 4px;
	margin: 0;
	font-family: inherit;
	font-size: 14px;
	line-height: 20px;
	white-space: nowrap;
}
.iw-news-product__price-label  { color: #888; font-weight: 400; }
.iw-news-product__price-value  { color: var(--iw-accent, #4564ed); font-weight: 590; }
.iw-news-product__price-period { color: var(--iw-accent, #4564ed); font-weight: 590; }

/* ─── Đăng ký ngay button ─── */
.iw-news-product__cta {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	padding: 13px 24px;
	background: var(--iw-cta-bg, #4564ed);
	color: var(--iw-cta-fg, #fff);
	font-family: inherit;
	font-size: 16px;
	font-weight: 510;
	line-height: 22px;
	text-align: center;
	text-decoration: none;
	border-radius: 8px;
	box-sizing: border-box;
	transition: background 0.2s;
	margin-top: auto;
}
.iw-news-product__cta:hover {
	background: var(--iw-cta-bg-hover, #3a52c4);
	color: var(--iw-cta-fg, #fff);
}

/* ─── Nav buttons (Swiper prev/next, chỉ hiển thị khi >4 gói init Swiper) ─── */
.iw-news-product__nav {
	position: absolute;
	/* Vertical center của image — JS đo image height runtime, set var trên
	   slider-wrap. Fallback 121px = card 336 × aspect 500/361 ≈ 243 / 2. */
	top: var(--iw-news-product-nav-top, 121px);
	transform: translateY(-50%);
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 1px solid #e7e7e7;
	background: #fff;
	color: var(--iw-accent, #4564ed); /* chevron (svg currentColor) theo scheme */
	cursor: pointer;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.2s, background 0.2s;
	margin: 0;
	padding: 0;
	/* Reset Flatsome default `button` styles có thể inject icon/shadow. */
	box-shadow: none;
	text-shadow: none;
}
.iw-news-product__nav > svg {
	display: block;
	width: 14px;
	height: 14px;
	flex-shrink: 0;
}
.iw-news-product__nav--prev { left: -20px; }
.iw-news-product__nav--next { right: -20px; }
.iw-news-product__nav:hover { background: #f7f7f8; }
.iw-news-product__nav.swiper-button-disabled {
	opacity: 0.35;
	cursor: default;
	pointer-events: none;
}
/* Swiper add `.swiper-button-lock` khi watchOverflow detect tất cả slides fit
   → ≤4 gói desktop không cần scroll → ẩn hẳn nav. */
.iw-news-product__nav.swiper-button-lock { display: none; }

/* ─── Mobile: vẫn horizontal scroll, Swiper init bình thường ─── */
@media (max-width: 991px) {
	.iw-news-product__heading {
		padding: 0 var(--iw-container-pad-x);
		font-size: 24px;
		line-height: 32px;
	}

	/* Static list (≤4 gói): edge-bleed scroll ngang. Container padding 0,
	   first/last card mang margin = container-pad-x → tab cuối không bị cắt
	   khi scroll hết (xem feedback news-tabs về padding-right scroll bug). */
	.iw-news-product__list {
		flex-direction: row;
		gap: 16px;
		overflow-x: auto;
		overflow-y: hidden;
		scrollbar-width: none;
		-ms-overflow-style: none;
		-webkit-overflow-scrolling: touch;
		scroll-snap-type: x proximity;
		scroll-padding-left: var(--iw-container-pad-x);
	}
	.iw-news-product__list::-webkit-scrollbar { display: none; }
	.iw-news-product__list > .iw-news-product__card:first-child {
		margin-left: var(--iw-container-pad-x);
	}
	.iw-news-product__list > .iw-news-product__card:last-child {
		margin-right: var(--iw-container-pad-x);
	}

	/* Swiper slider-wrap: padding 2 bên + offsetBefore/After ở JS để first/last
	   card thẳng hàng với heading. */
	.iw-news-product__slider-wrap {
		margin: 0;
	}

	/* Card mobile: vertical card thu nhỏ — image top, title + detail bottom.
	   Width 280px ≈ 2.x cards visible trên 360-414 viewport. */
	.iw-news-product__card,
	.iw-news-product__slider .swiper-slide {
		width: 280px;
	}
	.iw-news-product__slider:not(.swiper-initialized) .swiper-slide {
		flex: 0 0 280px;
		width: 280px;
	}
	.iw-news-product__card {
		scroll-snap-align: start;
	}

	/* Mobile: aspect-ratio kế thừa từ rule chung — không cần override. */

	.iw-news-product__title {
		font-size: 14px;
		line-height: 20px;
	}

	.iw-news-product__price {
		font-size: 13px;
		line-height: 18px;
	}
	.iw-news-product__cta {
		padding: 10px 16px;
		font-size: 14px;
		line-height: 20px;
	}

	/* `--single` variant overrides (moved from line 113-127 cũ). */
	.iw-news-product--single .iw-news-product__heading {
		padding: 0;
		font-size: 18px;
		line-height: 24px;
	}
	.iw-news-product--single .iw-news-product__inner {
		padding: 16px;
	}
	.iw-news-product--single .iw-news-product__list > .iw-news-product__card:first-child,
	.iw-news-product--single .iw-news-product__list > .iw-news-product__card:last-child {
		margin-left: 0;
		margin-right: 0;
	}
}

@media (max-width: 540px) {

	.iw-news-product__inner {
		/* Mobile: bỏ padding-x trên inner, slider bleed full viewport. Heading
		   tự có padding-x riêng → cân đúng với slidesOffsetBefore của Swiper. */
		padding: 0;
	}

	/* Nav buttons ẩn ở mobile — touch swipe đủ. */
	.iw-news-product__nav { display: none; }
}
