/**
 * Angry Ajax Search — minimal scoped styles
 * Every selector is prefixed with .aas-search to avoid clashing with
 * theme / Elementor / page-builder CSS. No resets, no framework.
 */

.aas-search {
	position: relative;
	width: 100%;
	max-width: 480px;
	font-family: inherit;
}

.aas-search__input {
	width: 100%;
	box-sizing: border-box;
	padding: 10px 14px;
	font-size: 15px;
	border: 1px solid #ccc;
	border-radius: 4px;
	outline: none;
}

.aas-search__input:focus {
	border-color: #888;
}

/*
 * The panel is intentionally NOT set to left:0; right:0 (which would
 * inherit the search input's width). It has its own fixed width so it
 * reads correctly regardless of how narrow/wide the input itself is.
 */
.aas-search__panel {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	z-index: 2147483647; /* effective CSS max — always wins over page elements with a high z-index */
	display: flex;
	flex-direction: column;
	width: 700px;
	max-width: calc(100vw - 24px); /* keep it on-screen on narrow viewports */
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
	max-height: 420px;
	overflow: hidden;
	box-sizing: border-box;
}

.aas-search__panel[hidden] {
	display: none;
}

/*
 * Full-width header above both columns, static (doesn't scroll away) on
 * desktop — the list column below scrolls independently, in its own
 * area, so the category chips always stay visible.
 */
.aas-search__categories {
	flex-shrink: 0;
	width: 100%;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 5px;
	border-bottom: 1px solid #eee;
}

.aas-search__categories[hidden] {
	display: none;
	padding: 0;
	border-bottom: none;
}

.aas-search__categories-label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: #888;
}

.aas-search__categories-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.aas-search__cat-chip {
	font-family: inherit;
	font-size: 10px;
	line-height: 1;
	padding: 5px;
	background: #f0f0f0;
	border: none;
	border-radius: 50%;
	text-decoration: none;
	color: #333;
	white-space: nowrap;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}

.aas-search__cat-chip:hover {
	background: #e2e2e2;
}

.aas-search__cat-chip.is-active {
	background: #2271b1;
	color: #fff;
}

/*
 * Row containing the two columns below the static categories header.
 * min-height:0 is required here — without it, flex children can't
 * shrink below their content size, which silently breaks the nested
 * scroll area in .aas-search__list.
 */
.aas-search__columns {
	display: flex;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
}

.aas-search__list-col {
	flex: 0 0 350px;
	width: 350px;
	display: flex;
	flex-direction: column;
	min-height: 0;
	border-right: 1px solid #eee;
	box-sizing: border-box;
	overflow: hidden;
}

.aas-search__list {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
}

.aas-search__view-all {
	flex-shrink: 0;
	border-top: 1px solid #eee;
}

.aas-search__view-all:empty {
	display: none;
	border-top: none;
}

.aas-search__view-all a {
	display: block;
	padding: 10px 12px;
	text-align: center;
	font-size: 13px;
	color: #1a5fb4;
	text-decoration: none;
}

.aas-search__view-all a:hover {
	text-decoration: underline;
}

.aas-search__item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 12px;
	text-decoration: none;
	color: inherit;
	border-bottom: 1px solid #f2f2f2;
}

.aas-search__item:last-child {
	border-bottom: none;
}

.aas-search__item.is-active,
.aas-search__item:hover {
	background: #f7f7f7;
}

.aas-search__thumb {
	width: 80px;
	height: 80px;
	object-fit: cover;
	border-radius: 3px;
	background: #f0f0f0;
	flex-shrink: 0;
}

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

.aas-search__title {
	font-size: 13.5px;
	line-height: 1.3;
	/* Clamp to 2 lines instead of wrapping indefinitely and pushing
	   the row height around unpredictably. */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.aas-search__item-price {
	font-size: 12.5px;
	color: #555;
	/* Clearfix — some themes float WooCommerce's <del>/<ins> price
	   elements for their own layouts; without this, that float can
	   escape and push whatever comes after (e.g. SKU) up beside it
	   instead of below it. overflow:hidden establishes a new block
	   formatting context that contains the float properly. */
	overflow: hidden;
}

.aas-search__item-price .woocommerce-Price-amount {
	font-size: inherit;
	color: inherit;
}

/* Regular price when on sale: muted, struck-through, smaller */
.aas-search__item-price del {
	opacity: 0.6;
	font-weight: 400;
	margin-right: 4px;
}

/* Sale price: bold, slightly larger, full-strength color */
.aas-search__item-price ins {
	text-decoration: none;
	font-weight: 700;
}

.aas-search__item-price ins .woocommerce-Price-amount {
	font-size: 1.08em;
	color: #1a1a1a;
}

.aas-search__detail {
	flex: 0 0 350px;
	width: 350px;
	padding: 14px;
	font-size: 13.5px;
	box-sizing: border-box;
	overflow-y: auto;
}

.aas-search__detail-thumb {
	display: block;
	width: 85%;
	aspect-ratio: 1 / 1;
	height: auto;
	margin: 0 auto 12px;
	border-radius: 4px;
	background: #f0f0f0;
	object-fit: cover;
	opacity: 0;
	transition: opacity 150ms ease;
}

.aas-search__detail-thumb.is-loaded {
	opacity: 1;
}

.aas-search__detail-title {
	display: block;
	font-weight: 600;
	margin-bottom: 8px;
	line-height: 1.35;
	color: inherit;
	text-decoration: none;
}

.aas-search__detail-title:hover {
	text-decoration: underline;
}

.aas-search__detail-price {
	font-size: 15px;
	margin-bottom: 6px;
	/* Same clearfix reasoning as .aas-search__item-price above. */
	overflow: hidden;
}

.aas-search__detail-price del {
	opacity: 0.6;
	font-weight: 400;
	margin-right: 6px;
}

.aas-search__detail-price ins {
	text-decoration: none;
	font-weight: 700;
}

.aas-search__detail-price ins .woocommerce-Price-amount {
	font-size: 1.15em;
}

.aas-search__detail-sku {
	display: block;
	clear: both;
	color: #777;
	margin-bottom: 6px;
}

.aas-search__stock--out {
	color: #b3261e;
	font-weight: 600;
}

.aas-search__add-to-cart,
.aas-search__view-product {
	display: inline-block;
	margin-top: 8px;
	padding: 8px 14px;
	font-size: 13px;
	font-weight: 600;
	background: #2271b1;
	color: #fff;
	text-decoration: none;
	border-radius: 4px;
	text-align: center;
	border: none;
	cursor: pointer;
}

.aas-search__add-to-cart:hover,
.aas-search__view-product:hover {
	background: #175683;
	color: #fff;
}

/* WooCommerce's own add-to-cart.js toggles this class while the AJAX
   request is in flight. */
.aas-search__add-to-cart.loading {
	opacity: 0.6;
	pointer-events: none;
}

/* WooCommerce injects a "View cart" link right after the button once
   the item's added — keep it compact in this small detail panel. */
.aas-search__detail .added_to_cart {
	display: inline-block;
	margin-top: 8px;
	margin-left: 8px;
	font-size: 12px;
}

.aas-search__empty {
	padding: 14px;
	color: #777;
	font-size: 13.5px;
}

/*
 * Desktop alignment relative to the search input — configurable in
 * Tools → Angry Ajax Search, since where the search bar sits in the
 * page template (left edge of a wide header, centered, etc) determines
 * which anchor makes the dropdown land in a sensible spot.
 */
.aas-search__panel--align-left {
	left: 0;
}

.aas-search__panel--align-center {
	left: 50%;
	transform: translateX(-50%);
}

.aas-search__panel--align-right {
	left: auto;
	right: 0;
}

/*
 * Mobile: always centered on the viewport at 90% width, regardless of
 * the alignment setting above and regardless of where the search input
 * sits in the page (header, sidebar, wherever). This requires
 * position:fixed — an absolutely-positioned element still inherits its
 * width/offset context from the (possibly narrow) search bar, which is
 * exactly the bug being fixed here. The exact `top` is computed in JS
 * (positionForMobile()) since it depends on the input's on-page position.
 */
@media (max-width: 600px) {
	.aas-search__panel,
	.aas-search__panel--align-left,
	.aas-search__panel--align-center,
	.aas-search__panel--align-right {
		position: fixed;
		left: 50%;
		right: auto;
		transform: translateX(-50%);
		width: 90vw;
		max-width: 90vw;
		max-height: 70vh;
		/* The whole panel scrolls as one unit here — categories, list,
		   and view-all all move together, instead of the categories
		   staying static like on desktop. */
		overflow-y: auto;
	}

	.aas-search__detail {
		display: none;
	}

	.aas-search__categories {
		flex-shrink: 0; /* still doesn't compress, just no longer "sticky" */
	}

	.aas-search__columns {
		display: block;
		overflow: visible;
		min-height: 0;
	}

	.aas-search__list-col {
		display: block;
		width: 100%;
		border-right: none;
		overflow: visible;
	}

	.aas-search__list {
		overflow: visible;
	}
}
