/**
 * Advanced Product Search styles.
 *
 * Every value is driven by a custom property on `.aps`, so the look can be
 * overridden from a theme stylesheet without touching this file, e.g.
 *
 *   .aps { --aps-accent: #e2401c; --aps-radius: 4px; }
 */

.aps {
	--aps-accent: #2563eb;
	--aps-text: #1f2937;
	--aps-muted: #6b7280;
	--aps-border: #d9dde5;
	--aps-bg: #fff;
	--aps-hover-bg: #f3f6fb;
	--aps-radius: 8px;
	--aps-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
	--aps-thumb-size: 48px;
	--aps-font-size: 15px;
	--aps-max-height: 420px;
	--aps-dropdown-width: 100%;
	--aps-instock: #15803d;
	--aps-outofstock: #b91c1c;
	--aps-onbackorder: #b45309;

	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	color: var(--aps-text);
	font-size: var(--aps-font-size);
}

.aps *,
.aps *::before,
.aps *::after {
	box-sizing: inherit;
}

.aps__form {
	position: relative;
	margin: 0;
}

/* Search field ---------------------------------------------------------- */

.aps__field {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 0 6px 0 10px;
	background: var(--aps-bg);
	border: 1px solid var(--aps-border);
	border-radius: var(--aps-radius);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.aps__field:focus-within {
	border-color: var(--aps-accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.aps__icon {
	display: flex;
	flex: 0 0 auto;
	color: var(--aps-muted);
}

.aps__input.aps__input {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	margin: 0;
	padding: 12px 4px;
	color: inherit;
	font: inherit;
	background: transparent;
	border: 0;
	border-radius: 0;
	outline: none;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
}

.aps__input::-webkit-search-cancel-button,
.aps__input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
}

.aps__input::placeholder {
	color: var(--aps-muted);
	opacity: 1;
}

.aps__clear {
	flex: 0 0 auto;
	padding: 0 6px;
	color: var(--aps-muted);
	font-size: 20px;
	line-height: 1;
	background: none;
	border: 0;
	cursor: pointer;
}

.aps__clear:hover,
.aps__clear:focus {
	color: var(--aps-text);
	background: none;
}

.aps__submit.aps__submit {
	flex: 0 0 auto;
	margin: 0;
	padding: 10px 20px;
	color: #fff;
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
	background: var(--aps-accent);
	border: 0;
	border-radius: calc(var(--aps-radius) - 2px);
	cursor: pointer;
}

.aps__submit:hover,
.aps__submit:focus {
	filter: brightness(0.92);
}

/* Spinner --------------------------------------------------------------- */

.aps__spinner {
	display: none;
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	border: 2px solid var(--aps-border);
	border-top-color: var(--aps-accent);
	border-radius: 50%;
	animation: aps-spin 0.7s linear infinite;
}

.aps.is-loading .aps__spinner {
	display: block;
}

@keyframes aps-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.aps__spinner {
		animation-duration: 2s;
	}
}

/* Results dropdown ------------------------------------------------------ */

.aps__results {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	z-index: 9999;
	width: var(--aps-dropdown-width);
	min-width: 100%;
	max-height: var(--aps-max-height);
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	background: var(--aps-bg);
	border: 1px solid var(--aps-border);
	border-radius: var(--aps-radius);
	box-shadow: var(--aps-shadow);
}

.aps__results[hidden] {
	display: none;
}

.aps__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.aps__item {
	margin: 0;
	border-bottom: 1px solid var(--aps-border);
}

.aps__item:last-child {
	border-bottom: 0;
}

.aps__link {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	color: inherit;
	text-decoration: none;
	box-shadow: none;
}

.aps__link:hover,
.aps__link:focus,
.aps__link.is-active {
	color: inherit;
	text-decoration: none;
	background: var(--aps-hover-bg);
	outline: none;
}

.aps__thumb {
	flex: 0 0 auto;
	width: var(--aps-thumb-size);
	height: var(--aps-thumb-size);
	object-fit: cover;
	background: var(--aps-hover-bg);
	border-radius: calc(var(--aps-radius) - 3px);
}

.aps__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.aps__name {
	overflow: hidden;
	font-weight: 600;
	line-height: 1.35;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.aps__mark {
	color: inherit;
	background: rgba(37, 99, 235, 0.14);
	padding: 0 1px;
	border-radius: 2px;
}

.aps__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 10px;
	color: var(--aps-muted);
	font-size: 0.8em;
	line-height: 1.3;
}

.aps__price {
	color: var(--aps-text);
	font-size: 0.9em;
	line-height: 1.3;
}

.aps__price del {
	margin-right: 4px;
	color: var(--aps-muted);
	opacity: 0.8;
}

/* Stock status badges ---------------------------------------------------- */

.aps__stock {
	display: inline-block;
	padding: 1px 7px;
	font-weight: 600;
	line-height: 1.5;
	white-space: nowrap;
	border-radius: 999px;
	background: var(--aps-hover-bg);
}

.aps__stock--instock {
	color: var(--aps-instock);
	background: rgba(21, 128, 61, 0.1);
}

.aps__stock--outofstock {
	color: var(--aps-outofstock);
	background: rgba(185, 28, 28, 0.1);
}

.aps__stock--onbackorder {
	color: var(--aps-onbackorder);
	background: rgba(180, 83, 9, 0.1);
}

.aps__price ins {
	text-decoration: none;
}

/* Visibility toggles set by the shortcode attributes and settings. */
.aps--no-image .aps__thumb,
.aps--no-price .aps__price,
.aps--no-sku .aps__sku,
.aps--no-stock .aps__stock,
.aps--no-category .aps__category {
	display: none;
}

.aps__empty {
	margin: 0;
	padding: 18px 14px;
	color: var(--aps-muted);
	text-align: center;
}

.aps__all {
	display: block;
	padding: 11px 12px;
	color: var(--aps-accent);
	font-size: 0.9em;
	font-weight: 600;
	text-align: center;
	text-decoration: none;
	background: var(--aps-hover-bg);
	border-top: 1px solid var(--aps-border);
}

.aps__all:hover,
.aps__all:focus {
	text-decoration: underline;
}

/* "Did you mean?" suggestion bar ----------------------------------------- */

.aps__suggestion {
	padding: 8px 12px;
	border-bottom: 1px solid var(--aps-border);
	background: var(--aps-bg);
}

.aps__suggestion-link {
	padding: 0;
	color: var(--aps-accent);
	font-size: 13px;
	font-style: italic;
	text-decoration: underline;
	background: none;
	border: none;
	cursor: pointer;
}

.aps__suggestion-link:hover {
	text-decoration: none;
}

/* Responsive ------------------------------------------------------------ */

@media (max-width: 782px) {
	.aps {
		--aps-thumb-size: 44px;
		--aps-max-height: 340px;
	}
}

@media (max-width: 480px) {
	.aps {
		--aps-thumb-size: 40px;
		--aps-font-size: 14px;
	}

	.aps__field {
		padding-left: 8px;
	}

	.aps__input.aps__input {
		padding: 10px 2px;
		/* Prevents iOS from zooming the viewport on focus. */
		font-size: 16px;
	}

	.aps__submit.aps__submit {
		padding: 9px 12px;
	}

	.aps__name {
		white-space: normal;
	}
}

/* Fallback for themes without WordPress' accessibility helper class. */
.aps .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	border: 0;
	word-wrap: normal !important;
}
