/* Header product search (Figma: "Otsinguriba – päise lahendus") */

.enervit-hs {
	--hs-red: #e30613;
	--hs-red-dark: #be000b;
	--hs-text: #1a1a1a;
	--hs-muted: #6b6b6b;
	--hs-faint: #9a9a9a;
	--hs-line: #eaeaea;
	--hs-border: #dadada;
	--hs-hover: #f5f5f5;
	--hs-font: var(--e-global-typography-text-font-family, "Trade Gothic LT"), sans-serif;
	--hs-font-bold: var(--e-global-typography-secondary-font-family, "Trade Gothic LT Bold"), sans-serif;

	position: relative;
	display: flex;
	align-items: center;
	flex: 0 1 304px;
	box-sizing: border-box;
	min-width: 184px;
	/* Auto margin keeps the search next to the language switcher; the padding is the minimum gap to the menu. */
	margin: 0 20px 0 auto;
	padding-left: 24px;
	font-family: var(--hs-font);
	font-weight: normal;
	line-height: normal;
	text-align: left;
}

.enervit-hs *,
.enervit-hs *::before,
.enervit-hs *::after {
	box-sizing: border-box;
}

.enervit-hs svg {
	display: block;
	flex-shrink: 0;
}

.enervit-hs ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.enervit-hs p {
	margin: 0;
}

.enervit-hs.enervit-hs button,
.enervit-hs.enervit-hs button:hover,
.enervit-hs.enervit-hs button:focus,
.enervit-hs.enervit-hs button:active {
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	line-height: 1;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.enervit-hs [hidden] {
	display: none !important;
}

/* style.css pushes the language switcher right with an auto margin; the search takes that role instead. */
.elementor-location-header .e-con > .enervit-hs + .elementor-widget-wpml-language-switcher {
	margin-left: 0;
}

/* On desktop the logo + menu, language switcher, account and cart keep their size; the field gives way instead. */
@media (min-width: 1025px) {
	.elementor-location-header .e-con:has(> .enervit-hs) > .e-con:first-child,
	.elementor-location-header .e-con > .enervit-hs ~ .elementor-widget {
		flex-shrink: 0;
	}
}

/* ---------- Field ---------- */

.enervit-hs__panel {
	width: 100%;
}

.enervit-hs__form {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	height: 44px;
	margin: 0;
	padding: 0 16px;
	border: 1px solid rgba(255, 255, 255, 0.45);
	border-radius: 22px;
	background: rgba(255, 255, 255, 0.14);
	background-clip: padding-box;
	color: #fff;
	cursor: text;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.enervit-hs__form:hover {
	background-color: rgba(255, 255, 255, 0.2);
}

.enervit-hs__icon {
	display: flex;
	color: inherit;
}

.enervit-hs .enervit-hs__input,
.enervit-hs .enervit-hs__input:focus {
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	outline: 0;
	background: transparent;
	box-shadow: none;
	color: inherit;
	font-family: var(--hs-font);
	font-size: 15px;
	font-weight: normal;
	line-height: normal;
	letter-spacing: normal;
	text-overflow: ellipsis;
	caret-color: var(--hs-red);
	-webkit-appearance: none;
	appearance: none;
}

.enervit-hs__input::placeholder {
	color: rgba(255, 255, 255, 0.8);
	opacity: 1;
}

.enervit-hs__input::-webkit-search-decoration,
.enervit-hs__input::-webkit-search-cancel-button,
.enervit-hs__input::-webkit-search-results-button,
.enervit-hs__input::-webkit-search-results-decoration {
	display: none;
	-webkit-appearance: none;
}

/* Active: white field with focus ring (ring is the semi-transparent border over the red header) */
.enervit-hs__form:focus-within,
.enervit-hs.is-open .enervit-hs__form {
	padding: 0 10px 0 14px;
	border-width: 3px;
	background-color: #fff;
	color: var(--hs-text);
}

.enervit-hs__form:focus-within .enervit-hs__icon,
.enervit-hs.is-open .enervit-hs__icon {
	color: var(--hs-red);
}

.enervit-hs__form:focus-within .enervit-hs__input::placeholder,
.enervit-hs.is-open .enervit-hs__input::placeholder {
	color: var(--hs-faint);
}

.enervit-hs.enervit-hs button.enervit-hs__clear {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 24px;
	height: 24px;
	border-radius: 12px;
	background: #efefef;
	color: var(--hs-text);
}

.enervit-hs.enervit-hs button.enervit-hs__clear:hover,
.enervit-hs.enervit-hs button.enervit-hs__clear:focus-visible {
	background: #e2e2e2;
}

/* ---------- Loading ---------- */

.enervit-hs__icon {
	position: relative;
}

.enervit-hs__spinner {
	display: block;
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: enervit-hs-spin 0.7s linear infinite;
}

.enervit-hs__icon .enervit-hs__spinner {
	position: absolute;
	top: 1px;
	left: 1px;
	display: none;
}

.enervit-hs.is-loading .enervit-hs__icon svg {
	visibility: hidden;
}

.enervit-hs.is-loading .enervit-hs__icon .enervit-hs__spinner {
	display: block;
}

.enervit-hs__loading {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 48px;
	color: var(--hs-muted);
	font-size: 14px;
}

.enervit-hs__loading .enervit-hs__spinner {
	color: var(--hs-red);
}

.enervit-hs__list {
	transition: opacity 0.15s ease;
}

.enervit-hs.is-loading .enervit-hs__list {
	opacity: 0.5;
}

@keyframes enervit-hs-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ---------- Dropdown ---------- */

.enervit-hs__dropdown {
	position: absolute;
	top: calc(100% + 20px);
	right: 0;
	z-index: 1000;
	display: flex;
	flex-direction: column;
	gap: 16px;
	width: 560px;
	max-width: calc(100vw - 32px);
	max-height: calc(100vh - 140px);
	max-height: calc(100dvh - 140px);
	padding: 20px 20px 16px;
	overflow-y: auto;
	overscroll-behavior: contain;
	border-radius: 8px;
	background: #fff;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
	color: var(--hs-text);
}

.enervit-hs__section,
.enervit-hs__results {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.enervit-hs__results {
	gap: 16px;
}

.enervit-hs__section + .enervit-hs__results {
	padding-top: 16px;
	border-top: 1px solid var(--hs-line);
}

.enervit-hs__label {
	color: var(--hs-muted);
	font-size: 12px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.enervit-hs__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.enervit-hs .enervit-hs__chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 14px 7px 12px;
	border: 1px solid var(--hs-border);
	border-radius: 999px;
	background: #fff;
	color: var(--hs-text);
	font-size: 14px;
	line-height: 20px;
	text-decoration: none;
	white-space: nowrap;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.enervit-hs .enervit-hs__chip svg {
	width: 14px;
	height: 14px;
}

.enervit-hs .enervit-hs__chip:hover,
.enervit-hs .enervit-hs__chip:focus-visible {
	border-color: var(--hs-red);
	color: var(--hs-red);
}

.enervit-hs__results-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.enervit-hs__count {
	color: var(--hs-muted);
	font-size: 12px;
	white-space: nowrap;
}

.enervit-hs__list {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-top: -4px !important;
}

.enervit-hs .enervit-hs__item {
	display: flex;
	align-items: center;
	gap: 16px;
	min-height: 80px;
	padding: 8px;
	border-radius: 6px;
	color: var(--hs-text);
	text-decoration: none;
}

.enervit-hs .enervit-hs__item:hover,
.enervit-hs .enervit-hs__item.is-active {
	background: var(--hs-hover);
	color: var(--hs-text);
}

.enervit-hs__thumb {
	flex: 0 0 64px;
	width: 64px;
	height: 64px;
	overflow: hidden;
	border: 1px solid #ededed;
	border-radius: 4px;
	background: #fff;
}

.enervit-hs .enervit-hs__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	border-radius: 0;
	object-fit: contain;
}

.enervit-hs__info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.enervit-hs__brand {
	color: var(--hs-muted);
	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.enervit-hs__name {
	display: -webkit-box;
	overflow: hidden;
	font-size: 15px;
	line-height: 1.3;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.enervit-hs__name strong {
	font-family: var(--hs-font-bold);
	font-weight: bold;
}

.enervit-hs__price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0 8px;
}

.enervit-hs__price-now {
	font-family: var(--hs-font-bold);
	font-size: 15px;
	font-weight: bold;
}

.enervit-hs__price.is-sale .enervit-hs__price-now {
	color: var(--hs-red);
}

.enervit-hs__price del {
	color: var(--hs-faint);
	font-size: 13px;
	text-decoration: line-through;
}

.enervit-hs__message {
	color: var(--hs-muted);
	font-size: 14px;
	line-height: 1.4;
}

.enervit-hs__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding-top: 16px;
	border-top: 1px solid var(--hs-line);
}

.enervit-hs .enervit-hs__all {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--hs-red);
	font-family: var(--hs-font-bold);
	font-size: 15px;
	font-weight: bold;
	text-decoration: none;
}

.enervit-hs .enervit-hs__all:hover,
.enervit-hs .enervit-hs__all:focus-visible,
.enervit-hs .enervit-hs__all.is-active {
	color: var(--hs-red-dark);
	text-decoration: underline;
}

.enervit-hs__hint {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--hs-muted);
	font-size: 12px;
	white-space: nowrap;
}

.enervit-hs__hint kbd {
	padding: 2px 6px;
	border: 1px solid var(--hs-border);
	border-radius: 4px;
	background: var(--hs-hover);
	box-shadow: none;
	color: var(--hs-muted);
	font-family: inherit;
	font-size: 11px;
	line-height: 16px;
}

/* ---------- Toggle (compact header) ---------- */

.enervit-hs.enervit-hs button.enervit-hs__toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: var(--hs-red-dark);
	color: #fff;
}

.enervit-hs.enervit-hs .enervit-hs__toggle svg {
	width: 22px;
	height: 22px;
}

.enervit-hs__toggle-icon {
	display: flex;
}

.enervit-hs__toggle-icon--close,
.enervit-hs.is-open .enervit-hs__toggle-icon--search {
	display: none;
}

.enervit-hs.is-open .enervit-hs__toggle-icon--close {
	display: flex;
}

.enervit-hs.enervit-hs button.enervit-hs__toggle:focus-visible,
.enervit-hs.enervit-hs button.enervit-hs__clear:focus-visible,
.enervit-hs .enervit-hs__chip:focus-visible,
.enervit-hs .enervit-hs__all:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.enervit-hs__dropdown :focus-visible {
	outline-color: var(--hs-text) !important;
}

/* Dim the page while the search is open */
.enervit-hs-backdrop {
	position: fixed;
	inset: 0;
	z-index: 98;
	background: rgba(0, 0, 0, 0.45);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.enervit-hs-backdrop.is-visible {
	opacity: 1;
}

/*
 * Below 1440px the header has no room for a 280px field next to the menu,
 * so the search collapses to a round button (same look as the account icon)
 * that opens the field and results as a panel under the header.
 */
@media (max-width: 1439px) {
	.enervit-hs {
		flex: 0 0 auto;
		min-width: 0;
		margin: 0 8px 0 auto;
		padding-left: 12px;
	}

	.enervit-hs.enervit-hs button.enervit-hs__toggle {
		display: flex;
	}

	.enervit-hs__panel {
		position: fixed;
		top: var(--enervit-hs-top, 80px);
		right: var(--enervit-hs-right, 16px);
		z-index: 1000;
		display: none;
		flex-direction: column;
		gap: 16px;
		width: 560px;
		max-width: calc(100vw - 32px);
		max-height: calc(100vh - var(--enervit-hs-top, 80px) - 16px);
		max-height: calc(100dvh - var(--enervit-hs-top, 80px) - 16px);
		padding: 16px 20px;
		overflow-y: auto;
		overscroll-behavior: contain;
		border-radius: 8px;
		background: #fff;
		box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
	}

	.enervit-hs.is-open .enervit-hs__panel {
		display: flex;
	}

	.enervit-hs__form,
	.enervit-hs__form:focus-within,
	.enervit-hs.is-open .enervit-hs__form {
		flex-shrink: 0;
		padding: 0 10px 0 14px;
		border: 1px solid var(--hs-border);
		background: #fff;
		color: var(--hs-text);
	}

	.enervit-hs__form:focus-within {
		border-color: var(--hs-red);
		box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12);
	}

	.enervit-hs__icon {
		color: var(--hs-red);
	}

	.enervit-hs__input::placeholder {
		color: var(--hs-faint);
	}

	.enervit-hs__dropdown {
		position: static;
		width: auto;
		max-width: none;
		max-height: none;
		padding: 0;
		overflow: visible;
		border-radius: 0;
		box-shadow: none;
	}
}

/*
 * 1025–1199px: the original header menu already wraps to two lines here.
 * Tighten the menu item padding and the outer gutters so the menu and the
 * search button fit on one row (structural selectors: the header element IDs
 * differ per language).
 */
@media (min-width: 1025px) and (max-width: 1199px) {
	.elementor-location-header .e-con:has(> .enervit-hs) > .e-con:first-child {
		--padding-left: 24px;
	}

	.elementor-location-header .e-con:has(> .enervit-hs) .e-n-menu-heading > .e-n-menu-item > .e-n-menu-title {
		padding-right: 8px;
		padding-left: 8px;
	}

	.elementor-location-header .e-con > .enervit-hs ~ .elementor-widget-woocommerce-menu-cart > .elementor-widget-container {
		padding-right: 24px;
	}

	.enervit-hs {
		margin-right: 4px;
		padding-left: 4px;
	}
}

@media (max-width: 1024px) {
	.enervit-hs {
		margin-right: 4px;
		padding-left: 0;
	}
}

@media (max-width: 767px) {
	.enervit-hs {
		margin-right: 0;
	}

	/* Make room for the button: the logo + menu block shrinks (the logo too on very narrow screens), the cart never does. */
	.elementor-location-header .e-con:has(> .enervit-hs) > .e-con:first-child,
	.elementor-location-header .e-con:has(> .enervit-hs) > .e-con:first-child > .elementor-widget-image {
		flex-shrink: 1;
		min-width: 0;
	}

	.elementor-location-header .e-con > .enervit-hs ~ .elementor-widget-woocommerce-menu-cart {
		flex-shrink: 0;
	}

	.enervit-hs.enervit-hs button.enervit-hs__toggle {
		width: 36px;
		height: 36px;
	}

	.enervit-hs.enervit-hs .enervit-hs__toggle svg {
		width: 16px;
		height: 16px;
	}

	.enervit-hs__panel {
		right: 10px;
		left: 10px;
		width: auto;
		max-width: none;
		padding: 12px 16px 16px;
	}

	/* 16px stops iOS from zooming into the field */
	.enervit-hs .enervit-hs__input,
	.enervit-hs .enervit-hs__input:focus {
		font-size: 16px;
	}

	.enervit-hs .enervit-hs__item {
		gap: 12px;
		min-height: 72px;
	}

	.enervit-hs__thumb {
		flex-basis: 56px;
		width: 56px;
		height: 56px;
	}

	.enervit-hs__name {
		font-size: 14px;
	}
}

@media (max-width: 374px) {
	.elementor-location-header .e-con:has(> .enervit-hs) > .e-con:first-child {
		--flex-wrap: nowrap;
		flex-wrap: nowrap;
	}
}

@media (hover: none), (max-width: 767px) {
	.enervit-hs__hint {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.enervit-hs *,
	.enervit-hs-backdrop {
		transition: none !important;
	}

	.enervit-hs__spinner {
		animation-duration: 1.6s;
	}
}
