/* ==========================================================================
   Services Sidebar — services-sidebar.css
   CSS custom properties are set by Elementor's dynamic CSS engine via
   {{WRAPPER}} .allstar-services-sidebar selectors. Defaults below act as
   fallbacks when the widget is rendered outside the editor.
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Property Defaults (also set on {{WRAPPER}} via Elementor)
   -------------------------------------------------------------------------- */
.elementor-widget-allstar-services-sidebar,
.allstar-services-sidebar {
	--sidebar-bg:              #ffffff;
	--sidebar-width-expanded:  260px;
	--sidebar-width-collapsed: 60px;
	--sidebar-transition:      300ms;
	--icon-size-collapsed:     24px;
}

/* --------------------------------------------------------------------------
   Elementor Column Wrapper
   Elementor wraps the widget in .elementor-widget-allstar-services-sidebar.
   We must give that element an explicit width so the adjacent content column
   cannot overlap it. The CSS custom properties are set on {{WRAPPER}} by
   the PHP controls, so they are available here.
   -------------------------------------------------------------------------- */
/*
 * Elementor often sets overflow:hidden on sections/columns for entrance
 * animations. That silently kills position:sticky on any descendant.
 * These :has() rules target only the ancestors that contain our widget
 * and force overflow:visible so sticky can reach the scroll root (viewport).
 */
.elementor-section:has( .elementor-widget-allstar-services-sidebar ),
.elementor-container:has( .elementor-widget-allstar-services-sidebar ),
.elementor-column:has( .elementor-widget-allstar-services-sidebar ),
.elementor-widget-wrap:has( .elementor-widget-allstar-services-sidebar ),
.e-con:has( .elementor-widget-allstar-services-sidebar ),
.e-con-inner:has( .elementor-widget-allstar-services-sidebar ) {
	overflow: visible !important;
}

.elementor-widget-allstar-services-sidebar {
	flex-shrink: 0 !important;
	align-self: flex-start;
	width: var( --sidebar-width-expanded, 260px );
	transition: width var( --sidebar-transition, 300ms ) ease;
	position: sticky;
	top: 0;
	margin-top: 0 !important;
}

/* Collapsed state — toggled by JS adding .allstar-wrapper-is-collapsed */
.elementor-widget-allstar-services-sidebar.allstar-wrapper-is-collapsed {
	width: var( --sidebar-width-collapsed, 60px );
}

/* JS sticky fallback — applied when CSS sticky cannot engage */
.allstar-sticky-sentinel {
	position: absolute;
	top: 0;
	height: 0;
	visibility: hidden;
	pointer-events: none;
}

.elementor-widget-allstar-services-sidebar.allstar-is-stuck {
	position: fixed !important;
	top: var( --allstar-sticky-top, 0px ) !important;
	z-index: 100;
}

/* The inner Elementor widget-container must fill its wrapper */
.elementor-widget-allstar-services-sidebar > .elementor-widget-container {
	width: 100%;
}

/* --------------------------------------------------------------------------
   Sidebar Layout
   -------------------------------------------------------------------------- */
.allstar-services-sidebar {
	width: 100%;
	max-height: 100vh;
	overflow-y: auto;
	overflow-x: hidden;
	background-color: var( --sidebar-bg );
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
	scrollbar-width: thin;
}

/* Smooth scrollbar */
.allstar-services-sidebar::-webkit-scrollbar {
	width: 4px;
}

.allstar-services-sidebar::-webkit-scrollbar-thumb {
	background: rgba( 0, 0, 0, 0.15 );
	border-radius: 2px;
}

/* --------------------------------------------------------------------------
   Header — single flex row: [title | toggle button]
   The title div collapses to max-width: 0 when the sidebar is closed so the
   toggle button is ALWAYS reachable and never pushed off-screen.
   -------------------------------------------------------------------------- */
.allstar-sidebar-header {
	display: flex;
	align-items: center;
	flex-shrink: 0;
	overflow: hidden;
	padding: 8px;
}

/* Title area — grows to fill available space, shrinks cleanly */
.allstar-sidebar-header__title {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	transition: max-width var( --sidebar-transition ) ease, opacity var( --sidebar-transition ) ease;
}

/* Collapsed: physically remove the title from layout so the button has room */
.allstar-services-sidebar.allstar-is-collapsed .allstar-sidebar-header__title {
	max-width: 0;
	opacity: 0;
	pointer-events: none;
}

/* --------------------------------------------------------------------------
   Collapse Toggle Button
   -------------------------------------------------------------------------- */
.allstar-sidebar-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 36px;
	height: 36px;
	padding: 0;
	background-color: transparent;
	border: none;
	cursor: pointer;
	color: #444;
	border-radius: 4px;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
	transition: background-color var( --sidebar-transition ) ease, color var( --sidebar-transition ) ease;
}

.allstar-sidebar-toggle:hover {
	background-color: rgba( 0, 0, 0, 0.06 );
}

.allstar-sidebar-toggle:active {
	background-color: rgba( 0, 0, 0, 0.1 );
}

/* Toggle icon visibility — swap icons based on sidebar state.
   Both icons are always inside the button; CSS shows the correct one. */
.allstar-toggle-icon {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* Expand icon hidden when sidebar is open */
.allstar-toggle-icon--expand {
	display: none;
}

/* Collapsed: show expand icon, hide collapse icon */
.allstar-services-sidebar.allstar-is-collapsed .allstar-toggle-icon--collapse {
	display: none;
}

.allstar-services-sidebar.allstar-is-collapsed .allstar-toggle-icon--expand {
	display: block;
}

.allstar-sidebar-title {
	display: block;
	font-weight: 700;
	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #222;
	white-space: nowrap;
	transition: opacity var( --sidebar-transition ) ease;
}

.allstar-sidebar-instruction {
	overflow: hidden;
	max-height: 200px;
	padding: 0 0 8px;
	font-size: 11px;
	line-height: 1.4;
	color: #888;
	transition:
		max-height var( --sidebar-transition ) ease,
		opacity var( --sidebar-transition ) ease;
}

.allstar-sidebar-instruction p {
	margin: 6px 0 0;
}

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */
.allstar-sidebar-nav {
	flex: 1;
	overflow-x: hidden;
}

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

.allstar-sidebar-menu {
	padding: 8px 0;
}

/* --------------------------------------------------------------------------
   Menu Items — Parent (Accordion Trigger)
   -------------------------------------------------------------------------- */
.allstar-accordion-trigger {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 10px 16px;
	background-color: transparent;
	border: none;
	cursor: pointer;
	color: #444;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	text-align: left;
	text-decoration: none;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 150ms ease, color 150ms ease;
	overflow: hidden;
	white-space: nowrap;
}

.allstar-accordion-trigger:hover {
	background-color: #f5f5f5;
	color: #000;
}

.allstar-accordion-trigger:active {
	background-color: #ebebeb;
}

.allstar-is-open > .allstar-accordion-trigger {
	color: #000;
	background-color: #f0f0f0;
}

.allstar-has-active-child > .allstar-accordion-trigger {
	color: #0055a5;
}

/* --------------------------------------------------------------------------
   SVG Icons — visible in collapsed mode only
   -------------------------------------------------------------------------- */
.allstar-item-icon {
	display: none; /* removed from layout when sidebar is expanded */
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: var( --icon-size-collapsed );
	height: var( --icon-size-collapsed );
}

.allstar-item-icon img {
	width: var( --icon-size-collapsed );
	height: var( --icon-size-collapsed );
	object-fit: contain;
	display: block;
	flex-shrink: 0;
}

.allstar-services-sidebar.allstar-is-collapsed .allstar-item-icon {
	display: flex;
}

/* --------------------------------------------------------------------------
   Labels, Title, Chevron — hidden in collapsed mode
   -------------------------------------------------------------------------- */
.allstar-item-label,
.allstar-sidebar-title,
.allstar-chevron {
	transition: opacity var( --sidebar-transition ) ease;
}

.allstar-services-sidebar.allstar-is-collapsed .allstar-sidebar-title {
	opacity: 0;
	pointer-events: none;
}

/* Remove label and chevron from layout so icon can center without gap interference */
.allstar-services-sidebar.allstar-is-collapsed .allstar-item-label,
.allstar-services-sidebar.allstar-is-collapsed .allstar-chevron {
	display: none;
}

/* Center the icon now that label and chevron are gone */
.allstar-services-sidebar.allstar-is-collapsed .allstar-accordion-trigger {
	justify-content: center;
	gap: 0;
}

.allstar-services-sidebar.allstar-is-collapsed .allstar-sidebar-instruction {
	max-height: 0;
	opacity: 0;
	pointer-events: none;
}

/* Force open submenus closed when the sidebar is collapsed */
.allstar-services-sidebar.allstar-is-collapsed .allstar-submenu {
	max-height: 0 !important;
}

.allstar-item-label {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.allstar-chevron {
	display: flex;
	align-items: center;
	color: #aaa;
	flex-shrink: 0;
	transition:
		transform 200ms ease,
		opacity var( --sidebar-transition ) ease;
}

.allstar-is-open > .allstar-accordion-trigger .allstar-chevron {
	transform: rotate( 180deg );
}

/* --------------------------------------------------------------------------
   Submenu / Accordion
   -------------------------------------------------------------------------- */
.allstar-submenu {
	max-height: 0;
	overflow: hidden;
	transition: max-height 250ms ease;
    display: flex;
    flex-direction: column;
	gap: 8px;
}

.allstar-is-open > .allstar-submenu {
	max-height: 800px;
}

/* --------------------------------------------------------------------------
   Child Link Items
   -------------------------------------------------------------------------- */
.allstar-item-link {
	display: flex;
	align-items: center;
	padding: 8px 16px 8px 32px;
	color: #444;
	font-size: 13px;
	text-decoration: none;
	border-left: 3px solid transparent;
	transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.allstar-item-link:hover {
	background-color: #e8f0fb;
	color: #0055a5;
}

.allstar-current-item .allstar-item-link,
.allstar-item-link[aria-current="page"] {
	background-color: #0055a5;
	color: #ffffff;
	border-left-color: #003d7a;
}

/* --------------------------------------------------------------------------
   Mobile Drawer
   -------------------------------------------------------------------------- */
@media ( max-width: 1024px ) {
	/* Override the Elementor wrapper's sticky/width so the drawer can slide in */
	.elementor-widget-allstar-services-sidebar {
		position: fixed !important;
		top: 24px !important;
		left: calc( -1 * var( --sidebar-width-expanded, 260px ) ) !important;
		height: calc( 100vh - 24px ) !important;
		width: var( --sidebar-width-expanded, 260px ) !important;
		z-index: 9999;
		transition: left var( --sidebar-transition, 300ms ) ease !important;
	}

	.elementor-widget-allstar-services-sidebar.allstar-drawer-open {
		left: 24px !important;
	}

	/* Collapsed mode is disabled on mobile — always show full-width labels */
	.elementor-widget-allstar-services-sidebar.allstar-wrapper-is-collapsed {
		width: var( --sidebar-width-expanded, 260px ) !important;
	}

	/* Restore full header: show title, hide the desktop collapse toggle */
	.allstar-services-sidebar .allstar-sidebar-toggle {
		display: none;
	}

	.allstar-services-sidebar.allstar-is-collapsed .allstar-sidebar-header__title {
		max-width: none;
		opacity: 1;
		pointer-events: auto;
	}

	.allstar-services-sidebar.allstar-is-collapsed .allstar-sidebar-title {
		opacity: 1;
		pointer-events: auto;
	}

	.allstar-services-sidebar.allstar-is-collapsed .allstar-item-label {
		display: inline;
	}

	.allstar-services-sidebar.allstar-is-collapsed .allstar-chevron {
		display: flex;
	}

	.allstar-services-sidebar.allstar-is-collapsed .allstar-accordion-trigger {
		justify-content: flex-start;
		gap: 10px;
	}

	.allstar-services-sidebar.allstar-is-collapsed .allstar-sidebar-instruction {
		max-height: 200px;
		opacity: 1;
		pointer-events: auto;
	}

	/* On mobile, open sections should still show their children */
	.allstar-services-sidebar.allstar-is-collapsed .allstar-is-open > .allstar-submenu {
		max-height: 800px !important;
	}

	/* On mobile, icons stay hidden even if the sidebar has the collapsed class */
	.allstar-services-sidebar.allstar-is-collapsed .allstar-item-icon {
		display: none;
	}
}

/* --------------------------------------------------------------------------
   Phone — centered bottom-sheet drawer ( ≤ 600px )
   Overrides the tablet left-slide with a centered slide-from-below.
   -------------------------------------------------------------------------- */
@media ( max-width: 600px ) {
	.elementor-widget-allstar-services-sidebar {
		/* centre horizontally: 2.5vw left + 95vw width + 2.5vw right = 100vw */
		left: 2.5vw !important;
		width: 95vw !important;
		/* hide below viewport when closed */
		top: 100vh !important;
		height: auto !important;
		max-height: 90vh !important;
		/* animate on top instead of left */
		transition: top var( --sidebar-transition, 300ms ) ease !important;
		border-radius: 12px 12px 0 0;
		overflow: hidden;
	}

	.elementor-widget-allstar-services-sidebar.allstar-drawer-open {
		/* slide up so bottom of panel sits at bottom of viewport */
		top: 10vh !important;
		left: 2.5vw !important; /* override tablet's left: 24px */
	}

	/* Inner sidebar scrolls when nav is taller than 90vh */
	.allstar-services-sidebar {
		max-height: 90vh;
		overflow-y: auto;
	}

}

/* Mobile trigger button (injected by JS) */
.allstar-mobile-trigger {
	display: none;
	position: fixed;
	bottom: 20px;
	left: 20px;
	z-index: 10000; /* above backdrop (9998) and sidebar (9999) — always tappable */
	width: 48px;
	height: 48px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background-color: #0055a5;
	color: #ffffff;
	cursor: pointer;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba( 0, 0, 0, 0.25 );
	transition: background-color 150ms ease;
}

.allstar-mobile-trigger:hover {
	background-color: #003d7a;
}

@media ( max-width: 1024px ) {
	.allstar-mobile-trigger {
		display: flex;
	}
}

/* Mobile backdrop (injected by JS) */
.allstar-mobile-backdrop {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba( 0, 0, 0, 0.5 );
	z-index: 9998;
}

.allstar-mobile-backdrop.is-visible {
	display: block;
}

/* Phone trigger positioning — must come after base styles to win the cascade */
@media ( max-width: 600px ) {
	.allstar-mobile-trigger {
		left: 16px !important;
		bottom: calc( 24px + env( safe-area-inset-bottom, 0px ) ) !important;
	}
}

/* --------------------------------------------------------------------------
   Bottom Image
   -------------------------------------------------------------------------- */
.allstar-sidebar-bottom-image {
	display: flex;
	justify-content: center;
	padding: 16px;
	flex-shrink: 0;
	overflow: hidden;
	transition: opacity var( --sidebar-transition ) ease;
}

.allstar-sidebar-bottom-image img {
	display: block;
	width: 80%;
	max-width: 100%;
	height: auto;
}

/* Hide bottom image in icon-only (collapsed) mode on desktop */
.allstar-services-sidebar.allstar-is-collapsed .allstar-sidebar-bottom-image {
	opacity: 0;
	pointer-events: none;
	max-height: 0;
	padding-top: 0;
	padding-bottom: 0;
}
