/* Same variable names as Khulna Social's ks-style.css (--ks-*), so when
   that stylesheet is loaded (it always is, site-wide) both plugins stay
   in perfect visual sync automatically. This :root block only acts as a
   fallback in case Khulna Social's own stylesheet is ever missing. */
:root {
	--ks-primary: #0A2647;
	--ks-bg: #FFFFFF;
	--ks-accent: #10B981;
	--ks-border: #E7ECF3;
	--ks-muted: #6B7A90;
	--ks-danger: #E24C4C;
}

.km-marketplace {
	max-width: 960px;
	margin: 0 auto;
}

/* ---------------- Filter bar ---------------- */
.km-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 14px;
}

.km-filter-search {
	position: relative;
	flex: 1 1 200px;
	display: flex;
	align-items: center;
}

.km-filter-search .dashicons {
	position: absolute;
	left: 10px;
	color: var(--ks-muted);
	font-size: 16px;
	width: 16px;
	height: 16px;
}

.km-search-input {
	width: 100%;
	padding: 8px 10px 8px 32px;
	border: 1px solid var(--ks-border);
	border-radius: 8px;
	font-size: 13px;
}

.km-thana-select,
.km-sort-select {
	padding: 8px 10px;
	border: 1px solid var(--ks-border);
	border-radius: 8px;
	font-size: 13px;
	background: var(--ks-bg);
	color: var(--ks-primary);
}

.km-search-input:focus,
.km-thana-select:focus,
.km-sort-select:focus {
	outline: none;
	border-color: var(--ks-accent);
}

/* ---------------- Product grid (3 per row, same card shape as "My Store") ---------------- */
.km-product-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 12px;
}

.km-no-products {
	grid-column: 1 / -1;
	text-align: center;
	color: var(--ks-muted);
	padding: 24px 0;
}

/* Shown above the grid when the exact search had nothing and we fell
   back to nearby-price / related / newest items instead — see
   KM_Ajax::related_query(). */
.km-search-notice {
	grid-column: 1 / -1;
	font-size: 13px;
	color: var(--ks-muted);
	background: var(--ks-bg-soft, #F5F6F8);
	border-radius: 8px;
	padding: 8px 12px;
	margin: 0 0 10px;
}

.km-product-card {
	background: var(--ks-bg);
	border: 1px solid var(--ks-border);
	border-radius: 10px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.km-product-open {
	background: none;
	border: none;
	padding: 0;
	margin: 0;
	text-align: left;
	cursor: pointer;
	display: block;
	width: 100%;
}

.km-product-image {
	aspect-ratio: 1 / 1;
	background: var(--ks-border);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.km-product-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.km-product-image .dashicons {
	font-size: 26px;
	width: 26px;
	height: 26px;
	color: var(--ks-muted);
}

.km-product-name {
	font-size: 12px;
	font-weight: 600;
	color: var(--ks-primary);
	padding: 6px 8px 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.km-product-seller {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 4px 8px 0;
	text-decoration: none;
}

.km-product-seller img {
	border-radius: 50%;
	width: 18px;
	height: 18px;
}

.km-product-seller span {
	font-size: 11px;
	color: var(--ks-muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.km-product-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
	padding: 4px 8px 8px;
	margin-top: auto;
}

.km-product-price {
	font-size: 12px;
	font-weight: 700;
	color: var(--ks-accent);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Display only for now, matches Khulna Social's own store-grid cart icon. */
.km-product-cart-btn {
	flex-shrink: 0;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	border: none;
	background: var(--ks-primary);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
}

.km-product-cart-btn .dashicons {
	font-size: 14px;
	width: 14px;
	height: 14px;
}

/* Display only for now, matches Khulna Social's newsfeed .ks-buy-btn. */
.km-product-buy-btn {
	flex-shrink: 0;
	background: #1D4ED8;
	color: #fff;
	border: none;
	font-weight: 600;
	font-size: 11px;
	padding: 4px 10px;
	border-radius: 8px;
	cursor: pointer;
	white-space: nowrap;
}

.km-grid-sentinel {
	height: 1px;
}

.km-no-more {
	text-align: center;
	color: var(--ks-muted);
	font-size: 12px;
	padding: 14px 0;
	grid-column: 1 / -1;
}

.km-grid-loading {
	text-align: center;
	color: var(--ks-muted);
	font-size: 12px;
	padding: 10px 0;
	grid-column: 1 / -1;
}

/* ---------------- Product detail modal ---------------- */
.km-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
}

.km-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 38, 71, 0.55);
}

.km-modal-dialog {
	position: relative;
	background: var(--ks-bg);
	border-radius: 12px;
	max-width: 480px;
	width: 92%;
	max-height: 88vh;
	overflow-y: auto;
	padding: 8px;
}

.km-modal-close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: none;
	background: var(--ks-border);
	color: var(--ks-primary);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	z-index: 1;
}

.km-modal-body {
	padding: 6px;
}

.km-modal-body .ks-post {
	border: none;
	padding: 0;
}

.km-modal-loading {
	text-align: center;
	color: var(--ks-muted);
	padding: 30px 0;
}

@media (max-width: 640px) {
	.km-product-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 360px) {
	.km-product-grid {
		gap: 8px;
	}
}
