/**
 * GF Sidebar – Base styles.
 *
 * Everything position/layout related.
 * Visual customisation is handled by Elementor controls (selectors).
 */

/* Wrapper: hidden by default, full-screen fixed overlay */
.gf-sidebar-wrapper {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	/* Above WP admin bar (32px tall, z-index 99999) and Elementor popups (9999). */
	z-index: 100000;
	pointer-events: none;
	visibility: hidden;
	/* Delay visibility change until panel slide-out finishes when closing,
	   but switch to visible immediately when opening (handled by --open rule). */
	transition: visibility 0s linear 0.3s;
}

.gf-sidebar-wrapper.gf-sidebar--open {
	pointer-events: auto;
	visibility: visible;
	transition: visibility 0s linear 0s;
}

/* Overlay */
.gf-sidebar-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.5);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.gf-sidebar--open .gf-sidebar-overlay {
	opacity: 1;
}

/* Panel */
:where(.gf-sidebar-panel) {
	position: absolute;
	top: 0;
	height: 100%;
	width: 320px;
	max-width: 100%;
	display: flex;
	flex-direction: column;
	background: #fff;
	/* Panel itself never scrolls – the body inside does. */
	overflow: hidden;
	transition: transform 0.3s ease;
}

/* Slide from left */
.gf-sidebar-panel--left {
	left: 0;
	transform: translateX(-100%);
}

.gf-sidebar--open .gf-sidebar-panel--left {
	transform: translateX(0);
}

/* Slide from right */
.gf-sidebar-panel--right {
	right: 0;
	transform: translateX(100%);
}

.gf-sidebar--open .gf-sidebar-panel--right {
	transform: translateX(0);
}

/* Header / Close */
:where(.gf-sidebar-header) {
	display: flex;
	align-items: center;
	flex-shrink: 0;
}

/* Absolute layout: float close button over the panel content */
.gf-sidebar-header--absolute {
	position: absolute;
	top: 0;
	z-index: 2;
}

.gf-sidebar-header--absolute[data-close-position="right"] {
	right: 0;
	left: auto;
}

.gf-sidebar-header--absolute[data-close-position="left"] {
	left: 0;
	right: auto;
}

.gf-sidebar-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	cursor: pointer;
	padding: 12px;
	line-height: 1;
	font-size: 20px;
	color: #333;
}

.gf-sidebar-close--right {
	margin-left: auto;
}

.gf-sidebar-close--left {
	margin-right: auto;
}

/* Body – grows to fill remaining space and scrolls its own overflow.
   `min-height: 0` is required for the flex child to shrink below its
   intrinsic content size, which is what makes overflow:auto kick in. */
:where(.gf-sidebar-body) {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

/* ---- Sticky Footer mode ---- */
/* The last sidebar_items child is rendered as a SIBLING of .gf-sidebar-body
   (in .gf-sidebar-footer) when "Show Footer" is enabled. The panel is already
   flex-direction: column, so the body grows (flex: 1) and the footer stays
   pinned at the bottom (flex-shrink: 0) — no grid/flex magic on the body
   itself, so user containers inside it are never disturbed. */
:where(.gf-sidebar-footer) {
	flex-shrink: 0;
}

/* Body lock when sidebar is open */
body.gf-sidebar-body-open {
	overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* WP Admin Bar offset                                                */
/* ------------------------------------------------------------------ */
/* --gf-admin-bar-height is set by sidebar-frontend.js on load + resize. */
body.admin-bar .gf-sidebar-wrapper {
	top: var(--gf-admin-bar-height, 32px);
	height: calc(100% - var(--gf-admin-bar-height, 32px));
}

/* ------------------------------------------------------------------ */
/* Editor overrides                                                   */
/* ------------------------------------------------------------------ */

/* Default in editor: widget takes no layout space */
.elementor-editor-active .elementor-widget-gf-sidebar,
.elementor-editor-preview .elementor-widget-gf-sidebar {
	position: relative;
	min-height: 0;
}

/* Hide wrapper completely until the widget is selected */
.elementor-editor-active .elementor-widget-gf-sidebar:not(.gf-sidebar--editor-active) .gf-sidebar-wrapper,
.elementor-editor-preview .elementor-widget-gf-sidebar:not(.gf-sidebar--editor-active) .gf-sidebar-wrapper {
	display: none;
}

/* When selected: neutralise ancestor transforms that would break position:fixed */
.elementor-editor-active .elementor-element.gf-sidebar--editor-active,
.elementor-editor-preview .elementor-element.gf-sidebar--editor-active {
	transform: none !important;
	will-change: auto !important;
	filter: none !important;
	perspective: none !important;
}

/* Active: show with a dashed editor outline so user knows it's edit mode.
   All positioning, slide-from, animation duration, panel width etc.
   come from the regular frontend rules and Elementor controls. */
.elementor-editor-active .gf-sidebar--editor-active .gf-sidebar-panel,
.elementor-editor-preview .gf-sidebar--editor-active .gf-sidebar-panel {
	outline: 2px dashed #93003f;
	outline-offset: -2px;
}

/* Force the wrapper to render in "open" state inside the editor when the
   widget is selected — without needing the JS-toggled .gf-sidebar--open class
   (which gets wiped on every re-render). */
.elementor-editor-active .gf-sidebar--editor-active .gf-sidebar-wrapper,
.elementor-editor-preview .gf-sidebar--editor-active .gf-sidebar-wrapper {
	pointer-events: auto;
	visibility: visible;
}

.elementor-editor-active .gf-sidebar--editor-active .gf-sidebar-overlay,
.elementor-editor-preview .gf-sidebar--editor-active .gf-sidebar-overlay {
	opacity: 1;
}

.elementor-editor-active .gf-sidebar--editor-active .gf-sidebar-panel--left,
.elementor-editor-active .gf-sidebar--editor-active .gf-sidebar-panel--right,
.elementor-editor-preview .gf-sidebar--editor-active .gf-sidebar-panel--left,
.elementor-editor-preview .gf-sidebar--editor-active .gf-sidebar-panel--right {
	transform: translateX(0);
}
