/**
 * TopOpti Product Search — dropdown + header styling.
 * Colours come from custom properties so a site can re-skin without
 * editing this file (override --tops-* on :root in the theme/child CSS).
 * Defaults: navy accent, soft borders, rounded panel, pill fields.
 */

:root {
	--tops-accent: #002a8f;
	--tops-accent-soft: #eef2fb;
	--tops-text: #0f1b3d;
	--tops-muted: #5b6478;
	--tops-border: #d6dcea;
	--tops-line: #eef0f5;
	--tops-radius: 14px;
}

.tops-wrap {
	position: relative;
	display: inline-block;
	width: 100%;
}

.tops-panel {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	min-width: 320px;
	max-width: 440px;
	background: #fff;
	border: 1px solid var(--tops-border);
	border-radius: var(--tops-radius);
	box-shadow: 0 16px 40px rgba(0, 42, 143, 0.14);
	overflow: hidden;
	z-index: 9999;
	text-align: left;
}

.tops-listbox {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 480px;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	touch-action: pan-y;
}

.tops-option {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	margin: 0;
	cursor: pointer;
	border-bottom: 1px solid var(--tops-line);
}

.tops-option.is-active,
.tops-option:hover {
	background: var(--tops-accent-soft);
}

.tops-thumb {
	width: 40px;
	height: 50px;
	object-fit: cover;
	flex: 0 0 40px;
	border-radius: 8px;
	background: #f4f6fa;
}

.tops-text {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.tops-title {
	color: var(--tops-accent);
	font-weight: 600;
	font-size: 14px;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.tops-sku {
	font-size: 11px;
	letter-spacing: 0.04em;
	color: var(--tops-muted);
}

.tops-price {
	flex: 0 0 auto;
	color: var(--tops-text);
	font-size: 13px;
	font-weight: 700;
	white-space: nowrap;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
}

.tops-price del {
	color: #9aa1b2;
	font-weight: 400;
	margin-right: 4px;
}

.tops-price ins {
	text-decoration: none;
}

.tops-viewall {
	padding: 12px 14px;
	margin: 0;
	text-align: center;
	font-size: 13px;
	font-weight: 600;
	color: var(--tops-accent);
	background: #fff;
	cursor: pointer;
}

.tops-viewall.is-active,
.tops-viewall:hover {
	background: var(--tops-accent);
	color: #fff;
}

.tops-empty {
	padding: 14px;
	margin: 0;
	color: var(--tops-muted);
	font-size: 13px;
}

.tops-correction {
	padding: 10px 14px;
	margin: 0;
	font-size: 13px;
	color: var(--tops-text);
	cursor: pointer;
}

.tops-correction strong {
	color: var(--tops-accent);
	border-bottom: 2px solid var(--tops-accent);
}

.tops-correction.is-active,
.tops-correction:hover {
	background: var(--tops-accent-soft);
}

.tops-group-label {
	padding: 10px 14px 4px;
	margin: 0;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--tops-muted);
}

.tops-panel.tops-settling .tops-listbox {
	pointer-events: none;
}

.tops-loading input[name="s"] {
	background-image: linear-gradient(90deg, transparent 0%, rgba(0, 42, 143, 0.10) 50%, transparent 100%) !important;
	background-size: 200% 100% !important;
	animation: tops-shimmer 1s linear infinite;
}

@keyframes tops-shimmer {
	from { background-position: 200% 0; }
	to   { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
	.tops-loading input[name="s"] {
		animation: none;
		background-image: none !important;
	}
}

.tops-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* -------------------------------------------------------------------------
 * Header search (header_mode 'astra', body.tops-astra)
 * ---------------------------------------------------------------------- */

/* Astra's own search icon, once tops-search.js has put our spyglass in its place. */
.tops-replaced {
	display: none !important;
}

/* LEGACY (1.4.x row under the header): kept one release so pages still in
   the page cache render sensibly until their TTL runs out. */
.tops-d-row {
	padding: 12px 20px;
	background: #fff;
	border-bottom: 1px solid var(--tops-line);
}

.tops-d-row .tops-form {
	max-width: 560px;
	margin: 0 auto;
}

.tops-form {
	position: relative;
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 0 5px 0 16px;
	background: #fff;
	border: 1px solid var(--tops-border);
	border-radius: 999px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tops-form:focus-within {
	border-color: var(--tops-accent);
	box-shadow: 0 0 0 3px rgba(0, 42, 143, 0.12);
}

.tops-form .tops-wrap {
	flex: 1 1 auto;
	min-width: 0;
}

/* Native inputs: body prefix + !important beats theme @layer rules. */
body .tops-form .tops-field {
	display: block !important;
	width: 100% !important;
	height: 40px !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	background-color: transparent !important;
	box-shadow: none !important;
	outline: none !important;
	font-size: 15px !important;
	line-height: 40px !important;
	color: var(--tops-text) !important;
	-webkit-appearance: none;
	appearance: none;
}

body .tops-form .tops-field::placeholder {
	color: var(--tops-muted);
	opacity: 1;
}

body .tops-form .tops-field::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

body .tops-form .tops-submit {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	min-height: 0;
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 999px !important;
	background: var(--tops-accent) !important;
	color: #fff !important;
	box-shadow: none !important;
	cursor: pointer;
}

/* Dropdown spans the whole pill (the input wrap sits inside its padding,
   with the submit button to its right). */
.tops-form .tops-panel {
	left: -17px;
	right: -44px;
	min-width: 0;
	max-width: none;
}

/* Spyglass toggles (desktop: in Astra's icon slot; mobile: before the cart). */
/* A small white round button: same language as the search pill itself
   (white, soft #d6dcea border, navy icon) and the site's rounded buttons. */
body .tops-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	min-height: 0;
	margin: 0 10px 0 0;
	padding: 0 !important;
	border: 1px solid var(--tops-border) !important;
	border-radius: 999px !important;
	background: #fff !important;
	color: var(--tops-accent) !important;
	box-shadow: 0 1px 2px rgba(0, 42, 143, 0.08) !important;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

body .tops-toggle svg {
	width: 17px;
	height: 17px;
}

body .tops-toggle svg circle,
body .tops-toggle svg path {
	stroke-width: 2.4;
}

body .tops-toggle:hover,
body .tops-toggle[aria-expanded="true"] {
	border-color: var(--tops-accent) !important;
	background: var(--tops-accent-soft) !important;
}

/* Astra's mobile cart wrapper is taller than its glyph (count badge), so a
   plain flex-centre sits 2px low next to the bag: nudge to the glyph line. */
body.tops-astra #ast-mobile-header .tops-m-toggle,
body.tops-astra #ast-desktop-header .tops-d-toggle {
	margin-top: -4px;
}

body .tops-toggle:focus-visible,
body .tops-close:focus-visible {
	outline: 2px solid var(--tops-accent) !important;
	outline-offset: 2px;
}

/* Desktop: overlay over the header bar, so the header height never changes. */
.tops-overlay-host {
	position: relative;
}

.tops-d-overlay {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 100;
	display: flex;
	align-items: center;
	padding: 0 20px;
	background-color: var(--tops-overlay-bg, #fff); /* JS copies the bar colour */
}

.tops-d-overlay[hidden] {
	display: none !important;
}

.tops-d-inner {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	max-width: 680px;
	margin: 0 auto;
}

.tops-d-inner .tops-form {
	flex: 1 1 auto;
	min-width: 0;
}

body .tops-close {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	min-height: 0;
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 999px !important;
	background: transparent !important;
	color: var(--tops-accent) !important;
	box-shadow: none !important;
	cursor: pointer;
}

body .tops-close:hover {
	background: var(--tops-accent-soft) !important;
}

/* Mobile panel under the mobile header. */
.tops-m-panel {
	position: relative;
	z-index: 99;
	padding: 10px 16px 12px;
	background: #fff;
	border-bottom: 1px solid var(--tops-line);
	box-shadow: 0 10px 20px rgba(0, 42, 143, 0.06);
}

.tops-m-panel[hidden] {
	display: none !important;
}

body .tops-m-panel .tops-form .tops-field {
	height: 44px !important;
	line-height: 44px !important;
	font-size: 16px !important; /* 16px stops iOS zooming on focus */
}

body .tops-m-panel .tops-submit {
	width: 36px;
	height: 36px;
}

@media (max-width: 921px) {
	.tops-d-row,
	.tops-d-overlay,
	body .tops-d-toggle {
		display: none !important;
	}
}

@media (min-width: 922px) {
	body .tops-m-toggle,
	.tops-m-panel {
		display: none !important;
	}
}

@media (max-width: 600px) {
	.tops-panel,
	.tops-form .tops-panel {
		min-width: 0;
		max-width: none;
		position: fixed;
		left: 12px;
		right: 12px;
		top: auto; /* set per-open by tops-search.js (place) */
		overscroll-behavior: contain;
	}
	.tops-listbox {
		max-height: 60vh;
		max-height: 60dvh;
	}
}
