/* ===================================
   AJAX Search Autocomplete Styles
   =================================== */

/* Search Results Dropdown Container */
.ajaxSearchResults {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-top: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 450px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 0;
    border-radius: 0 0 4px 4px;
}

/* Results List Container */
.search-results-list {
    padding: 8px 0;
}

/* Individual Result Item */
.search-result-item {
    border-bottom: 1px solid #f5f5f5;
    transition: background-color 0.2s ease;
}

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

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

/* Result Link */
.search-result-link {
    display: flex;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.search-result-link:hover {
    text-decoration: none;
}

/* Result Image */
.search-result-image {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    margin-right: 14px;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid #f0f0f0;
}

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

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

/* Result Content */
.search-result-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0; /* Allow text truncation */
}

/* Result Title */
.search-result-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: #333;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-link:hover .search-result-title {
    color: #e53935;
}

/* Result Category Badge */
.search-result-category {
    display: inline-block;
    font-size: 11px;
    color: #fff;
    background: #1976d2;
    padding: 2px 8px;
    border-radius: 3px;
    margin-bottom: 6px;
    width: fit-content;
    font-weight: 500;
}

.news-item .search-result-category {
    background: #43a047;
}

/* Result Price */
.search-result-price {
    font-size: 15px;
    font-weight: 700;
    color: #e53935;
    margin-top: 4px;
}

.search-result-price .price-sale {
    color: #e53935;
    margin-right: 10px;
}

.search-result-price .price-regular {
    color: #999;
    text-decoration: line-through;
    font-size: 13px;
    font-weight: 400;
}

.search-result-price .price {
    color: #333;
}

/* Result Date (for news items) */
.search-result-date {
    font-size: 12px;
    color: #757575;
    margin-top: 4px;
    display: block;
}

/* Loading, No Results, Error States */
.search-loading,
.search-no-results,
.search-error {
    padding: 30px 20px;
    text-align: center;
    font-size: 14px;
}

.search-loading {
    color: #1976d2;
    font-weight: 500;
}

.search-loading::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #1976d2;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

.search-no-results {
    color: #757575;
}

.search-error {
    color: #e53935;
    font-weight: 500;
}

/* Scrollbar Styling */
.ajaxSearchResults::-webkit-scrollbar {
    width: 6px;
}

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

.ajaxSearchResults::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ajaxSearchResults::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ajaxSearchResults {
        max-height: 350px;
    }

    .search-result-image {
        width: 60px;
        height: 60px;
        margin-right: 12px;
    }

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

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

/* Ensure search box container has position relative */
.search-box {
    position: relative;
}
