/*
 * AFB Vertical Menu — Frontend Stylesheet
 * Version: 2.0.0
 *
 * Architecture:
 *   1. CSS custom property declarations (set via inline style on wrapper)
 *   2. Base layout
 *   3. Menu items & links
 *   4. Icons
 *   5. Toggle arrows
 *   6. Submenus
 *   7. Style variants (tree, lines)
 *   8. State (hover, active, open)
 *   9. Animations
 *  10. RTL overrides
 *  11. Responsive
 *  12. Accessibility
 */

/* ============================================================
   1. CSS Custom Property Tokens (fallback defaults)
   ============================================================ */
.afb-vertical-menu {
	--afb-text-color:      #333333;
	--afb-bg-color:        #ffffff;
	--afb-sub-bg:          #fafafa;
	--afb-hover-bg:        #f5f5f5;
	--afb-hover-color:     #333333;
	--afb-active-bg:       #0073aa;
	--afb-active-color:    #ffffff;
	--afb-arrow-color:     #555555;
	--afb-border-color:    #e8e8e8;
	--afb-border-radius:   6px;
	--afb-separator-color: #ececec;
	--afb-shadow:          0 2px 8px 0 rgba(0,0,0,0.08);
	--afb-shadow-hover:    0 4px 12px 0 rgba(0,0,0,0.12);
	--afb-shadow-active:   0 5px 16px 0 rgba(0,0,0,0.18);
	--afb-item-height:     44px;
	--afb-item-spacing:    4px;
	--afb-padding-x:       16px;
	--afb-padding-y:       0px;
	--afb-font-size:       14px;
	--afb-font-weight:     500;
	--afb-icon-size:       14px;
	--afb-animation-speed: 280ms;
}

/* ============================================================
   2. Base Layout
   ============================================================ */
.afb-vertical-menu,
.afb-vertical-menu * {
	box-sizing: border-box;
}

.afb-vertical-menu {
	width: 100%;
	font-size: var(--afb-font-size);
	font-weight: var(--afb-font-weight);
	line-height: 1.4;
}

.afb-nav-wrap {
	width: 100%;
}

.afb-menu-list,
.afb-submenu {
	list-style: none;
	margin: 0;
	padding: 0;
}

.afb-menu-list > .afb-menu-item + .afb-menu-item {
	margin-top: var(--afb-item-spacing);
}

/* ============================================================
   3. Menu Item & Link
   ============================================================ */
.afb-menu-item {
	position: relative;
	background-color: var(--afb-bg-color);
	border-radius: var(--afb-border-radius);
	overflow: hidden;
	transition:
		box-shadow var(--afb-animation-speed) ease,
		background-color var(--afb-animation-speed) ease;
}

.afb-has-shadow .afb-menu-item {
	box-shadow: var(--afb-shadow);
}

.afb-has-shadow .afb-menu-item:hover {
	box-shadow: var(--afb-shadow-hover);
}

.afb-item-wrap {
	position: relative;
	display: flex;
	align-items: stretch;
	min-height: var(--afb-item-height);
}

.afb-menu-link {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 0;
	min-height: var(--afb-item-height);
	padding: var(--afb-padding-y) var(--afb-padding-x);
	color: var(--afb-text-color);
	background-color: transparent;
	text-decoration: none;
	font-size: var(--afb-font-size);
	font-weight: var(--afb-font-weight);
	transition:
		color var(--afb-animation-speed) ease,
		background-color var(--afb-animation-speed) ease;
}

.afb-menu-link:hover,
.afb-menu-link:focus-visible {
	color: var(--afb-hover-color);
	background-color: var(--afb-hover-bg);
	text-decoration: none;
	outline: none;
}

.afb-menu-text {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ============================================================
   4. Icons
   ============================================================ */
.afb-menu-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: var(--afb-icon-size);
	width: calc(var(--afb-icon-size) + 2px);
	color: inherit;
	transition: color var(--afb-animation-speed) ease;
}

/* Dot icons (auto-generated fallback) are smaller */
.afb-menu-icon .afb-icon-dot {
	font-size: calc(var(--afb-icon-size) * 0.45);
	opacity: 0.5;
}

/* LTR icon spacing */
.afb-ltr .afb-icon-left  { margin-inline-end: 10px; }
.afb-ltr .afb-icon-right { margin-inline-start: 10px; }

/* RTL icon spacing */
.afb-rtl .afb-icon-left  { margin-inline-start: 10px; }
.afb-rtl .afb-icon-right { margin-inline-end: 10px; }

/* ============================================================
   5. Toggle Arrows
   ============================================================ */
.afb-toggle {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	min-height: var(--afb-item-height);
	padding: 0;
	border: none;
	border-inline-start: 1px solid var(--afb-border-color);
	background: transparent;
	color: var(--afb-arrow-color);
	cursor: pointer;
	transition:
		background-color var(--afb-animation-speed) ease,
		color var(--afb-animation-speed) ease,
		transform var(--afb-animation-speed) ease;
	-webkit-appearance: none;
	appearance: none;
	outline: none;
}

.afb-toggle:hover,
.afb-toggle:focus-visible {
	background-color: var(--afb-hover-bg);
	color: var(--afb-hover-color);
	outline: 2px solid var(--afb-active-bg);
	outline-offset: -2px;
}

/* Rotate the icon when open */
.afb-has-children.afb-is-open > .afb-item-wrap > .afb-toggle,
.afb-has-children.afb-submenu-open > .afb-item-wrap > .afb-toggle {
	color: var(--afb-active-color);
	background-color: var(--afb-active-bg);
}

.afb-toggle i,
.afb-toggle .fa {
	transition: transform var(--afb-animation-speed) cubic-bezier(0.4, 0, 0.2, 1);
	display: block;
}

.afb-has-children.afb-is-open > .afb-item-wrap > .afb-toggle i,
.afb-has-children.afb-submenu-open > .afb-item-wrap > .afb-toggle i {
	transform: rotate(180deg);
}

/* Plus/minus toggle */
.afb-plus-icon {
	position: relative;
	width: 12px;
	height: 12px;
}

.afb-plus-h,
.afb-plus-v {
	position: absolute;
	background: currentColor;
	transition: opacity var(--afb-animation-speed) ease,
	            transform var(--afb-animation-speed) ease;
}

.afb-plus-h {
	top: 50%; left: 0;
	width: 100%; height: 2px;
	transform: translateY(-50%);
}

.afb-plus-v {
	top: 0; left: 50%;
	height: 100%; width: 2px;
	transform: translateX(-50%);
}

.afb-has-children.afb-is-open .afb-plus-v {
	transform: translateX(-50%) rotate(90deg);
	opacity: 0;
}

/* ============================================================
   6. Submenus
   ============================================================ */
.afb-submenu {
	display: none;
	width: 100%;
	overflow: hidden;
	background-color: var(--afb-sub-bg);
}

.afb-submenu.afb-submenu-open {
	display: block;
}

.afb-submenu .afb-menu-item {
	border-radius: 0;
	background-color: transparent;
	box-shadow: none !important;
}

.afb-submenu .afb-menu-link {
	font-size: calc(var(--afb-font-size) * 0.95);
	font-weight: 400;
}

/* ============================================================
   7. Style Variants
   ============================================================ */

/* --- Tree style --- */
.afb-style-tree .afb-menu-item {
	border-radius: 0;
	border-inline-start: 2px solid transparent;
}

.afb-style-tree .afb-menu-item:hover,
.afb-style-tree .afb-menu-item.afb-is-open {
	border-inline-start-color: var(--afb-active-bg);
}

.afb-style-tree .afb-submenu {
	border-inline-start: 2px dashed var(--afb-border-color);
	margin-inline-start: calc(var(--afb-padding-x) + 6px);
}

/* --- Lines style --- */
.afb-style-lines .afb-menu-item + .afb-menu-item {
	border-top: 1px solid var(--afb-separator-color);
}

.afb-style-lines .afb-menu-item {
	border-radius: 0;
	box-shadow: none !important;
}

/* ============================================================
   8. State: Active / Open
   ============================================================ */
.afb-menu-item.afb-is-active > .afb-item-wrap > .afb-menu-link,
.afb-menu-item.current-menu-item > .afb-item-wrap > .afb-menu-link,
.afb-menu-item.current-menu-ancestor > .afb-item-wrap > .afb-menu-link {
	color: var(--afb-active-color);
	background-color: var(--afb-active-bg);
	font-weight: 600;
}

.afb-has-shadow .afb-menu-item.afb-is-active {
	box-shadow: var(--afb-shadow-active);
}

/* Separator */
.afb-has-separator .afb-menu-item + .afb-menu-item {
	border-top: 1px solid var(--afb-separator-color);
}

.afb-has-separator .afb-menu-item:first-child {
	border-top: 1px solid var(--afb-border-color);
}

.afb-has-separator .afb-menu-item:last-child {
	border-bottom: 1px solid var(--afb-border-color);
}

/* ============================================================
   9. Animations
   ============================================================ */

/* --- Slide --- */
.afb-anim-slide .afb-submenu {
	display: block;
	max-height: 0;
	overflow: hidden;
	transition: max-height var(--afb-animation-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

.afb-anim-slide .afb-submenu.afb-submenu-open {
	max-height: 2000px;
}

/* --- Fade --- */
.afb-anim-fade .afb-submenu {
	display: block;
	opacity: 0;
	visibility: hidden;
	transition:
		opacity var(--afb-animation-speed) ease,
		visibility 0s linear var(--afb-animation-speed);
}

.afb-anim-fade .afb-submenu.afb-submenu-open {
	opacity: 1;
	visibility: visible;
	transition:
		opacity var(--afb-animation-speed) ease,
		visibility 0s;
}

/* --- Slide + Fade --- */
.afb-anim-both .afb-submenu {
	display: block;
	max-height: 0;
	overflow: hidden;
	opacity: 0;
	transition:
		max-height var(--afb-animation-speed) cubic-bezier(0.4, 0, 0.2, 1),
		opacity var(--afb-animation-speed) ease;
}

.afb-anim-both .afb-submenu.afb-submenu-open {
	max-height: 2000px;
	opacity: 1;
}

/* ============================================================
   10. RTL
   ============================================================ */
.afb-rtl .afb-menu-link {
	direction: rtl;
	text-align: start;
}

.afb-rtl .afb-toggle {
	border-inline-start: none;
	border-inline-end: 1px solid var(--afb-border-color);
}

/* ============================================================
   11. Responsive
   ============================================================ */
@media (max-width: 768px) {
	.afb-vertical-menu {
		--afb-font-size:  13px;
		--afb-padding-x:  12px;
	}

	.afb-toggle {
		width: 40px;
	}
}

/* ============================================================
   12. Accessibility
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
	.afb-vertical-menu,
	.afb-vertical-menu * {
		transition-duration: 0.01ms !important;
		animation-duration:  0.01ms !important;
	}
}

.afb-menu-link:focus-visible {
	outline: 2px solid var(--afb-active-bg);
	outline-offset: -2px;
}

/* Screen-reader only utilities */
.afb-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0,0,0,0);
	white-space: nowrap;
	border: 0;
}

/* ============================================================
   Editor placeholder
   ============================================================ */
.afb-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 30px 20px;
	background: #f9f9f9;
	border: 2px dashed #ccc;
	border-radius: 6px;
	color: #888;
	text-align: center;
}

.afb-placeholder .dashicons {
	font-size: 36px;
	width: 36px;
	height: 36px;
	margin-bottom: 10px;
	opacity: 0.5;
}

.afb-placeholder p {
	margin: 0;
	font-size: 13px;
}
