/**
 * LAKASG Account Menu — frontend styles (v2.10.0)
 *
 * Responsive header dropdown. Works inside Astra's Header Builder, classic
 * widget areas, and Elementor-built headers. No framework assumptions —
 * pure scoped CSS.
 */

/* ============================================================================
   Wrapper + trigger
   ============================================================================ */
.lakasg-am {
	position: relative;
	display: inline-block;
	line-height: 1;
}

.lakasg-am-trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 4px 6px;
	background: transparent;
	border: 0;
	cursor: pointer;
	color: inherit;
	font: inherit;
	line-height: 1;
	transition: color 150ms;
}
.lakasg-am-trigger:hover,
.lakasg-am-trigger:focus-visible {
	color: #2271b1;
	outline: none;
}
.lakasg-am-trigger:focus-visible {
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.35);
	border-radius: 4px;
}

.lakasg-am-trigger svg {
	width: 24px;
	height: 24px;
	display: block;
	flex-shrink: 0;
}
.lakasg-am-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	display: block;
	flex-shrink: 0;
}
.lakasg-am-trigger-label {
	font-size: 0.9rem;
	white-space: nowrap;
}

/* Default label visibility:
   - Hidden when the widget setting `show_label` is off (no --show-label class)
   - Shown when --show-label class is present
   The mobile-menu-item context below overrides this to force-show. */
.lakasg-am:not(.lakasg-am--show-label) .lakasg-am-trigger-label {
	display: none;
}


/* Hard no-flash guard: the dropdown ships with the native hidden attribute
   so it cannot appear during first paint before the stylesheet finishes. */
.lakasg-am-dropdown[hidden] {
	display: none !important;
}

/* ============================================================================
   Dropdown panel
   ============================================================================ */
.lakasg-am-dropdown {
	/* Hidden by default — JS toggles `is-open` on the root */
	position: absolute;
	top: calc(100% + 8px);
	min-width: 220px;
	max-width: calc(100vw - 20px);
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
	padding: 6px 0;
	z-index: 9999;

	/* Hidden state */
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	transition: opacity 150ms, transform 150ms, visibility 0ms linear 150ms;
	pointer-events: none;
}

/* Alignment — driven by a class on the widget root (set in the PHP render).
   We no longer use Elementor's selectors_dictionary pattern for this. */
.lakasg-am--align-right .lakasg-am-dropdown { right: 0; left: auto; }
.lakasg-am--align-left  .lakasg-am-dropdown { left: 0;  right: auto; }

.lakasg-am.is-open .lakasg-am-dropdown {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	transition: opacity 150ms, transform 150ms, visibility 0ms;
	pointer-events: auto;
}

/* ============================================================================
   Dropdown content
   ============================================================================ */
.lakasg-am-header {
	padding: 10px 14px 8px;
	font-size: 0.8rem;
	color: #666;
	border-bottom: 1px solid rgba(0, 0, 0, 0.06);
	margin-bottom: 4px;
	overflow-wrap: anywhere;
}

.lakasg-am-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	color: #222;
	text-decoration: none;
	font-size: 0.9rem;
	transition: background-color 120ms;
	cursor: pointer;
	border: 0;
	background: transparent;
	width: 100%;
	text-align: left;
	line-height: 1.2;
}
.lakasg-am-item:hover,
.lakasg-am-item:focus-visible {
	background-color: #f6f7f7;
	outline: none;
	text-decoration: none;
}

.lakasg-am-item--primary {
	color: #2271b1;
	font-weight: 600;
}
.lakasg-am-item--logout {
	color: #b32d2e;
}

.lakasg-am-divider {
	height: 1px;
	margin: 4px 0;
	background-color: rgba(0, 0, 0, 0.08);
}

/* ============================================================================
   Mobile tweaks (standalone widget, not inside a nav menu)
   ============================================================================ */
@media (max-width: 600px) {
	/* On small screens make the dropdown wider + pin its right edge to the
	   page margin so it never pokes off-screen. */
	.lakasg-am-dropdown {
		min-width: min(280px, calc(100vw - 20px));
	}
	/* Hide the label on very narrow viewports when show_label is on. Saves
	   space in tight header layouts. The menu-item override below wins for
	   menu-context usage where a full-width row with a label reads better. */
	.lakasg-am--show-label .lakasg-am-trigger-label {
		display: none;
	}
}

/* ============================================================================
   Nav-menu integration (v2.10.2 + mobile polish v2.10.3 + reliability v2.10.4)

   When placed inside a WordPress nav menu via a Custom Link item whose label
   is `[lakasg_account_menu]`, the filter in the main plugin replaces the
   menu item's <a> wrapper with our dropdown markup.

   The JS detects nav-menu ancestry on init and adds `.lakasg-am--in-menu`
   to our root element. This is the selector the styles below hook. We also
   (best-effort) add `.menu-item-lakasg-account` to the closest <li> for
   theme developers who want to target the row itself, but we do NOT rely
   on it — Astra and some other themes use custom walkers that bypass the
   nav_menu_css_class filter.
   ============================================================================ */

/* Desktop + mobile: make sure the wrapping <li> doesn't clip the dropdown */
.menu-item-lakasg-account,
li:has(> .lakasg-am--in-menu) {
	position: relative;
	overflow: visible !important;
	list-style: none;
}
.lakasg-am--in-menu {
	display: inline-flex;
	align-items: center;
	vertical-align: middle;
}
.lakasg-am--in-menu .lakasg-am-trigger {
	padding: 0 6px;
}

/* ─── Mobile nav context: full-width row with a label ───────────────────
   Breakpoint 921px matches Astra's default mobile menu cutoff and most
   major WP themes. Style kicks in slightly earlier/later relative to any
   theme's exact switch but visually remains correct. */
@media (max-width: 921px) {

	/* Widget fills the menu row */
	.lakasg-am--in-menu {
		display: block;
		width: 100%;
	}

	/* Trigger: full-width, left-aligned, label always visible, inherits
	   theme font/color so it blends with surrounding menu items */
	.lakasg-am--in-menu .lakasg-am-trigger {
		width: 100%;
		padding: 14px 20px;
		justify-content: flex-start;
		gap: 12px;
		font-size: inherit;
		color: inherit;
	}
	/* Force show the label in mobile menu regardless of show_label setting */
	.lakasg-am--in-menu .lakasg-am-trigger-label {
		display: inline !important;
		font-size: inherit;
	}

	/* Dropdown: flow inline as a submenu, not absolute-positioned overlay */
	.lakasg-am--in-menu .lakasg-am-dropdown {
		position: static;
		box-shadow: none;
		border: 0;
		border-radius: 0;
		padding: 0;
		width: 100%;
		max-width: none;
		margin: 0;
		background: rgba(0, 0, 0, 0.04);
		/* Use max-height + visibility for smooth collapse/expand without
		   breaking drawer scroll. */
		opacity: 1;
		transform: none;
		visibility: hidden;
		pointer-events: none;
		max-height: 0;
		overflow: hidden;
		transition: max-height 200ms ease, visibility 0ms linear 200ms;
	}
	.lakasg-am--in-menu.is-open .lakasg-am-dropdown {
		visibility: visible;
		pointer-events: auto;
		max-height: 500px;
		transition: max-height 200ms ease, visibility 0ms;
	}

	/* Dropdown items: indented like a theme submenu */
	.lakasg-am--in-menu .lakasg-am-item {
		padding: 12px 20px 12px 50px;
		font-size: inherit;
	}
	.lakasg-am--in-menu .lakasg-am-header {
		padding: 10px 20px 10px 50px;
		font-size: 0.85em;
		opacity: 0.7;
		/* Let the background show through rather than forcing a color —
		   works on both light and dark mobile drawers. */
		background: transparent;
		color: inherit;
		border: 0;
	}
	.lakasg-am--in-menu .lakasg-am-divider {
		margin: 0;
		background-color: rgba(0, 0, 0, 0.08);
	}
}
