/**
 * [account_menu] header button and panel.
 *
 * Every rule sits under .hafez-umenu and buttons/links are reset first, so
 * Elementor kit and theme styles for button and a do not leak in. Colours are
 * the visual identity variables (--hafez-dp-*) printed for .hafez-umenu; the
 * site's dark mode swaps them through .hafez-dp--accskin.
 */

.hafez-umenu {
	--hafez-umenu-size: 36px;
	--hafez-umenu-bg: var(--hafez-dp-box-bg, #ffffff);
	--hafez-umenu-text: var(--hafez-dp-label, #1f2328);
	--hafez-umenu-muted: var(--hafez-dp-help, #6b7280);
	--hafez-umenu-border: var(--hafez-dp-box-border-color, #e5e7eb);
	--hafez-umenu-accent: var(--hafez-dp-primary-bg, #f15a24);
	--hafez-umenu-accent-text: var(--hafez-dp-primary-text, #ffffff);
	--hafez-umenu-accent-ink: var(--hafez-dp-primary-ink, var(--hafez-umenu-accent));
	--hafez-umenu-hover: color-mix(in srgb, var(--hafez-umenu-accent) 9%, transparent);
	--hafez-umenu-radius: var(--hafez-dp-radius-box, 14px);
	--hafez-umenu-radius-sm: var(--hafez-dp-radius-button, 10px);
	position: relative;
	display: inline-flex;
	align-items: center;
	box-sizing: border-box;
	direction: rtl;
	font-family: var(--hafez-dp-font, inherit);
	font-size: 14px;
	line-height: 1.6;
	color: var(--hafez-umenu-text);
	text-align: right;
	vertical-align: middle;
}

.hafez-umenu *,
.hafez-umenu *::before,
.hafez-umenu *::after {
	box-sizing: border-box;
}

/* Resets against theme / Elementor button and link styles. */
.hafez-umenu .hafez-umenu__toggle,
.hafez-umenu .hafez-umenu__login,
.hafez-umenu .hafez-umenu__link,
.hafez-umenu .hafez-umenu__logout,
.hafez-umenu .hafez-umenu__stat {
	all: unset;
	box-sizing: border-box;
	font-family: inherit;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.hafez-umenu .hafez-umenu__toggle:focus-visible,
.hafez-umenu .hafez-umenu__login:focus-visible,
.hafez-umenu .hafez-umenu__link:focus-visible,
.hafez-umenu .hafez-umenu__logout:focus-visible,
.hafez-umenu .hafez-umenu__stat:focus-visible {
	outline: 2px solid var(--hafez-umenu-accent);
	outline-offset: 2px;
}

.hafez-umenu .hafez-umenu__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* Toggle button */
.hafez-umenu .hafez-umenu__toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 40px;
	padding: 3px 4px 3px 10px;
	border-radius: 999px;
	color: var(--hafez-umenu-text);
	font-size: 14px;
	line-height: 1.4;
	transition: background-color .15s ease;
}

.hafez-umenu .hafez-umenu__toggle:hover,
.hafez-umenu.is-open .hafez-umenu__toggle {
	background: var(--hafez-umenu-hover);
}

.hafez-umenu .hafez-umenu__avatar {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: var(--hafez-umenu-size);
	height: var(--hafez-umenu-size);
	overflow: hidden;
	border-radius: 50%;
	background: var(--hafez-umenu-hover);
	color: var(--hafez-umenu-accent-ink);
}

.hafez-umenu .hafez-umenu__avatar img,
.hafez-umenu .hafez-umenu__avatar .avatar {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	border-radius: 50%;
	object-fit: cover;
	box-shadow: none;
}

.hafez-umenu .hafez-umenu__avatar--big {
	width: 52px;
	height: 52px;
}

.hafez-umenu .hafez-umenu__name {
	max-width: 140px;
	overflow: hidden;
	font-weight: 600;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.hafez-umenu .hafez-umenu__caret {
	flex: 0 0 auto;
	opacity: .7;
	transition: transform .2s ease;
}

.hafez-umenu.is-open .hafez-umenu__caret {
	transform: rotate(180deg);
}

/* Panel */
.hafez-umenu .hafez-umenu__panel {
	position: absolute;
	top: calc(100% + 8px);
	inset-inline-end: 0;
	z-index: 99990;
	width: 290px;
	max-width: calc(100vw - 24px);
	max-height: min(75vh, 560px);
	overflow-y: auto;
	padding: 10px;
	border: 1px solid var(--hafez-umenu-border);
	border-radius: var(--hafez-umenu-radius);
	background: var(--hafez-umenu-bg);
	color: var(--hafez-umenu-text);
	box-shadow: 0 16px 40px rgba(15, 23, 42, .14), 0 2px 6px rgba(15, 23, 42, .06);
	text-align: right;
}

.hafez-umenu .hafez-umenu__panel[hidden] {
	display: none;
}

.hafez-umenu.hafez-umenu--align-start .hafez-umenu__panel {
	inset-inline-start: 0;
	inset-inline-end: auto;
}

.hafez-umenu.hafez-umenu--align-center .hafez-umenu__panel {
	inset-inline-end: auto;
	left: 50%;
	transform: translateX(-50%);
}

.hafez-umenu .hafez-umenu__head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 6px 12px;
	border-bottom: 1px solid var(--hafez-umenu-border);
}

.hafez-umenu .hafez-umenu__who {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.hafez-umenu .hafez-umenu__who-name {
	overflow: hidden;
	font-size: 15px;
	font-weight: 700;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.hafez-umenu .hafez-umenu__who-mail {
	overflow: hidden;
	color: var(--hafez-umenu-muted);
	font-size: 12px;
	white-space: nowrap;
	text-overflow: ellipsis;
	text-align: right;
}

/* Wallet and club */
.hafez-umenu .hafez-umenu__stats {
	display: grid;
	gap: 6px;
	padding: 10px 0;
	border-bottom: 1px solid var(--hafez-umenu-border);
}

.hafez-umenu .hafez-umenu__stat {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 10px;
	border-radius: var(--hafez-umenu-radius-sm);
	background: var(--hafez-umenu-hover);
	color: var(--hafez-umenu-text);
	font-size: 13px;
}

.hafez-umenu div.hafez-umenu__stat {
	cursor: default;
}

.hafez-umenu a.hafez-umenu__stat:hover {
	background: color-mix(in srgb, var(--hafez-umenu-accent) 15%, transparent);
}

.hafez-umenu .hafez-umenu__stat-label {
	color: var(--hafez-umenu-muted);
}

.hafez-umenu .hafez-umenu__stat-value {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 6px;
	font-weight: 700;
}

.hafez-umenu .hafez-umenu__stat-value .woocommerce-Price-amount,
.hafez-umenu .hafez-umenu__stat-value bdi {
	color: inherit;
	font: inherit;
}

.hafez-umenu .hafez-umenu__level {
	display: inline-block;
	padding: 1px 8px;
	border-radius: 999px;
	background: var(--hafez-umenu-level, var(--hafez-umenu-accent));
	color: #ffffff;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.7;
}

/* Menu rows */
.hafez-umenu .hafez-umenu__nav {
	padding: 6px 0;
}

.hafez-umenu .hafez-umenu__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hafez-umenu .hafez-umenu__item {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hafez-umenu .hafez-umenu__item::before,
.hafez-umenu .hafez-umenu__item::marker {
	content: none;
}

.hafez-umenu .hafez-umenu__link,
.hafez-umenu .hafez-umenu__logout {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	min-height: 40px;
	padding: 7px 10px;
	border-radius: var(--hafez-umenu-radius-sm);
	color: var(--hafez-umenu-text);
	font-size: 14px;
	line-height: 1.5;
	text-decoration: none;
}

.hafez-umenu .hafez-umenu__link:hover,
.hafez-umenu .hafez-umenu__link:focus-visible {
	background: var(--hafez-umenu-hover);
	color: var(--hafez-umenu-accent-ink);
}

.hafez-umenu .hafez-umenu__link[aria-current="page"] {
	background: var(--hafez-umenu-hover);
	color: var(--hafez-umenu-accent-ink);
	font-weight: 700;
}

.hafez-umenu .hafez-umenu__icon {
	display: inline-flex;
	flex: 0 0 20px;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	color: currentColor;
	opacity: .85;
}

.hafez-umenu .hafez-umenu__icon svg,
.hafez-umenu .hafez-umenu__icon img {
	display: block;
	width: 18px;
	height: 18px;
	max-width: none;
}

.hafez-umenu .hafez-umenu__icon .dashicons {
	width: 18px;
	height: 18px;
	font-size: 18px;
	line-height: 1;
}

.hafez-umenu .hafez-umenu__label {
	flex: 1 1 auto;
	min-width: 0;
}

.hafez-umenu .hafez-umenu__badge {
	min-width: 20px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--hafez-umenu-accent);
	color: var(--hafez-umenu-accent-text);
	font-size: 11px;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
}

.hafez-umenu .hafez-umenu__logout {
	margin-top: 4px;
	border-top: 1px solid var(--hafez-umenu-border);
	border-radius: 0 0 var(--hafez-umenu-radius-sm) var(--hafez-umenu-radius-sm);
	padding-top: 10px;
	color: #d63638;
}

.hafez-umenu .hafez-umenu__logout:hover,
.hafez-umenu .hafez-umenu__logout:focus-visible {
	background: rgba(214, 54, 56, .08);
}

/* Guest button */
.hafez-umenu .hafez-umenu__login {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 40px;
	padding: 8px 16px;
	border-radius: var(--hafez-umenu-radius-sm);
	background: var(--hafez-umenu-accent);
	color: var(--hafez-umenu-accent-text);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color .15s ease, color .15s ease;
}

.hafez-umenu .hafez-umenu__login:hover {
	background: var(--hafez-dp-primary-hover-bg, var(--hafez-umenu-accent));
	color: var(--hafez-dp-primary-hover-text, var(--hafez-umenu-accent-text));
}

.hafez-umenu .hafez-umenu__login-icon {
	display: inline-flex;
}

.hafez-umenu .hafez-umenu__login-icon svg {
	width: 18px;
	height: 18px;
}

/* Dark mode: a deeper shadow and a readable logout colour. */
:is(html[data-dark-mode="true"], body[data-dark-mode="true"], body.hafez-dark) .hafez-umenu .hafez-umenu__panel {
	box-shadow: 0 18px 44px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .35);
}

:is(html[data-dark-mode="true"], body[data-dark-mode="true"], body.hafez-dark) .hafez-umenu .hafez-umenu__logout {
	color: #f87171;
}

/* Phones: the panel opens as a sheet from the bottom of the screen. */
@media (max-width: 480px) {
	.hafez-umenu .hafez-umenu__name {
		display: none;
	}

	.hafez-umenu .hafez-umenu__panel,
	.hafez-umenu.hafez-umenu--align-start .hafez-umenu__panel,
	.hafez-umenu.hafez-umenu--align-center .hafez-umenu__panel {
		position: fixed;
		top: auto;
		right: 0;
		bottom: 0;
		left: 0;
		width: auto;
		max-width: none;
		max-height: 80vh;
		padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
		border-radius: var(--hafez-umenu-radius) var(--hafez-umenu-radius) 0 0;
		transform: none;
	}

	.hafez-umenu .hafez-umenu__link,
	.hafez-umenu .hafez-umenu__logout {
		min-height: 44px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hafez-umenu .hafez-umenu__toggle,
	.hafez-umenu .hafez-umenu__caret,
	.hafez-umenu .hafez-umenu__login {
		transition: none;
	}
}
