.am-cps-search {
	--am-cps-border: #d8dadd;
	--am-cps-text: #17191c;
	--am-cps-muted: #6b7280;
	--am-cps-accent: #b1935a;
	--am-cps-accent-hover: #967a47;
	--am-cps-background: #fff;
	position: relative;
	width: 100%;
	z-index: 20;
}

.am-cps-header-search-source {
	display: none !important;
}

.am-cps-header-search-slot {
	flex: 0 1 360px;
	width: clamp(280px, 23vw, 360px);
	min-width: 0;
	margin-inline-end: 10px;
}

/* There must be one product search only: the exact standalone gold-icon form
 * lives in the header, so the duplicate search group in Trejka's shop sidebar
 * is suppressed while the remaining stock/category/price filters stay intact. */
.am-cps-header-search-slot .am-cps-header-search-form {
	display: flex !important;
	align-items: stretch;
	box-sizing: border-box;
	width: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	overflow: hidden;
	border: 1px solid #ddd;
	border-radius: 6px;
	background: #fff;
}

.am-cps-header-search-slot .am-cps-header-search-form .twf-search-input {
	display: block !important;
	flex: 1 1 auto !important;
	box-sizing: border-box;
	width: auto !important;
	min-width: 0 !important;
	min-height: 42px !important;
	margin: 0 !important;
	padding: 10px 12px !important;
	border: 0 !important;
	border-radius: 0 !important;
	outline: 0;
	background: transparent !important;
	box-shadow: none !important;
	color: #17191c !important;
	-webkit-text-fill-color: #17191c !important;
	caret-color: #17191c !important;
	font-size: 14px;
}

/* Blocksy/Trejka can inherit the black header's white text into mobile search
 * inputs. Keep typed text, the caret, and placeholders readable everywhere the
 * controlled search reuses those forms, including iOS WebKit. */
.am-cps-search input.am-cps-search__input,
form.twf-search input.twf-search-input {
	color: #17191c !important;
	-webkit-text-fill-color: #17191c !important;
	caret-color: #17191c !important;
	opacity: 1 !important;
}

.am-cps-search input.am-cps-search__input::placeholder,
form.twf-search input.twf-search-input::placeholder {
	color: #6b7280 !important;
	-webkit-text-fill-color: #6b7280 !important;
	opacity: 1 !important;
}

.am-cps-header-search-slot .am-cps-header-search-form .twf-search-btn {
	display: block !important;
	flex: 0 0 46px !important;
	box-sizing: border-box;
	width: 46px !important;
	min-width: 46px !important;
	min-height: 42px !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	background-color: #b1935a !important;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='16.5' y1='16.5' x2='21' y2='21'/%3E%3C/svg%3E") !important;
	background-repeat: no-repeat !important;
	background-position: center !important;
	background-size: 20px 20px !important;
	box-shadow: none !important;
	color: transparent !important;
	font-size: 0 !important;
	cursor: pointer;
}

.am-cps-header-search-slot .am-cps-header-search-form .twf-search-btn::before,
.am-cps-header-search-slot .am-cps-header-search-form .twf-search-btn::after {
	display: none !important;
	content: none !important;
}

.am-cps-search__form,
.am-cps-search__control {
	width: 100%;
}

.am-cps-search .am-cps-search__control {
	display: flex !important;
	gap: 8px;
	align-items: stretch;
	position: relative;
}

.am-cps-search .am-cps-search__input {
	display: block;
	flex: 1 1 auto !important;
	box-sizing: border-box;
	width: auto !important;
	min-width: 0 !important;
	max-width: none !important;
	min-height: 46px;
	margin: 0 !important;
	padding: 10px 44px 10px 14px;
	border: 1px solid var(--am-cps-border);
	border-radius: 6px;
	background: var(--am-cps-background);
	color: var(--am-cps-text);
	font: inherit;
	line-height: 1.3;
	outline: none;
}

.am-cps-search__input:focus {
	border-color: var(--am-cps-accent);
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--am-cps-accent) 18%, transparent);
}

.am-cps-search .am-cps-search__button {
	display: inline-flex !important;
	flex: 0 0 auto !important;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: auto !important;
	min-width: 124px;
	min-height: 46px;
	margin: 0 !important;
	padding: 0 22px !important;
	border: 0;
	border-radius: 6px;
	background: var(--am-cps-accent) !important;
	color: #fff !important;
	font: inherit;
	font-weight: 600;
	line-height: 1 !important;
	text-transform: none;
	cursor: pointer;
}

.am-cps-search .am-cps-search__button:hover,
.am-cps-search .am-cps-search__button:focus {
	background: var(--am-cps-accent-hover) !important;
	color: #fff !important;
}

.am-cps-search--with-button .am-cps-search__spinner {
	right: 146px;
}

.am-cps-search__spinner {
	position: absolute;
	top: 50%;
	right: 15px;
	width: 17px;
	height: 17px;
	margin-top: -9px;
	border: 2px solid transparent;
	border-top-color: var(--am-cps-muted);
	border-radius: 50%;
	opacity: 0;
	pointer-events: none;
}

.am-cps-search.is-loading .am-cps-search__spinner {
	opacity: 1;
	animation: am-cps-spin 0.7s linear infinite;
}

.am-cps-search__dropdown {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	max-height: min(70vh, 520px);
	overflow-y: auto;
	border: 1px solid var(--am-cps-border);
	border-radius: 8px;
	background: var(--am-cps-background);
	box-shadow: 0 14px 36px rgba(0, 0, 0, 0.14);
}

.am-cps-search__dropdown[hidden] {
	display: none;
}

.am-cps-search__result {
	display: grid;
	grid-template-columns: 58px minmax(0, 1fr) auto;
	gap: 12px;
	align-items: center;
	min-height: 70px;
	padding: 9px 12px;
	border-bottom: 1px solid #eceef0;
	color: var(--am-cps-text);
	text-decoration: none;
}

.am-cps-search__result:hover,
.am-cps-search__result:focus,
.am-cps-search__result.is-active {
	background: #f7f7f8;
	color: var(--am-cps-text);
	outline: none;
}

.am-cps-search__image {
	width: 58px;
	height: 58px;
	border-radius: 5px;
	object-fit: contain;
	background: #fff;
}

.am-cps-search__result-content {
	display: flex;
	min-width: 0;
	flex-direction: column;
	gap: 4px;
}

.am-cps-search__name {
	overflow: hidden;
	font-weight: 600;
	line-height: 1.3;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.am-cps-search__meta {
	overflow: hidden;
	color: var(--am-cps-muted);
	font-size: 12px;
	line-height: 1.35;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.am-cps-search__price {
	color: var(--am-cps-text);
	font-weight: 600;
	white-space: nowrap;
}

.am-cps-search__message,
.am-cps-search__correction,
.am-cps-search__view-all {
	display: block;
	padding: 13px 14px;
}

.am-cps-search__correction {
	border-bottom: 1px solid #eceef0;
	color: var(--am-cps-muted);
	font-size: 13px;
}

.am-cps-search__message {
	color: var(--am-cps-muted);
}

.am-cps-search__message--error {
	color: #b42318;
}

.am-cps-search__view-all {
	color: var(--am-cps-accent);
	font-weight: 600;
	text-align: center;
	text-decoration: none;
}

.am-cps-results__header {
	margin-bottom: 24px;
}

/* Keep the page title available to breadcrumbs, but do not render a duplicate
 * H1 above the query-specific controlled-search heading. */
body.am-cps-controlled-results-page h1.entry-title,
body.am-cps-controlled-results-page h1.page-title,
body.am-cps-controlled-results-page h1.wp-block-post-title,
body.am-cps-controlled-results-page .entry-header > h1,
body.am-cps-controlled-results-page .page-header > h1 {
	display: none !important;
}

.am-cps-results__title {
	margin-bottom: 6px;
}

.am-cps-results__count {
	margin: 0;
	color: #6b7280;
}

/* Theme pagination rules currently reduce the result navigation to tiny bare
 * numbers and a long border. Fully own this component so every page and the
 * active state remain obvious on desktop and mobile. */
.am-cps-results .am-cps-pagination {
	display: flex !important;
	clear: both;
	justify-content: center;
	box-sizing: border-box;
	width: 100%;
	margin: 38px 0 8px !important;
	padding: 0 !important;
	border: 0 !important;
	overflow: visible !important;
}

.am-cps-results .am-cps-pagination ul.page-numbers {
	display: flex !important;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	justify-content: center;
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	background: transparent !important;
	list-style: none !important;
}

.am-cps-results .am-cps-pagination ul.page-numbers::before,
.am-cps-results .am-cps-pagination ul.page-numbers::after {
	display: none !important;
	content: none !important;
}

.am-cps-results .am-cps-pagination ul.page-numbers > li {
	display: block !important;
	float: none !important;
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	background: transparent !important;
}

.am-cps-results .am-cps-pagination ul.page-numbers > li > .page-numbers {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 42px;
	height: 42px;
	margin: 0 !important;
	padding: 0 12px !important;
	border: 1px solid #d8dadd !important;
	border-radius: 6px !important;
	background: #fff !important;
	box-shadow: none !important;
	color: #17191c !important;
	font-size: 15px !important;
	font-weight: 600 !important;
	line-height: 1 !important;
	text-decoration: none !important;
	opacity: 1 !important;
}

.am-cps-results .am-cps-pagination ul.page-numbers > li > a.page-numbers:hover,
.am-cps-results .am-cps-pagination ul.page-numbers > li > a.page-numbers:focus {
	border-color: #b1935a !important;
	background: #f7f2e8 !important;
	color: #17191c !important;
	outline: none;
}

.am-cps-results .am-cps-pagination ul.page-numbers > li > .page-numbers.current {
	border-color: #b1935a !important;
	background: #b1935a !important;
	color: #fff !important;
	-webkit-text-fill-color: #fff !important;
}

.am-cps-results--empty {
	padding: 18px;
	border: 1px solid #e5e7eb;
	border-radius: 6px;
	background: #f9fafb;
}

@keyframes am-cps-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (max-width: 640px) {
	.am-cps-results .am-cps-pagination {
		margin-top: 30px !important;
	}

	.am-cps-results .am-cps-pagination ul.page-numbers {
		gap: 6px;
	}

	.am-cps-results .am-cps-pagination ul.page-numbers > li > .page-numbers {
		min-width: 40px;
		height: 40px;
		padding: 0 10px !important;
	}

	.am-cps-search__result {
		grid-template-columns: 50px minmax(0, 1fr);
	}

	.am-cps-search__image {
		width: 50px;
		height: 50px;
	}

	.am-cps-search__price {
		display: none;
	}

	.am-cps-search .am-cps-search__button {
		min-width: 104px;
		padding: 0 14px !important;
	}

	.am-cps-search--with-button .am-cps-search__spinner {
		right: 124px;
	}
}

@media (max-width: 1199px) and (min-width: 1000px) {
	.am-cps-header-search-slot {
		flex-basis: 280px;
		width: 280px;
	}
}

@media (min-width: 1000px) {
	.twf-filter .twf-group-search {
		display: none !important;
	}
}

@media (max-width: 999px) {
	.am-cps-header-search-slot {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.am-cps-search.is-loading .am-cps-search__spinner {
		animation-duration: 1.5s;
	}
}
