/**
 * Live Search Suggestions Styles
 *
 * @package SCode_Theme
 */

/* Search suggestions container */
#search-suggestions,
.search-suggestions-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.08);
    max-height: 500px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Scrollbar styling */
#search-suggestions::-webkit-scrollbar,
.search-suggestions-container::-webkit-scrollbar {
    width: 8px;
}

#search-suggestions::-webkit-scrollbar-track,
.search-suggestions-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 0 12px 12px 0;
}

#search-suggestions::-webkit-scrollbar-thumb,
.search-suggestions-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

#search-suggestions::-webkit-scrollbar-thumb:hover,
.search-suggestions-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Suggestions list */
.search-suggestions-list {
    padding: 8px;
}

/* Individual suggestion item */
.search-suggestion-item {
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.search-suggestion-item:hover,
.search-suggestion-item.active {
    background: linear-gradient(to right, #fef2f2, #fff7ed);
    transform: translateX(4px);
}

.search-suggestion-item a {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
}

/* Product image in suggestions */
.search-suggestion-item img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: transform 0.2s ease;
}

.search-suggestion-item:hover img {
    transform: scale(1.05);
}

/* Highlight matched text */
.search-suggestion-item mark {
    background-color: #fef08a;
    color: #1f2937;
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
}

/* Footer with "View all" link */
.search-suggestion-footer {
    border-top: 1px solid #e5e7eb;
    margin-top: 8px;
}

.search-suggestion-footer a {
    text-decoration: none;
    transition: all 0.2s ease;
}

.search-suggestion-footer a:hover {
    background: linear-gradient(to right, #fef2f2, #fff7ed);
}

/* Loading state */
.search-suggestions-loading {
    padding: 24px;
    text-align: center;
}

.search-suggestions-loading svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Empty state */
.search-suggestions-empty {
    padding: 32px 24px;
    text-align: center;
}

/* Error state */
.search-suggestions-error {
    padding: 24px;
    text-align: center;
}

/* Mobile responsive */
@media (max-width: 768px) {
    #search-suggestions,
    .search-suggestions-container {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 70vh;
        margin-top: 0;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    .search-suggestion-item {
        padding: 4px;
    }

    .search-suggestion-item img {
        width: 40px;
        height: 40px;
    }

    /* Backdrop for mobile */
    #search-suggestions::before,
    .search-suggestions-container::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 70vh;
        background: rgba(0, 0, 0, 0.3);
        z-index: -1;
        pointer-events: none;
    }
}

/* Animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#search-suggestions[style*="display: block"],
.search-suggestions-container[style*="display: block"] {
    animation: slideDown 0.2s ease;
}

/* Stock status badges */
.search-suggestion-item .bg-red-100 {
    background-color: #fee2e2;
    color: #991b1b;
}

.search-suggestion-item .bg-green-100 {
    background-color: #dcfce7;
    color: #166534;
}

/* Category badge */
.search-suggestion-item .text-xs {
    font-size: 11px;
    opacity: 0.8;
}

/* Price styling */
.search-suggestion-item .text-red-600 {
    color: #dc2626;
    font-weight: 700;
}

/* Hover effects */
.search-suggestion-item:hover .text-gray-900 {
    color: #ef4444;
}

/* Focus states */
.search-suggestion-item:focus-within {
    outline: 2px solid #fca5a5;
    outline-offset: 2px;
}

/* Loading spinner */
.animate-spin {
    animation: spin 1s linear infinite;
}

/* Ensure parent form has position relative */
form[role="search"] {
    position: relative;
}

/* Smooth transitions */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
