/**
 * AJAX Search for Header
 * Dropdown search results styling
 */

/* Search Results Container */
#header-search-results {
    position: fixed;
    z-index: 9999;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    max-height: 500px;
    overflow-y: auto;
}

/* Loading State */
.search-results-loading {
    padding: 30px;
    text-align: center;
}

.search-results-loading .loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #d32f2f;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.search-results-loading p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Results Grid */
.search-results-grid {
    padding: 10px;
}

.search-result-item {
    margin-bottom: 2px;
}

.search-result-item .result-link {
    display: flex;
    gap: 12px;
    padding: 12px;
    text-decoration: none;
    color: inherit;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.search-result-item .result-link:hover {
    background-color: #f8f9fa;
}

.result-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-image .no-image {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

.result-content {
    flex: 1;
    min-width: 0;
}

.result-title {
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.result-rating {
    margin-bottom: 6px;
}

.star-rating {
    display: flex;
    gap: 2px;
    font-size: 12px;
}

.star-rating .star {
    color: #ffc107;
}

.star-rating .star.empty {
    color: #ddd;
}

.star-rating .star.half {
    background: linear-gradient(90deg, #ffc107 50%, #ddd 50%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.result-price {
    font-size: 15px;
    font-weight: 700;
    color: #d32f2f;
}

.result-price del {
    color: #999;
    font-weight: 400;
    margin-right: 6px;
    font-size: 13px;
}

/* No Results */
.no-results {
    padding: 40px 20px;
    text-align: center;
}

.no-results svg {
    stroke: #ccc;
    margin-bottom: 15px;
}

.no-results p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Recent Searches */
.recent-searches-container {
    padding: 15px;
}

.recent-searches-container h4 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.recent-searches-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.recent-searches-list li {
    margin-bottom: 2px;
}

.recent-search-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-decoration: none;
    color: #555;
    font-size: 14px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.recent-search-link:hover {
    background-color: #f8f9fa;
    color: #333;
}

.recent-search-link svg {
    flex-shrink: 0;
    stroke: #999;
}

/* Footer */
.search-results-footer {
    padding: 12px 15px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    text-align: center;
    border-radius: 0 0 8px 8px;
}

.view-all-results {
    display: inline-block;
    padding: 8px 20px;
    background: #d32f2f;
    color: #ffffff;
    text-decoration: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.view-all-results:hover {
    background: #b71c1c;
    color: #ffffff;
}

/* Scrollbar Styling */
#header-search-results::-webkit-scrollbar {
    width: 8px;
}

#header-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 8px 8px 0;
}

#header-search-results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

#header-search-results::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive */
@media (max-width: 768px) {
    #header-search-results {
        left: 10px !important;
        right: 10px !important;
        width: calc(100% - 20px) !important;
        max-height: 400px;
    }

    .result-image {
        width: 50px;
        height: 50px;
    }

    .result-title {
        font-size: 13px;
    }
}
