/* Advanced Search Styles */

.search-suggestions {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-color: #e5e7eb;
}

.search-suggestions a {
    transition: all 0.2s ease;
}

.search-suggestions a:hover {
    background-color: #f9fafb;
}

.search-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Search input enhancements */
input[name="q"] {
    transition: all 0.2s ease;
}

input[name="q"]:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

/* Mobile search enhancements */
@media (max-width: 1023px) {
    .search-suggestions {
        position: fixed !important;
        top: auto !important;
        left: 1rem !important;
        right: 1rem !important;
        bottom: 1rem !important;
        max-height: 70vh;
        border-radius: 12px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
        z-index: 1001;
    }

    .search-suggestions::before {
        content: '';
        position: absolute;
        top: -8px;
        left: 50%;
        transform: translateX(-50%);
        width: 0;
        height: 0;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-bottom: 8px solid white;
    }

    /* Hide desktop search on mobile when overlay is active */
    .search-overlay.active ~ header .lg\\:flex {
        display: none !important;
    }
}

/* Loading animation */
@keyframes search-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-suggestions {
    animation: search-fade-in 0.2s ease-out;
}

/* Loading states */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.search-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.search-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
}

/* Smooth transitions */
.search-suggestions a,
.search-suggestions button,
.search-suggestions input {
    transition: all 0.2s ease;
}

/* Hover effects */
.search-suggestions .category-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.search-suggestions .product-suggestion:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Focus states for accessibility */
.search-suggestions a:focus,
.search-suggestions button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Animation for search results */
@keyframes slide-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-results-enter {
    animation: slide-in-up 0.3s ease-out;
}

/* Staggered animations */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fade-in 0.3s ease-out forwards;
}

.category-pill {
    opacity: 0;
    animation: fade-in 0.4s ease-out forwards;
}

.product-suggestion {
    opacity: 0;
    animation: fade-in 0.4s ease-out forwards;
}

/* Smooth transitions for all interactive elements */
.search-suggestions *,
.mobile-search-container * {
    transition: all 0.2s ease;
}

/* Enhanced focus states */
input[name="q"]:focus {
    transform: scale(1.02);
}

@media (min-width: 1024px) {
    input[name="q"]:focus {
        transform: none;
    }
}

/* Highlighted text */
mark {
    background-color: #fef3c7 !important;
    color: #92400e !important;
    padding: 0 2px;
    border-radius: 2px;
}

/* Category pills */
.category-summaries .category-pill {
    transition: all 0.2s ease;
}

.category-summaries .category-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Product suggestion cards */
.search-suggestions .product-suggestion {
    transition: all 0.2s ease;
}

.search-suggestions .product-suggestion:hover {
    background-color: #f3f4f6;
    transform: translateX(4px);
}

/* Search overlay for mobile */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Enhanced mobile search */
.mobile-search-container {
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.mobile-search-container.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.mobile-search-container input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
}

.mobile-search-container input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Loading states */
.search-loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: spin 1s ease-in-out infinite;
}

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

/* Responsive adjustments */
@media (min-width: 1024px) {
    .search-suggestions {
        max-width: 600px;
    }
}

@media (max-width: 640px) {
    .search-suggestions {
        left: 0.5rem;
        right: 0.5rem;
    }

    .search-suggestions .product-suggestion {
        padding: 0.75rem;
    }

    .search-suggestions .product-image {
        width: 48px;
        height: 48px;
    }
}

/* Accessibility improvements */
.search-suggestions a:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}