/**
 * Search Autocomplete Styles - Version 2.0
 * Styling for product search autocomplete dropdown
 * Enhanced with search history and better UX
 */

/* Search suggest container */
.search-suggest {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: #fff;
	border: 1px solid #e0e0e0;
	border-top: none;
	border-radius: 0 0 8px 8px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
	max-height: 0;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transition: all 0.3s ease;
	z-index: 9999; /* Higher z-index to ensure it's on top */
	margin-top: -1px;
}

.search-suggest.active {
	max-height: 600px;
	opacity: 1;
	visibility: visible;
	overflow-y: auto;
}

/* Search list container */
.list-search {
	max-height: 500px;
	overflow-y: auto;
	padding: 8px 0;
}

.list-search::-webkit-scrollbar {
	width: 6px;
}

.list-search::-webkit-scrollbar-track {
	background: #f1f1f1;
}

.list-search::-webkit-scrollbar-thumb {
	background: #888;
	border-radius: 3px;
}

.list-search::-webkit-scrollbar-thumb:hover {
	background: #555;
}

/* Loading state */
.search-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 40px 16px;
	color: #6c757d;
	font-size: 14px;
}

.spinner-border-sm {
	width: 1rem;
	height: 1rem;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
	to {
		transform: rotate(360deg);
	}
}

/* Error state */
.search-error {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 40px 16px;
	color: #dc3545;
	font-size: 14px;
	text-align: center;
}

.search-error i {
	font-size: 18px;
}

/* No results */
.search-no-results {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 16px;
	text-align: center;
	color: #6c757d;
}

.search-no-results svg {
	margin-bottom: 16px;
	opacity: 0.5;
}

.search-no-results p {
	margin: 0;
	font-size: 14px;
	line-height: 1.5;
}

.search-no-results strong {
	color: #495057;
}

/* Search results header */
.search-results-header {
	padding: 10px 16px;
	background: #f8f9fa;
	border-bottom: 1px solid #e9ecef;
	font-size: 13px;
	color: #6c757d;
	font-weight: 500;
}

/* Search results list */
.search-results-list {
	padding: 0;
	margin: 0;
	max-height: 400px;
	overflow-y: auto;
}

/* Individual search result item */
.search-result-item {
	display: flex;
	align-items: center;
	padding: 12px 16px;
	text-decoration: none;
	color: #333;
	transition: background-color 0.2s ease;
	border-bottom: 1px solid #f0f0f0;
}

.search-result-item:last-child {
	border-bottom: none;
}

.search-result-item:hover,
.search-result-item.selected {
	background-color: #f8f9fa;
}

.search-result-item.selected::before {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 3px;
	background: var(--mainColor, #007bff);
}

.search-result-item {
	position: relative;
}

/* Result image */
.search-result-image {
	flex-shrink: 0;
	width: 60px;
	height: 60px;
	margin-right: 12px;
	border-radius: 6px;
	overflow: hidden;
	background: #f5f5f5;
}

.search-result-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s ease;
}

.search-result-item:hover .search-result-image img {
	transform: scale(1.05);
}

/* Result info */
.search-result-info {
	flex: 1;
	min-width: 0;
}

.search-result-name {
	font-size: 14px;
	font-weight: 500;
	color: #333;
	margin-bottom: 4px;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	line-height: 1.4;
}

.search-result-name strong {
	color: var(--mainColor, #002d3a);
	font-weight: 600;
}

.search-result-price {
	font-size: 14px;
	font-weight: 600;
	color: var(--price, #c30000);
}

/* View all link */
.search-view-all {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 16px;
	text-align: center;
	color: var(--mainColor, #007bff);
	font-weight: 600;
	font-size: 14px;
	text-decoration: none;
	border-top: 1px solid #e0e0e0;
	background: #f8f9fa;
	transition: all 0.2s ease;
}

.search-view-all:hover {
	background-color: #e9ecef;
	color: var(--hoverColor, #0056b3);
}

.search-view-all i {
	font-size: 12px;
}

/* Existing search sections */
.search-recent,
.item-suggest {
	padding: 12px 16px;
	border-bottom: 1px solid #f0f0f0;
	display: block; /* Ensure it's visible */
}

.search-title {
	display: flex;
	align-items: center;
	font-size: 13px;
	font-weight: 600;
	color: #666;
	margin-bottom: 8px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.search-title svg {
	margin-right: 8px;
	flex-shrink: 0;
}

.search-list .search-item {
	display: inline-block;
	padding: 6px 12px;
	margin: 4px 4px 4px 0;
	background: #f5f5f5;
	border-radius: 16px;
	font-size: 13px;
	color: #333;
	text-decoration: none;
	transition: all 0.2s ease;
}

.search-list .search-item:hover {
	background: var(--mainColor, #002d3a);
	color: #fff;
	transform: translateY(-1px);
}

/* Search clear history button */
.search-list .search-clear-history {
	background: #fff3cd;
	color: #856404;
	border: 1px solid #ffeaa7;
}

.search-list .search-clear-history:hover {
	background: #ffe8a1;
	color: #533f03;
	border-color: #ffc107;
}

.search-list .search-clear-history i {
	margin-right: 4px;
	font-size: 11px;
}

/* Responsive adjustments */
@media (max-width: 767px) {
	.search-suggest {
		position: fixed;
		left: 0;
		right: 0;
		top: auto;
		border-radius: 0;
		max-height: 70vh;
	}

	.search-result-image {
		width: 50px;
		height: 50px;
	}

	.search-result-name {
		font-size: 13px;
	}

	.search-result-price {
		font-size: 13px;
	}
}

/* Animation for results appearing */
@keyframes slideDown {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.search-suggest.active .search-result-item {
	animation: slideDown 0.3s ease forwards;
}

.search-suggest.active .search-result-item:nth-child(1) {
	animation-delay: 0.05s;
}

.search-suggest.active .search-result-item:nth-child(2) {
	animation-delay: 0.1s;
}

.search-suggest.active .search-result-item:nth-child(3) {
	animation-delay: 0.15s;
}

.search-suggest.active .search-result-item:nth-child(4) {
	animation-delay: 0.2s;
}

.search-suggest.active .search-result-item:nth-child(5) {
	animation-delay: 0.25s;
}

.search-suggest.active .search-result-item:nth-child(6) {
	animation-delay: 0.3s;
}

.search-suggest.active .search-result-item:nth-child(7) {
	animation-delay: 0.35s;
}

.search-suggest.active .search-result-item:nth-child(8) {
	animation-delay: 0.4s;
}