/* ==========================================================================
   MJ Filters – Sidebar & filter UI
   ========================================================================== */

:root {
	--mjf-sidebar-w: 260px;
	--mjf-gap: 1.5rem;
	--mjf-radius: 8px;
	--mjf-border: #e5e7eb;
	--mjf-bg: #ffffff;
	--mjf-text: #1e293b;
	--mjf-muted: #64748b;
	--mjf-primary: var(--mj-color-secondary, #2563eb);
	--mjf-primary-light: #eff6ff;
	--mjf-transition: .2s ease;
}

/* ---------- Layout grid ---------- */

.mjf-shop-layout {
	display: grid;
	grid-template-columns: var(--mjf-sidebar-w) 1fr;
	gap: var(--mjf-gap);
	align-items: start;
}

/* Reduce product columns when sidebar is visible */
@media (min-width: 1024px) {
	.mjf-shop-layout .mjf-products-wrap ul.products {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (min-width: 1440px) {
	.mjf-shop-layout .mjf-products-wrap ul.products {
		grid-template-columns: repeat(4, 1fr);
	}
}

/* ---------- Products wrapper ---------- */

.mjf-products-wrap {
	min-width: 0;
	position: relative;
}

/* Loading overlay */
.mjf-products-wrap.mjf-loading::after {
	content: '';
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, .55);
	z-index: 5;
	border-radius: var(--mjf-radius);
}

.mjf-products-wrap.mjf-loading::before {
	content: '';
	position: absolute;
	top: 30%;
	left: 50%;
	width: 30px;
	height: 30px;
	margin: -15px 0 0 -15px;
	border: 3px solid var(--mjf-border);
	border-top-color: var(--mjf-primary);
	border-radius: 50%;
	animation: mjf-spin .6s linear infinite;
	z-index: 6;
}

@keyframes mjf-spin { to { transform: rotate(360deg); } }

/* ---------- Sidebar ---------- */

.mjf-sidebar {
	position: sticky;
	top: 80px;
	max-height: calc(100vh - 100px);
	overflow-y: auto;
	background: var(--mjf-bg);
	border: 1px solid var(--mjf-border);
	border-radius: var(--mjf-radius);
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: var(--mjf-border) transparent;
}

.mjf-sidebar::-webkit-scrollbar { width: 4px; }
.mjf-sidebar::-webkit-scrollbar-thumb { background: var(--mjf-border); border-radius: 2px; }

/* Header */
.mjf-sidebar__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: .875rem 1.125rem;
	border-bottom: 1px solid var(--mjf-border);
	position: sticky;
	top: 0;
	background: var(--mjf-bg);
	z-index: 2;
	border-radius: var(--mjf-radius) var(--mjf-radius) 0 0;
}

.mjf-sidebar__title {
	font-size: .8125rem;
	font-weight: 700;
	margin: 0;
	color: var(--mjf-text);
	text-transform: uppercase;
	letter-spacing: .05em;
}

.mjf-sidebar__close {
	display: none;
	background: none;
	border: none;
	font-size: 1.5rem;
	cursor: pointer;
	color: var(--mjf-muted);
	line-height: 1;
	padding: 0;
}

/* ---------- Filter groups ---------- */

.mjf-group {
	border-bottom: 1px solid var(--mjf-border);
}

.mjf-group:last-of-type {
	border-bottom: none;
}

.mjf-group__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: .75rem 1.125rem;
	background: none;
	border: none;
	font-family: inherit;
	font-size: .8125rem;
	font-weight: 600;
	color: var(--mjf-text);
	cursor: pointer;
	text-align: left;
}

.mjf-group__toggle:hover { color: var(--mjf-primary); }

.mjf-group__arrow {
	font-size: .5rem;
	transition: transform var(--mjf-transition);
	display: inline-block;
}

.mjf-group__arrow::after { content: '▼'; }

.mjf-group--open > .mjf-group__toggle .mjf-group__arrow {
	transform: rotate(180deg);
}

.mjf-group__body {
	display: none;
	padding: 0 1.125rem .875rem;
}

.mjf-group--open > .mjf-group__body {
	display: block;
}

/* ---------- Checkbox rows ---------- */

.mjf-check {
	display: flex;
	align-items: center;
	gap: .5rem;
	padding: .25rem 0;
	cursor: pointer;
	font-size: .8125rem;
	color: var(--mjf-text);
	line-height: 1.3;
}

.mjf-check input[type="checkbox"],
.mjf-check input[type="radio"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.mjf-check__box {
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	border: 1.5px solid #cbd5e1;
	border-radius: 3px;
	transition: all var(--mjf-transition);
	position: relative;
}

.mjf-check input:checked + .mjf-check__box {
	background: var(--mjf-primary);
	border-color: var(--mjf-primary);
}

.mjf-check input:checked + .mjf-check__box::after {
	content: '';
	position: absolute;
	left: 4.5px;
	top: 1px;
	width: 5px;
	height: 9px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.mjf-check__label { flex: 1; }

.mjf-check__count {
	font-size: .6875rem;
	color: var(--mjf-muted);
	min-width: 1.25em;
	text-align: right;
}

/* ---------- Rating row ---------- */

.mjf-rating-row {
	padding: .3rem .5rem;
	margin: 0 -.5rem;
	border-radius: 4px;
	transition: background var(--mjf-transition);
}

.mjf-rating-row:has(input:checked) {
	background: var(--mjf-primary-light);
}

.mjf-rating-stars {
	color: #f59e0b;
	font-size: .875rem;
	letter-spacing: 1px;
}

/* ---------- Category tree ---------- */

.mjf-cat-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.mjf-cat-list--child {
	padding-left: 1.125rem;
	margin-top: .125rem;
}

/* ---------- Attribute list ---------- */

.mjf-attr-list {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 220px;
	overflow-y: auto;
	scrollbar-width: thin;
}

/* ---------- Price inputs ---------- */

.mjf-price-currency {
	display: flex;
	gap: .75rem;
	margin-bottom: .625rem;
}

.mjf-radio {
	font-size: .8125rem;
	color: var(--mjf-text);
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: .25rem;
}

.mjf-price-inputs {
	display: flex;
	align-items: center;
	gap: .5rem;
	margin-bottom: .625rem;
}

.mjf-input {
	width: 100%;
	padding: .4375rem .5rem;
	border: 1.5px solid var(--mjf-border);
	border-radius: 6px;
	font-family: inherit;
	font-size: .8125rem;
	color: var(--mjf-text);
	outline: none;
	transition: border-color var(--mjf-transition);
	-moz-appearance: textfield;
	appearance: textfield;
}

.mjf-input::-webkit-inner-spin-button,
.mjf-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.mjf-input:focus { border-color: var(--mjf-primary); }

.mjf-price-sep {
	color: var(--mjf-muted);
	flex-shrink: 0;
	font-size: .75rem;
}

/* ---------- Buttons ---------- */

.mjf-btn {
	display: block;
	width: 100%;
	padding: .4375rem;
	border: none;
	border-radius: 6px;
	font-family: inherit;
	font-size: .8125rem;
	font-weight: 600;
	cursor: pointer;
	text-align: center;
	transition: all var(--mjf-transition);
}

.mjf-btn--price {
	background: var(--mjf-primary);
	color: #fff;
}

.mjf-btn--price:hover { opacity: .85; }

.mjf-btn--clear {
	background: none;
	border: 1.5px solid var(--mjf-border);
	color: var(--mjf-muted);
}

.mjf-btn--clear:hover {
	border-color: var(--mjf-primary);
	color: var(--mjf-primary);
}

/* ---------- Toggle switches ---------- */

.mjf-group--toggle {
	padding: .625rem 1.125rem;
	border-bottom: 1px solid var(--mjf-border);
}

.mjf-switch {
	display: flex;
	align-items: center;
	gap: .625rem;
	cursor: pointer;
	font-size: .8125rem;
	color: var(--mjf-text);
}

.mjf-switch input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.mjf-switch__track {
	position: relative;
	width: 34px;
	height: 18px;
	background: #cbd5e1;
	border-radius: 9px;
	transition: background var(--mjf-transition);
	flex-shrink: 0;
}

.mjf-switch__thumb {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 14px;
	height: 14px;
	background: #fff;
	border-radius: 50%;
	transition: transform var(--mjf-transition);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}

.mjf-switch input:checked + .mjf-switch__track {
	background: var(--mjf-primary);
}

.mjf-switch input:checked + .mjf-switch__track .mjf-switch__thumb {
	transform: translateX(16px);
}

/* ---------- Actions ---------- */

.mjf-actions {
	padding: .875rem 1.125rem;
}

/* ---------- Mobile toggle button ---------- */

.mjf-mobile-toggle {
	display: none;
	align-items: center;
	gap: .375rem;
	padding: .4375rem .875rem;
	background: var(--mjf-bg);
	border: 1.5px solid var(--mjf-border);
	border-radius: 6px;
	font-family: inherit;
	font-size: .8125rem;
	font-weight: 600;
	color: var(--mjf-text);
	cursor: pointer;
	margin-bottom: 1rem;
	transition: all var(--mjf-transition);
}

.mjf-mobile-toggle svg {
	flex-shrink: 0;
}

.mjf-mobile-toggle:hover {
	border-color: var(--mjf-primary);
	color: var(--mjf-primary);
}

/* ---------- Active filter chips ---------- */

.mjf-chips {
	display: flex;
	flex-wrap: wrap;
	gap: .375rem;
	margin-bottom: 1rem;
}

.mjf-chips:empty { display: none; }

.mjf-chip {
	display: inline-flex;
	align-items: center;
	gap: .25rem;
	padding: .1875rem .625rem;
	background: var(--mjf-primary-light);
	color: var(--mjf-primary);
	border: none;
	border-radius: 20px;
	font-family: inherit;
	font-size: .6875rem;
	font-weight: 500;
	line-height: 1.4;
	cursor: default;
}

.mjf-chip__x {
	background: none;
	border: none;
	color: inherit;
	font-size: .8125rem;
	cursor: pointer;
	padding: 0;
	line-height: 1;
	opacity: .7;
}

.mjf-chip__x:hover { opacity: 1; }

.mjf-chip--clear {
	background: none;
	color: var(--mjf-muted);
	text-decoration: underline;
	cursor: pointer;
	font-weight: 400;
}

.mjf-chip--clear:hover { color: var(--mjf-primary); }

/* ---------- No-results message ---------- */

.mjf-no-results {
	text-align: center;
	padding: 3rem 1rem;
	color: var(--mjf-muted);
	font-size: .9375rem;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1023px) {
	.mjf-shop-layout {
		display: block;
	}

	.mjf-mobile-toggle {
		display: inline-flex;
	}

	/* Sidebar becomes a slide-out drawer */
	.mjf-sidebar {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		width: 300px;
		max-height: none;
		z-index: 9999;
		border: none;
		border-radius: 0;
		transform: translateX(-100%);
		transition: transform .3s ease;
		box-shadow: none;
	}

	.mjf-sidebar--open {
		transform: translateX(0);
		box-shadow: 4px 0 24px rgba(0, 0, 0, .15);
	}

	.mjf-sidebar__close {
		display: block;
	}

	.mjf-sidebar__header {
		border-radius: 0;
	}

	/* Body overlay */
	body.mjf-no-scroll { overflow: hidden; }

	body.mjf-no-scroll::after {
		content: '';
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, .35);
		z-index: 9998;
	}
}

@media (max-width: 480px) {
	.mjf-sidebar {
		width: 85vw;
	}
}
