/**
 * Search Autocomplete Styles
 *
 * Styles for the real-time search suggestions dropdown.
 *
 * @package VHP_Theme
 * @since 1.1.0
 */

/* -----------------------------------------------------------------------------
 * Autocomplete Container
 * -------------------------------------------------------------------------- */

.search-autocomplete {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: #fff;
	border: 1px solid var(--color-border, #e0e0e0);
	border-top: none;
	border-radius: 0 0 8px 8px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
	z-index: 1000;
	max-height: 400px;
	overflow-y: auto;
}

/* Scrollbar styling */
.search-autocomplete::-webkit-scrollbar {
	width: 8px;
}

.search-autocomplete::-webkit-scrollbar-track {
	background: #f5f5f5;
}

.search-autocomplete::-webkit-scrollbar-thumb {
	background: var(--color-border, #ccc);
	border-radius: 4px;
}

.search-autocomplete::-webkit-scrollbar-thumb:hover {
	background: var(--color-text-muted, #999);
}

/* -----------------------------------------------------------------------------
 * Sections
 * -------------------------------------------------------------------------- */

.search-autocomplete__section {
	padding: 12px 0;
	border-bottom: 1px solid var(--color-border, #e0e0e0);
}

.search-autocomplete__section:last-of-type {
	border-bottom: none;
}

.search-autocomplete__heading {
	margin: 0 16px 8px;
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--color-text-muted, #666);
}

/* -----------------------------------------------------------------------------
 * Result Items
 * -------------------------------------------------------------------------- */

.search-autocomplete__item {
	margin: 0;
}

.search-autocomplete__item a {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
	color: var(--color-text, #1d1d1d);
	text-decoration: none;
	transition: background-color 0.15s ease;
}

.search-autocomplete__item a:hover,
.search-autocomplete__item.is-selected a {
	background: var(--color-primary-light, #e8f0eb);
}

.search-autocomplete__item.is-selected a {
	outline: 2px solid var(--color-primary, #4a7c59);
	outline-offset: -2px;
}

/* Product items */
.search-autocomplete__item--product a {
	padding: 12px 16px;
}

.search-autocomplete__thumb {
	width: 48px;
	height: 48px;
	object-fit: cover;
	border-radius: 4px;
	flex-shrink: 0;
	background: #f5f5f5;
}

.search-autocomplete__thumb-placeholder {
	width: 48px;
	height: 48px;
	background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
	border-radius: 4px;
	flex-shrink: 0;
}

.search-autocomplete__info {
	flex: 1;
	min-width: 0;
}

.search-autocomplete__title {
	display: block;
	font-size: 0.95rem;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.search-autocomplete__sku {
	display: block;
	font-size: 0.8rem;
	color: var(--color-text-muted, #666);
	margin-top: 2px;
}

/* Term items (categories/brands) */
.search-autocomplete__item--category a,
.search-autocomplete__item--brand a {
	justify-content: space-between;
}

.search-autocomplete__count {
	font-size: 0.85rem;
	color: var(--color-text-muted, #666);
}

/* -----------------------------------------------------------------------------
 * Footer (View All)
 * -------------------------------------------------------------------------- */

.search-autocomplete__footer {
	padding: 12px 16px;
	border-top: 1px solid var(--color-border, #e0e0e0);
	background: #f9f9f9;
}

.search-autocomplete__view-all {
	display: block;
	text-align: center;
	font-size: 0.9rem;
	font-weight: 500;
	color: var(--color-primary, #4a7c59);
	text-decoration: none;
	padding: 8px;
	border-radius: 4px;
	transition: background-color 0.15s ease;
}

.search-autocomplete__view-all:hover {
	background: rgba(74, 124, 89, 0.1);
	text-decoration: underline;
}

/* -----------------------------------------------------------------------------
 * Loading State
 * -------------------------------------------------------------------------- */

.search-autocomplete__loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 24px 16px;
	color: var(--color-text-muted, #666);
	font-size: 0.9rem;
}

.search-autocomplete__spinner {
	width: 18px;
	height: 18px;
	border: 2px solid var(--color-border, #e0e0e0);
	border-top-color: var(--color-primary, #4a7c59);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

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

/* -----------------------------------------------------------------------------
 * Empty State
 * -------------------------------------------------------------------------- */

.search-autocomplete__empty {
	padding: 24px 16px;
	text-align: center;
}

.search-autocomplete__empty p {
	margin: 0;
	color: var(--color-text-muted, #666);
	font-size: 0.9rem;
}

/* -----------------------------------------------------------------------------
 * Search Form Enhancements
 * -------------------------------------------------------------------------- */

.search-form {
	position: relative;
}

.search-form__input-wrapper {
	position: relative;
}

/* When autocomplete is open */
.search-form__input:focus ~ .search-autocomplete,
.search-form__input[aria-expanded="true"] {
	border-color: var(--color-primary, #4a7c59);
}

/* Rounded corners adjustment when open */
.search-form__input[aria-expanded="true"] {
	border-radius: 8px 8px 0 0;
}

/* -----------------------------------------------------------------------------
 * Mobile Adjustments
 * -------------------------------------------------------------------------- */

@media (max-width: 767px) {
	.search-autocomplete {
		max-height: 60vh;
		border-radius: 0 0 12px 12px;
	}

	.search-autocomplete__item a {
		padding: 12px 16px;
	}

	.search-autocomplete__thumb {
		width: 40px;
		height: 40px;
	}

	.search-autocomplete__thumb-placeholder {
		width: 40px;
		height: 40px;
	}

	.search-autocomplete__title {
		font-size: 0.9rem;
	}
}

/* -----------------------------------------------------------------------------
 * Header Search Specific
 * -------------------------------------------------------------------------- */

.site-header .search-autocomplete {
	top: calc(100% + 4px);
	border-top: 1px solid var(--color-border, #e0e0e0);
	border-radius: 8px;
}

/* Dark header variant */
.site-header--dark .search-autocomplete {
	border-color: rgba(255, 255, 255, 0.2);
}
