/* ==========================================================================
   Koko Mart — Product Card
   Matches Figma node 27:638
   ========================================================================== */

/* ─── Card Container ───────────────────────────────────────────────────── */

.km-product-card {
	background: var(--wp--preset--color--white, #fff);
	border-radius: var(--km-radius-xs, 4px);
	border: 1px solid var(--wp--preset--color--border, #e2e2e2);
}

.wc-block-product-template.is-layout-flow {
	& .km-product-card {
		display: flex;
		flex-direction: column;
	}
}

.wc-block-product-template.is-layout-flex {
	& .km-product-card {
		display: flex;
		flex-direction: column;
		width: 150px;
		overflow: hidden;
		position: relative;
		flex-shrink: 0;
	}
}

/* ─── Image ────────────────────────────────────────────────────────────── */

.km-product-card .km-product-card__image {
	aspect-ratio: 1;
	background: var(--wp--preset--color--white, #fff);
	overflow: hidden;
	margin: 0;
	padding: 4px;
}

.km-product-card .km-product-card__image img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	border-radius: 0;
}

/* ─── "Pilih Lokal" Badge ──────────────────────────────────────────────── */

.km-product-card__badge {
	position: absolute;
	top: 6px;
	right: 6px;
	z-index: 1;
	background: rgba(232, 136, 127, 0.16);
	color: var(--wp--preset--color--primary, #c1382d);
	font-size: 10px;
	font-weight: 500;
	line-height: 1.3;
	letter-spacing: 0.1px;
	padding: 2px 4px;
	border-radius: 4px;
	text-align: center;
	white-space: nowrap;
}

/* ─── Content Area ─────────────────────────────────────────────────────── */

.km-product-card__content {
	display: flex;
	flex-direction: column;
	flex-grow: 1;
	gap: var(--km-space-xs);
	padding: 8px 8px 12px;
	justify-content: space-between;
}

/* ─── Title ────────────────────────────────────────────────────────────── */

.km-product-card .km-product-card__title .wp-block-post-title{
	font-size: var(--wp--preset--fontSizes--lg);
	font-weight: 400;
	line-height: 1.4;
	color: var(--wp--preset--color--black, #141413);
	margin: 0;
}

.km-product-card {
	.km-product-card__title, .wp-block-post-title {
		a {
			color: inherit;
			text-decoration: none;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 3;
			line-clamp: 3;
			overflow: hidden;
			text-overflow: ellipsis;
		}
	}
}

/* ─── Price ────────────────────────────────────────────────────────────── */

/*
 * WooCommerce renders del + ins (+ our injected badge) as siblings inside
 * span.wc-block-components-product-price__value.
 *
 * Desired two-row layout:
 *   Row 1 → [del strikethrough]  [% badge]
 *   Row 2 → [ins current price]
 *
 * flex-wrap: wrap + flex: 0 0 100% on ins forces it onto a new row.
 */

.km-product-card {
	overflow: hidden;
}

/*
 * Both old WC block markup (del/ins direct children of price div)
 * and new markup (__value wrapper in between) need the same flex row.
 */
.single-product .wc-block-components-product-price,
.single-product .wc-block-components-product-price__value,
.km-product-card .wc-block-components-product-price,
.km-product-card .wc-block-components-product-price__value {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px;
	margin: 0;
}

/* Original (strikethrough) price — the <del> element */
.km-product-card .wc-block-components-product-price del {
	font-size: var(--km-fs-md);
	font-weight: 500;
	color: var(--wp--preset--color--neutral-300, #d4d4d3);
	line-height: 1.3;
}

/* % discount badge — injected by woocommerce_get_price_html filter */
.km-product-card__sale-badge {
	background: var(--wp--preset--color--primary-400, #d95a4f);
	color: #fff;
	font-size: 10px;
	font-weight: 500;
	line-height: 1.3;
	letter-spacing: 0.1px;
	padding: 0 4px;
	border-radius: 6px;
	white-space: nowrap;
}

/* Sale price (ins) — pushed to its own row so layout is:
 *   Row 1 → [del]  [% badge]
 *   Row 2 → [ins current price]
 * Descendant selector covers both old (direct child) and new (__value wrapper) markup.
 */
.single-product .wc-block-components-product-price ins,
.km-product-card .wc-block-components-product-price ins {
	flex: 0 0 100%;
}

/* Current / sale price */
.km-product-card .wc-block-components-product-price {
	font-size: var(--km-fs-xl);
	font-weight: 600;
	line-height: 1.2;
	color: var(--wp--preset--color--black, #141413);
	text-decoration: none;
}
	
/* Regular (non-sale) price */
.km-product-card .wc-block-components-product-price ins .woocommerce-Price-amount {
	font-size: var(--km-fs-xl);
	font-weight: 600;
	line-height: 1.2;
	color: var(--wp--preset--color--black, #141413);
}

/* ─── Footer: Rating + Terjual ─────────────────────────────────────────── */

.km-product-card__footer {
	display: flex;
	gap: 4px;
	align-items: center;
	margin-top: auto;
}

.km-product-card__rating {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	font-size: 12px;
	font-weight: 500;
	color: rgba(20, 20, 19, 0.6);
	line-height: 1.3;
}

.km-product-card__rating svg {
	width: 12px;
	height: 12px;
	flex-shrink: 0;
}

.km-product-card__divider {
	width: 0;
	height: 12px;
	border-left: 0.5px solid rgba(20, 20, 19, 0.6);
}

.km-product-card__sold {
	font-size: 12px;
	font-weight: 500;
	color: rgba(20, 20, 19, 0.6);
	line-height: 1.3;
	white-space: nowrap;
}

/* ─── WooCommerce Block Resets inside Card ─────────────────────────────── */

.h-full {
	height: 100%;
}

.wc-block-product-template.is-layout-flex{
	margin-block-start: 0;
	height: auto !important;
	display: flex;
	align-items: stretch;
	padding: 0 var(--wp--preset--spacing--md);
}

.km-product-card .wc-block-components-product-image {
	margin: 0;
}

.km-product-card .wp-block-post-title {
	margin: 0 !important;
	text-align: left;
	font-size: var(--km-fs-lg) !important;
}

.km-product-card .wp-block-woocommerce-product-price {
	text-align: left;
}

.km-product-card .wc-block-components-product-sale-badge{
	display: none;
}
/* ─── Product Grid (block-based product-template) ──────────────────────── */

.km-product-grid {
	display: grid !important;
	grid-template-columns: repeat(2, 1fr) !important;
	gap: 8px !important;
	list-style: none !important;
	padding: 0 !important;
}

.km-product-grid .wc-block-product {
	padding: 0 !important;
}

@media (min-width: 768px) {
	.km-product-grid {
		grid-template-columns: repeat(4, 1fr) !important;
	}
}
