@use 'sass:math' as math;
@use 'sass:color' as color;

// ---------------------------------------------------------------------------
// Admin palette — consolidated neutrals/borders: `$line` (WP-ish UI borders),
// `$line-ui` (slightly stronger / dividers), `$surface` / `$surface-raised` (fills).
// Form fields: `--megamenu-form-control-border` on `body.maxmegamenu-admin` (default `$neutral` / #8c8f94).
// Accent: `$wp-admin-theme-color` → WordPress `var(--wp-admin-theme-color)` on `body`.
// `$admin-blue-dark` → `var(--wp-admin-theme-color-darker-20)` (tracks active admin color scheme).
// `$icon-dim` covers dim icons and muted text (merged from `$text-muted`; were #787c82 vs #777).
// `$neutral` = form-border grey only; icon/option tints use `$icon-dim`.
// ---------------------------------------------------------------------------
$white: white;
$black: hsl(0deg 0% 0%);

$wp-admin-theme-color: var(--wp-admin-theme-color);
// Block editor “synced pattern” purple (see `wp-includes/css/dist/editor`); fallback matches core default.
$wp-block-synced-color: var(--wp-block-synced-color, #7a00df);
$admin-blue-dark: var(--wp-admin-theme-color-darker-20);

$success: #46b450;

$error: #d0011b;
$error-link: #b32d2e;
$error-link-hover: #8a2424;
$error-surface: #ffdddd;
$warning: #ffb900;

$ink: #1d2327;
$text: #444;
$text-secondary: #646970;
$text-placeholder: #a7aaad;
$icon-dim: #787c82;
$neutral: #8c8f94;

$surface: #f6f7f7;
$surface-raised: #f0f0f1;

$line: #dcdcde;
$line-ui: #c3c4c7;
$line-strong: #50575e;
$line-dark: #373737;

// Native fields in plugin admin: `body.maxmegamenu-admin` sets `--megamenu-form-control-border` (#{$neutral}).
$megamenu-form-control-border: var(--megamenu-form-control-border, #{$neutral});

// Horizontal gap between settings-page rail nav and main canvas (matches dialog rail column width intent).
$megamenu-settings-rail-gap: 24px;

// Alpha / composed shadows (derived from $black; focus halos use `--wp-admin-theme-color--rgb`)
// Five levels: feather (a05) → light (a07) → mid (a12) → strong (a22) → scrim (a45).
// a04 merged into a05 (0.01 gap); a1 merged into a12 (0.02 gap); a18/white-zero unused → removed.
$shadow-a05: rgba($black, 0.05);
$shadow-a07: rgba($black, 0.07);
$shadow-a12: rgba($black, 0.12);
$shadow-a22: rgba($black, 0.22);
$shadow-a45: rgba($black, 0.45);

// Semantic elevation — four levels covering every shadow use in this file.
$shadow-small:       0 1px 2px $shadow-a07;
$shadow-small-hover: 0 1px 2px $shadow-a05, 0 4px 16px $shadow-a07;
$shadow-large:       0 1px 2px $shadow-a12, 0 12px 48px -8px $shadow-a22;
$shadow-large-hover: 0 4px 28px $shadow-a22;
// Chevron for `.mega-toolbar-native-select` (inline-end; `+ 3px` nudges left vs a 10px baseline).
$mega-toolbar-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2350575e' stroke-width='1.35' stroke-linecap='round' stroke-linejoin='round' d='M2.75 4.5L6 7.75 9.25 4.5'/%3E%3C/svg%3E");
// Modal chrome (Gutenberg / component-style dialogs)
$modal-radius: 10px;
$modal-padding-x: 36px;

@function wp-admin-theme-rgba($alpha) {
	@return #{'rgba(var(--wp-admin-theme-color--rgb), #{$alpha})'};
}

$focus-ring-blue-soft: wp-admin-theme-rgba(0.4);
$focus-ring-blue-strong: wp-admin-theme-rgba(0.45);

$mega-admin-icon-hit: 40px;
$mega-admin-icon-glyph: 24px;

// Standard `:focus-visible` ring for admin controls (color + offset; use inside `&:focus-visible { }`).
@mixin mega-admin-focus-ring($color: $wp-admin-theme-color, $outline-offset: 2px) {
	outline: 2px solid $color;
	outline-offset: $outline-offset;
}

@mixin tablet {
	@media only screen and (max-width: 1200px) {
		@content;
	}
}

@mixin megamenu-admin-icon-dashicon-child($size: $mega-admin-icon-glyph) {
	.dashicons {
		width: $size;
		height: $size;
		font-size: $size;
		line-height: 1;
		speak: none;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}
}

@mixin megamenu-admin-ghost-icon-button-shell(
	$hit: $mega-admin-icon-hit,
	$icon: $mega-admin-icon-glyph
) {
	appearance: none;
	-webkit-appearance: none;
	box-sizing: border-box;
	flex-shrink: 0;
	width: $hit;
	height: $hit;
	margin: 0;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 4px;
	background: transparent;
	cursor: pointer;
	color: $icon-dim;
	line-height: 1;
	box-shadow: none;
	text-shadow: none;
	transition:
		background 0.15s ease,
		color 0.15s ease;

	@include megamenu-admin-icon-dashicon-child($icon);
}

@mixin megamenu-admin-ghost-icon-button-states {
	&:focus:not(:hover) {
		color: $ink;
		background: $surface-raised;
	}

	&:hover {
		color: $ink;
		background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
	}

	&:focus-visible {
		@include mega-admin-focus-ring;
	}
}

// Square ghost control + centered Dashicon (no positioning — use in toolbars / footers).
@mixin megamenu-admin-ghost-icon-button(
	$hit: $mega-admin-icon-hit,
	$icon: $mega-admin-icon-glyph
) {
	@include megamenu-admin-ghost-icon-button-shell($hit, $icon);
	@include megamenu-admin-ghost-icon-button-states;
}

// Dashicon tile rendered on `::before` (menu icon grid); matches ghost button colors / radius / transitions.
@mixin megamenu-admin-icon-pseudo-dashicon-tile(
	$hit: $mega-admin-icon-hit,
	$glyph: $mega-admin-icon-glyph
) {
	box-sizing: border-box;
	width: $hit;
	height: $hit;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	padding: 0;
	border-radius: 4px;
	background: transparent;
	color: $icon-dim;
	line-height: 1;
	font-size: $glyph;
	cursor: pointer;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	transition:
		background 0.15s ease,
		color 0.15s ease,
		box-shadow 0.15s ease;
}

// Shared close control: ghost icon button (header corner on menu item + location modals).
@mixin megamenu-modal-close-button {
	@include megamenu-admin-ghost-icon-button-shell;
	@include megamenu-admin-ghost-icon-button-states;
	position: absolute;
	top: 14px;
	right: 12px;
	z-index: 2;
}

.megamenu-modal-close {
	@include megamenu-modal-close-button;

	.dashicons {
		display: block;
		pointer-events: none;
	}
}


// Sliding underline shared by Menu Themes tabs and the location settings dialog.
@mixin nav-tab-slider-indicator {
	.nav-tab-slider {
		position: absolute;
		bottom: 0;
		left: 0;
		height: 3px;
		background-color: $wp-admin-theme-color;
		border-radius: 2px;
		transition: left 0.3s ease-out, width 0.3s ease-out;
		z-index: 1;
	}
}

// Column span control pill: grid `.mega-col-header > .mega-col-span` + standard `.mega-widget-title-action .mega-col-span`.
@mixin mega-col-span-pill {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 2px;
	flex: 0 1 auto;
	min-width: 0;
	max-width: 100%;
	padding: 3px 2px;
	border-radius: 9999px;
	box-sizing: border-box;
	background: $white;
	border: 1px solid $wp-admin-theme-color;
	color: $wp-admin-theme-color;
}

// Shared vertical rail tabs: Appearance > Menus menu-item modal body + location settings modal.
@mixin megamenu-dialog-side-tab(
	$accent: $wp-admin-theme-color,
	$active-bg: transparent
) {
	appearance: none;
	-webkit-appearance: none;
	margin: 0;
	width: 100%;
	display: block;
	padding: 10px 12px;
	box-sizing: border-box;
	position: relative;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	line-height: 20px;
	text-align: start;
	color: $ink;
	cursor: pointer;
	border: 1px solid transparent;
	border-radius: 0;
	margin-bottom: 2px;
	border-inline-start: 3px solid transparent;
	background: transparent;

	&:focus-visible {
		@include mega-admin-focus-ring($accent);
	}

	&:hover {
		background: $surface;
		color: $ink;
		border-color: transparent;
	}

	&.is-active {
		color: $accent;
		background: $active-bg;
		border-color: transparent;
		font-weight: 600;
		box-shadow: none;
		border-inline-start-color: $accent;

		&:before {
			color: $accent;
		}

		&:after {
			display: none;
		}
	}
}

// Menu item modal: dashed “add widget to this column” slot (`.mega-col-add-widget`) — reused e.g. for “add another menu location”.
@mixin mega-col-add-widget-appearance {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	box-sizing: border-box;
	min-height: 32px;
	padding: 6px 8px;
	border: 1px dashed $line;
	border-radius: 4px;
	background: color.scale($surface, $lightness: 1%);
	cursor: pointer;
	color: $icon-dim;
	transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, opacity 0.2s ease;

	.dashicons {
		font-size: 18px;
		width: 18px;
		height: 18px;
		line-height: 1;
		opacity: 0.45;
		transition: opacity 0.2s ease;
	}

	&:hover,
	&:focus-visible {
		color: $wp-admin-theme-color;
		border-color: $focus-ring-blue-strong;
		background: $white;

		.dashicons {
			opacity: 1;
		}
	}

	&:focus-visible {
		@include mega-admin-focus-ring;
	}
}

@mixin megamenu-dialog-rail-grid($column-gap: 0, $row-gap: 0) {
	display: grid;
	grid-template-columns: 230px 1fr;
	grid-template-rows: minmax(0, 1fr);
	align-items: stretch;
	width: 100%;
	box-sizing: border-box;
	column-gap: $column-gap;
	row-gap: $row-gap;
}

@mixin megamenu-dialog-tablist-shell {
	grid-column: 1;
	grid-row: 1;
	width: 100%;
	position: relative;
	min-height: 0;
	align-self: stretch;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0;
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	overflow-x: hidden;
	overflow-y: auto;
	background: $white;
}

@mixin megamenu-dialog-panels-shell($overflow: auto) {
	grid-column: 2;
	grid-row: 1;
	min-width: 0;
	min-height: 0;
	overflow: $overflow;
	box-sizing: border-box;
	position: relative;
	background: $white;
	border: 0;
}

// Tooltip bubble: any element with [data-mega-tooltip] (plain text and/or dual enabled/disabled). Always centered below the trigger.
@mixin tooltip-popup-base {
	&:before {
		position: absolute;
		content: attr(data-mega-tooltip);
		top: calc(100% + 6px);
		left: 50%;
		transform: translateX(-50%);
		background: $white;
		color: $ink;
		padding: 6px 10px;
		font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
		font-size: 12px;
		font-weight: 400;
		line-height: 1.4;
		border-radius: 2px;
		border: 1px solid $line-strong;
		box-shadow: $shadow-small;
		margin-left: 0;
		width: auto;
		max-width: 280px;
		white-space: nowrap;
		box-sizing: border-box;
		z-index: 101;
		text-align: center;
	}

	// Bordered chevron (not a filled triangle): rotated square so stroke meets the bubble border.
	&:after {
		content: "";
		position: absolute;
		top: calc(100% + 6px);
		left: 50%;
		width: 9px;
		height: 9px;
		margin: 0;
		background: $white;
		border-left: 1px solid $line-strong;
		border-top: 1px solid $line-strong;
		border-right: none;
		border-bottom: none;
		box-sizing: border-box;
		transform: translate(-50%, -50%) rotate(45deg);
		z-index: 102;
	}

	&:before,
	&:after {
		opacity: 0;
		pointer-events: none;
		text-align: center;
		transition: opacity 0.3s ease;
		transition-delay: 0.3s;
	}

	&:focus:before,
	&:focus:after,
	&:focus-visible:before,
	&:focus-visible:after,
	&:hover:before,
	&:hover:after {
		opacity: 1;
	}
}

// Percent widths via nested @for — used by #megamenu-standard (data-columns) only.
@mixin grid-col-widths($container-attr, $item-selector, $item-attr) {
	@for $of from 1 through 12 {
		@for $cols from 1 through $of {
			&[#{$container-attr}='#{$of}'] #{$item-selector}[#{$item-attr}='#{$cols}'] {
				width: math.percentage(math.div($cols, $of));
			}
		}
	}
}

// Full-cell overlay used to visually disable table rows.
@mixin disabled-row-overlay {
	background: $surface;
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	width: 100%;
	content: "";
	opacity: 0.5;
	z-index: 9;
}

// Small caps label above a native `<select>` (matches Menu Themes `.theme-selector-field .mega-short-desc`).
@mixin mega-toolbar-field-label {
	font-size: 11px;
	text-transform: uppercase;
	color: $text;
	display: block;
	margin: 0 0 2px 1px;
}

// Theme editor only: custom chevron + chrome (dialogs use native / WP admin `<select>` styling).
@mixin mega-toolbar-native-select {
	-webkit-appearance: none;
	appearance: none;
	-moz-appearance: none;
	box-sizing: border-box;
	width: 300px;
	max-width: 100%;
	min-height: 40px;
	margin: 0;
	padding: 0 34px 0 10px;
	border: 1px solid $megamenu-form-control-border;
	border-radius: 4px;
	background-color: $white;
	background-image: $mega-toolbar-select-chevron;
	background-repeat: no-repeat;
	background-position: right calc(10px + 3px) center;
	background-size: 12px 12px;
	color: $text;
	font-size: 14px;
	line-height: 1.4;
	font-weight: 400;
	box-shadow: none;
	cursor: pointer;
	transition:
		background-color 0.15s ease,
		color 0.15s ease;

	&:hover,
	&:focus {
		color: $black;
		background-color: $surface;
		border-color: $neutral;
		background-image: $mega-toolbar-select-chevron;
	}

	&:focus-visible {
		@include mega-admin-focus-ring;
		border-color: $wp-admin-theme-color;
		background-image: $mega-toolbar-select-chevron;
	}

	&:disabled {
		opacity: 0.6;
		cursor: default;
		background-color: $surface;
		border-color: $megamenu-form-control-border;
		background-image: $mega-toolbar-select-chevron;
	}
}

// Icon-only destructive control (widget form footer + toggle bar block settings).
@mixin mega-admin-trash-icon-button {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	font: inherit;
	cursor: pointer;
	color: $error;
	text-decoration: none;

	.dashicons {
		width: 20px;
		height: 20px;
		font-size: 20px;
		line-height: 1;
	}

	&:hover,
	&:focus-visible {
		color: $error-link-hover;
		background: $error-surface;
	}

	&:focus-visible {
		@include mega-admin-focus-ring;
	}
}

// Card chrome for theme editor fields (e.g. toggle block picker). Menu Themes `.theme_selector` in the dialog rail uses plain layout only (no card shell).
@mixin mega-theme-editor-card-shell {
	padding: 16px 20px;
	border-radius: 8px;
	border: 1px solid $megamenu-form-control-border;
	background: $surface;
	box-shadow: $shadow-small;
	color: $text;
	box-sizing: border-box;
	transition: box-shadow 0.2s ease;

	&:hover {
		box-shadow: $shadow-small-hover;
	}
}

body.maxmegamenu-admin .megamenu_outer_wrap table {

	width: 100%;
	border-collapse: collapse;

	label {
	    font-size: 0.9em;
	    display: inline-block;
	}

	h5 {
		font-size: 16px;
		margin: 0;
	}

	.mega-radio-row {
		// `td.mega-value` is a row flex container; without a full line basis, rows sit side-by-side.
		flex: 1 1 100%;
		width: 100%;
		max-width: 100%;
		min-width: 0;
		box-sizing: border-box;
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		align-items: center;
		gap: 8px;
		margin: 0;

		input[type="radio"] {
			margin: 0;
			flex-shrink: 0;
		}

		label {
			float: none;
			position: static;
			top: auto;
			margin: 0;
			font-size: 1em;
			line-height: 1.4;
		}
	}

	textarea,
	input[type=text],
	input[type=number],
	select {
		font-size: 12px;
		min-height: 28px;
		line-height: 26px;
	}

	textarea {
		box-sizing: border-box;
		width: 100%;
		max-width: 100%;
		min-width: 0;
		font-family: monospace;
		min-height: 150px;
	}

	input[type=number] {
		height: auto;
	}

	input[name=export] {
		margin-top: 20px;
	}

	input[type=text] {
		min-width: 70px;
		field-sizing: content;
	}

	input[type=text].wide {
		width: 300px;
	}

	input[type=submit] {
		width: auto;
	}

	input[type=checkbox] {
		margin-top: 2px;
		vertical-align: middle;
	}

	.wide input[type=text] {
		width: 300px;
	}
	
	.CodeMirror {
		width: 100%;
		height: auto;
	    min-height: 150px;
		border: 1px solid $megamenu-form-control-border;
	}

	div.CodeMirror span.CodeMirror-matchingbracket {
		color: green;
	}

	.CodeMirror-scroll {
		min-height: 150px;
	}

	th {
		text-align: left;
	}

	td {
		position: relative;
		padding-bottom: 25px;
		padding-top: 15px;

		&.mega-name {
			width: 33%;
			line-height: 2em;
			padding-right: 30px;
			vertical-align: top;
		}

		&.mega-value {
			min-width: 0;
			padding-top: 20px;
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			align-items: flex-start;
			gap: 10px;

			> label {
				display: flex;
				flex-direction: column;
				align-items: flex-start;
				margin: 0;
			}

			// Custom icon (Pro): same label + `.mega-short-desc` + number + unit pattern as theme rows,
			// but row layout so the unit stays on the line with the input (overrides column `> label` above).
			> label.mega-desc-with-input {
				flex-direction: row;
				flex-wrap: wrap;
				align-items: center;
				gap: 6px;
				float: none;
				width: auto;
				max-width: 100%;
				min-width: 0;
				box-sizing: border-box;

				.mega-short-desc {
					flex: 1 0 100%;
					float: none;
					width: auto;
				}

				// Keep digit-sized fields from stretching in the flex row (icon/logo width & height in Pro).
				input[type='number'] {
					flex: 0 0 auto;
					width: auto;
					min-width: 3.5em;
					max-width: 6em;
				}

				.mega-after {
					flex: 0 0 auto;
					display: inline;
					float: none;
					margin: 0;
					vertical-align: middle;
					line-height: inherit;
					height: auto;
					border: 0;
					background: none;
					box-shadow: none;
					padding: 0;
				}
			}

			form {
				width: 100%;
			}

			// Full-width blocks (e.g. Menu Locations card grid): flex row would otherwise shrink-wrap.
			> p,
			> .mega-location-cards-root {
				flex: 1 1 100%;
				width: 100%;
				min-width: 0;
				box-sizing: border-box;
			}

			.mega-description {
				margin-top: 5px;
			}

			.mega-info {
				flex: 1 1 100%;
				display: block;
				font-size: 0.9em;
				color: $icon-dim;
				line-height: 20px;
				width: 100%;

				&:before {
					font: 400 20px/1 dashicons;
					content: "\f348";
					speak: none;
					padding: 0;
					margin-right: 6px;
					display: inline-block;
					vertical-align: top;
					-webkit-font-smoothing: antialiased;
					-moz-osx-font-smoothing: grayscale;
				}
			}

			#megamenu-theme-textarea-custom_css {
				flex: 1 1 100%;
				width: 100%;
				min-width: 0;
				align-self: stretch;
			}
		}

	}	


	td.mega-name:has(.mega-description) .mega-name-title {
		font-weight: 500;
	}

	.mega-description {
		font-size: 13px;
		color: $icon-dim;
		line-height: 1.5em;
		width: 80%;

		p {
			font-size: 12px;
		}
	}

	ul.custom_styling_tips {
		list-style-type: disc;
		list-style-position: inside;

		code {
			margin: 10px 0 0 0;
			font-size: 0.9em;
		}
	}

	label.mega-error input {
		border: 1px solid $error;
		background: $error-surface;
	}

	label.mega-toggle_blocks {
		width: 100%;
		max-width: 100%;
		box-sizing: border-box;
		cursor: auto;

		.mega-value {
		    padding-bottom: 0;
		}

		.mega-description {
		    display: block;
		    width: 100%;
		    margin-top: 20px;
		}

		.toggle-bar-designer {
			width: 100%;
			max-width: 100%;
			box-sizing: border-box;

			.mega-blocks {
				display: flex;
				box-sizing: border-box;
				width: 100%;
				min-width: 0;
			}

			.mega-blocks .mega-left,
			.mega-blocks .mega-center,
			.mega-blocks .mega-right {
			    box-sizing: border-box;
			    border: 1px solid $line-ui;
			    background: $surface;
			    height: 60px;
			    padding: 10px;
			    margin-top: 15px;
			    display: flex;
			    flex-basis: 33.3333%;
			}
			.mega-blocks .mega-left {
				border-right: 0px;
				flex: 1;
			}
			.mega-blocks .mega-center {
			    border-left: 1px dashed $line-ui;
			    border-right: 1px dashed $line-ui;
			    justify-content: center;
			}
			.mega-blocks .mega-right {
			    border-left: 0px;
			    flex: 1;
			    justify-content: flex-end;
			}
			.mega-blocks .mega-right .block {
			    margin: 0 0 0 5px;
			}
			.mega-blocks .block.mega-open .block-title {
			    border-bottom: 1px solid $white;
			    border-radius: 3px 3px 0 0;
			}
			.mega-blocks .block .block-title {
			    padding: 0 10px;
			    display: inline-block;
			    height: 35px;
			    line-height: 35px;
			    font-size: 0.9em;
			    background: $white;
			    color: $text;
			    cursor: move;
			    border: 1px solid $line-ui;
			    position: relative;
			    z-index: 2;
			    border-radius: 3px;
			    text-align: left;
			    box-sizing: border-box;
			    white-space: nowrap;
			}

			.mega-blocks .block.ui-sortable-helper {
			    width: auto !important;
			}

			.mega-blocks .block .block-title .dashicons {
			    line-height: 35px;
			    cursor: pointer;
			    font-size: 20px;
			}

			.mega-blocks .block .block-settings {
			    padding: 10px;
			    display: none;
			    width: 300px;
			    vertical-align: top;
			    background: $white;
			    text-align: left;
			    color: $text;
			    position: absolute;
			    left: 0px;
			    top: 34px;
			    z-index: 1;
			    border: 1px solid $megamenu-form-control-border;

			    .mega-custom-color-input-wrapper {
			    	margin-left: auto;
			    }
			}

			.mega-blocks .mega-right .block .block-settings {
			    left: auto;
			    right: 0;
			}

			.mega-blocks .block h3 {
			    margin-top: 5px;
			    border-bottom: 1px solid $line-ui;
			    padding-bottom: 10px;
			}

			// Label text left, inputs grouped on the right (sentence case — no toolbar all-caps).
			.block-settings label {
				width: 100%;
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				align-items: center;
				justify-content: flex-start;
				gap: 8px 12px;
				box-sizing: border-box;
				margin: 0 0 12px 0;
				font-size: 13px;
				font-weight: 400;
				line-height: 1.4;
				color: $text;
				text-transform: none;
			}

			.block-settings label:last-of-type {
				margin-bottom: 0;
			}

			.block-settings label .mega-description {
				flex: 1 0 100%;
				width: 100%;
				text-transform: none;
				font-size: 12px;
				font-weight: 400;
				line-height: 1.45;
				color: $icon-dim;
				margin: 4px 0 0;
			}

			.block-settings label input,
			.block-settings label select,
			.block-settings label input[type='number'],
			.block-settings label .icon_dropdown {
				flex: 0 1 auto;
				width: auto;
				min-width: 0;
				max-width: min(240px, 58%);
				margin-left: auto;
				box-sizing: border-box;
				font-size: 14px;
				font-weight: 400;
				text-transform: none;
				color: $text;
			}

			.block-settings label textarea {
				flex: 0 1 auto;
				width: auto;
				min-width: 0;
				max-width: min(100%, 320px);
				min-height: 80px;
				margin-left: auto;
				box-sizing: border-box;
				font-size: 14px;
				font-weight: 400;
				text-transform: none;
				color: $text;
			}

			.block-settings label input[type='number'] {
				height: 32px;
				line-height: 32px;
			}

			.block-settings .mega-custom-color-input-wrapper {
				flex: 0 1 auto;
				margin-left: auto;
				width: auto;
				max-width: min(240px, 58%);
			}

			.block-settings label .mmm_image_selector {
				flex: 0 1 auto;
				margin-left: auto;
				max-width: min(240px, 58%);
			}

			// Beat `.mega-blocks .block input[type=text] { width: 50%; }` — keep controls on the right, not half-bar width.
			.mega-blocks .block .block-settings label input[type='text'],
			.mega-blocks .block .block-settings label input[type='number'] {
				width: auto;
				max-width: min(240px, 58%);
			}

			.mega-blocks .block .block-settings label textarea {
				width: auto;
				max-width: min(100%, 320px);
			}

			.block-settings .mega-delete {
				@include mega-admin-trash-icon-button;
				margin-top: 12px;
			}

			.toggle-left {
				border-right: 1px dashed $line-ui;
			}

			.toggle-right {
			    border-left: 0px solid $line-ui;
			    text-align: right;

			}

			.mega-blocks .block {
			    position: relative;
			    display: inline-block;
			    vertical-align: top;
			    margin: 0 5px 0 0;

			    input[type=text] {
				    width: 50%;
				}
			}
		}
	}


	.mega-validation-message {
	    display: none;
	    font-size: 0.8em;
	    color: $error;
	}

	label span.mega-short-desc {
		font-size: 11px;
		text-transform: uppercase;
		color: $icon-dim;
		display: block;
		margin: 0 0 5px;
	}

	label.mega-copy_color {
	    margin-right: 3px;

	    span.mega-short-desc {
		    visibility: hidden;
		}

		span.dashicons {
		    opacity: 0.5;
		    margin-top: 6px;
		    font-size: 16px;
		    cursor: pointer;
		}
	}

	label:has(textarea) {
		width: 100%;
	}

	// Menu item + sub-menu align rows: `select` + `.mega-description` on one line.
	// Global `.mega-description { width: 80% }` above would force the description to ~80% of the cell,
	// so it wraps below the select; override so both rows match.
	.mega-menu-item-align,
	.mega-sub-menu-align {
		td.mega-value {
			display: flex;
			flex-wrap: wrap;
			align-items: flex-start;
			gap: 10px;

			select {
				float: none;
				flex: 0 0 auto;
			}

			.mega-description {
				float: none;
				margin-left: 0;
				margin-right: 0;
				margin-top: 0;
				width: auto;
				max-width: 100%;
				flex: 1 1 auto;
				min-width: 0;
			}
		}
	}

}

// Menu item modal: label column vertical padding (overrides global `.megamenu_outer_wrap table td`).
body.maxmegamenu-admin .megamenu-menu-item-dialog .megamenu_outer_wrap table td.mega-name {
	padding-top: 10px;
	padding-bottom: 10px;
}

// Pro "Styling" tab: name/enable column widths + row striping; dim name/value from checkbox via :has (no JS).
body.maxmegamenu-admin.nav-menus-php .megamenu-menu-item-dialog .megamenu_outer_wrap .megamenu_content.styling {
	.mega-name {
		width: 40%;
	}

	.mega-enable {
		width: 1%;
	}

	td.mega-enable:after {
		display: none;
	}

	tr:has(.override_toggle_enabled:checked) td:after {
		display: none;
	}

	tr:has(.override_toggle_enabled:not(:checked)) td.mega-name,
	tr:has(.override_toggle_enabled:not(:checked)) td.mega-value {
		opacity: 0.45;
		filter: grayscale(0.15);
		transition: opacity 0.15s ease, filter 0.15s ease;
	}

	tr:has(.override_toggle_enabled:checked) td.mega-name,
	tr:has(.override_toggle_enabled:checked) td.mega-value {
		opacity: 1;
		filter: none;
	}

	td {
		position: relative;
		padding: 10px;
		vertical-align: middle;
	}

	td:after {
		content: "";
		background: $surface-raised;
		display: block;
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		opacity: 0.5;
		z-index: -1;
		pointer-events: none;
	}
}

body.rtl.maxmegamenu-admin.nav-menus-php {
	.megamenu_launch {
		margin-left: 0;
		margin-right: 8px;
	}
	.megamenu-menu-item-dialog .megamenu_outer_wrap.megamenu-dialog-rail {
		grid-template-columns: 1fr 230px;
	}
	.megamenu-menu-item-dialog .megamenu_outer_wrap .mega-tablist {
		grid-column: 2;
	}
	.megamenu-menu-item-dialog .megamenu_outer_wrap .megamenu-dialog-panels {
		grid-column: 1;
	}
	.megamenu-menu-item-dialog .megamenu-admin-modal__title {
		flex-direction: row-reverse;
	}
	.megamenu-menu-item-dialog .megamenu_outer_wrap table .mega-menu-item-align td.mega-value,
	.megamenu-menu-item-dialog .megamenu_outer_wrap table .mega-sub-menu-align td.mega-value {
		display: flex;
		flex-wrap: wrap;
		align-items: flex-start;
		gap: 10px;

		select {
			float: none;
			flex: 0 0 auto;
		}

		.mega-description {
			float: none;
			margin-left: 0;
			margin-right: 0;
			margin-top: 0;
			width: auto;
			max-width: 100%;
			flex: 1 1 auto;
			min-width: 0;
		}
	}
	.megamenu-menu-item-dialog .megamenu_outer_wrap .mega-tablist button.is-active:after {
		right: auto;
		left: 0;
	}
	.megamenu-menu-item-dialog .megamenu_outer_wrap .mega_menu .mega-widget-title-action {
		direction: ltr;
	}
	.megamenu-admin-modal {
		left: 0;
		right: 160px;
	}
}

body.folded.maxmegamenu-admin:not(.rtl) .megamenu-admin-modal {
	left: 36px;
	right: 0;
}

body.rtl.folded.maxmegamenu-admin .megamenu-admin-modal {
	left: 0;
	right: 36px;
}

@media screen and (max-width: 782px) {
	body.maxmegamenu-admin .megamenu-admin-modal {
		left: 0 !important;
		right: 0 !important;
	}
}

body.rtl.maxmegamenu-admin .megamenu-admin-modal {
	left: 0;
	right: 160px;
}

body.maxmegamenu-admin .wp-media-buttons {
	.button {
		margin: 0;
		padding: 0 8px;
	}

	.button:has(.dashicons) {
		display: inline-flex;
		align-items: center;
		gap: 4px;
	}

	.button span.dashicons {
		display: flex;
		align-items: center;
		font-size: 16px;
	}
}

// Icon-only admin buttons (e.g. Pro media selector): tighter horizontal padding than `.button-compact`.
body.maxmegamenu-admin .button.button-compact.button-icon-only {
	padding: 0 6px;
}

// Core accordion / postbox overflow would clip ::before/::after tooltips on the Menus screen.
body.maxmegamenu-admin #mega_menu_meta_box,
body.maxmegamenu-admin #mega_menu_meta_box-content,
body.maxmegamenu-admin #mega_menu_meta_box-content > :first-child,
body.maxmegamenu-admin #mega_menu_meta_box .accordion-section-content {
	overflow: visible !important;
}

// Menu Locations tab: full-width intro stacks above the card grid (no table column layout).
body.maxmegamenu-admin .megamenu_wrap.megamenu-dialog-rail > .megamenu-dialog-panels .menu_settings.menu_settings_menu_locations {
	> .mega-menu-locations-page-intro {
		margin: 0 0 50px;
		max-width: 100%;
		box-sizing: border-box;

		.mega-description {
			margin: 0;
			max-width: 52em;
			color: $icon-dim;
			font-size: 13px;
			line-height: 1.5;

			p {
				margin: 0 0 1em;

				&:last-child {
					margin-bottom: 0;
				}
			}
		}

		.mega-menu-locations-page-intro__empty {
			margin: 1em 0 0;
			color: $icon-dim;
			font-size: 13px;
			line-height: 1.5;
		}
	}
}

// Location cards (Menu Locations + Max Mega Menu meta box on nav-menus.php): one root, optional `--meta` for narrow column.
body.maxmegamenu-admin .menu_settings.menu_settings_menu_locations.mega-location-cards-root {
	.mega-location-cards {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 24px;
		width: 100%;

		&:empty {
			display: none;
		}

		@media screen and (max-width: 782px) {
			grid-template-columns: minmax(0, 1fr);
		}

		@media screen and (min-width: 1800px) {
			grid-template-columns: repeat(3, minmax(0, 1fr));
		}
	}

	// Same chrome as menu item modal `.mega-col-add-widget` (dashed add slot).
	a.mega-location-add-card {
		@include mega-col-add-widget-appearance;
		height: 150px;
		min-height: 150px;
		gap: 6px;
		text-decoration: none;
		vertical-align: middle;
		font-size: 13px;
		font-weight: 500;
	}

	.mega-location.postbox {
		margin: 0;
		min-width: 0;
		border: 1px solid $line-ui;
		border-radius: 4px;
		box-shadow: $shadow-small;
		background: $white;
		font-size: 14px;

		&:hover {
			box-shadow: $shadow-small-hover;
		}

		&.mega-location--new-highlight {
			animation: mm-mega-widget-selector-pulse 0.85s ease-in-out infinite;

			@media (prefers-reduced-motion: reduce) {
				animation-iteration-count: 2;
			}
		}

		&.mega-location-mmm-off > .mega-inside > footer .wp-media-buttons .button,
		&.mega-location-disabled > .mega-inside > footer .wp-media-buttons .button {
			margin: 0;
			opacity: 0.5;
			filter: grayscale(1);
		}

		> .mega-inside {
			margin: 0;
			padding: 20px;
			box-sizing: border-box;
		}

		.mega-location__header {
			padding: 0 0 10px;
			border: 0;
		}

		.mega-location__header-row {
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			justify-content: space-between;
			gap: 12px;
		}

		.mega-location__title {
			display: flex;
			align-items: center;
			gap: 8px;
			margin: 0;
			font-size: 16px;
			font-weight: 600;
			line-height: 1.35;
			color: $ink;
			flex: 1 1 auto;
			min-width: 0;
		}

		.mega-location__title-icon {
			flex-shrink: 0;
			width: 22px;
			height: 22px;
			font-size: 22px;
			line-height: 1;
			color: $text-secondary;
		}

		.mega-location__title--editable .mega-location__title-cluster {
			display: flex;
			align-items: center;
			gap: 4px;
			min-width: 0;
			flex: 0 0 auto;
			cursor: pointer;
		}

		.mega-location__title--editable .mega-location__title-display {
			min-width: 0;
			flex: 0 1 auto;
		}

		.mega-location__title--editable .mega-location__title-text {
			display: block;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}

		/* Our `display: block` above beats UA `[hidden]` — restore hiding when editing. */
		.mega-location__title--editable .mega-location__title-text[hidden] {
			display: none;
		}

		.mega-location__title-edit {
			@include megamenu-admin-ghost-icon-button-shell;
			flex-shrink: 0;
			opacity: 0;
			transition: opacity 0.15s ease;

			&:focus-visible {
				@include mega-admin-focus-ring;
			}
		}

		.mega-location__title--editable .mega-location__title-cluster:hover .mega-location__title-edit,
		.mega-location__title--editable .mega-location__title-cluster:focus-within .mega-location__title-edit {
			opacity: 1;
		}

		.mega-location__title-cluster:has(.mega-location__title-edit-field:not([hidden])) .mega-location__title-edit {
			display: none;
		}

		.mega-location-card-title-input {
			box-sizing: border-box;
			width: fit-content;
			min-width: 3ch;
			max-width: 100%;
			margin: 0;
			font-size: 16px;
			font-weight: 600;
			line-height: 1.35;
			-webkit-field-sizing: content;
			field-sizing: content;
		}

		.mega-location__header-actions {
			display: inline-flex;
			align-items: center;
			gap: 8px;
			flex-shrink: 0;
		}

		&[data-mega-location^="max_mega_menu_"] .mega-location__delete {
			display: none;
		}

		&[data-mega-location^="max_mega_menu_"].mega-location-mmm-off .mega-location__delete {
			display: inline-flex;
		}

		button.mega-location-delete-link {
			display: inline-flex;
			align-items: center;
			margin: 0;
			padding: 0 10px;
			border: 0;
			border-radius: 4px;
			background: transparent;
			color: $error-link;
			font: inherit;
			line-height: inherit;
			text-align: inherit;
			text-decoration: none;
			cursor: pointer;
			box-shadow: none;

			&:hover,
			&:focus {
				color: $error-link-hover;
			}

			&[aria-disabled="true"] {
				cursor: not-allowed;
				opacity: 0.6;
			}

			.dashicons {
				margin-right: 4px;
				font-size: 18px;
				width: 18px;
				height: 18px;
			}
		}

		.mega-location__meta {
			display: flex;
			flex-direction: column;
			gap: 8px;
			padding: 0 0 10px;
			font-size: 13px;
			line-height: 1.5;
			color: $text-secondary;
		}

		.mega-location__meta p {
			margin: 0;
		}

		.mega-location__assigned-link {
			color: $wp-admin-theme-color;
			font-weight: 400;
			text-decoration: underline;
			text-underline-offset: 2px;

			&:hover,
			&:focus {
				color: $admin-blue-dark;
			}
		}

		&.mega-location-disabled-assign-menu .mega-location__header-row .components-form-toggle {
			opacity: 0.5;
			pointer-events: none;
			filter: grayscale(1);
		}

		> .mega-inside > footer.mega-location__footer {
			display: flex;
			padding: 15px 0 0;
			border: 0;
		}

		footer.mega-location__footer .wp-media-buttons {
			display: flex;
			flex-wrap: wrap;
			gap: 10px;
			align-items: center;
			margin: 0;
		}

		button.megamenu-preview-open:disabled,
		button.megamenu-preview-open[disabled] {
			cursor: not-allowed;
		}
	}

	&.mega-location-cards-root--meta {
		.mega-location-cards {
			grid-template-columns: minmax(0, 1fr);
			align-items: start;
		}

		.mega-location.postbox {
			&.mega-location-mmm-off > .mega-inside > footer.mega-location__footer {
				max-height: 0;
				min-height: 0;
				padding-top: 0;
				padding-bottom: 0;
				gap: 0;
				opacity: 0;
				pointer-events: none;
				visibility: hidden;
				overflow: hidden;
				transition:
					max-height 0.35s ease,
					padding 0.35s ease,
					opacity 0.25s ease,
					visibility 0s linear 0.35s;

				@media (prefers-reduced-motion: reduce) {
					transition-duration: 0.01ms;
					transition-delay: 0s;
				}

				.wp-media-buttons .button {
					opacity: 1;
					filter: none;
				}
			}

			> .mega-inside > footer.mega-location__footer {
				max-height: 320px;
				opacity: 1;
				pointer-events: auto;
				visibility: visible;
				transition:
					max-height 0.35s ease,
					padding 0.35s ease,
					opacity 0.28s ease,
					visibility 0s linear;

				@media (prefers-reduced-motion: reduce) {
					transition-duration: 0.01ms;
				}

				.wp-media-buttons {
					float: none;
					clear: none;
					width: 100%;
					max-width: 100%;
					box-sizing: border-box;
					margin: 0;
					gap: 10px;
				}
			}

			.mega-location__header-row {
				flex-wrap: nowrap;
			}
		}

		.mega-location__assigned,
		footer.mega-location__footer .delete,
		.mega-location__delete,
		button.mega-location-delete-link {
			display: none !important;
		}

		.mega-location__meta:not(:has(.mega-location__description)) {
			display: none !important;
		}
	}
}

// Plugin admin screens: white #wpwrap main canvas (Appearance > Menus keeps core WP chrome).
body.maxmegamenu-admin:not(.nav-menus-php) #wpwrap {
	background-color: $white;
}

// Lock document scroll while any mega admin dialog is open (menu item, preview, location settings, theme editor).
// `html` + `body`: dialog-menu-item-settings.js; `body` only: dialog-preview.js, dialog-location-settings.js, theme-editor.js.
html.megamenu-dialog-open,
body.megamenu-dialog-open {
	overflow: hidden;
	overscroll-behavior: none;
}

body.megamenu-dialog-open #wpwrap {
	overflow: hidden;
}

body.maxmegamenu-admin.nav-menus-php {


	&.megamenu-dialog-open {
		ul#adminmenu a.wp-has-current-submenu:after,
		ul#adminmenu>li.current>a.current:after {
			border-right-color: $line-dark;
		}
	}

	// Appearance > Menus: map pin before the "Display location" legend (core `.menu-theme-locations` fieldset).
	.menu-theme-locations .menu-settings-group-name::before {
		display: inline-block;
		margin-inline-end: 5px;
		font-family: dashicons;
		font-size: 16px;
		font-weight: normal;
		font-style: normal;
		line-height: 1;
		vertical-align: -0.15em;
		speak: never;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
		content: "\f230"; // dashicons-location
	}

	.megamenu-menu-item-dialog .megamenu_outer_wrap.megamenu-dialog-rail {
		flex: 1 1 auto;
		width: 100%;
		min-height: 0;
		padding: 0;
		user-select: none;
		position: relative;

		.CodeMirror {
			user-select: auto;
		}

		// Custom HTML widget (core): constrain CodeMirror inside the menu-item widget form.
		.mega-widget .custom-html-widget-fields .CodeMirror {
			max-height: 150px;
			min-height: 150px;
			height: auto;
		}

		.mega-widget .custom-html-widget-fields .CodeMirror-scroll {
			max-height: 150px;
			min-height: 0;
		}

		.notice {
			margin: 10px 0 0 0;

			.notice-dismiss:focus {
				box-shadow: none;
			}
		}

		.megamenu_tabs {
			li.megamenu_tab_horizontal {
				cursor: pointer;
				font-size: 12px;
				font-weight: normal;
				padding: 3px 5px;
				margin: 0;
				color: $text;
				border-radius: 3px;
				background: $surface;
				border: 1px solid $line;

				&.active,
				&:hover {
					background: $wp-admin-theme-color;
					border-color: $wp-admin-theme-color;
					color: $white;
				}
			}

			&.horizontal {
				width: auto;
				max-width: 100%;
				margin-top: 0;
				margin-bottom: 0;
				display: flex;
				flex-flow: row wrap;
				align-items: center;
				gap: 8px 15px;
			}
		}

		.megamenu_icon_tab_toolbar {
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			align-items: center;
			gap: 12px 16px;
			width: 100%;
			margin-top: 10px;
			margin-bottom: 0;
			box-sizing: border-box;

			.megamenu_tabs.horizontal {
				flex: 1 1 auto;
				min-width: 0;
			}

			#filter_icons.filter_icons {
				flex: 0 0 auto;
				margin-left: auto;
				min-height: 28px;
			}

			// Custom Icon sub-tab has no dashicons/FA grid — hide search (rel matches menu-item-manager `megamenu_tab_{$id}`).
			&:has(li.megamenu_tab_horizontal.active[rel='megamenu_tab_custom']) {
				.filter_icons,
				#filter_icons.filter_icons {
					display: none;
				}
			}
		}

		.filter_icons {
			width: auto;
			min-width: 120px;
			max-width: 220px;
			font-size: 0.9em;
			box-sizing: border-box;
		}

		p.submit {
			margin: 0;
			padding-top: 16px;
			padding-bottom: 20px;
			position: sticky;
			bottom: 0;
			z-index: 1;
			background: $white;
		}

		.megamenu-dialog-panels {
			padding: 20px 32px 0;
			width: auto;
			height: auto;
			align-self: stretch;
			position: relative;

			&:has(.mega-widget.open) {
				isolation: isolate;
				overflow: auto;
				overscroll-behavior: contain;
				height: 100%;
				max-height: 100%;
				min-height: 0;

				// Transparent click-capture layer: prevents accidental clicks on the grid behind the
				// open widget form. Visual dimming is handled by the box-shadow on `.mega-widget-inner`.
				&::before {
					content: "";
					position: absolute;
					inset: 0;
					z-index: 40;
					pointer-events: auto;
					background: transparent;
				}

				// Anchor `.mega-widget-inner` to this panels element (override grid + WP widget positioning contexts).
				// This ensures `position: absolute` on `.mega-widget-inner` resolves to the panels container.
				.megamenu_content.mega_menu #megamenu-grid .mega-row {
					position: static;
				}

				.megamenu_content.mega_menu #megamenu-grid .mega-row .mega-col {
					position: static;
				}

				.megamenu_content.mega_menu .mega-widget.open {
					position: static;
				}
			}
		}

		.megamenu_content.mega_menu {
			display: flex;
			flex-direction: column;
			gap: 16px;

			#megamenu-standard,
			#megamenu-grid {
				display: none;
			}

			// `mm_panel_options` matches megamenu-pro (columns + widget); visibility follows sub menu type.
			.mega-submenu-toolbar > .mm_panel_options {
				display: none;
			}

			&[data-type='grid'] {
				#megamenu-grid {
					display: block;
				}

				.mega-submenu-toolbar > .mm_panel_options {
					display: flex;
				}
			}

			&[data-type='megamenu'] {
				.mega-submenu-toolbar > .mm_panel_options {
					display: flex;
				}

				#megamenu-standard {
					display: flex;
				}

				.mega-submenu-toolbar > .mm_panel_options select#mm_number_of_columns {
					display: inline-block;
					width: auto;
					min-width: 120px;
					max-width: 200px;
				}
			}

			#megamenu-tabbed {
				display: none;
				margin-top: 20px;

				p {
					font-style: italic;
				}
			}

			&[data-type='tabbed'] #megamenu-tabbed {
				display: block;
			}

			&[data-type='tabbed'] .mega-submenu-toolbar > .mm_panel_options {
				display: none;
			}

			// Flyout: only the display-mode field stays in the top toolbar; hide columns + widget row.
			&[data-type='flyout'] .mega-submenu-toolbar > .mm_panel_options {
				display: none;
			}

			.mega-submenu-toolbar {
				display: flex;
				flex-wrap: wrap;
				align-items: flex-end;
				column-gap: 16px;
				row-gap: 12px;
				width: 100%;
				margin-bottom: 20px;
				overflow: visible;

				> label[for='mm_enable_mega_menu'] {
					@include mega-toolbar-field-label;
					flex: 0 0 100%;
					width: 100%;
				}

				// Menu item modal: layout only — no `@include mega-toolbar-native-select` (theme editor only).
				> select#mm_enable_mega_menu {
					width: auto;
					min-width: 200px;
					max-width: min(360px, 100%);
				}

				> .mm_panel_options {
					flex-flow: row nowrap;
					align-items: flex-end;
					justify-content: flex-end;
					gap: 12px 16px;
					min-width: 0;
					margin-left: auto;
					flex: 1 1 auto;

					// Column count applies to Standard layout only (not Grid).
					select#mm_number_of_columns {
						display: none;
					}

					select#mm_widget_selector {
						min-width: 200px;
						max-width: 360px;
						width: auto;
						flex: 1 1 auto;
					}

					select#mm_widget_selector.mega-widget-selector-pulse {
						border-radius: 4px;
						animation: mm-mega-widget-selector-pulse 0.85s ease-in-out 2;

						@media (prefers-reduced-motion: reduce) {
							animation-iteration-count: 1;
						}
					}
				}
			}

			> #megamenu-standard,
			> #megamenu-grid {
				width: 100%;
			}

			#megamenu-grid {
				padding-bottom: 100px;

				> .drop-area.ui-sortable-placeholder {
					max-height: none !important;
					min-height: 0;
				}

				> .mega-row.ui-sortable-helper {
					min-height: 0;
					max-height: none;
				}

				&:not(.mega-grid--rows-sortable) .mega-row .mega-row-header {
					cursor: default;

					&:active {
						cursor: default;
					}
				}

				> .drop-area {
					margin-top: 20px;
					border: 1px dashed $line-ui;
					background: $surface;
					max-height: 100px !important;
				}

				// Primary add buttons: icon aligned with label (overrides `.mega-row-header .dashicons` on Column).
				button.mega-add-row,
				button.mega-add-column {
					display: inline-flex;
					align-items: center;
					gap: 4px;

					.dashicons {
						color: $white;
						line-height: 1;
						width: 16px;
						height: 16px;
						font-size: 16px;
						flex-shrink: 0;
						margin: 0;
					}
				}

				.mega-row {
					width: 100%;
					display: flex;
					flex-direction: column;
					align-items: stretch;
					background-color: $surface;
					border: 1px solid $line-ui;
					border-radius: 4px;
					box-shadow: $shadow-small;
					padding: 20px;
					margin-top: 20px;
					box-sizing: border-box;
					position: relative;

					&:first-child {
						margin-top: 0;
					}

					// `--row-tracks` / `--span` on `.mega-row` / `.mega-col`; `--mega-cols-gap-slots` = column count − 1 (JS)
					// for gap-aware widths. Flex + explicit width matches grid track fractions and allows width transitions.
					.mega-row-cols {
						display: flex;
						flex-direction: row;
						flex-wrap: nowrap;
						align-items: flex-start;
						width: 100%;
						min-width: 0;
						gap: 8px;
						box-sizing: border-box;

						> .drop-area.ui-sortable-placeholder {
							flex-shrink: 0;
							max-height: none !important;
							min-height: 0;
						}

						> .mega-col {
							flex: 0 0 auto;
							width: calc(
								(100% - 8px * var(--mega-cols-gap-slots, 0)) * var(--span, 1) / var(--row-tracks, 12)
							);
							min-width: 0;
							box-sizing: border-box;
							transition: width 0.35s ease;

							@media (prefers-reduced-motion: reduce) {
								transition: none;
							}
						}
					}

					.mega-row-header {
						display: flex;
						flex-wrap: wrap;
						align-items: center;
						align-content: center;
						gap: 8px;
						width: 100%;
						padding: 0 0 20px 0;
						box-sizing: border-box;
						cursor: grab;
						user-select: none;

						a {
							cursor: pointer;
						}

						&:active {
							cursor: grabbing;
						}

						.mega-disabled .dashicons {
							opacity: 1;
						}

						.mega-row-actions .dashicons.mega-settings-open {
							opacity: 1;
							color: $ink;
						}

						.mega-row-actions .dashicons {
							opacity: 1;
							color: $icon-dim;
							transition: color 0.15s ease, background 0.15s ease;
						}

						.mega-row-actions {
							order: 1;
							display: flex;
							flex-direction: row;
							flex-wrap: nowrap;
							align-items: center;
							gap: 10px;
							flex: 0 1 auto;

							.mega-row-header__action--delete {
								display: none;
								color: $error;
							}
						}

						// Row toolbar: settings/trash are icon `button.dashicons.mega-row-header__action`; desktop/mobile
						// use an inner `.dashicons` — use one box size so flex cross-axis alignment matches.
						.mega-row-header__action {
							appearance: none;
							-webkit-appearance: none;
							border: 0;
							background: transparent;
							padding: 0;
							margin: 0;
							cursor: pointer;
							box-shadow: none;
							color: inherit;
							display: inline-flex;
							align-items: center;
							justify-content: center;
							flex-shrink: 0;
							line-height: 1;

							&:focus-visible {
								@include mega-admin-focus-ring;
							}

							&.dashicons {
								width: 16px;
								height: 16px;
								font-size: 16px;
							}

							.dashicons {
								width: 16px;
								height: 16px;
								font-size: 16px;
								line-height: 1;
								display: block;
							}

						}

						.mega-row-actions:hover .dashicons {
							color: $ink;
						}

						.mega-row-settings {
							order: 3;
							flex: 1 1 100%;
							width: 100%;
						}

						button.mega-add-column {
							order: 2;
							margin-left: auto;
							cursor: pointer;
						}
					}

					&[data-used-cols='0'] {
						.mega-row-header .mega-row-actions .mega-row-header__action--delete {
							display: inline-flex;
							opacity: 1;
						}
					}

					.mega-too-many-cols {
						display: none;
					}

					&[data-too-many-cols='true'] {
						.mega-too-many-cols {
							display: block;
						}
					}

					.mega-row-is-full {
						display: none;
					}

					.notice {
						margin: 10px 5px;
					    cursor: pointer;
					}
				}

				.mega-col {
					display: block;
					position: relative;
					min-width: 0;
					box-sizing: border-box;

					&.mega-col-add-target .mega-col-wrap {
						border-color: $wp-admin-theme-color;
						box-shadow: 0 0 0 1px $wp-admin-theme-color;
					}

					.mega-col-wrap {
						background-color: $white;
						border: 1px solid $line-ui;
						border-radius: 2px;
						box-shadow: $shadow-small;
						margin: 0;
						padding: 10px;
						transition: border-color 0.15s ease, box-shadow 0.15s ease;

						&:hover {
							box-shadow: $shadow-small-hover;
						}
					}

					.mega-col-widgets {
						display: flex;
						flex-direction: column;
						align-items: stretch;
						gap: 10px;
						min-height: 50px;

						.mega-col-add-widget {
							@include mega-col-add-widget-appearance;
							margin-top: auto;
							border-color: $line-ui;
							background: $white;
							color: $ink;

							.dashicons {
								opacity: 0.85;
								color: $icon-dim;
							}

							&:hover,
							&:focus-visible {
								color: $wp-admin-theme-color;
								border-color: $wp-admin-theme-color;
								background: $white;

								.dashicons {
									opacity: 1;
									color: $wp-admin-theme-color;
								}
							}
						}

						.mega-widget {
							float: none;
							width: 100%;
							border: 0;
							margin: 0;

							&.mega-widget-added-pulse .mega-widget-top {
								animation: mm-mega-widget-selector-pulse 0.85s ease-in-out infinite;

								@media (prefers-reduced-motion: reduce) {
									animation-iteration-count: 2;
								}
							}

							.mega-widget-top {
								display: flex;
								flex-direction: row;
								flex-wrap: nowrap;
								align-items: center;
								gap: 8px;
								min-height: 42px;
								box-sizing: border-box;
								padding: 4px 10px;
								background: $white;
								border: 1px solid $line-ui;
								border-radius: 2px;
								box-shadow: $shadow-small;
								overflow: hidden;
								transition:
									border-color 0.15s ease,
									box-shadow 0.15s ease;
							}

							&:hover .mega-widget-top {
								border: 1px solid $text;
								box-shadow: $shadow-small-hover;
							}

							&.open .mega-widget-top {
								border: 1px solid $line-dark;
							}

							&.open .mega-widget-inner {
								border: 1px solid $line-dark;
							}

							.mega-widget-title {
								flex: 1 1 auto;
								min-width: 0;
								margin: 0;

								h4 {
									font-weight: normal;
									margin: 0;
									line-height: 1.35;
									overflow: hidden;
									text-overflow: ellipsis;
									white-space: nowrap;
								}

								.mega-widget-desc {
									font-weight: normal;
									font-size: 11px;
									color: $text-secondary;
									font-style: italic;
								}
							}

							.mega-widget-title-action {
								flex: 0 0 auto;
								display: flex;
								flex-direction: row;
								flex-wrap: nowrap;
								align-items: center;
								justify-content: flex-end;
								gap: 8px;
								position: static;
								margin: 0;
								padding: 0;
								background: $white;
								border: 0;
							}

							&[data-type=item] form {
								display: flex;
								flex-direction: column;
								align-items: stretch;
								gap: 6px;

								input, select {
									align-self: flex-end;
									max-width: 100%;
								}

								p {
									width: 100%;
									margin-bottom: 0;
								}

								.mega-widget-content {
									padding-top: 10px;
								}
							}

						}

					}

					.mega-col-header {
						display: flex;
						flex-wrap: wrap;
						align-items: center;
						align-content: center;
						justify-content: flex-start;
						width: 100%;
						min-height: 40px;
						height: auto;
						box-sizing: border-box;
						gap: 8px;
						row-gap: 6px;
						min-width: 0;
						margin-bottom: 10px;

						> .mega-col-actions {
							display: inline-flex;
							flex-wrap: wrap;
							align-items: center;
							align-content: center;
							gap: 5px;
							row-gap: 6px;
							flex: 1 1 auto;
							min-width: 0;
							max-width: 100%;
							user-select: none;

							> :not(.mega-col-drag-handle) {
								flex-shrink: 0;
							}

							.mega-col-header__action {
								appearance: none;
								-webkit-appearance: none;
								border: 0;
								background: transparent;
								padding: 0;
								margin: 0;
								cursor: pointer;
								box-shadow: none;
								color: inherit;
								display: inline-flex;
								align-items: center;
								justify-content: center;
								line-height: 1;

								&:focus-visible {
									@include mega-admin-focus-ring;
								}
							}

							> .mega-col-drag-handle {
								flex: 1 1 auto;
								align-self: stretch;
								min-width: 24px;
								margin: 0;
								padding: 0;
								border: 0;
								background: transparent;
								cursor: grab;
								border-radius: 2px;

								&:active {
									cursor: grabbing;
								}
							}

							.mega-disabled .dashicons {
								opacity: 1;
							}

							.dashicons.mega-settings-open {
								opacity: 1;
								color: $ink;
							}

							.dashicons {
								opacity: 1;
								color: $icon-dim;
								transition: color 0.15s ease;
								width: 14px;
								height: 14px;
								font-size: 14px;
								line-height: 1;
								display: inline-flex;
								align-items: center;
								justify-content: center;
							}

							.mega-col-header__action--delete {
								display: none;
								color: $error;
							}

							&:hover .dashicons {
								color: $ink;
							}
						}

						> .mega-col-span {
							@include mega-col-span-pill;

							button.mega-col-contract,
							button.mega-col-expand {
								appearance: none;
								-webkit-appearance: none;
								display: inline-flex;
								align-items: center;
								justify-content: center;
								margin: 0;
								padding: 0;
								border: 0;
								background: transparent;
								font: inherit;
								color: inherit;
								line-height: 1;
								border-radius: 2px;
								cursor: pointer;
								box-shadow: none;

								&:hover,
								&:focus-visible {
									color: $admin-blue-dark;
								}

								&:focus-visible {
									@include mega-admin-focus-ring($wp-admin-theme-color, 1px);
								}
							}

							button.mega-col-expand:disabled,
							button.mega-col-contract:disabled {
								color: $text-placeholder;
								cursor: not-allowed;

								&:hover,
								&:focus-visible {
									color: $text-placeholder;
								}

								.dashicons {
									cursor: not-allowed;
								}
							}

							.dashicons {
								margin-right: 0;
								width: 14px;
								height: 14px;
								font-size: 14px;
								line-height: 1;
								cursor: pointer;
								color: inherit;
								opacity: 1;
							}

							.mega-col-cols {
								display: inline-flex;
								align-items: center;
								line-height: 1.2;
								font-size: 11px;
								font-weight: 600;
								color: inherit;
							}
						}
					}

					// After `.mega-col-header__action--delete { display: none }` so higher specificity wins.
					&[data-total-blocks='0'] .mega-col-header > .mega-col-actions > .mega-col-header__action--delete {
						display: inline-flex;
						opacity: 1;
					}

				}

				button.mega-add-row {
					margin-top: 20px;
				}

				.mega-col-settings,
				.mega-row-settings {
					width: 100%;
					display: none;
					margin: 8px 0 20px;
					padding: 12px 14px;
					box-sizing: border-box;
					background: $white;
					border: 1px solid $line-ui;
					border-radius: 2px;
					box-shadow: none;
				}

				.mega-col-settings {
					label {
						width: 100%;
						font-size: 11px;
						text-transform: uppercase;
						margin-right: 5px;
						color: $ink;
						font-weight: 600;
						letter-spacing: 0.02em;
					}

					input {
						font-size: 13px;
						max-width: 100%;
						display: block;
						width: 100%;
						margin: 5px 0 10px 0;
						color: $ink;
						border-color: $megamenu-form-control-border;
					}
				}

				.mega-row-settings {
					.mega-settings-row {
						display: flex;
						flex-direction: row;
						flex-wrap: wrap;
						align-items: center;
						gap: 8px 12px;
						margin-bottom: 8px;
					}

					label {
						width: 150px;
						font-size: 11px;
						text-transform: uppercase;
						display: inline-block;
						color: $ink;
						font-weight: 600;
						letter-spacing: 0.02em;
					}

					input,
					select {
						font-size: 13px;
						color: $ink;
						border-color: $megamenu-form-control-border;
					}
				}
				.mega-row-header .dashicons,
				.mega-col-header .dashicons {
					font-size: 13px;
					width: 15px;
					cursor: pointer;
				}

				.mega-col-header {
					user-select: none;

					a {
						cursor: pointer;
					}
				}

				.mega-disabled .dashicons {
					&:before {
						color: $error;
					}
				}

				.drop-area {
					display: inline-block;
					box-sizing: border-box;
				}

				.ui-sortable-helper {
					opacity: 0.5;
				}

			}

			#megamenu-standard {
				flex-flow: row wrap;
				align-items: flex-start;
				align-content: flex-start;
				gap: 0;
				background: $surface;
				border: 1px solid $line;
				padding: 5px;
				width: 100%;
				box-sizing: border-box;
				min-height: 200px;

				.no_widgets {
					font-size: 0.9em;
					margin-left: 10px;
					font-style: italic;
					margin-top: 10px;
					color: $text;
					flex: 1 0 100%;
				}

				.drop-area {
					display: block;
					border: 1px solid $surface;
					box-sizing: border-box;
				}

				.mega-widget {
					width: 100%;

					h4 {
						max-width: 700px;
					}
				}
			}

			.mega-widget {
				box-sizing: border-box;
				width: 160px;
				margin: 0;
				color: $text;
				font-size: 12px;
				display: block;
				border: 5px solid transparent;
				flex: 0 0 auto;

				&:hover {
					.mega-widget-top {
						border: 1px solid $text;
					}
					.mega-widget-inner {
						border: 1px solid $text;
					}
				}

				textarea {
					max-height: 100px;
				}
			}

			.mega-widget.open {
				.mega-widget-top {
					border: 1px solid $text;
					cursor: move;
					position: relative;
					z-index: 50;
					box-sizing: border-box;
					opacity: 0.5;
					filter: brightness(0.88);
					transition: opacity 0.15s ease, filter 0.15s ease;
				}

				.mega-widget-inner {
					border: 1px solid $text;
					// Absolute within the panels container (rows, cols, and the open widget are all
					// position: static so `.megamenu-dialog-panels` is the nearest positioned ancestor).
					// JS sets --mmm-panels-scroll to the panels' scrollTop when the widget opens, so
					// `top: calc(var(…) + 50%)` places the form at the centre of the *visible* panels
					// area regardless of how far the user has scrolled.
					position: absolute;
					left: 10%;
					right: 10%;
					top: calc(var(--mmm-panels-scroll, 0px) + 50%);
					bottom: auto;
					transform: translateY(-50%);
					width: auto;
					margin: 0;
					z-index: 60;
					box-sizing: border-box;
					max-width: 100%;
					// Cap height to 90% of the panels visible height so the form never overflows.
					max-height: 90%;
					height: max-content;
					min-width: 0;
					min-height: 0;
					overflow-x: hidden;
					overflow-y: auto;
					overscroll-behavior: contain;
					display: flex;
					flex-direction: column;
					background: $white;
					box-shadow:
						$shadow-large-hover,
						0 0 0 1px $shadow-a07,
						0 0 0 9999px rgba(0, 0, 0, 0.4);
					border-radius: 4px;

					&.mmm-widget-inner--preparing {
						opacity: 0;
						pointer-events: none;
						transition: none;
					}

					&.mmm-widget-inner--show {
						opacity: 1;
						transition: opacity 0.2s ease;
					}
				}

				.mega-widget-inner > form {
					display: flex;
					flex-direction: column;
					flex: 1 1 auto;
					min-height: 0;
					padding: 0 15px 0;
					margin-bottom: 0;
					box-sizing: border-box;
				}

				.mega-widget-inner .mega-widget-dialog-header {
					flex: 0 0 auto;
					display: flex;
					flex-direction: row;
					flex-wrap: nowrap;
					align-items: center;
					justify-content: space-between;
					gap: 8px;
					padding: 8px 0 10px;
					margin: 0;
					border-bottom: 1px solid $line;
				}

				.mega-widget-inner .mega-widget-dialog-title {
					flex: 1 1 auto;
					min-width: 0;
					margin: 0;
					padding: 0 4px 0 2px;
					font-size: 14px;
					font-weight: 600;
					line-height: 1.35;
					color: $ink;
					border-bottom: 0;
				}

				.mega-widget-inner .mega-widget-dialog-close {
					flex: 0 0 auto;
					display: inline-flex;
					align-items: center;
					justify-content: center;
					width: 32px;
					height: 32px;
					margin: 0;
					padding: 0;
					border: 0;
					border-radius: 4px;
					background: transparent;
					color: $icon-dim;
					cursor: pointer;
					box-sizing: border-box;

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

					&:hover,
					&:focus-visible {
						color: $ink;
						background: $surface;
					}

					&:focus-visible {
						@include mega-admin-focus-ring;
					}
				}

				.mega-widget-inner .mega-widget-content {
					flex: 1 1 auto;
					min-height: 0;
					overflow-x: hidden;
					// Single scrollbar on `.mega-widget-inner` (viewport-capped).
					overflow-y: visible;
				}

				.mega-widget-inner .mega-widget-form-footer {
					flex: 0 0 auto;
					margin-top: 0;
					padding-top: 10px;
					padding-bottom: 12px;
					border-top: 1px solid $line;
					background: $white;
				}

				.mega-widget-action {
					&::after {
						content: '\f142';
					}
				}
			}

			.mega-widget-top {
				display: flex;
				flex-direction: row;
				flex-wrap: nowrap;
				align-items: center;
				justify-content: space-between;
				gap: 8px;
				min-height: 42px;
				box-sizing: border-box;
				border: 0;
				box-shadow: none;
				border: 1px solid $line;
				padding: 0 10px;
				background: $white;
				overflow: hidden;
			}



			.mega-widget[data-type='menu_item'] {
				.mega-widget-top {
					cursor: default;
				}
			}

			.mega-widget-title {
				flex: 1 1 auto;
				min-width: 0;

				h4 {
					color: $text;
					margin: 0;
					padding: 0;
					overflow: hidden;
					white-space: nowrap;
					border-bottom: 0;
					font-size: 12px;
					text-overflow: ellipsis;
					line-height: 1.35;

					&:after {
						color: #d54e21;
						display: none;
						font: normal 20px/1 'dashicons';
						speak: none;
						-webkit-font-smoothing: antialiased;
						-moz-osx-font-smoothing: grayscale;
						margin-left: 5px;
						content: '\f463';
						animation: mm-rotation 2s infinite linear;
						vertical-align: middle;
					}
				}

				h4.loading {
					&:after {
						display: inline-block;
					}
				}
			}

			.mega-widget[data-type='menu_item'] {
				.mega-widget-title {
					h4 {
						&:before {
							color: $text;
							font: normal 16px/1 'dashicons';
							speak: none;
							-webkit-font-smoothing: antialiased;
							-moz-osx-font-smoothing: grayscale;
							margin-right: 2px;
							content: "\f333";
							vertical-align: middle;
							top: -1px;
							position: relative;
						}
					}
				}
				form {
					display: flex;
					flex-direction: column;
					align-items: stretch;
					gap: 6px;

					input, select {
						align-self: flex-end;
						max-width: 100%;
					}

					p {
						width: 100%;
						margin-bottom: 0;
					}
				}
			}

			.mega-widget-form-footer {
				display: flex;
				flex-direction: row;
				flex-wrap: nowrap;
				align-items: center;
				justify-content: space-between;
				gap: 12px;
				width: 100%;
				box-sizing: border-box;
				margin-top: 12px;
				padding-top: 4px;
				clear: both;

				.mega-widget-controls {
					display: flex;
					align-items: center;
					flex: 0 0 auto;
					margin: 0;
					padding: 0;
				}
			}

			.mega-widget-controls {
				flex: 0 0 auto;

				.mega-delete {
					@include mega-admin-trash-icon-button;
				}
			}

			.mega-widget-inner {
				display: none;
				width: 100%;
				background: $white;

				form {
					padding: 0 15px 15px 15px;
					margin-bottom: 0;
				}
				p {
					font-size: 12px;
				}
				select {
					font-size: 12px;
				}
				input {
					font-size: 12px;
				}
			}

			.mega-widget-title-action {
				flex: 0 0 auto;
				display: flex;
				flex-direction: row;
				flex-wrap: nowrap;
				align-items: center;
				justify-content: flex-start;
				gap: 8px;
				padding: 0;
				margin: 0;
				position: static;
				font-weight: normal;
				opacity: 1;
				background: $white;

				.mega-col-span {
					@include mega-col-span-pill;

					.mega-widget-option.mega-widget-contract,
					.mega-widget-option.mega-widget-expand {
						display: inline-flex;
						align-items: center;
						justify-content: center;
						line-height: 1;
						border-radius: 2px;
						color: inherit;

						&:hover,
						&:focus-visible {
							color: $admin-blue-dark;
						}

						&::after {
							color: inherit;
						}

						&:focus-visible {
							@include mega-admin-focus-ring($wp-admin-theme-color, 1px);
						}
					}

					.mega-widget-cols {
						display: inline-flex;
						align-items: center;
						line-height: 1.2;
						font-size: 11px;
						font-weight: 600;
						color: inherit;
					}
				}
			}

			.mega-widget-option {
				right: 0;
				appearance: none;
				-webkit-appearance: none;
				border: 0;
				background: 0 0;
				font: 400 16px/1 dashicons;
				speak: none;
				display: block;
				padding: 0;
				margin: 0;
				text-indent: 0;
				text-align: center;
				position: relative;
				-webkit-font-smoothing: antialiased;
				-moz-osx-font-smoothing: grayscale;
				text-decoration: none !important;
				color: $icon-dim;
				box-shadow: none;

				&:hover {
					color: $text;
					cursor: pointer;
				}

				&::after {
					padding: 0;
					font: 400 16px/1 dashicons;
					display: block;
				}
			}

			.mega-widget-cols {
				display: inline-flex;
				align-items: center;
				line-height: 1.2;
				color: $icon-dim;
				font-size: 11px;
			}

			h5 {
				margin: 10px 0 0 10px;
				text-transform: uppercase;
			}

			.mega-widget-expand {
				&::after {
					content: '\f345';
				}
			}

			.mega-widget-contract {
				&::after {
					content: '\f341';
				}
			}

			.mega-widget-action {
				&::after {
					content: '\f107';
					margin: 0;
				}
			}

			.mega-widget-option.disabled {
				&:hover {
					color: $icon-dim;
				}
			}

			.mega-widget[data-columns='1'] {
				.mega-widget-contract {
					display: none;
				}
			}

			#megamenu-standard {
				@include grid-col-widths('data-columns', '.mega-widget', 'data-columns');

				.mega-widget {
					transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);

					@media (prefers-reduced-motion: reduce) {
						transition: none;
					}
				}
			}

		}

		.menu_icon {
			.icon_selector {
				display: flex;
				flex-flow: row wrap;
				align-items: flex-start;
				gap: 10px;

				>div {
					flex: 0 0 auto;
					padding: 0;
					width: 40px;
					height: 40px;
					box-sizing: border-box;
				}

				> div.mmm-icon-filter-hidden {
					display: none !important;
				}

				label {
					display: block;
					width: 40px;
					height: 40px;

					&:before {
						content: attr(rel);
						speak: none;
						@include megamenu-admin-icon-pseudo-dashicon-tile;
					}
				}

				input.radio {
					&:empty {
						margin-left: -9999px;

						~ {
							label {
								position: relative;
								cursor: pointer;
								user-select: none;
							}
						}
					}

					&:checked {
						~ {
							label {
								color: $icon-dim;
							}
						}
					}
				}

				> div:has(input:focus-visible) label:before {
					@include mega-admin-focus-ring;
				}

				> div:has(input:checked) label:before {
					color: $wp-admin-theme-color;
					background: transparent;
					box-shadow: inset 0 0 0 2px $wp-admin-theme-color;
				}

				> div:has(input:checked):hover label:before {
					color: $wp-admin-theme-color;
					background: $surface-raised;
					box-shadow: inset 0 0 0 2px $wp-admin-theme-color;
				}

				> div:has(input:not(:checked)):hover label:before {
					color: $ink;
					background: $surface-raised;
				}

				.dash {
					label {
						&:before {
							font-style: normal;
							font-variant: normal;
							text-decoration: inherit;
							text-rendering: auto;
							font-family: dashicons;
						}
					}
				}
			}
		}

		@at-root body.maxmegamenu-admin.nav-menus-php .megamenu-menu-item-dialog .general_settings table {
			td {
				padding-top: 3px;
				padding-bottom: 3px;
			}

			td.mega-value--pill {
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				align-items: center;
				justify-content: flex-start;
				gap: 10px 12px;

				.components-form-toggle {
					flex-shrink: 0;
				}

				.mega-description,
				em {
					flex: 0 1 auto;
					min-width: 0;
					max-width: 100%;
					margin: 0;
					text-align: inherit;
				}

				.mega-description {
					display: block;
				}
			}
		}

		form,
		.megamenu_content {
			> h4.first {
				margin: 0 0 0.85em 0;
			}
			> h4 {
				display: flow-root;
				border-bottom: 1px solid $line;
				padding: 0 0 12px 0;
				font-size: 1.05em;
				font-weight: 600;
				color: $ink;
				margin: 1.5em 0 1em 0;
			}
		}

		select {
			border-radius: 4px;
			border-color: $megamenu-form-control-border;
			background-color: $white;
		}

		.description,
		.mega-description {
			color: $text-secondary;
			font-style: italic;
		}

		img {
			height: auto;
			max-width: 100%;
		}
	}

	&.megamenu_enabled {
		.megamenu_prefix {
			display: block;
			font-size: 0.9em;
			border-left: 3px solid $warning;
			padding-left: 10px;
			margin-top: 3px;
		}
	}

	.megamenu_prefix {
		display: none;
	}

	// Uses core .button.button-primary.button-small; only layout, reveal, dashicon, and non-disabled attr state.
	.megamenu_launch.button.button-primary.button-small {
		margin-left: 8px;
		display: inline-flex;
		align-items: center;
		gap: 3px;
		line-height: 1.15;
		min-height: 22px;
		padding-top: 0;
		padding-bottom: 0;
		opacity: 0;
		transition: opacity 0.2s ease;
		z-index: 1;
		position: relative;

		&:focus-visible {
			opacity: 1;
		}

		&.megamenu_disabled,
		&[aria-disabled="true"] {
			cursor: not-allowed;
			color: $icon-dim !important;
			background: $surface !important;
			border-color: $line !important;
			box-shadow: none !important;
		}

		&.megamenu_disabled:hover,
		&.megamenu_disabled:active,
		&[aria-disabled="true"]:hover,
		&[aria-disabled="true"]:active {
			color: $icon-dim !important;
			background: $surface !important;
			border-color: $line !important;
			box-shadow: none !important;
		}

		&:before {
			font-family: dashicons;
			content: "\f111"; // dashicons-admin-generic
			font-size: 12px;
			width: 12px;
			height: 12px;
			line-height: 12px;
			color: rgba($white, 0.92);
			display: inline-block;
			flex-shrink: 0;
		}

		&.megamenu_disabled:before,
		&[aria-disabled="true"]:before {
			color: $text-placeholder;
		}
	}

	// Restore hidden state when the launch control has programmatic :focus (e.g. after modal close) but not :focus-visible.
	.menu-item-bar .menu-item-handle:not(:hover) .megamenu_launch.button.button-primary.button-small:focus:not(:focus-visible) {
		opacity: 0;
	}

	.menu-item-bar {
		.menu-item-handle {
			// Hover only: focus-within would keep the button visible when focus returns after closing the modal.
			&:hover {
				.megamenu_launch {
					opacity: 1;
				}
			}
		}
		.dashicons-admin-generic {
			&:before {
				font-size: 1.2em;
				margin-right: 1px;
				height: auto;
			}
		}
	}

	#nav-menu-meta .mega_menu_meta_box {
		// Core wraps the callback in a div (historically .inside); target first child without using that class name.
		#mega_menu_meta_box-content > :first-child {
			margin: 0;
			padding: 14px;
			box-sizing: border-box;
		}

		.accordion-section-content {
			padding: 0;
		}
	}

	.menu-item-handle {
		.item-title {
			margin-right: 0;
		}
	}
}

// Shared modal shell (menu item editor, preview, location settings): fixed overlay inset from the admin menu edge.
// Same `body` block continues below with theme editor / `#wpbody` layout (icon dropdown, Menu Themes tabs, etc.).
body.maxmegamenu-admin {

	--megamenu-form-control-border: #{$neutral};

	.megamenu_outer_wrap {
		input[type='text'],
		input[type='password'],
		input[type='date'],
		input[type='datetime'],
		input[type='datetime-local'],
		input[type='email'],
		input[type='month'],
		input[type='number'],
		input[type='search'],
		input[type='tel'],
		input[type='time'],
		input[type='url'],
		input[type='week'] {
			padding: 0 6px;
		}
	}

	.megamenu-admin-modal td.mega-value p {
		margin: 0;
		font-style: italic;
	}

	input.button-primary.is-busy,
	button.button-primary.is-busy {
		pointer-events: none;
		background-size: 100px 100% !important;
		background-image: linear-gradient(
			-45deg,
			var(--wp-admin-theme-color) 28%,
			var(--wp-admin-theme-color-darker-20) 0,
			var(--wp-admin-theme-color-darker-20) 72%,
			var(--wp-admin-theme-color) 0
		) !important;
		border-color: var(--wp-admin-theme-color) !important;
		animation: busy-animation 2.5s linear infinite;
	}

	[data-mega-tooltip] {
		position: relative;
		@include tooltip-popup-base;
	}

	// Optional placement (default mixin is below). Used e.g. for disabled mobile preview in footer toolbar.
	// Gap must clear a 9px square at 45° (~6.4px half-extent each way); 8px was too narrow and drew the
	// chevron inside the bubble. Use 14px gutter and center the arrow on it.
	[data-mega-tooltip][data-mega-tooltip-position="right"] {
		&:before {
			top: 50%;
			left: 100%;
			right: auto;
			margin-left: 14px;
			margin-top: 0;
			transform: translateY(-50%);
			text-align: start;
			white-space: normal;
			width: max-content;
			max-width: min(400px, calc(100vw - 100px));
			min-width: 0;
		}

		// SW-corner L + 45deg → tip points left (offset tuned vs :before margin-left).
		&:after {
			top: 50%;
			left: calc(100% + 14px);
			width: 9px;
			height: 9px;
			margin: 0;
			background: $white;
			border-left: 1px solid $line-strong;
			border-bottom: 1px solid $line-strong;
			border-right: none;
			border-top: none;
			box-sizing: border-box;
			transform: translate(-50%, -50%) rotate(45deg);
		}
	}

	&.rtl [data-mega-tooltip][data-mega-tooltip-position="right"] {
		&:before {
			left: auto;
			right: 100%;
			margin-left: 0;
			margin-right: 14px;
			transform: translateY(-50%);
		}

		// NE-corner L + 45deg → tip points right; mirror LTR.
		&:after {
			left: auto;
			right: calc(100% + 14px);
			width: 9px;
			height: 9px;
			margin: 0;
			background: $white;
			border-top: 1px solid $line-strong;
			border-right: 1px solid $line-strong;
			border-bottom: none;
			border-left: none;
			box-sizing: border-box;
			transform: translate(50%, -50%) rotate(45deg);
		}
	}

	[data-mega-tooltip][data-mega-tooltip-enabled] {
		&.mega-enabled:before {
			content: attr(data-mega-tooltip-enabled);
		}

		&.mega-disabled:before {
			content: attr(data-mega-tooltip-disabled);
		}
	}

	// Labels wrapping core `components-form-toggle` (styles from `wp-components`).
	.mega-mmm-enable-toggle,
	.mmm-settings-pill-field-label {
		display: inline-flex;
		align-items: center;
		flex-wrap: wrap;
		gap: 8px;
		max-width: 100%;
		cursor: pointer;
	}

	.mega-mmm-enable-toggle .components-form-toggle {
		flex-shrink: 0;
		margin-right: 4px;
	}

	// Location settings modal pill wrapper (label + switch inside).
	.mmm-settings-pill-field {
		display: inline-block;
		vertical-align: top;
		align-self: flex-start;
		margin: 0 0 14px 0;
		max-width: 100%;
		box-sizing: border-box;

		&:last-child {
			margin-bottom: 0;
		}
	}

	// Collapsed panel size — same for preview, location settings, and menu item (until expanded).
	$megamenu-modal-panel-collapsed-max-width: 1200px;
	$megamenu-modal-panel-collapsed-max-vh: 70vh;
	$megamenu-modal-panel-collapsed-height-cap: 960px;
	// Expanded: explicit calc so height/max-height can transition (not `auto` / `none`).
	$megamenu-modal-panel-expanded-height: calc(100vh - var(--wp-admin--admin-bar--height, 32px) - 40px);

	.megamenu-admin-modal {
		display: none;
		position: fixed;
		z-index: 159000;
		top: var(--wp-admin--admin-bar--height, 32px);
		right: 0;
		bottom: 0;
		left: 160px;
		margin: 0;
		border: none;
		outline: none;
		padding: 20px 24px;
		overflow: auto;
		box-sizing: border-box;
		flex-direction: row;
		// Stretch on the main axis only; keep cross-axis centering so height changes grow from the middle.
		align-items: center;
		justify-content: stretch;

		&.is-open {
			display: flex;
		}

		&.megamenu-admin-modal--wpcontent-expanded {
			.megamenu-admin-modal__panel {
				// Same width model as collapsed (`width: 100%` + max-width); only max-width grows — interpolates smoothly.
				max-width: 100%;
				// Stay centered like collapsed; do not stretch to top (that caused jump-then-expand-down).
				height: $megamenu-modal-panel-expanded-height;
				max-height: $megamenu-modal-panel-expanded-height;
				min-height: 0;
				// Match collapsed so margin doesn’t snap (auto → 0 was causing a horizontal jump with width).
				margin-inline: auto;
				margin-block: auto;
			}
		}

		&__backdrop {
			position: absolute;
			inset: 0;
			margin: 0;
			padding: 0;
			border: 0;
			background: $shadow-a45;
			cursor: pointer;
		}

		&__panel {
			position: relative;
			z-index: 1;
			display: flex;
			flex-direction: column;
			// Interpolates cleanly to expanded `max-width: 100%` (avoid `width: min()` ↔ `100%` which jumps).
			width: 100%;
			max-width: $megamenu-modal-panel-collapsed-max-width;
			// Same expression for height + max-height so transitions don’t fight (was max-height: 70vh with height min(70vh, 960px)).
			$megamenu-modal-panel-collapsed-height: min(#{$megamenu-modal-panel-collapsed-max-vh}, #{$megamenu-modal-panel-collapsed-height-cap});
			max-height: $megamenu-modal-panel-collapsed-height;
			height: $megamenu-modal-panel-collapsed-height;
			min-height: 0;
			flex-shrink: 0;
			margin-inline: auto;
			margin-block: auto;
			align-self: center;
			background: $white;
			border-radius: $modal-radius;
			box-shadow: $shadow-large;
			overflow: hidden;
			font-size: 14px;
			line-height: 1.5;
			transition:
				width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
				max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
				max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
				height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
				margin-inline 0.3s ease;

			@media (prefers-reduced-motion: reduce) {
				transition: none;
			}
		}

		&__header {
			flex: 0 0 auto;
			position: relative;
			z-index: 1;
			display: flex;
			align-items: center;
			justify-content: space-between;
			gap: 12px;
			width: 100%;
			box-sizing: border-box;
			padding: 24px;
			min-height: 0;
			border-bottom: 0;
			box-shadow: $shadow-small;
			background: $white;

			.megamenu-admin-modal__title-group {
				display: flex;
				flex-direction: column;
				gap: 6px;
				flex: 1 1 auto;
				min-width: 0;
				padding-right: 40px;
			}

			.megamenu-admin-modal__title {
				display: flex;
				align-items: center;
				gap: 8px;
				margin: 0;
				min-width: 0;
				font-size: 1.25rem;
				font-weight: 600;
				line-height: 1.3;
				letter-spacing: 0;
				color: $ink;

				br {
					display: none;
				}
			}

			.megamenu-admin-modal__title-icon.dashicons {
				flex-shrink: 0;
				width: 24px;
				height: 24px;
				font-size: 24px;
				line-height: 1;
				color: $text-secondary;
			}

			.megamenu-admin-modal__title-text {
				min-width: 0;
			}

			.megamenu_subtitle {
				margin: 0;
				font-size: 13px;
				font-family:
					-apple-system,
					BlinkMacSystemFont,
					"Segoe UI",
					Roboto,
					Oxygen-Sans,
					Ubuntu,
					Cantarell,
					"Helvetica Neue",
					sans-serif;
				color: $text-secondary;
				line-height: 1.3;
				letter-spacing: 0;
			}

			.megamenu-admin-modal__header-meta {
				flex: 0 0 auto;
				align-self: center;
			}

			.megamenu-admin-modal__header-actions {
				position: absolute;
				top: 14px;
				right: 12px;
				z-index: 2;
				display: inline-flex;
				flex-direction: row;
				align-items: center;
				gap: 6px;

				.megamenu-modal-close {
					position: static;
					top: auto;
					right: auto;
					z-index: auto;
				}

					.megamenu-admin-modal__expand-btn {
					@include megamenu-admin-ghost-icon-button-shell;
					@include megamenu-admin-ghost-icon-button-states;
					position: static;
					top: auto;
					right: auto;
					z-index: auto;

					.megamenu-admin-modal__expand-icon {
						pointer-events: none;
						width: 24px;
						height: 24px;
						font-size: 24px;
						line-height: 1;
						display: inline-flex;
						align-items: center;
						justify-content: center;

						&--contract {
							display: none;
						}
					}

					&.megamenu-admin-modal__expand-btn--expanded {
						.megamenu-admin-modal__expand-icon--expand {
							display: none;
						}

						.megamenu-admin-modal__expand-icon--contract {
							display: inline-flex;
						}
					}
				}
			}
		}

		&__body {
			flex: 1 1 auto;
			min-height: 0;
			overflow: hidden;
			padding: 0;
			box-sizing: border-box;
			background: $white;
			display: flex;
			flex-direction: column;

			textarea,
			input[type="text"],
			input[type="number"],
			input[type="search"],
			select {
				border-radius: 4px;
			}
		}

		// Centered loading overlay + spinner (preview iframe shell, location + menu item modal bodies).
		.megamenu-admin-modal__loading-host {
			position: relative;
		}

		.megamenu-admin-modal__loading-overlay {
			display: none;
			position: absolute;
			inset: 0;
			z-index: 2;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			gap: 12px;
			background: rgba($surface-raised, 0.94);
			pointer-events: none;
		}

		.megamenu-admin-modal__loading-host--loading .megamenu-admin-modal__loading-overlay {
			display: flex;
		}

		.megamenu-admin-modal__loading-spinner {
			box-sizing: border-box;
			width: 36px;
			height: 36px;
			border: 3px solid $line;
			border-top-color: $wp-admin-theme-color;
			border-radius: 50%;
			animation: megamenu-admin-modal-loading-spin 0.7s linear infinite;
		}

		@keyframes megamenu-admin-modal-loading-spin {
			to {
				transform: rotate(360deg);
			}
		}

		.megamenu-admin-modal__body-slot {
			flex: 1 1 auto;
			min-height: 0;
			overflow: auto;
			display: flex;
			flex-direction: column;
			box-sizing: border-box;
		}

		&.megamenu-location-settings-dialog &__body {
			padding: 0;
		}

		&.megamenu-location-settings-dialog &__body .megamenu-admin-modal__body-slot {
			padding: 8px $modal-padding-x 0;
		}

		&.megamenu-menu-item-dialog &__body,
		&.megamenu-preview-dialog &__body {
			padding: 0;
		}

		// Footer bar: location settings (Save + spinner), preview dialog (viewport toggle). Menu item modal has no footer row.
		&__footer {
			flex: 0 0 auto;
			display: flex;
			align-items: center;
			justify-content: flex-end;
			gap: 12px;
			padding: 24px;
			border-top: 0;
			background: $white;

			p.submit {
				margin: 0;
				padding: 0;
				line-height: inherit;
			}

			.spinner {
				float: none;
				margin: 0;
				visibility: hidden;
			}

			// Secondary actions: text-style control (reference “Cancel”).
			.button:not(.button-primary) {
				background: transparent;
				border-color: transparent;
				color: $wp-admin-theme-color;
				box-shadow: none;

				&:hover,
				&:focus {
					background: $surface;
					border-color: transparent;
					color: $admin-blue-dark;
				}
			}
		}
	}

	// Menu item modal body grid (sibling of .megamenu-admin-modal to avoid Sass duplicating `body` when nesting `.megamenu-admin-modal__*`).
	// Collapsed panel width/height match preview + location (shared `&__panel` above).
	.megamenu-admin-modal.megamenu-menu-item-dialog {
		.megamenu-admin-modal__header {
			#megamenu-menu-item-dialog-breadcrumb.megamenu-menu-item-dialog-breadcrumb {
				margin: 0;
				height: 26px;
				display: flex;
				align-items: center;
				box-sizing: border-box;
				font-size: 13px;
				font-family:
					-apple-system,
					BlinkMacSystemFont,
					"Segoe UI",
					Roboto,
					Oxygen-Sans,
					Ubuntu,
					Cantarell,
					"Helvetica Neue",
					sans-serif;
				color: $text-secondary;
				line-height: 1.3;
				letter-spacing: 0;

				.megamenu-menu-item-dialog-breadcrumb__inner {
					display: flex;
					align-items: center;
					width: 100%;
					min-width: 0;
					box-sizing: border-box;
				}

				.megamenu-menu-item-dialog-breadcrumb__text {
					flex: 1 1 auto;
					min-width: 0;
					display: flex;
					flex-wrap: wrap;
					align-items: center;
					column-gap: 6px;
					row-gap: 2px;
					line-height: 1.35;

					.megamenu-menu-item-dialog-breadcrumb__start-icon.dashicons {
						flex-shrink: 0;
						position: relative;
						top: -2px;
						width: 18px;
						height: 18px;
						font-size: 18px;
						line-height: 1;
						color: $text-secondary;
					}
				}

				.megamenu-menu-item-dialog-breadcrumb__sep.dashicons {
					flex-shrink: 0;
					display: inline-flex;
					align-items: center;
					justify-content: center;
					width: 14px;
					height: 1.35em;
					font-size: 14px;
					line-height: 1;
					margin: 0;
					color: $text-placeholder;

					&::before {
						line-height: 1;
					}
				}
			}
		}

		.megamenu-admin-modal__header-actions .megamenu-menu-item-dialog-saving-indicator {
			display: inline-flex;
			align-items: center;
			justify-content: center;
			width: 32px;
			height: 32px;
			margin: 0;
			padding: 0;
			flex-shrink: 0;
			pointer-events: none;

			&[hidden] {
				display: none !important;
			}

			.megamenu-menu-item-dialog-saving-indicator__icon {
				display: inline-flex;
				align-items: center;
				justify-content: center;
				width: 22px;
				height: 22px;
				font-size: 22px;
				line-height: 1;
				color: $text-secondary;
				animation: mm-rotation 2s infinite linear;
			}
		}

		.megamenu-admin-modal__body .megamenu_outer_wrap {
			flex: 1 1 auto;
			min-height: 0;
			overflow: hidden;
			font-size: 14px;
			line-height: 1.5;

			.mega-tablist {
				button.megamenu-dialog-tab.mega_menu:before {
					content: "\f116";
				}

				button.megamenu-dialog-tab.general_settings:before {
					content: "\f111";
				}

				button.megamenu-dialog-tab.menu_icon:before {
					content: "\f128";
				}

				button.megamenu-dialog-tab.styling:before {
					content: "\f540";
				}

				button.megamenu-dialog-tab.roles:before {
					content: "\f110";
				}

				button.megamenu-dialog-tab.badge:before {
					content: "\f313"; // dashicons-awards
				}

				button.megamenu-dialog-tab .mm-tab-dirty-indicator {
					display: inline-flex;
					align-items: center;
					vertical-align: middle;
					margin-inline-start: 4px;

					.dashicons {
						width: 16px;
						height: 16px;
						font-size: 16px;
						line-height: 1;
						color: #dba617;
						speak: none;
						-webkit-font-smoothing: antialiased;
						-moz-osx-font-smoothing: grayscale;
					}
				}
			}

			.megamenu_tabs li.megamenu_tab_horizontal {
				font-size: 14px;
				padding: 5px 8px;
			}

			.filter_icons {
				font-size: 1em;
			}
		}
	}

	.megamenu-admin-modal.megamenu-preview-dialog {
		.megamenu-admin-modal__loading-spinner {
			border-top-color: $wp-block-synced-color;
		}

		.megamenu-admin-modal__header {
			.megamenu-admin-modal__header-actions {
				.megamenu-preview-dialog__refresh-btn {
					@include megamenu-admin-ghost-icon-button-shell;
					@include megamenu-admin-ghost-icon-button-states;
					position: static;
					top: auto;
					right: auto;
					z-index: auto;
				}
			}
		}

		.megamenu-preview-dialog__iframe-shell {
			position: relative;
			flex: 1 1 auto;
			min-height: 0;
			height: 100%;
			width: 100%;
			display: flex;
			justify-content: center;
			align-items: stretch;
			$checker-base: $surface-raised;
			$checker-tile: color.mix($black, $checker-base, 6%);
			background-color: $checker-base;
			background-image: repeating-conic-gradient($checker-base 0% 25%, $checker-tile 0% 50%);
			background-size: 16px 16px;
		}

		.megamenu-preview-dialog__iframe {
			flex: 1 1 auto;
			width: 100%;
			max-width: 100%;
			border: 0;
			background: transparent;
			min-height: 0;
			transition: max-width 0.2s ease-out;
		}

		&.megamenu-preview-dialog--mobile-preview .megamenu-preview-dialog__iframe {
			max-width: var(--megamenu-preview-mobile-width, 390px);
			width: 100%;
		}

		.megamenu-admin-modal__footer {
			justify-content: flex-start;
			align-items: center;
			gap: 0;
		}

		.megamenu-preview-dialog__viewport-toggle {
			display: inline-flex;
			align-items: center;
			gap: 6px;
		}

		.megamenu-preview-dialog__viewport-btn {
			@include megamenu-admin-ghost-icon-button-shell;
			@include megamenu-admin-ghost-icon-button-states;

			&--active {
				background: $white;
				border: 1px solid $wp-admin-theme-color;
				color: $wp-admin-theme-color;
				box-shadow: none;
			}

			// Keep the selected viewport tile solid white (states mixin tints inactive controls on hover/focus).
			&--active:hover,
			&--active:focus:not(:hover) {
				background: $white;
				color: $wp-admin-theme-color;
			}

			&:disabled {
				opacity: 0.45;
				cursor: not-allowed;

				&:hover,
				&:focus:not(:hover) {
					background: transparent;
					color: $icon-dim;
				}
			}

			&--unavailable {
				opacity: 0.45;
				cursor: not-allowed;
				pointer-events: auto;

				&:hover,
				&:focus:not(:hover) {
					background: transparent;
					color: $icon-dim;
				}
			}
		}
	}

	.megamenu-admin-modal.megamenu-scss-variables-dialog {
		#megamenu-scss-variables-dialog-body.megamenu-scss-variables-dialog__slot {
			display: flex;
			flex-direction: column;
			gap: 12px;
			min-height: 0;
			padding: 20px;
			box-sizing: border-box;
		}

		.megamenu-scss-variables-dialog__intro {
			margin: 0;
		}

		.megamenu-scss-vars-list {
			display: grid;
			grid-template-columns: minmax(0, auto) minmax(0, 1fr);
			column-gap: 20px;
			row-gap: 0;
			align-items: start;
			margin: 0;
			overflow: auto;
			padding: 0;
			border: 1px solid $line;
			border-radius: $modal-radius;
			background: $white;
			font-size: 12px;
			line-height: 1.45;
		}

		.megamenu-scss-vars-list dt {
			margin: 0;
			padding: 10px 0 10px 14px;
			font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
			font-weight: 600;
			color: $text-secondary;
			border-bottom: 1px solid $line;
		}

		.megamenu-scss-vars-list dd {
			margin: 0;
			padding: 10px 14px 10px 0;
			font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
			word-break: break-word;
			white-space: pre-wrap;
			border-bottom: 1px solid $line;
			color: $ink;
		}

		.megamenu-scss-vars-list dt:last-of-type,
		.megamenu-scss-vars-list dd:last-of-type {
			border-bottom: 0;
		}
	}

	.megamenu-admin-modal.megamenu-location-settings-dialog {
		.megamenu-admin-modal__loading-spinner {
			border-top-color: $wp-block-synced-color;
		}

		.megamenu-admin-modal__title .megamenu-admin-modal__title-text {
			display: inline-flex;
			align-items: center;
			gap: 5px;
			min-width: 0;
			max-width: 100%;
		}

		.megamenu-location-settings-title-prefix {
			flex-shrink: 0;
		}

		.megamenu-location-title {
			min-width: 0;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}

		.megamenu-location-settings-dialog__footer .megamenu-location-settings-dialog-save.button.button-primary {
			background: $wp-block-synced-color;
			border-color: $wp-block-synced-color;
			color: $white;
			box-shadow: none;
			text-shadow: none;

			&:hover:not(:disabled):not([aria-disabled="true"]) {
				filter: brightness(0.92);
			}

			&:active:not(:disabled):not([aria-disabled="true"]) {
				filter: brightness(0.86);
			}

			&:focus {
				box-shadow:
					0 0 0 1px $white,
					0 0 0 3px $wp-block-synced-color;
			}

			&:focus-visible {
				outline: none;
				box-shadow:
					0 0 0 1px $white,
					0 0 0 3px $wp-block-synced-color;
			}

			&:disabled,
			&[aria-disabled="true"] {
				filter: none;
				opacity: 0.65;
			}
		}

		.megamenu-admin-modal__body {
			.megamenu-location-settings-dialog__surface {
				margin: 0;
				padding: 0;
				border: 0;
				width: 100%;
				height: 100%;
				min-height: 0;
				box-sizing: border-box;
				font-size: 14px;
				display: flex;
				flex-direction: column;

				form.megamenu-location-settings-dialog-form {
					flex: 1 1 auto;
					min-height: 0;
					display: flex;
					flex-direction: column;
				}

				.megamenu-location-settings-dialog-theme-selector {
					display: inline-flex;
					align-items: center;
					flex-wrap: wrap;
					gap: 6px;
				}

				.megamenu-location-settings-dialog-edit-theme {
					min-width: $mega-admin-icon-hit;
					@include megamenu-admin-ghost-icon-button;
				}

				.megamenu-dialog-rail {
					flex: 1 1 auto;
					min-height: 0;
				}

				tr.mega-effect_mobile {
					td.mega-value {
						display: flex;
						flex-wrap: wrap;
						align-items: flex-end;
						column-gap: 24px;
						row-gap: 12px;
					}

					td.mega-value > label {
						display: flex;
						flex-direction: column;
						align-items: flex-start;
						margin: 0;
					}

					.mega-effect_mobile_direction {
						display: none;
					}

					&.mega-is-offcanvas .mega-effect_mobile_direction {
						display: flex;
						flex-direction: column;
						align-items: flex-start;
					}
				}

				// Vertical rail tabs: synced-pattern accent + section dashicons (PHP/JS only add `is-active`).
				.mega-tablist button {
					&:focus-visible {
						@include mega-admin-focus-ring($wp-block-synced-color);
					}

					&.is-active {
						color: $wp-block-synced-color;
						border-inline-start-color: $wp-block-synced-color;

						&::before {
							color: $wp-block-synced-color;
						}
					}

					&::before {
						content: "\f111";
					}

					&[data-tab-section="general"]::before {
						content: "\f472";
					}

					&[data-tab-section="theme"]::before {
						content: "\f100";
					}

					&[data-tab-section="advanced"]::before {
						content: "\f107";
					}

					&[data-tab-section="output_options"]::before {
						content: "\f177";
					}

					&[data-tab-section="sticky"]::before {
						content: "\f103";
					}

					&[data-tab-section="overlay"]::before {
						content: "\f188";
					}

					&[data-tab-section="mobile"]::before {
						content: "\f470";
					}
				}

				.megamenu-dialog-panels {
					padding: 10px 32px 32px;
				}

				h5 {
					font-size: 12px;
				}
			}
		}
	}

	// Vertical rail: tab button chrome (WP admin blue). Location settings dialog overrides with synced accent in `.megamenu-location-settings-dialog__surface`.
	.mega-tablist button {
		@include megamenu-dialog-side-tab;

		&::before {
			color: $icon-dim;
			display: inline-block;
			font-family: dashicons;
			speak: none;
			-webkit-font-smoothing: antialiased;
			-moz-osx-font-smoothing: grayscale;
			vertical-align: middle;
			margin-right: 8px;
			content: '\f463';
			font-size: 17px;
			width: 18px;
			transition: color 0.15s ease;
		}
	}

	// Let plugin settings pages use full #wpbody width (not Appearance > Menus, which shares this body class).
	&:not(.nav-menus-php) #wpbody-content > .wrap {
		margin-block-start: 0;
		margin-inline: 0;
		padding-inline: 0;
		padding-block-start: 0;
	}

	&:not(.nav-menus-php) #wpcontent {
		padding-inline-start: 0;
	}

	.megamenu_outer_wrap {
		display: inline-block;
		width: 100%;
		padding: 0;
		box-sizing: border-box;

		.notice {
			margin: 0 0 20px 0;
		}
	}

	// Menu-item modal + location settings modal + plugin settings page: two-column rail (modal: no gap; settings: gutter).
	.megamenu-admin-modal .megamenu-dialog-rail {
		@include megamenu-dialog-rail-grid;
	}

	.megamenu_wrap.megamenu-dialog-rail {
		@include megamenu-dialog-rail-grid($megamenu-settings-rail-gap, 0);
		background: $white;

		@include tablet {
			grid-template-columns: 1fr;
			grid-template-rows: auto auto;
			row-gap: $megamenu-settings-rail-gap;
		}
	}

	.mega-tablist {
		@include megamenu-dialog-tablist-shell;
		padding-top: 10px;
	}

	.megamenu-admin-modal .megamenu-dialog-panels {
		@include megamenu-dialog-panels-shell;
	}

	.megamenu_wrap.megamenu-dialog-rail > .megamenu-dialog-panels {
		@include megamenu-dialog-panels-shell(visible);

		// After this block, unqualified shell would override a rule inside `@include tablet` on the parent.
		@include tablet {
			grid-column: 1;
			grid-row: 2;
		}
	}

	*:focus {
		box-shadow: 0 0 0;
	}

	.icon_dropdown {

		.select2-choice > .select2-chosen {
		    line-height: 28px;
		    margin-right: 0;
		}

		.select2-choice .select2-arrow {
		    display: none;
		}

		.select2-choice {
		    padding: 0 5px;
		    height: 28px;
		    color: $line;
		    border: 1px solid $megamenu-form-control-border;
		}

		.select2-chosen i:before {
		    line-height: 28px;
		    font-size: 16px;
		    color: $text;
		}

	}

	.tpx-select2-drop {
	    box-shadow: 0 0 0;
	    min-width: 150px;
	}

	.select2-results {
		display: flex;
		flex-flow: row wrap;
		align-items: center;
	}

	.select2-results li {
	    flex: 0 0 auto;

	    &:first-child {
	    	i {
		    	display: none;
			}
	    }

		.select2-result-label {
			font-size: 0.9em;
		}
	}	

	.icon_dropdown .select2-choice > .select2-chosen i,
	.select2-result-label i {
		margin: 0;
	    display: inline-block;
	    width: 20px;
	    height: 20px;
	    font-size: 20px;
	    line-height: 1;
	    font-family: dashicons;
	    text-decoration: inherit;
	    font-weight: normal;
	    font-style: normal;
	    vertical-align: top;
	    text-align: center;
	    transition: color .1s ease-in 0;
	    -webkit-font-smoothing: antialiased;
	    -moz-osx-font-smoothing: grayscale;
	}

	.megamenu_header {
		position: relative;
		z-index: 1;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		align-items: flex-start;
		gap: 8px 20px;
		background: $white;
		padding: 30px 20px;
		margin-bottom: 20px;
		border-bottom: 1px solid $surface;
		box-shadow:
			0 1px 2px $shadow-a05,
			0 2px 10px $shadow-a07;
		width: 100%;
		box-sizing: border-box;

		.megamenu_header_left {
			flex: 1 1 200px;
			min-width: 0;

			.megamenu_header_title_row {
				display: flex;
				flex-direction: row;
				align-items: center;
				gap: 10px;
				margin-bottom: 10px;
			}

			.megamenu_header_icon {
				flex-shrink: 0;
				width: 28px;
				height: 28px;
				object-fit: contain;
			}

			.megamenu_header_title_row h2 {
				margin: 0;
				padding: 0;
				line-height: 1.2;
			}
		}

		.megamenu_header_right {
			flex: 0 0 auto;
			margin-inline-start: auto;
			font-size: 0.9em;
			line-height: 30px;

			ul {
				display: flex;
				flex-wrap: wrap;
				align-items: center;
				justify-content: flex-end;
				gap: 0 14px;
				margin: 0;
				padding: 0;
				list-style: none;
			}

			li {
				margin: 0;
				line-height: 30px;

				&.mega-highlight {
					border-radius: 5px;
					background: $wp-admin-theme-color;

					a {
						color: $white;
						line-height: 30px;
						padding: 0 10px;
					}
				}
			}
		}

		.version {
			color: $icon-dim;
			margin-bottom: 0;
			font-size: 12px;
		}
	}

	.megamenu_wrap.megamenu-dialog-rail > .mega-tablist {
		@include tablet {
			grid-column: 1;
			grid-row: 1;
			overflow-x: auto;
			overflow-y: visible;
		}

		nav.mega-page-navigation ul {
			list-style: none;
			margin: 0;
			padding: 0;

			@include tablet {
				display: flex;
				flex-flow: row wrap;
				align-items: stretch;
				justify-content: center;
				column-gap: 12px;
				row-gap: 8px;
			}

			li {
				margin: 0;
				padding: 0;

				@include tablet {
					display: flex;
					flex: 0 0 auto;
				}

				a {
					@include megamenu-dialog-side-tab;
					text-decoration: none;

					// Match `.mega-tablist button::before` (block tab + inline-block icon).
					&::before {
						color: $icon-dim;
						display: inline-block;
						font-family: dashicons;
						speak: none;
						-webkit-font-smoothing: antialiased;
						-moz-osx-font-smoothing: grayscale;
						vertical-align: middle;
						margin-right: 8px;
						content: none;
						font-size: 17px;
						width: 18px;
						transition: color 0.15s ease;
					}

					@include tablet {
						display: inline-flex;
						align-items: center;
						width: auto;
						margin-bottom: 0;
						text-align: center;
						border-inline-start: 3px solid transparent;
						border-bottom: 3px solid transparent;

						&:hover {
							border-inline-start-color: transparent;
						}

						&.is-active {
							border-inline-start-color: transparent;
							box-shadow: none;
							border-bottom-color: $wp-admin-theme-color;
						}

						&::before {
							margin-right: 6px;
						}
					}
				}

				&.menu_locations a::before {
					content: '\f230';
				}

				&.theme_editor a::before {
					content: '\f100';
				}

				&.general_settings a::before {
					content: '\f111';
				}

				&.tools a::before {
					content: '\f107';
				}

				&.license a::before,
				&.licence a::before {
					content: '\f112';
				}
			}
		}
	}

	h3.first {
		margin-top: 0;
	}

	h3 {
		display: flow-root;
		font-size: 1.1em;
		margin: 17px 0 5px 0;
		text-indent: 1px;
	    border-bottom: 1px solid $line;
	    padding: 0 0 10px 0;
	}

	h3 span {
		margin-right: 10px;
	}

	a {
		text-decoration: none;
	}

	.duplicate {
		margin-left: 15px;
	}

	.megamenu_submit {
		margin-bottom: 40px;
		padding-top: 35px;
		display: flex;
		flex-flow: row wrap;
		align-items: center;
		gap: 8px 16px;
		box-sizing: border-box;

		p.submit {
			margin: 0;
			padding: 0;
		}
	}

	.megamenu_wrap .megamenu_submit .saved {
	    background: transparent;
	    line-height: 28px;
	    margin: 0 0 0 5px;
	    flex: 0 0 auto;
	    border-radius: 0;
		color: $wp-admin-theme-color;
	    text-transform: uppercase;
	    font-weight: bold;
	}

	.megamenu_wrap .megamenu_submit .saved .dashicons {
		color: $wp-admin-theme-color;
	    width: 26px;
	    line-height: 28px;
	    height: 28px;
	}

	// Shared admin utility / tab callouts (was duplicated under location modal + Menu Locations settings).
	.mega-vertical-align-top {
		vertical-align: top;
	}

	.megamenu-admin-modal.megamenu-location-settings-dialog .megamenu-admin-modal__body .megamenu-location-settings-dialog__surface .mega-tab-content .warning,
	.megamenu_wrap.megamenu-dialog-rail > .megamenu-dialog-panels .menu_settings.menu_settings_menu_locations .mega-tab-content .warning {
		margin: 20px 0 0 0;
	}

	.megamenu_wrap.megamenu-dialog-rail > .megamenu-dialog-panels {
		padding: 20px 24px 32px 0;
		box-sizing: border-box;
		min-height: 400px;

		@include tablet {
			padding: 24px;
		}

		textarea.mega-export {
			width: 100%;
			height: 150px;
			font-family: monospace;
			margin-bottom: 10px;
			font-size: 0.9em;
		}

		.megamenu-nav-tab-wrapper {
			position: relative;
			margin: 0;
			padding: 0;
			display: inline-flex;
			align-items: center;
			align-content: center;
			height: 64px;
			gap: 30px;
			width: 100%;
			border: 0;
			box-sizing: border-box;

			@include tablet {
				gap: 16px;
				justify-content: space-between;
			}

			button.mega-tab {
				appearance: none;
				font: inherit;
				display: flex;
				cursor: pointer;
				height: 100%;
				align-content: center;
				flex-wrap: wrap;
				color: $text;
				font-weight: 500;
				font-size: 14px;
				padding: 0 5px;
				margin: 0;
				background: transparent;
				border: 0;
				box-shadow: none;
				text-decoration: none;
				text-align: inherit;

				&:hover {
					color: $wp-admin-theme-color;
				}

				&.nav-tab-active {
					background: $white;
					position: relative;
					z-index: 1;
					color: $wp-admin-theme-color;
				}
			}

			@include nav-tab-slider-indicator;
		}


		.menu_settings {

			&.menu_settings_menu_themes {

				.theme_selector {
					margin-bottom: 20px;
					display: flex;
					flex-wrap: wrap;
					align-items: flex-end;
					row-gap: 12px;
					column-gap: 32px;
					overflow: visible;
					box-sizing: border-box;

					.theme-selector-field {
						display: flex;
						flex-direction: column;
						align-items: stretch;
						gap: 4px;
						min-width: 0;
					}

					.theme-editor-actions-group,
					.theme-editor-preview-group {
						display: flex;
						flex-direction: column;
						align-items: flex-start;
						gap: 4px;
						min-width: 0;
					}

					// Same treatment as `label span.mega-short-desc` in `.megamenu_outer_wrap table` (location dialog / theme fields).
					.theme-selector-field .mega-short-desc,
					.theme-editor-actions-group .mega-short-desc,
					.theme-editor-preview-group .mega-short-desc {
						@include mega-toolbar-field-label;
					}

					.theme-editor-actions-group > .mega-short-desc,
					.theme-editor-preview-group > .mega-short-desc {
						margin: 0 0 0 1px;
					}

					// Native menulist (single chevron): core `.wp-core-ui select` adds a Dashicon
					// `background-image` — clear it or two arrows show.
					select#theme_selector,
					select {
						@include mega-toolbar-native-select;
					}
				}

				// Toggle Bar Designer: block-type picker (labeled `<select>` only — no card chrome or custom select styling).
				form.theme_editor .mega-toggle-block-selector-field {
					display: flex;
					flex-direction: column;
					align-items: stretch;
					gap: 4px;
					margin: 0 0 20px;
					max-width: 100%;

					// Label uses `for=` — without this it stretches full width and every click in that row focuses the select.
					.mega-short-desc {
						@include mega-toolbar-field-label;
						align-self: flex-start;
						width: fit-content;
						max-width: 100%;
					}

					select#toggle-block-selector {
						max-width: 100%;
					}
				}

				.mega-theme-editor-actions {
					display: inline-flex;
					align-items: center;
					flex-wrap: wrap;
					gap: 10px;
					margin: 0;
					overflow: visible;
				}

				// Theme toolbar icon buttons — `@include megamenu-admin-ghost-icon-button` (same as modal close / preview refresh).
				.mega-theme-editor-actions button.mega-theme-editor-action.megamenu-preview-open {
					font: inherit;
					text-align: center;
				}

				.mega-theme-editor-action.is-busy {
					pointer-events: none;
					opacity: 0.65;
				}

				.mega-theme-editor-action {
					position: relative;
					overflow: visible;
					text-decoration: none;
					@include megamenu-admin-ghost-icon-button;
					// Match `mega-toolbar-native-select` / theme editor fields.
					border: 1px solid $megamenu-form-control-border;
					background: $white;

					&:focus {
						border-color: $neutral;
					}

					&:hover {
						border-color: var(--wp-admin-theme-color-darker-20);
					}

					&:focus-visible {
						border-color: $wp-admin-theme-color;
					}

					&.mega-theme-editor-action--export .dashicons,
					&.mega-theme-editor-action--import .dashicons {
						transform: rotate(90deg);
					}
				}

			}

			div.mega-tab-content {
			    position: relative;
			    display: block;
			    width: 100%;
			    padding: 10px 0 0;
			    box-sizing: border-box;

			    &.mega-toggle-disabled {
			    	.mega-toggle_blocks td:after,
			    	.mega-toggle_bar_background td:after,
			    	.mega-toggle_bar_height td:after,
			    	.mega-mobile_menu_overlay td:after,
			    	.mega-mobile_menu_force_width td:after {
			    		@include disabled-row-overlay;
			    	}

				    .mega-mobile_toggle_disabled {
				    	display: table-row;
				    }
			    }

			    &.mega-mobile-disabled {
			    	tr:not(.mega-responsive_breakpoint):not(.mega-responsive_breakpoint_disabled) td:after {
			    		@include disabled-row-overlay;
			    	}

				    .mega-responsive_breakpoint_disabled {
				    	display: table-row;
				    }

				    .mega-mobile_toggle_disabled {
				    	display: none;
				    }
			    }

			    .mega-responsive_breakpoint_disabled,
			    .mega-mobile_toggle_disabled {
				    display: none;

				    td {
					    padding-top: 10px;
					    padding-bottom: 10px;
					    border-top: 0;
				    }

				    h5 {
					    border: 1px solid $line-ui;
					    padding: 10px;
					    box-sizing: border-box;
					    border-left: 3px solid $success;
					    font-size: 12px;
					    font-weight: normal;
					    margin: 0 10px;
				    }
			    }
			}
		}

	}

}

@keyframes mm-mega-widget-selector-pulse {
	0%,
	100% {
		box-shadow: 0 0 0 0 transparent;
	}
	50% {
		box-shadow: 0 0 0 3px $focus-ring-blue-soft;
	}
}

@keyframes mm-rotation {
	0% {
		transform: rotate(0deg);
	}
	100% {
		transform: rotate(359deg);
	}
}

@keyframes busy-animation {
	0% {
		background-position: 200px 0;
	}
}
