/**
 * Language Selector Styles
 * 
 * Supports two modes:
 * - Guest: Simple domain links
 * - Logged-in: Two sections (language preference + domain switch)
 */

/* Base Container */
.language-selector {
	position: relative;
	display: inline-flex;
	align-items: center;
	height: 48px;
}

/* Toggle Button */
.language-selector-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	height: 48px;
	padding: 0 16px;
	border: none;
	border-radius: 12px;
	background: transparent;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	box-shadow: none;
}

.language-selector-toggle:hover {
	background: rgba(114, 47, 55, 0.08);
}

.language-selector-toggle:focus {
	outline: 2px solid var(--wine-primary, #722f37);
	outline-offset: 2px;
}

.language-selector-toggle[aria-expanded="true"] {
	background: rgba(114, 47, 55, 0.1);
}

.language-selector-toggle[aria-expanded="true"] .language-name,
.language-selector-toggle[aria-expanded="true"] .language-arrow {
	color: var(--wine-primary);
}

/* Flag & Name */
.language-flag {
	font-size: 1.2em;
	line-height: 1;
}

.language-name {
	color: var(--wine-primary);
	font-weight: 600;
	transition: color 0.3s ease;
}

/* Arrow Icon */
.language-arrow {
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s ease;
	color: var(--wine-primary);
	width: 14px;
	height: 14px;
}

.language-selector-toggle[aria-expanded="true"] .language-arrow {
	transform: rotate(180deg);
}

/* Dropdown Menu */
.language-selector-menu {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	z-index: 1000;
	min-width: 200px;
	margin: 0;
	padding: 0;
	list-style: none;
	background: white;
	border: 1.5px solid rgba(114, 47, 55, 0.1);
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(114, 47, 55, 0.15), 0 4px 12px rgba(0, 0, 0, 0.08);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-12px);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	backdrop-filter: blur(12px);
	overflow: hidden;
}

.language-selector[aria-expanded="true"] .language-selector-menu,
.language-selector.active .language-selector-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* Language Options List */
.language-options {
	list-style: none;
	margin: 0;
	padding: 8px;
}

/* Section Styling (for logged-in users) */
.language-section {
	padding: 8px 0;
}

.language-section:first-child {
	padding-top: 0;
}

.language-section:last-child {
	padding-bottom: 0;
}

.language-section + .language-section {
	border-top: 1px solid rgba(114, 47, 55, 0.1);
	margin-top: 4px;
	padding-top: 12px;
}

.language-section-label {
	display: block;
	padding: 8px 16px 6px;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: rgba(114, 47, 55, 0.6);
}

/* Language Option */
.language-option {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	width: 100%;
	padding: 12px 16px;
	border: none;
	background: none;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	border-radius: 10px;
	transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
	text-decoration: none;
	color: inherit;
	text-align: left;
}

/* Language Label */
.language-label {
	flex: 1;
	color: #333;
}

.language-option:hover {
	background: linear-gradient(135deg, rgba(246, 244, 241, 0.8) 0%, rgba(250, 249, 247, 0.6) 100%);
	transform: translateX(2px);
}

.language-option:focus {
	outline: none;
	background: rgba(114, 47, 55, 0.08);
	box-shadow: inset 0 0 0 2px var(--wine-primary, #722f37);
}

/* Current Selection */
.language-option.current-language,
.language-option.current-domain {
	background: linear-gradient(135deg, var(--wine-accent, #8B4552) 0%, var(--wine-primary, #722f37) 100%);
	color: white;
	box-shadow: 0 2px 8px rgba(114, 47, 55, 0.2);
}

.language-option.current-language .language-name,
.language-option.current-language .domain-name,
.language-option.current-domain .language-name,
.language-option.current-domain .domain-name {
	color: white;
	font-weight: 600;
}

.language-option.current-language:hover,
.language-option.current-domain:hover {
	background: linear-gradient(135deg, var(--wine-primary, #722f37) 0%, var(--wine-accent, #8B4552) 100%);
	transform: none;
}

/* Check Mark */
.language-check {
	margin-left: auto;
	font-size: 14px;
	opacity: 0.9;
}

/* Domain Name in Domain Section */
.domain-name {
	font-size: 13px;
	color: #666;
	font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
}

.language-option.current-domain .domain-name {
	color: rgba(255, 255, 255, 0.9);
}

/* Domain Switch Notice */
.domain-notice {
	padding: 8px 16px 12px;
	margin: 4px 0 0;
	font-size: 11px;
	color: rgba(114, 47, 55, 0.6);
	font-style: italic;
	text-align: center;
}

/* Domain Section Options */
.language-domain-section .language-option {
	padding: 10px 16px;
}

.language-domain-section .language-flag {
	font-size: 1em;
}

/* Search Form Overrides */
.woocommerce .woocommerce-product-search input[type="search"]::placeholder {
	opacity: 0.7;
	font-style: italic;
}

/* ==========================================
   Mobile Responsive Styles
   ========================================== */

@media (max-width: 768px) {
	.language-selector-toggle {
		padding: 6px 12px;
		font-size: var(--font-size-sm, 14px);
		height: 40px;
	}
	
	.language-name {
		display: inline-block;
	}
	
	.language-selector-menu {
		right: 0;
		left: auto;
		min-width: 180px;
	}
	
	.language-option {
		padding: 10px 14px;
	}

	.language-section-label {
		padding: 6px 14px 4px;
		font-size: 10px;
	}

	.domain-notice {
		padding: 6px 14px 10px;
		font-size: 10px;
	}
}

@media (max-width: 480px) {
	.language-selector {
		height: 40px;
	}

	.language-selector-toggle {
		padding: 4px 10px;
		height: 36px;
		border-radius: 10px;
	}

	.language-flag {
		font-size: 1.1em;
	}

	.language-selector-menu {
		position: fixed;
		top: auto;
		bottom: 0;
		left: 0;
		right: 0;
		min-width: 100%;
		border-radius: 20px 20px 0 0;
		transform: translateY(100%);
		max-height: 70vh;
		overflow-y: auto;
	}

	.language-selector.active .language-selector-menu {
		transform: translateY(0);
	}

	.language-options {
		padding: 12px;
	}

	.language-option {
		padding: 14px 16px;
		border-radius: 12px;
		font-size: 15px;
	}

	.language-section-label {
		padding: 10px 16px 6px;
		font-size: 11px;
	}

	.domain-notice {
		padding: 10px 16px 16px;
		font-size: 11px;
	}

	/* Add backdrop for mobile */
	.language-selector.active::before {
		content: '';
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.4);
		z-index: 999;
		animation: fadeIn 0.2s ease-out;
	}

	@keyframes fadeIn {
		from { opacity: 0; }
		to { opacity: 1; }
	}
}

/* ==========================================
   High Contrast / Accessibility
   ========================================== */

@media (prefers-reduced-motion: reduce) {
	.language-selector-toggle,
	.language-selector-menu,
	.language-option,
	.language-arrow {
		transition: none;
	}
}

@media (prefers-contrast: high) {
	.language-selector-menu {
		border-width: 2px;
		border-color: #000;
	}

	.language-option:focus {
		box-shadow: inset 0 0 0 3px #000;
	}

	.language-option.current-language,
	.language-option.current-domain {
		background: #000;
		color: #fff;
	}
}
