/* ==========================================================================
   Single product — stock indicator + related / recently-viewed modules.
   ========================================================================== */

:root {
	--wm-sp-border: #E4E7EB;
	--wm-sp-text: var(--color-text-primary, #212529);
	--wm-sp-muted: #6B7280;
	--wm-sp-primary: var(--color-primary, #EF233C);
	--wm-sp-success: #16A34A;
	--wm-sp-warning: #D97706;
	--wm-sp-danger: #DC2626;
}

/* -------------------- Visible stock badge -------------------- */

.wm-single-stock {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 6px 0 14px;
	padding: 6px 12px;
	border: 1px solid var(--wm-sp-border);
	border-radius: 999px;
	background: #fff;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	color: var(--wm-sp-text);
}

.wm-single-stock__dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: currentColor;
	flex-shrink: 0;
}

.wm-single-stock.is-in {
	color: var(--wm-sp-success);
	border-color: rgba(22, 163, 74, 0.3);
	background: rgba(22, 163, 74, 0.06);
}

.wm-single-stock.is-backorder {
	color: var(--wm-sp-warning);
	border-color: rgba(217, 119, 6, 0.3);
	background: rgba(217, 119, 6, 0.06);
}

.wm-single-stock.is-out {
	color: var(--wm-sp-danger);
	border-color: rgba(220, 38, 38, 0.3);
	background: rgba(220, 38, 38, 0.06);
}

/* Hide the parent theme's redundant stock line inside rating.php so we don't
   show the same information twice. */
.product-detail .klb-single-stock { display: none; }

/* -------------------- Related / Up-sells / Recently viewed modules ----------

   These three modules render on the single product page via:
     - parent theme `partdo/woocommerce/single-product/related.php`
       → <section class="klb-module related products" id="related-products">
     - child override `woocommerce/single-product/up-sells.php`
       → <section class="klb-module up-sells products" id="up-sell-products">
     - child hook in `inc/single-product.php` (webmerc_render_recently_viewed)
       → <section class="klb-module recently-viewed" id="recently-viewed-products">

   Selectors below are scoped by the section `id` attribute so they match
   regardless of which class combinations survive on the element. Each
   renders the standard Woo loop via `wc_get_template_part( 'content',
   'product' )` — resolved to our child `woocommerce/content-product.php`
   template emitting `<li class="wm-card">…<article class="wm-card__inner">…`
   markup.

   The archive stylesheet `assets/css/shop-listing.css` is NOT enqueued on
   single product pages, so none of its `.wm-card` rules apply here. We
   provide a compact, VERTICAL card layout (stacked media → body → aside)
   — opposite of the 3-column horizontal list-view card used on archives.
   -------------------------------------------------------------------------- */

:is(#related-products, section.related, section.klb-module.related),
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells),
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) {
	width: 100%;
	flex-basis: 100%;
	margin-top: 3rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--wm-sp-border);
	clear: both;
}

:is(#related-products, section.related, section.klb-module.related) .klb-title.module-header,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .klb-title.module-header,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .klb-title.module-header {
	margin: 0 0 1.25rem;
}

:is(#related-products, section.related, section.klb-module.related) .entry-title,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .entry-title,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .entry-title,
:is(#related-products, section.related, section.klb-module.related) > h2,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) > h2,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) > h2 {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.2;
	color: var(--wm-sp-text);
}

@media (min-width: 64rem) {
	:is(#related-products, section.related, section.klb-module.related),
	:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells),
	:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) {
		margin-top: 4rem;
	}

	:is(#related-products, section.related, section.klb-module.related) .entry-title,
	:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .entry-title,
	:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .entry-title,
	:is(#related-products, section.related, section.klb-module.related) > h2,
	:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) > h2,
	:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) > h2 {
		font-size: 1.5rem;
	}
}

/* Product grid — we look for `.products` (or `.products` as fallback if
   the loop-start template emits a <div> instead of a <ul>). `!important`
   beats any parent-theme flex / float rules that might still reach us. */

:is(#related-products, section.related, section.klb-module.related) .products,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .products,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .products,
:is(#related-products, section.related, section.klb-module.related) > .products,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) > .products,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) > .products {
	display: grid !important;
	grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
	gap: 18px !important;
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
	width: 100% !important;
}

@media (max-width: 1199.98px) {
	:is(#related-products, section.related, section.klb-module.related) .products,
	:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .products,
	:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .products,
	:is(#related-products, section.related, section.klb-module.related) > .products,
	:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) > .products,
	:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) > .products {
		grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
	}
}

@media (max-width: 991.98px) {
	:is(#related-products, section.related, section.klb-module.related) .products,
	:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .products,
	:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .products,
	:is(#related-products, section.related, section.klb-module.related) > .products,
	:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) > .products,
	:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) > .products {
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
	}
}

@media (max-width: 640px) {
	:is(#related-products, section.related, section.klb-module.related) .products,
	:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .products,
	:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .products,
	:is(#related-products, section.related, section.klb-module.related) > .products,
	:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) > .products,
	:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) > .products {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		gap: 12px !important;
	}
}

/* Grid cell (<li class="wm-card product">) — override any parent-theme
   width / margin / float / flex that might reach it. */
:is(#related-products, section.related, section.klb-module.related) .wm-card,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card,
:is(#related-products, section.related, section.klb-module.related) .products > li.product,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .products > li.product,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .products > li.product {
	display: block !important;
	width: auto !important;
	max-width: none !important;
	margin: 0 !important;
	float: none !important;
	padding: 0 !important;
	list-style: none !important;
}

/* Card chrome — VERTICAL layout (opposite of archive's horizontal 3-col
   grid). `!important` on flex / grid-template-columns beats shop-listing.css
   if it ever leaks in. */
:is(#related-products, section.related, section.klb-module.related) .wm-card__inner,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__inner,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__inner {
	display: flex !important;
	flex-direction: column !important;
	grid-template-columns: none !important;
	gap: 0 !important;
	padding: 0 !important;
	border: 1px solid var(--wm-sp-border) !important;
	border-radius: 8px !important;
	background: #fff !important;
	overflow: hidden !important;
	height: 100% !important;
	box-shadow: none !important;
	transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease !important;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card:hover .wm-card__inner,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card:hover .wm-card__inner,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card:hover .wm-card__inner {
	border-color: var(--wm-sp-primary) !important;
	box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08) !important;
	transform: translateY(-2px);
}

/* Media — square, contained image, top of the card. */
:is(#related-products, section.related, section.klb-module.related) .wm-card__media,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__media,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__media {
	position: relative !important;
	width: auto !important;
	height: auto !important;
	aspect-ratio: 1 / 1 !important;
	flex: 0 0 auto !important;
	border: 0 !important;
	border-radius: 0 !important;
	background: #f7f8fa !important;
	display: block !important;
	overflow: hidden !important;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__media img,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__media img,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__media img {
	width: 100% !important;
	height: 100% !important;
	object-fit: contain !important;
	padding: 8px !important;
	transform: none !important;
}

/* Sale badge — scaled down. */
:is(#related-products, section.related, section.klb-module.related) .wm-card__flash,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__flash,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__flash {
	position: absolute;
	top: 6px;
	left: 6px;
	font-size: 10px;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 4px;
	background: var(--wm-sp-primary);
	color: #fff;
	line-height: 1;
}

/* Body — title + (hidden) meta + (hidden) attrs. */
:is(#related-products, section.related, section.klb-module.related) .wm-card__body,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__body,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__body {
	display: flex !important;
	flex-direction: column !important;
	padding: 12px 14px 0 !important;
	gap: 6px !important;
	flex: 1 1 auto !important;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__head,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__head,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__head {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__title,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__title,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__title {
	margin: 0 !important;
	font-size: 13.5px !important;
	font-weight: 600 !important;
	line-height: 1.35 !important;
	display: -webkit-box !important;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: calc(13.5px * 1.35 * 2);
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__title a,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__title a,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__title a {
	color: inherit !important;
	text-decoration: none !important;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__title a:hover,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__title a:hover,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__title a:hover {
	color: var(--wm-sp-primary) !important;
}

/* Hide meta + attribute chips inside compact modules to keep cards tight. */
:is(#related-products, section.related, section.klb-module.related) .wm-card__meta,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__meta,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__meta,
:is(#related-products, section.related, section.klb-module.related) .wm-card__attrs,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__attrs,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__attrs {
	display: none !important;
}

/* Aside — stock pill, price, primary CTA. Flip the archive's left-border
   into a top-border since layout is vertical here. */
:is(#related-products, section.related, section.klb-module.related) .wm-card__aside,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__aside,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__aside {
	margin-top: auto !important;
	padding: 10px 14px 12px !important;
	border-left: 0 !important;
	border-top: 1px solid var(--wm-sp-border) !important;
	gap: 8px !important;
	display: flex !important;
	flex-direction: column !important;
	justify-content: flex-start !important;
	align-items: stretch !important;
}

/* Stock pill — compact, self-contained colour set (archive CSS not loaded). */
:is(#related-products, section.related, section.klb-module.related) .wm-card__stock,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__stock,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__stock {
	display: inline-flex !important;
	align-items: center !important;
	gap: 5px !important;
	font-size: 11px !important;
	font-weight: 600 !important;
	line-height: 1 !important;
	padding: 2px 8px 2px 6px !important;
	border-radius: 999px !important;
	align-self: flex-start !important;
	max-width: 100%;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__stock-dot,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__stock-dot,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__stock-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
	flex-shrink: 0;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__stock--in,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__stock--in,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__stock--in {
	background: #f0fdf4 !important;
	color: #16a34a !important;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__stock--back,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__stock--back,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__stock--back {
	background: #fffbeb !important;
	color: #b45309 !important;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__stock--out,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__stock--out,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__stock--out {
	background: #fef2f2 !important;
	color: #dc2626 !important;
}

/* Price. */
:is(#related-products, section.related, section.klb-module.related) .wm-card__price,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__price,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__price {
	font-size: 15px !important;
	font-weight: 700 !important;
	color: var(--wm-sp-primary) !important;
	line-height: 1.2 !important;
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 6px;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__price del,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__price del,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__price del {
	color: var(--wm-sp-muted) !important;
	font-weight: 400 !important;
	opacity: 0.7 !important;
	margin-right: 6px;
	text-decoration: line-through !important;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__price ins,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__price ins,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__price ins {
	text-decoration: none !important;
	background: transparent !important;
	color: var(--wm-sp-primary) !important;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__price .price-without-tax,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__price .price-without-tax,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__price .price-without-tax,
:is(#related-products, section.related, section.klb-module.related) .wm-card__price small,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__price small,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__price small {
	display: block;
	width: 100%;
	margin-top: 2px;
	font-size: 11.5px;
	font-weight: 500;
	color: var(--wm-sp-muted);
}

/* Actions — compact add-to-cart only; hide secondary "Detail" link. */
:is(#related-products, section.related, section.klb-module.related) .wm-card__actions,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__actions,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__actions {
	display: flex !important;
	gap: 6px !important;
	align-items: center;
	flex-wrap: wrap;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__actions .button,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__actions .button,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__actions .button,
:is(#related-products, section.related, section.klb-module.related) .wm-card__actions .added_to_cart,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__actions .added_to_cart,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__actions .added_to_cart {
	display: inline-flex !important;
	align-items: center !important;
	gap: 6px !important;
	padding: 8px 10px !important;
	font-size: 12px !important;
	font-weight: 600 !important;
	border-radius: 6px !important;
	height: auto !important;
	line-height: 1.2 !important;
	min-height: 0 !important;
}

:is(#related-products, section.related, section.klb-module.related) .wm-card__view,
:is(#up-sell-products, section.up-sells, section.upsells, section.klb-module.up-sells) .wm-card__view,
:is(#recently-viewed-products, section.recently-viewed, section.klb-module.recently-viewed) .wm-card__view {
	display: none !important;
}
