/*
 * NEX Header — mobile panel, bottom bar and sheets.
 * Colors/sizes come from CSS variables emitted by PHP. Breakpoint-dependent
 * visibility rules are also emitted by PHP (media queries can't read vars).
 */

.nex-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* ===================== Slide panel (Module 5) ===================== */

.nex-panel-root {
	position: fixed;
	inset: 0;
	z-index: calc(var(--nex-z, 1090) + 10);
}

.nex-panel-root[hidden] {
	display: none;
}

.nex-panel-overlay {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.nex-panel-root.is-open .nex-panel-overlay {
	opacity: 1;
}

.nex-panel {
	position: absolute;
	display: flex;
	flex-direction: column;
	background: var(--nex-panel-bg, #fff);
	color: var(--nex-panel-text, #1f2937);
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	outline: none;
}

/* Bottom-sheet variant. */
.nex-panel--bottom .nex-panel {
	inset-inline: 0;
	bottom: 0;
	max-height: 86dvh;
	min-height: 40dvh;
	border-radius: var(--nex-panel-radius, 20px) var(--nex-panel-radius, 20px) 0 0;
	transform: translateY(105%);
	padding-bottom: env(safe-area-inset-bottom);
}

.nex-panel--bottom.is-open .nex-panel {
	transform: translateY(0);
}

/* Side-drawer variant (start side; flips automatically in RTL). */
.nex-panel--side .nex-panel {
	top: 0;
	bottom: 0;
	inset-inline-start: 0;
	width: min(360px, 86vw);
	transform: translateX(-105%);
}

html[dir="rtl"] .nex-panel--side .nex-panel {
	transform: translateX(105%);
}

/* Same specificity trap as the layers: RTL needs an explicit open rule. */
.nex-panel--side.is-open .nex-panel,
html[dir="rtl"] .nex-panel--side.is-open .nex-panel {
	transform: translateX(0);
}

/* Fixed-side drawer variants: pinned to a physical side regardless of text
   direction (unlike --side, which follows the start edge). Use these only
   when a site specifically needs the drawer on one visual side in both
   LTR and RTL — --side is the right default otherwise. */
.nex-panel--left .nex-panel {
	top: 0;
	bottom: 0;
	left: 0;
	width: min(360px, 86vw);
	transform: translateX(-105%);
}

.nex-panel--left.is-open .nex-panel {
	transform: translateX(0);
}

.nex-panel--right .nex-panel {
	top: 0;
	bottom: 0;
	right: 0;
	width: min(360px, 86vw);
	transform: translateX(105%);
}

.nex-panel--right.is-open .nex-panel {
	transform: translateX(0);
}

.nex-panel--left .nex-panel-grab,
.nex-panel--right .nex-panel-grab {
	display: none;
}

/* Fullscreen takeover: no drawer width, covers the whole viewport. */
.nex-panel--fullscreen .nex-panel {
	inset: 0;
	width: auto;
	border-radius: 0;
	transform: translateY(8%);
	opacity: 0;
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

.nex-panel--fullscreen.is-open .nex-panel {
	transform: translateY(0);
	opacity: 1;
}

.nex-panel--fullscreen .nex-panel-grab {
	display: none;
}

/* Top bar reserves its own row so the close button never overlaps the
   first menu item (was an absolute-position overlap bug in RTL). */
.nex-panel-topbar {
	position: relative;
	flex: 0 0 auto;
	min-height: 46px;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	padding: 6px 10px 0;
}

.nex-panel-grab {
	position: absolute;
	left: 50%;
	top: 8px;
	margin-left: -22px;
	width: 44px;
	height: 4px;
	border-radius: 4px;
	background: currentColor;
	opacity: 0.25;
}

.nex-panel--side .nex-panel-grab {
	display: none;
}

.nex-panel button.nex-panel-close,
.nex-panel-close {
	-webkit-appearance: none;
	appearance: none;
	width: 38px;
	height: 38px;
	margin: 0;
	padding: 0;
	display: grid;
	place-items: center;
	border: 0 !important;
	border-radius: 50% !important;
	background: rgba(0, 0, 0, 0.05) !important;
	box-shadow: none !important;
	color: inherit !important;
	cursor: pointer;
	transition: transform 0.15s ease;
}

.nex-panel-close:active {
	transform: scale(0.92);
}

.nex-panel-close svg {
	width: 18px;
	height: 18px;
}

.nex-panel-header,
.nex-panel-footer {
	flex: 0 0 auto;
	padding: 8px 16px;
}

.nex-panel-viewport {
	flex: 1 1 auto;
	position: relative;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 4px 8px;
}

/* Slide mode: viewport is a fixed stage; the base menu becomes layer 0
   (scrolls on its own) and pushed layers stack above it. */
.nex-panel-root[data-mode="slide"] .nex-panel-viewport {
	overflow: hidden;
}

.nex-panel-root[data-mode="slide"] .nex-panel-menu {
	position: absolute;
	inset: 0;
	overflow-y: auto;
	padding: 4px 8px;
	transition: opacity 0.25s ease, visibility 0.25s;
}

/* Base menu fades out behind open layers (was visibly peeking through). */
.nex-panel-viewport.nex-has-layers > .nex-panel-menu {
	opacity: 0;
	visibility: hidden;
}

/* --- Menu list ---------------------------------------------------- */
/* Covers the base menu AND cloned slide layers (bullets showed on layers). */
.nex-panel-viewport ul,
.nex-panel-menu ul,
.nex-layer ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.nex-mi-row {
	display: flex;
	align-items: center;
}

.nex-panel-menu a.nex-mi-link,
.nex-mi-link {
	flex: 1 1 auto;
	display: block;
	padding: 13px 12px;
	font-size: 15px;
	font-weight: 500;
	font-family: inherit;
	text-decoration: none !important;
	color: inherit !important;
	border-radius: 12px;
	transition: background-color 0.15s ease;
}

.nex-mi-link:active {
	background: rgba(0, 0, 0, 0.05);
}

.nex-panel-menu button.nex-mi-toggle,
.nex-mi-toggle {
	-webkit-appearance: none;
	appearance: none;
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	margin: 0;
	padding: 0;
	display: grid;
	place-items: center;
	border: 0 !important;
	border-radius: 50%;
	background: transparent !important;
	box-shadow: none !important;
	color: inherit !important;
	opacity: 0.55;
	cursor: pointer;
}

.nex-mi-toggle:active {
	background: rgba(0, 0, 0, 0.06) !important;
}

.nex-mi-toggle svg {
	width: 17px;
	height: 17px;
	transition: transform 0.25s ease;
}

/* Chevron points into reading direction. */
html[dir="rtl"] .nex-mi-toggle svg,
html[dir="rtl"] .nex-back-btn svg {
	transform: scaleX(-1);
}

.nex-mi + .nex-mi {
	border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* --- Accordion mode ------------------------------------------------ */
/* Children are indented via link padding (not list padding) so the row
   separators stay full-width — no ragged gap on the inline-start side. */
.nex-panel-root[data-mode="accordion"] .nex-submenu {
	overflow: hidden;
	max-height: 0;
	transition: max-height 0.3s ease, background-color 0.3s ease;
	border-radius: 12px;
}

.nex-panel-root[data-mode="accordion"] .nex-mi.is-open > .nex-submenu {
	background: rgba(0, 0, 0, 0.03);
}

.nex-panel-root[data-mode="accordion"] .nex-submenu .nex-mi-link {
	padding-inline-start: 26px;
	font-size: 14px;
	opacity: 0.9;
}

.nex-panel-root[data-mode="accordion"] .nex-submenu .nex-submenu .nex-mi-link {
	padding-inline-start: 40px;
}

/* Mega-menu template inside the panel (Elementor content, not a link row). */
.nex-mega-content {
	padding: 10px 6px;
}

.nex-mega-content + .nex-mi {
	border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Templates can be tall — give open mega accordions more room. */
.nex-panel-root[data-mode="accordion"] .nex-mi.is-open > .nex-submenu--mega {
	max-height: 400vh;
}

.nex-panel-root[data-mode="accordion"] .nex-mi.is-open > .nex-submenu {
	max-height: 100vh;
}

.nex-panel-root[data-mode="accordion"] .nex-mi.is-open > .nex-mi-row .nex-mi-toggle svg {
	transform: rotate(90deg);
}

html[dir="rtl"] .nex-panel-root[data-mode="accordion"] .nex-mi.is-open > .nex-mi-row .nex-mi-toggle svg {
	transform: scaleX(-1) rotate(90deg);
}

/* --- Slide mode (Apple-style) --------------------------------------- */
.nex-panel-root[data-mode="slide"] .nex-submenu {
	display: none; /* Cloned into layers by JS. */
}

.nex-layer {
	position: absolute;
	inset: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: var(--nex-panel-bg, #fff);
	padding: 4px 8px;
	transform: translateX(100%);
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	z-index: 1;
}

html[dir="rtl"] .nex-layer {
	transform: translateX(-100%);
}

/* Side drawer: submenu layers enter from the SAME side the drawer opened
   from (inline-start), instead of the reading-direction default. */
.nex-panel--side .nex-layer {
	transform: translateX(-100%);
}

html[dir="rtl"] .nex-panel--side .nex-layer {
	transform: translateX(100%);
}

/* The RTL/side selectors above outrank .nex-layer.is-in, so every variant
   needs an explicit open-state rule or layers never slide in. */
.nex-layer.is-in,
html[dir="rtl"] .nex-layer.is-in,
.nex-panel--side .nex-layer.is-in,
html[dir="rtl"] .nex-panel--side .nex-layer.is-in {
	transform: translateX(0);
}

.nex-back-row {
	display: flex;
	align-items: center;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	margin-bottom: 4px;
}

.nex-layer button.nex-back-btn,
.nex-back-btn {
	-webkit-appearance: none;
	appearance: none;
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 13px 12px;
	border: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	color: inherit !important;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	text-transform: none;
	cursor: pointer;
}

.nex-back-btn svg {
	width: 17px;
	height: 17px;
}

.nex-view-all {
	margin-inline-start: auto;
	padding: 13px 12px;
	font-size: 13px;
	color: inherit;
	opacity: 0.7;
	text-decoration: none;
}

.nex-panel-empty,
.nex-more-empty {
	padding: 16px;
	opacity: 0.7;
	font-size: 14px;
}

/* ===================== Bottom bar (Module 6) ===================== */

.nex-bar {
	position: fixed;
	bottom: 0;
	inset-inline: 0;
	z-index: calc(var(--nex-z, 1090) + 9);
	height: calc(var(--nex-bar-h, 60px) + env(safe-area-inset-bottom));
	padding-bottom: env(safe-area-inset-bottom);
	background: var(--nex-bar-bg, #fff);
	border-top: 1px solid rgba(0, 0, 0, 0.05);
	box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.07);
	transition: transform var(--nex-hide-duration, 0.3s) var(--nex-easing, ease);
}

/* +48px so the raised FAB is carried fully off-screen too. */
.nex-bar.nex-bar-hidden {
	transform: translateY(calc(100% + 48px));
}

.nex-bar-scroll {
	display: flex;
	height: var(--nex-bar-h, 60px);
	align-items: stretch;
}

/* Swipe-to-reveal when more than 5 items (Module 6). */
.nex-bar--overflow .nex-bar-scroll {
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}

.nex-bar--overflow .nex-bar-scroll::-webkit-scrollbar {
	display: none;
}

.nex-bar--overflow .nex-bar-item {
	flex: 0 0 20%;
	scroll-snap-align: start;
}

/* Hard normalization: items are a mix of <a> and <button>, and themes
   (WoodMart/Woo) style both aggressively — without this the two element
   types render with different colors/weights/backgrounds. */
.nex-bar a.nex-bar-item,
.nex-bar button.nex-bar-item,
.nex-bar-item {
	-webkit-appearance: none;
	appearance: none;
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	margin: 0;
	padding: 4px 2px;
	border: 0 !important;
	border-radius: 0;
	background: transparent !important;
	box-shadow: none !important;
	color: var(--nex-bar-text, #374151) !important;
	text-decoration: none !important;
	text-transform: none;
	font-family: inherit;
	font-size: var(--nex-bar-label-size, 11px);
	font-weight: 500;
	letter-spacing: 0;
	line-height: 1;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: color 0.2s ease;
}

.nex-bar .nex-bar-item.is-active {
	color: var(--nex-bar-accent, #2563eb) !important;
}

/* Icon sits in a soft pill that lights up for the active item. */
.nex-bar-icon {
	position: relative;
	display: grid;
	place-items: center;
	width: 46px;
	height: 27px;
	border-radius: 999px;
	transition: background-color 0.2s ease, transform 0.15s ease;
}

.nex-bar-item.is-active .nex-bar-icon {
	background: var(--nex-bar-accent-soft, rgba(37, 99, 235, 0.12));
}

.nex-bar-item:active .nex-bar-icon {
	transform: scale(0.9);
}

.nex-bar-icon svg {
	width: var(--nex-bar-icon-size, 23px);
	height: var(--nex-bar-icon-size, 23px);
}

.nex-bar-icon i {
	font-size: var(--nex-bar-icon-size, 21px);
}

.nex-bar-icon .nex-icon-main,
.nex-bar-icon .nex-icon-close {
	display: grid;
	place-items: center;
}

.nex-bar-label {
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Menu-button icon morphs to an X while the panel is open. */
.nex-bar-item .nex-icon-close {
	display: none;
}

.nex-bar-item.is-active .nex-icon-close {
	display: grid;
}

.nex-bar-item.is-active .nex-icon-main {
	display: none;
}

/* Badge (cart count). */
.nex-badge {
	position: absolute;
	top: -5px;
	inset-inline-end: -4px;
	min-width: 17px;
	height: 17px;
	padding: 0 4px;
	display: grid;
	place-items: center;
	background: var(--nex-badge-bg, #dc2626);
	color: #fff;
	font-size: 10px;
	font-weight: 600;
	font-family: inherit;
	border-radius: 999px;
	box-shadow: 0 0 0 2px var(--nex-bar-bg, #fff);
	line-height: 1;
}

.nex-badge.is-empty {
	display: none;
}

/* --- Presets -------------------------------------------------------- */
.nex-bar--glass {
	background: var(--nex-bar-bg, rgba(255, 255, 255, 0.85));
	-webkit-backdrop-filter: blur(var(--nex-bar-blur, 12px));
	backdrop-filter: blur(var(--nex-bar-blur, 12px));
}

.nex-bar--icons .nex-bar-label {
	display: none;
}

.nex-bar--icons .nex-bar-icon svg {
	width: 27px;
	height: 27px;
}

.nex-bar--fab {
	inset-inline: 12px;
	bottom: 10px;
	border-radius: 22px;
	padding-bottom: 0;
	height: var(--nex-bar-h, 60px);
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
	margin-bottom: env(safe-area-inset-bottom);
}

.nex-bar .nex-bar-item.nex-bar-fab {
	flex: 0 0 58px;
	align-self: flex-start;
	width: 58px;
	height: 58px;
	margin-top: -20px;
	border-radius: 50% !important;
	background: var(--nex-bar-accent, #2563eb) !important;
	color: #fff !important;
	box-shadow: 0 8px 20px var(--nex-bar-accent-soft, rgba(37, 99, 235, 0.35)),
		0 4px 12px rgba(0, 0, 0, 0.18) !important;
	transition: transform 0.15s ease;
}

.nex-bar .nex-bar-item.nex-bar-fab:active {
	transform: scale(0.94);
}

.nex-bar .nex-bar-item.nex-bar-fab.is-active {
	color: #fff !important;
}

.nex-bar-fab .nex-bar-icon {
	width: auto;
	height: auto;
}

.nex-bar-fab.is-active .nex-bar-icon {
	background: none;
}

.nex-bar-fab .nex-bar-icon svg {
	width: 26px;
	height: 26px;
}

.nex-bar-fab .nex-bar-label {
	display: none;
}

/* --- Product add-to-cart bar (Module 7) ----------------------------- */
.nex-pb {
	display: flex;
	align-items: center;
	gap: 10px;
	height: var(--nex-bar-h, 60px);
	padding: 0 12px;
}

.nex-pb-menu {
	flex: 0 0 40px;
}

.nex-pb-thumb {
	flex: 0 0 40px;
}

.nex-pb-thumb img {
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: 8px;
	display: block;
}

.nex-pb-info {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.nex-pb-title {
	font-size: 13px;
	font-weight: 600;
	color: var(--nex-bar-text, #374151);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.nex-pb-price {
	font-size: 12px;
	color: var(--nex-bar-accent, #2563eb);
}

.nex-bar a.nex-pb-btn,
.nex-bar button.nex-pb-btn,
.nex-pb-btn {
	-webkit-appearance: none;
	appearance: none;
	flex: 0 0 auto;
	margin: 0;
	padding: 11px 20px;
	border: 0 !important;
	border-radius: 999px !important;
	background: var(--nex-bar-accent, #2563eb) !important;
	color: #fff !important;
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none !important;
	text-transform: none;
	cursor: pointer;
	line-height: 1.2;
	box-shadow: 0 4px 14px var(--nex-bar-accent-soft, rgba(37, 99, 235, 0.3)) !important;
	transition: transform 0.15s ease;
}

.nex-pb-btn:active {
	transform: scale(0.96);
}

/* ===================== Sheets (search / more) ===================== */

.nex-sheet {
	position: fixed;
	inset-inline: 0;
	bottom: 0;
	z-index: calc(var(--nex-z, 1090) + 12);
	background: var(--nex-panel-bg, #fff);
	color: var(--nex-panel-text, #1f2937);
	border-radius: 16px 16px 0 0;
	box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.18);
	padding: 10px 12px calc(8px + env(safe-area-inset-bottom));
	transform: translateY(110%);
	transition: transform 0.25s ease;
}

.nex-sheet[hidden] {
	display: none;
}

.nex-sheet.is-open {
	transform: translateY(0);
}

.nex-search-form {
	display: flex;
	align-items: center;
	gap: 6px;
}

.nex-sheet input.nex-search-input,
.nex-search-input {
	-webkit-appearance: none;
	appearance: none;
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	font-size: 16px; /* Prevents iOS focus zoom. */
	font-family: inherit;
	padding: 8px 16px;
	height: 40px;
	box-sizing: border-box;
	border: 1px solid rgba(0, 0, 0, 0.1) !important;
	border-radius: 999px !important;
	background: rgba(0, 0, 0, 0.04) !important;
	color: inherit !important;
	box-shadow: none !important;
	outline: none;
	transition: border-color 0.2s ease, background-color 0.2s ease;
}

.nex-search-input:focus {
	border-color: var(--nex-bar-accent, #2563eb) !important;
	background: #fff !important;
}

.nex-sheet button.nex-search-submit,
.nex-sheet button.nex-sheet-close,
.nex-search-submit,
.nex-sheet-close {
	-webkit-appearance: none;
	appearance: none;
	flex: 0 0 38px;
	width: 38px;
	height: 38px;
	margin: 0;
	padding: 0;
	display: grid;
	place-items: center;
	border: 0 !important;
	border-radius: 50% !important;
	background: rgba(0, 0, 0, 0.05) !important;
	color: inherit !important;
	box-shadow: none !important;
	cursor: pointer;
	transition: background-color 0.2s ease, transform 0.15s ease;
}

.nex-search-submit {
	background: var(--nex-bar-accent, #2563eb) !important;
	color: #fff !important;
}

.nex-search-submit:active,
.nex-sheet-close:active {
	transform: scale(0.92);
}

.nex-search-submit svg,
.nex-sheet-close svg {
	width: 18px;
	height: 18px;
}

.nex-more-sheet .nex-sheet-close {
	position: absolute;
	top: 10px;
	inset-inline-end: 12px;
}

.nex-search-results {
	max-height: 40vh;
	overflow-y: auto;
	margin-top: 6px;
}

.nex-sr-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 6px;
	text-decoration: none;
	color: inherit;
	border-radius: 10px;
}

.nex-sr-item:hover,
.nex-sr-item:focus {
	background: rgba(0, 0, 0, 0.05);
}

.nex-sr-item img {
	width: 38px;
	height: 38px;
	border-radius: 8px;
	object-fit: cover;
}

.nex-sr-title {
	flex: 1 1 auto;
	min-width: 0;
	font-size: 14px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.nex-sr-price {
	font-size: 12px;
	opacity: 0.75;
}

.nex-more-list {
	list-style: none;
	margin: 26px 0 0;
	padding: 0;
}

.nex-more-list a {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 8px;
	text-decoration: none;
	color: inherit;
	font-size: 15px;
	border-radius: 10px;
}

.nex-more-list li + li {
	border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Body scroll lock while a panel/sheet is open. */
body.nex-lock {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.nex-panel,
	.nex-panel-overlay,
	.nex-layer,
	.nex-bar,
	.nex-sheet,
	.nex-mi-toggle svg,
	.nex-submenu {
		transition: none !important;
	}
}
