/**
 * Wholesale Language System — Frontend Styles
 *
 * Compact, accessible, B2B-appropriate language switcher.
 * No flags. No floating overlays. No brand-specific colours.
 *
 * @package WholesaleLanguageSystem
 */

/* ---------------------------------------------------------------------------
   1. Container — inline with navigation
   --------------------------------------------------------------------------- */

.wls-language-switcher {
	position: relative;
	display: inline-flex;
	align-items: center;
	user-select: none;
	-webkit-user-select: none;
	font-size: 14px;
	line-height: 1.4;
	color: inherit;
}

/* ---------------------------------------------------------------------------
   2. Trigger button
   --------------------------------------------------------------------------- */

.wls-trigger {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 8px;
	border: 1px solid transparent;
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font-size: inherit;
	font-family: inherit;
	line-height: inherit;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
	outline: none;
}

.wls-trigger:hover,
.wls-trigger:focus-visible {
	border-color: currentColor;
	background-color: rgba(128, 128, 128, 0.08);
}

/* Keyboard focus — always visible */
.wls-trigger:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.wls-globe-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	opacity: 0.85;
	line-height: 0;
}

.wls-globe-icon svg {
	display: block;
	width: 100%;
	height: 100%;
}

.wls-current-lang {
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
}

.wls-arrow {
	display: inline-flex;
	align-items: center;
	margin-left: 1px;
	opacity: 0.6;
	transition: transform 0.2s ease;
	line-height: 0;
}

.wls-arrow svg {
	display: block;
	width: 10px;
	height: 6px;
}

.wls-trigger[aria-expanded="true"] .wls-arrow {
	transform: rotate(180deg);
}

/* ---------------------------------------------------------------------------
   3. Dropdown
   --------------------------------------------------------------------------- */

.wls-dropdown {
	position: absolute;
	top: 100%;
	right: 0;
	z-index: 1000;
	min-width: 170px;
	margin-top: 4px;
	padding: 4px 0;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 6px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-4px);
	transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease;
	pointer-events: none;
}

.wls-dropdown--open,
.wls-trigger[aria-expanded="true"] + .wls-dropdown,
.wls-trigger[aria-expanded="true"] ~ .wls-dropdown {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

.wls-language-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.wls-language-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 14px;
	cursor: pointer;
	transition: background-color 0.12s ease;
	font-size: 14px;
	color: #333;
}

.wls-language-option:hover,
.wls-language-option:focus {
	background-color: #f0f0f0;
	outline: none;
}

.wls-language-option:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

.wls-language-option[aria-selected="true"] {
	font-weight: 600;
	color: #000;
	background-color: #f5f5f5;
}

.wls-language-option[aria-selected="true"]::before {
	content: "✓";
	font-size: 12px;
	margin-right: 4px;
	opacity: 0.7;
}

.wls-lang-code {
	font-size: 11px;
	opacity: 0.55;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	font-weight: 400;
}

/* ---------------------------------------------------------------------------
   4. Hidden GTranslate wrapper (visually hidden, functionally active)
   --------------------------------------------------------------------------- */

.wls-gtranslate-wrapper {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* ---------------------------------------------------------------------------
   5. Nav-item wrapper (inside wp-block-navigation)
   --------------------------------------------------------------------------- */

.wp-block-navigation-item.wls-nav-item {
	display: flex;
	align-items: center;
}

/* Invert dropdown background for dark nav bars */
.has-background .wls-dropdown,
.wp-block-navigation-item .wls-dropdown {
	background: #fff;
	color: #333;
}

/* Ensure the dropdown does not overflow the nav on small viewports */
.wls-nav-item .wls-language-switcher {
	position: static;
}

.wls-nav-item .wls-dropdown {
	right: auto;
	left: 0;
}

/* ---------------------------------------------------------------------------
   6. Mobile — tablet and below
   --------------------------------------------------------------------------- */

@media (max-width: 781px) {
	.wls-language-switcher {
		width: 100%;
	}

	.wls-trigger {
		width: 100%;
		justify-content: flex-start;
		padding: 8px 12px;
		border-radius: 0;
		border-bottom: 1px solid rgba(128, 128, 128, 0.15);
	}

	.wls-dropdown {
		position: static;
		width: 100%;
		margin-top: 0;
		border: none;
		border-radius: 0;
		box-shadow: none;
		background: transparent;
		transition: none;
	}

	/* Animate with max-height instead for mobile */
	.wls-language-list {
		max-height: 0;
		overflow: hidden;
		transition: max-height 0.25s ease;
	}

	.wls-dropdown--open .wls-language-list,
	.wls-trigger[aria-expanded="true"] ~ .wls-dropdown .wls-language-list,
	.wls-trigger[aria-expanded="true"] + .wls-dropdown .wls-language-list {
		max-height: 400px; /* Tall enough for 7 items */
	}

	.wls-language-option {
		padding: 10px 12px 10px 32px;
		font-size: 15px;
	}

	.wls-language-option[aria-selected="true"] {
		background-color: rgba(128, 128, 128, 0.06);
	}

	.wls-language-option:hover {
		background-color: rgba(128, 128, 128, 0.04);
	}

	/* Reset hidden-gtranslate wrapper on mobile so GTranslate scripts still work */
	.wls-gtranslate-wrapper {
		/* keep visually hidden — same as desktop */;
	}
}

/* ---------------------------------------------------------------------------
   7. Small desktop tweaks
   --------------------------------------------------------------------------- */

@media (min-width: 782px) {
	.wls-language-switcher {
		margin-left: 8px;
	}
}
