.asg-search {
	--asg-search-bg: #FFFFFF;
	--asg-search-border: #D9C7D6;
	--asg-search-text: #333333;
	--asg-search-placeholder: #999999;
	--asg-search-accent: #7B1E1E;
	--asg-search-radius: 4px;
	--asg-search-height: 46px;

	position: relative;
	box-sizing: border-box;
	font-family: 'Manrope', system-ui, -apple-system, sans-serif;
}

.asg-search *,
.asg-search *::before,
.asg-search *::after {
	box-sizing: border-box;
}

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

.asg-search-form {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	height: var(--asg-search-height);
	padding: 0 8px 0 14px;
	background: var(--asg-search-bg);
	border: 1px solid var(--asg-search-border);
	border-radius: var(--asg-search-radius);
	margin: 0;
}

.asg-search--icon-left .asg-search-form {
	flex-direction: row-reverse;
	padding: 0 14px 0 8px;
}

/* Elementor and most themes style bare inputs heavily, so these are
   pinned rather than inherited. */
.asg-search .asg-search-input {
	flex: 1 1 auto;
	min-width: 0;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0 !important;
	outline: none;
	background: transparent !important;
	box-shadow: none !important;
	font-family: inherit;
	font-size: 16px;
	font-weight: 500;
	line-height: normal;
	color: var(--asg-search-text);
	-webkit-appearance: none;
	appearance: none;
}

.asg-search .asg-search-input::placeholder {
	font-family: inherit;
	font-size: 16px;
	font-weight: 400;
	color: var(--asg-search-placeholder);
	opacity: 1;
}

/* Safari's own clear button duplicates the icon and misaligns the row. */
.asg-search .asg-search-input::-webkit-search-decoration,
.asg-search .asg-search-input::-webkit-search-cancel-button,
.asg-search .asg-search-input::-webkit-search-results-button {
	-webkit-appearance: none;
	appearance: none;
}

.asg-search-form:focus-within {
	border-color: var(--asg-search-accent);
}

.asg-search .asg-search-submit {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--asg-search-accent);
	cursor: pointer;
	transition: background-color .2s ease;
}

.asg-search .asg-search-submit:hover {
	background: rgba(0, 0, 0, .05);
}

.asg-search .asg-search-submit svg {
	width: 19px;
	height: 19px;
	display: block;
}

.asg-search .asg-search-submit img {
	width: 19px !important;
	height: 19px !important;
	max-width: none !important;
	object-fit: contain;
	display: block;
	margin: 0;
}

/* Screen-reader-only label - the placeholder alone is not a label. */
.asg-search-srlabel {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.asg-search-live {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

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

.asg-search-spinner {
	position: absolute;
	right: 46px;
	top: 50%;
	width: 15px;
	height: 15px;
	margin-top: -7px;
	border: 2px solid rgba(0, 0, 0, .12);
	border-top-color: var(--asg-search-accent);
	border-radius: 50%;
	opacity: 0;
	pointer-events: none;
}

.asg-search--icon-left .asg-search-spinner {
	right: 14px;
}

.asg-search-loading .asg-search-spinner {
	opacity: 1;
	animation: asg-search-spin .6s linear infinite;
}

@keyframes asg-search-spin {
	to { transform: rotate(360deg); }
}

/* ---- Results dropdown ---- */

.asg-search-results[hidden] {
	display: none;
}

.asg-search-results {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	z-index: 99999;
	max-height: min(70vh, 460px);
	overflow-y: auto;
	background: #fff;
	border: 1px solid var(--asg-search-border);
	border-radius: var(--asg-search-radius);
	box-shadow: 0 14px 40px rgba(0, 0, 0, .16);
	overscroll-behavior: contain;
}

.asg-search-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	text-decoration: none;
	color: var(--asg-search-text);
	border-bottom: 1px solid #f0ecef;
}

.asg-search-item:last-of-type {
	border-bottom: 0;
}

.asg-search-item:hover,
.asg-search-item.is-active {
	background: #faf5f5;
}

.asg-search .asg-search-thumb {
	flex: 0 0 auto;
	width: 46px !important;
	height: 46px !important;
	max-width: none !important;
	object-fit: cover !important;
	border-radius: 3px;
	display: block;
	background: #f3eee9;
	margin: 0;
}

.asg-search-item-body {
	flex: 1 1 auto;
	min-width: 0;
	display: block;
}

.asg-search-item-title {
	display: block;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.35;
	color: var(--asg-search-text);
	/* Two lines then ellipsis - product names in this catalogue run long
	   and a single truncated line loses the distinguishing part. */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.asg-search-item-price {
	display: block;
	margin-top: 3px;
	font-size: 13px;
	font-weight: 600;
	color: var(--asg-search-accent);
}

.asg-search-all {
	display: block;
	padding: 11px 14px;
	text-align: center;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: .02em;
	text-decoration: none;
	color: var(--asg-search-accent);
	background: #faf5f5;
	border-top: 1px solid #f0ecef;
}

.asg-search-all:hover,
.asg-search-all.is-active {
	background: #f3e9e9;
}

.asg-search-empty {
	padding: 18px 14px;
	text-align: center;
	font-size: 14px;
	color: #777;
}

/* ---- Legacy .custom-search upgrade ----
   The header's hand-written box already carries its own field styling
   from the HTML widget, so the wrapper stays transparent and only the
   dropdown is contributed. */

.asg-search--legacy .asg-search-form {
	background: transparent;
	border: 0;
	padding: 0;
	height: auto;
	gap: 8px;
}

.asg-search--legacy .asg-search-submit {
	width: auto;
	height: auto;
	border-radius: 0;
}

.asg-search--legacy .asg-search-submit:hover {
	background: transparent;
}

.asg-search--legacy .asg-search-spinner {
	right: 30px;
}

@media (max-width: 767px) {
	.asg-search-results {
		max-height: 60vh;
	}

	.asg-search .asg-search-thumb {
		width: 40px !important;
		height: 40px !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.asg-search-loading .asg-search-spinner {
		animation: none;
	}
}

/* ---- Matching categories ---- */

.asg-search-group {
	border-bottom: 1px solid #f0ecef;
}

.asg-search-group-label {
	display: block;
	padding: 9px 14px 5px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: #9a8f95;
}

.asg-search-cat {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	padding: 8px 14px;
	text-decoration: none;
	color: var(--asg-search-text);
}

.asg-search-cat:hover,
.asg-search-cat.is-active {
	background: #faf5f5;
}

.asg-search-cat-name {
	font-size: 14px;
	font-weight: 600;
	color: var(--asg-search-accent);
}

.asg-search-cat-count {
	flex: 0 0 auto;
	font-size: 12px;
	color: #9a8f95;
}

/* ---- Small phones (320-400px) ----
   A 46px thumbnail plus padding left only ~208px for the product name
   at 320px, so almost every title clipped to two ellipsised lines. */

@media (max-width: 400px) {
	.asg-search-form {
		padding: 0 6px 0 10px;
		gap: 6px;
	}

	.asg-search .asg-search-input,
	.asg-search .asg-search-input::placeholder {
		/* Stay at 16px: anything smaller makes iOS Safari zoom the page
		   when the field is focused. */
		font-size: 16px;
	}

	.asg-search .asg-search-thumb {
		width: 34px !important;
		height: 34px !important;
	}

	.asg-search-item {
		gap: 9px;
		padding: 9px 10px;
	}

	.asg-search-item-title {
		font-size: 13px;
	}

	.asg-search-item-price {
		font-size: 12px;
	}

	.asg-search-results {
		max-height: 56vh;
	}
}
