/* ==========================================================================
   Header — matches the live site's design 1:1: one visual block (top
   info row + menu row directly beneath, no border/gap splitting them
   into two separate bars).
   ========================================================================== */

/* Sticky offset: clears the WP admin bar. It is fixed at the top down to
   601px and scrolls away below that, so no offset there. Set on body so the
   mobile bar (a sibling of .ahan-header) inherits it too. */
body.admin-bar {
	--ahan-sticky-top: 32px;
}

@media (max-width: 782px) {
	body.admin-bar {
		--ahan-sticky-top: 46px;
	}
}

@media (max-width: 600px) {
	body.admin-bar {
		--ahan-sticky-top: 0px;
	}
}

.ahan-header {
	position: sticky;
	top: var(--ahan-sticky-top, 0px);
	z-index: 30;
	background: var(--c-surface);
	box-shadow: 0px 3px 20px 0px rgba(0, 0, 0, 0.117);
}

/* Measured from the live header: 136px = 9 + logo row 66 + 7 + menu row 42 + 12 (it closes with a soft shadow). */
.ahan-header__inner {
	max-width: var(--container-box);
	margin: 0 auto;
	padding: 9px var(--container-pad) 12px;
}

.ahan-header__logo img {
	display: block;
	height: 66px;
	width: auto;
}

/* ---------- Top info row: phone / search / logo ---------- */

.ahan-header__top {
	display: flex;
	align-items: center;
	gap: var(--gap);
	padding-bottom: 7px;
}

/* Text on the start side, the green icon at the end (left) edge; both lines left-aligned, like the live header. */
.ahan-header__phone {
	display: flex;
	flex-direction: row-reverse;
	align-items: center;
	gap: 12px;
	text-decoration: none;
	color: var(--c-text);
	white-space: nowrap;
	flex-shrink: 0;
	margin-inline-start: auto;
}

.ahan-header__phone-icon {
	display: inline-flex;
	width: 40px;
	height: 40px;
	flex-shrink: 0;
	color: #fff;
	padding: 8px;
	border-radius: 8px;
	background: #00cf60;
}

.ahan-header__phone-icon svg {
	width: 100%;
	height: 100%;
}

.ahan-header__phone-text {
	display: flex;
	flex-direction: column;
	align-items: flex-end; /* RTL: the cross-axis end is the left edge */
	line-height: 1.3;
}

.ahan-header__phone-label {
	font-size: var(--fs-sm);
	color: var(--c-text-muted);
	font-weight: var(--fw-medium);
}

.ahan-header__phone-number {
	font-size: var(--t-h3-size);
	font-weight: var(--fw-medium);
	direction: rtl;
	unicode-bidi: isolate;
	color: #00cf60;
	letter-spacing: .2px;
}

.ahan-header__search {
	flex: 1;
	max-width: 500px;
}
/* Live header: 48px tall field + a 56px-wide button of the same height. */
.ahan-header__search .ahan-search__input {
	height: 48px;
	min-height: 0;
	padding-block: 0;
}
.ahan-header__search .ahan-search__submit {
	width: 56px;
	height: 48px;
}
.ahan-header__search .ahan-search__submit svg {
	width: 28px;
	height: 28px;
}


/* ---------- Menu row: horizontal menu + cart/account/price ---------- */

.ahan-header__bottom {
	display: flex;
	align-items: center;
	gap: var(--gap);
	position: relative;
}

.ahan-header__actions {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
	margin-inline-start: auto;
}

.ahan-header__instant-price {
	display: inline-flex;
	align-items: center;
	height: 42px; /* live header: 136 x 42 */
	padding: 0 16px;
	border-radius: 8px;
	background: var(--c-primary);
	color: var(--c-primary-contrast);
	font-size: var(--fs-sm);
	font-weight: var(--fw-medium);
	text-decoration: none;
	white-space: nowrap;
}

/* Cart/account slots keep whatever the plugin renders; just align them. */
.ahp-cart-slot,
.ahp-auth-slot {
	display: inline-flex;
	align-items: center;
}

/* ==========================================================================
   Desktop horizontal menu (منوی اصلی) — generic: any item can carry a
   dropdown panel. A plain item's panel comes from its own WP children;
   a mega-menu item's panel (.is-megamenu) comes from its independent
   megamenu_source tree instead, rendered by the same markup/CSS.
   ========================================================================== */

.ahan-header__nav-list {
	display: flex;
	align-items: center;
	gap: 22px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.ahan-header__nav-item {
	position: relative;
}

/* An item with a full-width panel does not anchor it: the panel is positioned against the whole menu
   row (.ahan-header__bottom, 1140px), so it spans the content width whatever the item's own width.
   (A content-width panel keeps hanging under its own item.) */
.ahan-header__nav-item:has(> .ahan-header__nav-panel--width-full) {
	position: static;
}
/* Figma: a thin divider between items (drawn on the link, so it stays put when the item is static);
   the first item (categories) is darker, the others grey. */
.ahan-header__nav-item + .ahan-header__nav-item > .ahan-header__nav-link {
	position: relative;
}
.ahan-header__nav-item + .ahan-header__nav-item > .ahan-header__nav-link::before {
	content: '';
	position: absolute;
	inset-inline-start: -12px;
	top: 50%;
	width: 1.6px;
	height: 17.6px;
	background: var(--gray-3);
	transform: translateY(-50%);
}
.ahan-header__nav-item:first-child > .ahan-header__nav-link {
	color: var(--c-text);
}


.ahan-header__nav-link {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 0;
	color: var(--gray-7);
	text-decoration: none;
	font-size: var(--fs-sm);
	font-weight: var(--fw-medium);
	white-space: nowrap;
}

.ahan-header__nav-icon {
	display: inline-flex;
	line-height: 0;
}

.ahan-header__nav-icon svg {
	width: 20px;
	height: 20px;
}

.ahan-header__nav-chevron {
	display: inline-flex;
	line-height: 0;
}

/* Mega-menu items: the class is on the <svg> itself. Points down; up while the item is open. */
.ahan-header__nav-chevron svg,
svg.ahan-header__nav-chevron {
	width: 14px;
	height: 14px;
	flex: none;
	transform: rotate(90deg);
	transition: transform var(--dur) var(--ease);
}

.ahan-header__nav-item:hover .ahan-header__nav-chevron svg,
.ahan-header__nav-item:hover svg.ahan-header__nav-chevron,
.ahan-header__nav-item:focus-within svg.ahan-header__nav-chevron {
	transform: rotate(-90deg);
}

.ahan-header__nav-item:hover .ahan-header__nav-link {
	color: var(--c-primary);
}

.ahan-header__nav-panel {
	position: absolute;
	right: 0;
	top: 100%;
	z-index: 1000;
	padding-top: 6px;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(8px);
	transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}

.ahan-header__nav-item.has-children:hover .ahan-header__nav-panel {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: none;
	transition-delay: 0s;
}

/* Plain (non-mega) dropdown: a simple flat link grid, no category list. */
.ahan-simple-dropdown {
	display: flex;
	flex-direction: column;
	gap: 4px;
	background: var(--c-surface);
	border: 1px solid var(--c-border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow);
	padding: var(--gap);
	min-width: 220px;
}

.ahan-simple-dropdown__link {
	color: var(--c-text);
	text-decoration: none;
	font-size: var(--fs-sm);
	padding: 6px 4px;
}

.ahan-simple-dropdown__link:hover {
	color: var(--c-primary);
}

/* Mega-menu dropdown: the two-column panel (.ahan-catmenu__*). Its
   position/width is fully controlled by the width-style modifier below
   (--width-full spans the whole header row; --width-content sits under
   its own trigger, sized to its content). */

.ahan-header__nav-panel--width-full {
	position: absolute;
	inset-inline-start: 0;
	inset-inline-end: 0;
	top: 100%;
	width: auto;
}

.ahan-header__nav-panel--width-content {
	width: fit-content;
}

/* Dark overlay behind an open dropdown. */
.ahan-menu-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, .45);
	backdrop-filter: blur(2px);
	opacity: 0;
	transition: opacity .28s cubic-bezier(.4, 0, .2, 1);
	pointer-events: none;
}

.ahan-menu-overlay.is-visible {
	opacity: 1;
}

/* ==========================================================================
   Mega-menu panel content (.ahan-catmenu__*) — matches the previous
   custom-mega-menu 1:1: a fixed-width right-hand column of tabs
   (switching on hover, not click) + a flex-grow content area where each
   tab's section is absolutely positioned (stacked) so switching tabs
   never changes the panel's height. A section's children render as a
   multi-column grid; nested children stack underneath their parent
   cell, indented with a border, rather than a floating second panel.
   ========================================================================== */

.ahan-catmenu__body {
	display: flex;
	background: var(--c-surface);
	border: 1px solid var(--c-border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow);
	max-height: 70vh;
}

.ahan-header__nav-panel--width-full .ahan-catmenu__body {
	width: 100%;
	max-width: var(--container-max);
	margin: 0 auto;
}

.ahan-catmenu__tabs {
	background: var(--c-bg);
	flex-shrink: 0;
	overflow-y: auto;
}

.ahan-catmenu__tabs ul {
	list-style: none;
	margin: 0;
	min-width: 200px;
	display: flex;
	flex-direction: column;
	gap: 0px;
	padding: var(--space-1) 0;
}

.ahan-catmenu__tabs li {
	display: flex;
	width: 100%;
}

.ahan-catmenu__tab {
	padding: 8px var(--gap);
	color: var(--c-text-muted);
	text-decoration: none;
	font-size: var(--fs-sm);
	width: 100%;
	position: relative;
}

.ahan-catmenu__tab.is-active {
	color: var(--c-primary);
}

.ahan-catmenu__tab.is-active::before {
	content: "";
	position: absolute;
	inset-inline-end: 0;
	top: 0;
	width: 4px;
	height: 100%;
	border-radius: 20px 0 0 20px;
	background: var(--c-primary);
	animation: ahan-header-fade-in .18s ease both;
}

.ahan-catmenu__sections {
	flex-grow: 1;
	flex-basis: 0;
	position: relative;
	min-width: 480px;
	overflow: hidden;
}

.ahan-catmenu__section {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: 100%;
	box-sizing: border-box;
	padding: var(--gap);
	overflow-y: auto;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity .18s ease, visibility 0s linear .18s;
}

/* inherit, never "visible"/"auto": an explicit value here would override the
   closed panel (visibility:hidden) and make its invisible area hoverable. */
.ahan-catmenu__section.is-active {
	z-index: 1;
	opacity: 1;
	visibility: inherit;
	pointer-events: inherit;
	transition-delay: 0s;
}

.ahan-catmenu__grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: var(--gap);
	width: 100%;
	min-width: 0;
}

.ahan-catmenu__grid > li {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.ahan-catmenu__grid > li > a {
	font-size: var(--fs-sm);
	color: var(--c-text);
	text-decoration: none;
	padding: 0 var(--gap);
	position: relative;
	width: 100%;
	overflow-wrap: break-word;
}

.ahan-catmenu__grid > li > a::before {
	content: "";
	position: absolute;
	inset-inline-start: 0;
	top: 0;
	width: 4px;
	height: 100%;
	border-radius: 20px;
	background: var(--c-primary);
}

.ahan-catmenu__grid > li > a:hover {
	color: var(--c-primary);
}

.ahan-catmenu__grid > li > ul {
	list-style: none;
	margin: 4px 0 0;
	padding-inline-start: 12px;
	border-inline-start: 1px solid var(--c-border);
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.ahan-catmenu__grid ul li a {
	font-size: var(--fs-sm);
	color: var(--c-text-muted);
	text-decoration: none;
	padding: 2px 0;
	display: block;
}

.ahan-catmenu__grid ul li a:hover {
	color: var(--c-primary);
}

.ahan-catmenu__grid ul li ul {
	list-style: none;
	margin: 4px 0 0;
	padding-inline-start: 12px;
	border-inline-start: 1px solid var(--c-border);
	display: flex;
	flex-direction: column;
	gap: 4px;
}

@media screen and (max-width: 1440px) {
	.ahan-catmenu__tabs ul {
		gap: 2px;
		padding: 8px 0;
	}
	.ahan-catmenu__section {
		padding: 4px var(--gap);
	}
}

/* ==========================================================================
   Mobile top bar — order: burger (start) — logo (center) — cart/account (end)
   ========================================================================== */

.ahan-mobile-bar {
	display: none;
}

/* Live mobile header: the logo sits next to the burger (not centred), cart/account at the far end. */
.ahan-mobile-bar__logo {
	margin-inline-end: auto;
}

.ahan-mobile-bar__logo img {
	height: 56px; /* live header: 183 x 56 */
}

.ahan-mobile-bar__actions {
	display: flex;
	align-items: center;
	gap: var(--gap);
}

.ahan-mobile-bar__burger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 0;
	background: none;
	color: var(--c-text);
	cursor: pointer;
	padding: 0;
	flex-shrink: 0;
}

.ahan-mobile-bar__burger svg {
	width: 24px;
	height: 24px;
}

/* ==========================================================================
   Off-canvas content specific to the header (generic parts live in
   components/offcanvas.css, tabs.css, accordion.css)
   ========================================================================== */

.ahan-offcanvas__logo {
	display: block;
	margin-bottom: var(--gap-lg);
}

.ahan-offcanvas__logo img {
	height: 40px;
}

/* "فهرست" tab — flat links, from منوی اصلی */

.ahan-offcanvas__flat-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.ahan-offcanvas__flat-list li + li {
	border-top: 1px solid var(--c-border);
}

.ahan-offcanvas__flat-list a {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 0;
	color: var(--c-text);
	text-decoration: none;
	font-size: var(--fs-sm);
}

.ahan-offcanvas__flat-icon {
	display: inline-flex;
	line-height: 0;
}

.ahan-offcanvas__flat-icon svg {
	width: 18px;
	height: 18px;
}

/* ==========================================================================
   Breakpoint: mobile — hide the desktop header, show the mobile bar +
   off-canvas menu instead.
   ========================================================================== */

@media (max-width: 1024px) {
	/* The whole desktop header goes (its padding and border would otherwise leave a strip above the bar). */
	.ahan-header {
		display: none;
	}

	.ahan-mobile-bar {
		display: flex;
		align-items: center;
		gap: var(--gap);
		padding: 16px var(--container-pad);
		background: var(--c-surface);
		position: sticky;
		top: var(--ahan-sticky-top, 0px);
		z-index: 30;
		box-shadow: 0 1px 0 var(--c-border);
	}
}

/* ==========================================================================
   Motion — hover colour feedback + reduced-motion overrides
   ========================================================================== */

.ahan-header__nav-link,
.ahan-simple-dropdown__link,
.ahan-catmenu__tab,
.ahan-catmenu__grid a {
	transition: color var(--dur) var(--ease);
}

@keyframes ahan-header-fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ahan-header__nav-panel,
	.ahan-catmenu__section,
	.ahan-header__nav-link,
	.ahan-header__nav-chevron svg,
	.ahan-simple-dropdown__link,
	.ahan-catmenu__tab,
	.ahan-catmenu__grid a,
	.ahan-menu-overlay {
		transition-duration: .01ms;
		transition-delay: 0s;
	}

	.ahan-catmenu__tab.is-active::before {
		animation: none;
	}
}

/* hover-states: burger. */
.ahan-mobile-bar__burger {
	transition: color var(--dur-fast) var(--ease);
}

@media (hover: hover) {
	.ahan-mobile-bar__burger:hover {
		color: var(--c-primary);
	}
}

/* Menu item icons (from the menu editor): align the icon with the item text. */
.menu-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-inline-end: 6px;
	vertical-align: middle;
	line-height: 0;
}

.menu-icon svg {
	width: 1em;
	height: 1em;
	font-size: 20px;
	fill: currentColor;
}

.menu-item-text {
	display: inline-flex;
	align-items: center;
	vertical-align: middle;
}
