/* ==========================================================================
   Mega Menu — استایل فرانت (RTL)
   متغیرها را برای هماهنگی با رنگ سایت تغییر دهید.
   ========================================================================== */

.nmm {
	--nmm-accent: #ef4056;
	--nmm-text: #23254e;
	--nmm-muted: #5f6373;
	--nmm-border: #ececec;
	--nmm-bg: #fff;
	--nmm-sidebar-w: 210px;
	--nmm-dd-h: 460px;
	--nmm-radius: 8px;

	position: relative;
	display: inline-block;
	font-family: inherit;
}

/* ---------- دکمه ---------- */
.nmm__trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	background: none;
	border: 0;
	cursor: pointer;
	font: inherit;
	font-weight: 700;
	color: var(--nmm-text);
	line-height: 1;
}

.nmm__burger {
	display: inline-flex;
	flex-direction: column;
	gap: 3px;
	width: 18px;
}

.nmm__burger i {
	height: 2px;
	background: currentColor;
	border-radius: 2px;
}

.nmm:hover .nmm__trigger,
.nmm.is-open .nmm__trigger { color: var(--nmm-accent); }

/* ---------- کشوی اصلی ---------- */
.nmm__dd {
	position: absolute;
	inset-inline-start: 0;
	top: 100%;
	z-index: 9999;
	display: flex;
	width: min(1180px, 92vw);
	height: var(--nmm-dd-h);
	background: var(--nmm-bg);
	border: 1px solid var(--nmm-border);
	border-radius: var(--nmm-radius);
	box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
	overflow: hidden;

	/* پیش‌فرض: بسته — با CSS، بدون هیچ پرش یا فلش اولیه */
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity .16s ease, transform .16s ease, visibility 0s linear .16s;
}

.nmm:hover .nmm__dd,
.nmm:focus-within .nmm__dd,
.nmm.is-open .nmm__dd {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition-delay: 0s;
}

/* ---------- ستون دسته‌ها ---------- */
.nmm__cats {
	flex: 0 0 var(--nmm-sidebar-w);
	margin: 0;
	padding: 6px 0;
	list-style: none;
	border-inline-end: 1px solid var(--nmm-border);
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
}

.nmm__cat-item { margin: 0; }

.nmm__cat {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 9px 14px;
	color: var(--nmm-muted);
	text-decoration: none;
	font-size: 14px;
	line-height: 1.6;
	transition: color .12s ease, background-color .12s ease;
}

.nmm__cat-icon {
	display: inline-flex;
	flex: 0 0 20px;
	color: inherit;
	opacity: .9;
}

.nmm__cat-title {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.nmm__cat-arrow {
	width: 6px;
	height: 6px;
	border-inline-start: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(45deg);
	opacity: 0;
	transition: opacity .12s ease;
}

.nmm__cat.is-active,
.nmm__cat:hover,
.nmm__cat:focus-visible {
	color: var(--nmm-accent);
	background: #fafafa;
	outline: none;
}

.nmm__cat.is-active .nmm__cat-arrow { opacity: 1; }

/* ---------- ناحیه پنل‌ها ---------- */
.nmm__panels {
	position: relative;
	flex: 1;
	min-width: 0;
	overflow: hidden;
}

.nmm-panel {
	display: none;
	height: 100%;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	padding: 14px 18px;
}

.nmm-panel.is-active { display: block; }

.nmm-panel__inner {
	columns: 4;
	column-gap: 22px;
}

.nmm-panel__all {
	display: inline-block;
	margin-bottom: 10px;
	color: var(--nmm-accent);
	font-size: 13px;
	font-weight: 700;
	text-decoration: none;
	column-span: all;
}

.nmm-group {
	break-inside: avoid;
	page-break-inside: avoid;
	margin-bottom: 16px;
}

.nmm-group__title {
	display: block;
	margin-bottom: 6px;
	padding-inline-start: 8px;
	border-inline-start: 3px solid var(--nmm-accent);
	color: var(--nmm-text);
	font-size: 13.5px;
	font-weight: 700;
	text-decoration: none;
	line-height: 1.7;
}

a.nmm-group__title:hover { color: var(--nmm-accent); }

.nmm-group__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.nmm-group__list li { margin: 0; }

.nmm-group__list a,
.nmm-group__list span {
	display: block;
	padding: 3px 0;
	color: var(--nmm-muted);
	font-size: 13px;
	line-height: 1.9;
	text-decoration: none;
}

.nmm-group__list a:hover { color: var(--nmm-accent); }

/* اسکلت لودینگ برای پنل‌هایی که هنوز نیامده‌اند */
.nmm-panel[data-lazy] .nmm-panel__inner { min-height: 200px; }

.nmm-panel.is-loading::after {
	content: "";
	position: absolute;
	inset: 0;
	background:
		linear-gradient(90deg, transparent, rgba(0, 0, 0, .035), transparent) 0 0 / 40% 100% no-repeat;
	animation: nmm-shimmer 1s infinite;
}

@keyframes nmm-shimmer {
	to { background-position: 250% 0; }
}

/* ---------- موبایل و تبلت ---------- */
@media (max-width: 1024px) {
	.nmm__dd {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		max-height: 100%;
		border: 0;
		border-radius: 0;
		flex-direction: column;
		transform: translateX(100%);
		transition: transform .22s ease, visibility 0s linear .22s;
	}

	.nmm:hover .nmm__dd { /* روی تاچ، هاور نباید باز کند */
		opacity: 0;
		visibility: hidden;
		transform: translateX(100%);
	}

	.nmm.is-open .nmm__dd {
		opacity: 1;
		visibility: visible;
		transform: none;
		transition-delay: 0s;
	}

	.nmm__cats {
		flex: 0 0 auto;
		max-height: 100%;
		border-inline-end: 0;
	}

	.nmm__panels { display: none; }

	.nmm.is-panel-open .nmm__cats { display: none; }
	.nmm.is-panel-open .nmm__panels { display: block; flex: 1; }

	.nmm-panel__inner { columns: 1; }

	.nmm__back {
		display: none;
		align-items: center;
		gap: 6px;
		width: 100%;
		padding: 12px 14px;
		border: 0;
		border-bottom: 1px solid var(--nmm-border);
		background: #fafafa;
		font: inherit;
		font-weight: 700;
		cursor: pointer;
	}

	.nmm.is-open .nmm__back { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
	.nmm__dd { transition-duration: .01ms; }
	.nmm-panel.is-loading::after { animation: none; }
}
