/**
 * مگا منوی دسته‌بندی محصولات — پرومارت
 *
 * @package Ceritamed
 */

/* ── Parent trigger ── */
#primary-menu > li.ceritamed-has-mega-menu {
	position: static;
}

#primary-menu > li.ceritamed-has-mega-menu.menu-item-has-children::after {
	display: none;
}

/* دسکتاپ: زیرمنوی پیش‌فرض وردپرس نباید کنار پنل مگا منو نمایش داده شود */
@media (min-width: 993px) {
	#primary-menu > li.ceritamed-has-mega-menu > .sub-menu {
		display: none !important;
	}
}

#primary-menu > li.ceritamed-has-mega-menu > a.ceritamed-mega-trigger {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
}

#primary-menu > li.ceritamed-has-mega-menu > a .ceritamed-mega-trigger__icon {
	font-size: 1rem;
	transition: transform 0.2s ease;
}

#primary-menu > li.ceritamed-has-mega-menu.is-open > a .ceritamed-mega-trigger__icon,
#primary-menu > li.ceritamed-has-mega-menu:hover > a .ceritamed-mega-trigger__icon {
	transform: rotate(180deg);
}

/* ── Panel container ── */
.ceritamed-mega-panel {
	display: none;
	position: absolute;
	right: 0;
	left: 0;
	top: 100%;
	z-index: 110;
	background: #fff;
	color: #0a2540;
	border-top: 3px solid var(--primary, #008AC5);
	box-shadow: 0 18px 40px rgba(10, 37, 64, 0.14);
}

/*
 * پل نامرئی بین تریگر منو و پنل — مسیر موس از لینک به پنل
 * از محدوده li عبور می‌کند و بدون این پل mouseleave زودتر از رسیدن به پنل اجرا می‌شود.
 */
@media (min-width: 993px) {
	#primary-menu > li.ceritamed-has-mega-menu.is-open .ceritamed-mega-panel::before,
	#primary-menu > li.ceritamed-has-mega-menu:hover .ceritamed-mega-panel::before,
	#primary-menu > li.ceritamed-has-mega-menu:focus-within .ceritamed-mega-panel::before {
		content: '';
		position: absolute;
		right: 0;
		left: 0;
		bottom: 100%;
		height: 3.5rem;
	}
}

#ceritamed-primary-nav {
	overflow: visible;
}

#primary-menu > li.ceritamed-has-mega-menu.is-open .ceritamed-mega-panel,
#primary-menu > li.ceritamed-has-mega-menu:hover .ceritamed-mega-panel,
#primary-menu > li.ceritamed-has-mega-menu:focus-within .ceritamed-mega-panel {
	display: block;
}

#primary-menu > li.ceritamed-has-mega-menu.is-open .ceritamed-mega-panel[hidden],
#primary-menu > li.ceritamed-has-mega-menu:hover .ceritamed-mega-panel[hidden],
#primary-menu > li.ceritamed-has-mega-menu:focus-within .ceritamed-mega-panel[hidden] {
	display: block;
}

.ceritamed-mega-panel__inner {
	max-width: 1320px;
	margin: 0 auto;
	padding: 1.25rem 1rem 1.5rem;
	display: grid;
	grid-template-columns: minmax(220px, 260px) 1fr;
	grid-template-rows: 1fr;
	gap: 0;
	align-items: stretch;
	min-height: 380px;
}

/* ── Level 2 sidebar (right in RTL) ── */
.ceritamed-mega-sidebar {
	border-inline-start: 1px solid #e2e5ea;
	padding-inline-start: 1rem;
	grid-column: 1;
	grid-row: 1;
}

.ceritamed-mega-sidebar__title {
	margin: 0 0 0.85rem;
	font-size: 0.72rem;
	font-weight: 700;
	color: #6b7280;
}

.ceritamed-mega-l2 {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
}

.ceritamed-mega-l2__item {
	margin: 0;
	padding: 0;
}

.ceritamed-mega-l2__btn {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 0.55rem;
	padding: 0.65rem 0.75rem;
	border: none;
	border-radius: 0.5rem;
	background: transparent;
	color: #0a2540;
	font-family: inherit;
	font-size: 0.82rem;
	font-weight: 600;
	text-align: left;
	cursor: pointer;
	transition: background-color 0.18s ease, color 0.18s ease;
}

.ceritamed-mega-l2__btn:hover,
.ceritamed-mega-l2__item.is-active .ceritamed-mega-l2__btn {
	background: #f4f5f7;
	color: #0a2540;
}

.ceritamed-mega-l2__icon {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	min-width: 24px;
	min-height: 24px;
	max-width: 24px;
	max-height: 24px;
	overflow: hidden;
}

.ceritamed-mega-l2__icon-img {
	display: block;
	width: 24px !important;
	height: 24px !important;
	min-width: 24px;
	min-height: 24px;
	max-width: 24px;
	max-height: 24px;
	object-fit: contain;
	object-position: center;
	flex-shrink: 0;
}

.ceritamed-mega-l2__label {
	flex: 1;
	min-width: 0;
	text-align: left;
}

.ceritamed-mega-l2__chevron {
	font-size: 1rem;
	color: #9ca3af;
	flex-shrink: 0;
}

/* ── Level 2 group (columns + banner) — RTL: ستون‌ها وسط، بنر سمت چپ ── */
.ceritamed-mega-group {
	display: none;
	grid-column: 2;
	grid-row: 1;
	grid-template-columns: 1fr minmax(180px, 220px);
	gap: 1.25rem;
	align-items: start;
	padding-inline-end: 1rem;
}

.ceritamed-mega-group.is-active {
	display: grid;
}

/* ── Banner (far left in RTL) ── */
.ceritamed-mega-banner {
	position: relative;
	border-radius: 0.65rem;
	overflow: hidden;
	height: 320px;
	min-height: 320px;
	max-height: 320px;
	align-self: start;
	background: #0a2540;
	grid-column: 2;
}

.ceritamed-mega-banner__image {
	position: absolute;
	inset: 0;
	z-index: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	object-fit: cover;
	object-position: center;
}

.ceritamed-mega-banner__overlay {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	padding: 1.25rem 1rem;
	background: linear-gradient(180deg, rgba(10, 37, 64, 0.82) 0%, rgba(10, 37, 64, 0.2) 45%, rgba(10, 37, 64, 0.88) 100%);
}

.ceritamed-mega-banner__title {
	margin: 0;
	font-size: 1rem;
	font-weight: 800;
	line-height: 1.5;
	color: #fff;
}

.ceritamed-mega-banner__subtitle {
	margin: 0.35rem 0 0;
	font-size: 0.72rem;
	color: rgba(255, 255, 255, 0.85);
	line-height: 1.6;
}

.ceritamed-mega-banner__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.25rem;
	align-self: center;
	width: 100%;
	padding: 0.55rem 0.9rem;
	border: 1px solid rgba(255, 255, 255, 0.85);
	border-radius: 0.45rem;
	background: rgba(10, 37, 64, 0.55);
	color: #fff;
	font-size: 0.72rem;
	font-weight: 700;
	text-align: center;
	text-decoration: none;
	transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.ceritamed-mega-banner__btn .fa-solid {
	color: #fff;
	font-size: 1rem;
}

.ceritamed-mega-banner__btn:hover {
	background: var(--primary, #008AC5);
	border-color: var(--primary, #008AC5);
	color: #0a2540;
}

.ceritamed-mega-banner__btn:hover .fa-solid {
	color: #0a2540;
}

/* ── Level 3 columns (center — adjacent to sidebar in RTL) ── */
.ceritamed-mega-content {
	min-width: 0;
	grid-column: 1;
}

.ceritamed-mega-content:only-child {
	grid-column: 1 / -1;
}

.ceritamed-mega-columns {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 0 1.5rem;
	align-items: start;
}

.ceritamed-mega-column {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	min-height: auto;
	padding: 0.25rem 0.15rem;
}

.ceritamed-mega-column + .ceritamed-mega-column {
	position: relative;
}

.ceritamed-mega-column + .ceritamed-mega-column::before {
	content: "";
	position: absolute;
	top: 0.35rem;
	bottom: 0.35rem;
	inset-inline-start: -0.75rem;
	width: 1px;
	background: linear-gradient(
		180deg,
		transparent 0%,
		rgba(10, 37, 64, 0.08) 12%,
		rgba(10, 37, 64, 0.14) 50%,
		rgba(10, 37, 64, 0.08) 88%,
		transparent 100%
	);
	pointer-events: none;
}

.ceritamed-mega-column__body {
	flex: 1;
}

.ceritamed-mega-column__title {
	margin: 0 0 0.65rem;
	font-size: 0.82rem;
	font-weight: 800;
	color: #0a2540;
	line-height: 1.45;
}

.ceritamed-mega-column__title a {
	color: inherit;
	text-decoration: none;
	transition: color 0.18s ease;
}

.ceritamed-mega-column__title a:hover {
	color: #123a5c;
}

.ceritamed-mega-column__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.ceritamed-mega-column__list a {
	display: block;
	font-size: 0.78rem;
	font-weight: 400;
	color: #6b7280;
	text-decoration: none;
	transition: color 0.18s ease;
	line-height: 1.45;
}

.ceritamed-mega-column__list a:hover {
	color: #0a2540;
}

.ceritamed-mega-column__view-all {
	display: inline-flex;
	align-items: center;
	gap: 0.2rem;
	margin-top: 0.85rem;
	padding: 0.4rem 0.65rem;
	font-size: 0.72rem;
	font-weight: 700;
	color: #fff;
	text-decoration: none;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 0.35rem;
	background: #0a2540;
	transition: color 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.ceritamed-mega-column__view-all:hover {
	color: #0a2540;
	border-color: var(--primary, #008AC5);
	background: var(--primary, #008AC5);
}

.ceritamed-mega-column__view-all .fa-solid {
	font-size: 0.95rem;
	color: var(--primary, #008AC5);
}

.ceritamed-mega-column__view-all:hover .fa-solid {
	color: #0a2540;
}

/*
 * خنثی‌سازی color: inherit هدر (body.ceritamed-theme header a { color: inherit })
 * و استایل‌های سراسری (Tailwind Forms و ...) — در همه قالب‌ها
 */
body.ceritamed-theme header .ceritamed-mega-panel {
	color: #0a2540;
	isolation: isolate;
}

body.ceritamed-theme header .ceritamed-mega-panel a {
	text-decoration: none;
}

body.ceritamed-theme header .ceritamed-mega-sidebar__title {
	color: #6b7280;
}

body.ceritamed-theme header .ceritamed-mega-l2__btn {
	appearance: none;
	-webkit-appearance: none;
	border: none;
	background: transparent;
	color: #0a2540;
	font-family: inherit;
}

body.ceritamed-theme header .ceritamed-mega-l2__btn:hover,
body.ceritamed-theme header .ceritamed-mega-l2__item.is-active .ceritamed-mega-l2__btn {
	background: #f4f5f7;
	color: #0a2540;
}

body.ceritamed-theme header .ceritamed-mega-l2__label {
	color: #0a2540;
}

body.ceritamed-theme header .ceritamed-mega-l2__chevron {
	color: #9ca3af;
}

body.ceritamed-theme header .ceritamed-mega-banner__title {
	color: #fff;
}

body.ceritamed-theme header .ceritamed-mega-banner__subtitle {
	color: rgba(255, 255, 255, 0.85);
}

body.ceritamed-theme header .ceritamed-mega-column__title,
body.ceritamed-theme header .ceritamed-mega-column__title a {
	color: #0a2540;
}

body.ceritamed-theme header .ceritamed-mega-column__title a:hover {
	color: #123a5c;
}

body.ceritamed-theme header .ceritamed-mega-column__list a {
	color: #6b7280;
}

body.ceritamed-theme header .ceritamed-mega-column__list a:hover {
	color: #0a2540;
}

body.ceritamed-theme header .ceritamed-mega-column__view-all {
	color: #fff;
	background: #0a2540;
	border-color: rgba(255, 255, 255, 0.35);
}

body.ceritamed-theme header .ceritamed-mega-column__view-all .fa-solid {
	color: var(--primary, #008AC5);
}

body.ceritamed-theme header .ceritamed-mega-column__view-all:hover {
	color: #0a2540;
	background: var(--primary, #008AC5);
	border-color: var(--primary, #008AC5);
}

body.ceritamed-theme header .ceritamed-mega-column__view-all:hover .fa-solid {
	color: #0a2540;
}

body.ceritamed-theme header .ceritamed-mega-banner__btn {
	color: #fff;
	text-align: center;
	background: rgba(10, 37, 64, 0.55);
	border-color: rgba(255, 255, 255, 0.85);
}

body.ceritamed-theme header .ceritamed-mega-banner__btn .fa-solid {
	color: #fff;
}

body.ceritamed-theme header .ceritamed-mega-banner__btn:hover {
	color: #0a2540;
	background: var(--primary, #008AC5);
	border-color: var(--primary, #008AC5);
}

body.ceritamed-theme header .ceritamed-mega-banner__btn:hover .fa-solid {
	color: #0a2540;
}

/* خنثی‌سازی استایل‌های سراسری img (Tailwind / WooCommerce) داخل پنل مگا منو */
body.ceritamed-theme header .ceritamed-mega-panel img.ceritamed-mega-banner__image {
	position: absolute;
	inset: 0;
	z-index: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	object-fit: cover;
	object-position: center;
	box-shadow: none;
}

body.ceritamed-theme header .ceritamed-mega-panel img.ceritamed-mega-l2__icon-img {
	position: static;
	display: block;
	width: 24px !important;
	height: 24px !important;
	min-width: 24px;
	min-height: 24px;
	max-width: 24px;
	max-height: 24px;
	object-fit: contain;
	object-position: center;
	box-shadow: none;
}

body.ceritamed-theme header .ceritamed-mega-banner {
	height: 320px;
	min-height: 320px;
	max-height: 320px;
	align-self: start;
}

body.ceritamed-theme header .ceritamed-mega-banner__overlay {
	position: absolute;
	inset: 0;
	height: auto;
	min-height: 0;
}

body.ceritamed-theme header .ceritamed-mega-group {
	align-items: start;
}

/* ── Responsive ── */
@media (max-width: 992px) {
	.ceritamed-mega-panel {
		display: none !important;
	}
}

@media (min-width: 993px) {
	#primary-menu > li.ceritamed-has-mega-menu {
		position: static;
	}

	#primary-menu {
		overflow: visible;
	}

	.ceritamed-mega-panel__inner {
		grid-template-columns: minmax(220px, 260px) 1fr;
	}

	.ceritamed-mega-group {
		grid-template-columns: 1fr 180px;
	}
}

@media (min-width: 1200px) {
	.ceritamed-mega-group {
		grid-template-columns: 1fr 220px;
	}
}

@media (max-width: 1199px) {
	.ceritamed-mega-columns {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 1rem 1.5rem;
	}

	.ceritamed-mega-column + .ceritamed-mega-column::before {
		display: none;
	}

	.ceritamed-mega-column:nth-child(even) {
		position: relative;
	}

	.ceritamed-mega-column:nth-child(even)::before {
		content: "";
		display: block;
		position: absolute;
		top: 0.35rem;
		bottom: 0.35rem;
		inset-inline-start: -0.75rem;
		width: 1px;
		background: linear-gradient(
			180deg,
			transparent 0%,
			rgba(10, 37, 64, 0.08) 12%,
			rgba(10, 37, 64, 0.14) 50%,
			rgba(10, 37, 64, 0.08) 88%,
			transparent 100%
		);
		pointer-events: none;
	}
}

@media (max-width: 992px) {
	.ceritamed-mega-columns {
		grid-template-columns: 1fr;
	}
}

/* ── Ceritamed header integration (full-width panel like ProMart) ── */
#ceritamed-primary-nav {
	overflow: visible;
}

#ceritamed-primary-nav .nav-menu > li.ceritamed-has-mega-menu {
	position: static;
}

@media (min-width: 993px) {
	body.ceritamed-theme header {
		overflow: visible;
	}

	/* Positioning context for full-viewport mega panel (same as #site-navigation in ProMart). */
	body.ceritamed-theme .ceritamed-header-nav-row {
		position: relative;
		overflow: visible;
		z-index: 1;
	}

	body.ceritamed-theme .ceritamed-header-nav-row:has(.ceritamed-has-mega-menu.is-open),
	body.ceritamed-theme .ceritamed-header-nav-row:has(.ceritamed-has-mega-menu:hover),
	body.ceritamed-theme .ceritamed-header-nav-row:has(.ceritamed-has-mega-menu:focus-within) {
		z-index: 20;
	}

	body.ceritamed-theme .ceritamed-header-nav-row .header-main,
	body.ceritamed-theme .ceritamed-header-nav-row .header-container,
	body.ceritamed-theme .ceritamed-header-nav-row .header-primary-nav,
	body.ceritamed-theme .ceritamed-header-nav-row .ceritamed-mobile-nav__body {
		overflow: visible;
	}

	body.ceritamed-theme .ceritamed-header-nav-row .header-primary-nav,
	body.ceritamed-theme .ceritamed-header-nav-row #ceritamed-primary-nav {
		position: static;
	}

	#ceritamed-primary-nav .nav-menu {
		overflow: visible;
	}

	#primary-menu > li.ceritamed-has-mega-menu,
	#ceritamed-primary-nav .nav-menu > li.ceritamed-has-mega-menu {
		position: static;
	}

	.ceritamed-mega-panel {
		width: 100%;
		border-top-color: var(--primary, #008AC5);
	}

	.ceritamed-mega-panel__inner {
		max-width: 1320px;
		padding-left: 1rem;
		padding-right: 1rem;
	}

	body.ceritamed-theme header .ceritamed-mega-column__view-all {
		background: var(--primary, #008AC5);
		border-color: transparent;
	}

	body.ceritamed-theme header .ceritamed-mega-column__view-all .fa-solid {
		color: #fff;
	}

	body.ceritamed-theme header .ceritamed-mega-column__view-all:hover {
		background: #006fa0;
		color: #fff;
	}

	body.ceritamed-theme header .ceritamed-mega-banner__btn:hover {
		background: var(--primary, #008AC5);
		border-color: var(--primary, #008AC5);
		color: #fff;
	}
}

