/* ========================================
   Product Search — Autocomplete Dropdown

   Paired with assets/js/modules/product-search.js
   ======================================== */


/* -------------------------------------------------------
   CONTAINER
   ------------------------------------------------------- */

.starter-search {
	position: relative;
	width: 100%;
	max-width: 400px;
}

/* Header variant */
.site-header .starter-search {
	max-width: 280px;
}

/* Full-width variant */
.starter-search--wide {
	max-width: 100%;
}


/* -------------------------------------------------------
   INPUT
   ------------------------------------------------------- */

.starter-search__input-wrap {
	position: relative;
	display: flex;
	align-items: center;
}

.starter-search__icon {
	position: absolute;
	left: 0.85rem;
	color: var(--starter-color-text-light, #999);
	pointer-events: none;
	flex-shrink: 0;
}

.starter-search__input {
	width: 100%;
	padding: 0.65rem 2.25rem 0.65rem 2.65rem;
	border: 1px solid #ddd;
	border-radius: 8px;
	font-size: 0.95rem;
	background: #f8f8f8;
	color: var(--starter-color-text, #1a1a1a);
	transition:
		border-color 0.2s,
		box-shadow 0.2s,
		background 0.2s;
}

.starter-search__input::placeholder {
	color: var(--starter-color-text-light, #999);
}

.starter-search__input:focus {
	outline: none;
	border-color: var(--starter-color-accent, #0073aa);
	background: #fff;
	box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.12);
}

/* Open state */
.starter-search.is-open .starter-search__input {
	border-color: var(--starter-color-accent, #0073aa);
	border-bottom-left-radius: 0;
	border-bottom-right-radius: 0;
}

/* Clear button */
.starter-search__clear {
	position: absolute;
	right: 0.5rem;
	background: none;
	border: none;
	color: var(--starter-color-text-light, #999);
	font-size: 1.2rem;
	line-height: 1;
	cursor: pointer;
	padding: 0.25rem 0.4rem;
	border-radius: 4px;
}

.starter-search__clear:hover {
	color: #333;
	background: #eee;
}

.starter-search__clear[hidden] {
	display: none;
}


/* -------------------------------------------------------
   DROPDOWN
   ------------------------------------------------------- */

.starter-search__dropdown {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	z-index: 1000;
	background: #fff;
	border: 1px solid var(--starter-color-accent, #0073aa);
	border-top: none;
	border-bottom-left-radius: 8px;
	border-bottom-right-radius: 8px;
	box-shadow:
		0 8px 24px rgba(0, 0, 0, 0.12),
		0 2px 8px rgba(0, 0, 0, 0.06);
	max-height: 420px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

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

/* Screen reader status */
.starter-search__status {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
}


/* -------------------------------------------------------
   RESULTS LIST
   ------------------------------------------------------- */

.starter-search__results {
	list-style: none;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	max-height: 360px;
	scrollbar-width: thin;
}


/* -------------------------------------------------------
   RESULT ITEM
   ------------------------------------------------------- */

.starter-search__result {
	border-bottom: 1px solid #f0f0f0;
}

.starter-search__result:last-child {
	border-bottom: none;
}

.starter-search__result-link {
	display: flex;
	align-items: center;
	gap: 0.85rem;
	padding: 0.75rem 1rem;
	text-decoration: none;
	color: var(--starter-color-text, #1a1a1a);
	transition: background 0.15s;
}

.starter-search__result:hover,
.starter-search__result.is-active {
	background: #f5f9fc;
}

.starter-search__result.is-active .starter-search__result-title {
	color: var(--starter-color-accent, #0073aa);
}

/* Result image */
.starter-search__result-image {
	width: 48px;
	height: 48px;
	border-radius: 6px;
	object-fit: cover;
	flex-shrink: 0;
	background: #f0f0f0;
}

.starter-search__result-image--placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--starter-color-text-light, #ccc);
	font-size: 1.2rem;
}

/* Result info */
.starter-search__result-info {
	flex: 1;
	min-width: 0; /* enable text truncation */
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
}

.starter-search__result-title {
	font-size: 0.92rem;
	font-weight: 500;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.starter-search__result-title mark {
	background: #fff3cd;
	color: inherit;
	padding: 0 1px;
	border-radius: 2px;
}

.starter-search__result-cats {
	font-size: 0.75rem;
	color: var(--starter-color-text-light, #999);
}

.starter-search__result-price {
	font-size: 0.88rem;
	font-weight: 600;
	color: var(--starter-color-text, #1a1a1a);
}

.starter-search__result-price del {
	color: var(--starter-color-text-light, #999);
	font-weight: 400;
	margin-right: 0.25rem;
	font-size: 0.85em;
}

.starter-search__result-price ins {
	text-decoration: none;
	color: var(--starter-color-sale, #c53030);
}

/* Sale badge */
.starter-search__result-badge {
	background: var(--starter-color-sale, #c53030);
	color: #fff;
	font-size: 0.65rem;
	font-weight: 700;
	text-transform: uppercase;
	padding: 0.2rem 0.45rem;
	border-radius: 3px;
	flex-shrink: 0;
	align-self: flex-start;
	margin-top: 0.15rem;
}


/* -------------------------------------------------------
   EMPTY STATE
   ------------------------------------------------------- */

.starter-search__empty {
	padding: 1.5rem 1rem;
	text-align: center;
	color: var(--starter-color-text-light, #666);
	font-size: 0.9rem;
}


/* -------------------------------------------------------
   FOOTER (view all)
   ------------------------------------------------------- */

.starter-search__footer {
	border-top: 1px solid #eee;
	padding: 0.5rem 1rem;
	text-align: center;
}

.starter-search__view-all {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--starter-color-accent, #0073aa);
	text-decoration: none;
}

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


/* -------------------------------------------------------
   SKELETON LOADING
   ------------------------------------------------------- */

.starter-search__result--skeleton {
	pointer-events: none;
}

.starter-search__result--skeleton .starter-search__result-link {
	gap: 0.85rem;
	padding: 0.75rem 1rem;
}

.starter-search__skeleton-pulse {
	background: linear-gradient(110deg, #f0f0f0 8%, #e8e8e8 18%, #f0f0f0 33%);
	background-size: 200% 100%;
	animation: starter-shimmer 1.5s linear infinite;
	border-radius: 4px;
}


/* -------------------------------------------------------
   HEADER INTEGRATION
   ------------------------------------------------------- */

.site-header .starter-search__input {
	background: #f5f5f5;
	border-color: var(--starter-color-border, #e5e5e5);
	font-size: 0.88rem;
	padding: 0.5rem 2rem 0.5rem 2.4rem;
}

.site-header .starter-search__input:focus {
	background: #fff;
}

/* -------------------------------------------------------
   RESPONSIVE
   ------------------------------------------------------- */

@media (max-width: 768px) {
	.starter-search {
		max-width: 100%;
	}

	.starter-search__dropdown {
		position: fixed;
		top: auto;
		left: 0;
		right: 0;
		bottom: 0;
		border: none;
		border-radius: 12px 12px 0 0;
		box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
		max-height: 70vh;
	}

	.starter-search__results {
		max-height: 55vh;
	}
}
