/**
 * Search Autocomplete Styles
 * Modern, fast, and responsive
 */

.search-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    margin-top: 8px;
    max-height: 500px;
    overflow-y: auto;
    z-index: 1000;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.search-autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: #CBD5E0;
    border-radius: 3px;
}

.search-autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: #A0AEC0;
}

/* Section */
.autocomplete-section {
    padding: 12px 0;
    border-bottom: 1px solid #F7FAFC;
}

.autocomplete-section:last-of-type {
    border-bottom: none;
}

.autocomplete-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #718096;
    padding: 8px 16px;
    letter-spacing: 0.5px;
}

/* Autocomplete Items */
.autocomplete-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #2D3748;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
    gap: 12px;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: #F7FAFC;
}

.autocomplete-item:active {
    background: #EDF2F7;
}

/* Product Item */
.autocomplete-product {
    gap: 12px;
}

.autocomplete-product-image {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #F7FAFC;
    display: flex;
    align-items: center;
    justify-content: center;
}

.autocomplete-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.autocomplete-product-info {
    flex: 1;
    min-width: 0;
}

.autocomplete-product-title {
    font-size: 14px;
    font-weight: 500;
    color: #2D3748;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.autocomplete-product-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #718096;
}

.autocomplete-product-ref {
    font-size: 12px;
    color: #A0AEC0;
    margin-left: auto;
    padding-left: 12px;
    flex-shrink: 0;
    white-space: nowrap;
}

.autocomplete-product-price {
    font-weight: 600;
    color: #2F855A;
}

/* Price wrapper - under product title */
.autocomplete-price-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.autocomplete-price-current {
    font-size: 13px;
    font-weight: 600;
    color: #2F855A;
}

/* When has discount */
.autocomplete-price-wrapper.has-discount .autocomplete-price-current {
    color: #E53E3E;
}

.autocomplete-price-old {
    font-size: 12px;
    font-weight: 400;
    color: #A0AEC0;
    text-decoration: line-through;
}

/* Category, SubCategory, Post, Page & Route Items */
.autocomplete-category,
.autocomplete-subcategory,
.autocomplete-post,
.autocomplete-page,
.autocomplete-route {
    gap: 10px;
}

.autocomplete-category svg,
.autocomplete-subcategory svg,
.autocomplete-post svg,
.autocomplete-page svg,
.autocomplete-route svg {
    flex-shrink: 0;
    color: #718096;
}

.autocomplete-category span,
.autocomplete-subcategory span,
.autocomplete-post span,
.autocomplete-page span,
.autocomplete-route span {
    font-size: 14px;
    color: #2D3748;
}

/* Route Items - Quick Links */
.autocomplete-route {
    background: #F0FFF4;
    border-left: 3px solid #48BB78;
}

.autocomplete-route:hover,
.autocomplete-route.active {
    background: #C6F6D5;
}

.autocomplete-route svg {
    color: #2F855A;
}

/* SubCategory - slightly indented look */
.autocomplete-subcategory {
    padding-left: 24px;
}

/* Page Items */
.autocomplete-page svg {
    color: #805AD5;
}

/* Highlight matching text */
.autocomplete-item mark {
    background: #FEF3C7;
    color: #92400E;
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
}

/* Footer */
.autocomplete-footer {
    padding: 12px 16px;
    border-top: 1px solid #F7FAFC;
    background: #FAFAFA;
}

.view-all-link {
    display: block;
    text-align: center;
    color: #3182CE;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s;
}

.view-all-link:hover {
    color: #2C5282;
    text-decoration: underline;
}

/* Loading State */
.autocomplete-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    color: #718096;
    font-size: 14px;
}

.autocomplete-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #E2E8F0;
    border-top-color: #3182CE;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* No Results */
.autocomplete-no-results {
    text-align: center;
    padding: 32px 24px;
    color: #718096;
}

.autocomplete-no-results svg {
    margin: 0 auto 16px;
    opacity: 0.5;
}

.autocomplete-no-results p {
    font-size: 14px;
    font-weight: 500;
    color: #4A5568;
    margin: 0 0 4px;
}

.autocomplete-no-results small {
    font-size: 12px;
    color: #A0AEC0;
}

/* Responsive */
@media (max-width: 768px) {
    .search-autocomplete-dropdown {
        max-height: 400px;
        border-radius: 12px;
    }

    .autocomplete-product-image {
        width: 40px;
        height: 40px;
    }

    .autocomplete-product-title {
        font-size: 13px;
    }

    .autocomplete-section-title {
        font-size: 10px;
    }
}

/* RTL Support */
[dir="rtl"] .autocomplete-item {
    flex-direction: row-reverse;
}

[dir="rtl"] .autocomplete-product-meta {
    flex-direction: row-reverse;
}

[dir="rtl"] .view-all-link {
    direction: rtl;
}

[dir="rtl"] .autocomplete-product-ref {
    margin-left: 0;
    margin-right: auto;
    padding-left: 0;
    padding-right: 12px;
}
