/**
 * Dynamic Search System Styles
 * Modern, responsive search interface with smooth animations
 */

/* Search Container */
.search-results-container {
    position: relative;
    z-index: 9999;
}

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

/* Search Results Dropdown */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.25), 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    max-height: 500px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-15px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    margin-top: 12px;
    backdrop-filter: blur(20px);
    z-index: 10000;
}

/* Search Results Header */
.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px 12px 0 0;
    backdrop-filter: blur(10px);
}

.search-results-header h6 {
    margin: 0;
    font-weight: 700;
    color: #2c3e50;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

.close-search {
    background: rgba(108, 117, 125, 0.08);
    border: none;
    font-size: 1.1rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 8px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.close-search:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    transform: scale(1.05);
}

/* Search Results Content */
.search-results-content {
    padding: 0;
    max-height: 500px;
    overflow-y: auto;
}

.search-results-content::-webkit-scrollbar {
    width: 6px;
}

.search-results-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.search-results-content::-webkit-scrollbar-thumb {
    background: #28a745;
    border-radius: 3px;
}

/* Search Sections */
.search-section {
    border-bottom: 1px solid #f0f0f0;
}

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

.search-section-title {
    padding: 1rem 1.5rem 0.5rem;
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: #28a745;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-section-title i {
    font-size: 0.9rem;
}

/* Search Result Items */
.search-result-item {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.25rem;
    gap: 0.875rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    text-decoration: none;
    color: inherit;
    position: relative;
    background: #ffffff;
}

.search-result-item:last-child {
    border-bottom: none;
    border-radius: 0 0 12px 12px;
}

.search-result-item:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.search-result-item.product-item:hover {
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.03) 0%, rgba(40, 167, 69, 0.01) 100%);
    border-left: 3px solid #28a745;
    padding-left: calc(1.25rem - 3px);
}

.search-result-item.store-item:hover {
    background: linear-gradient(135deg, rgba(23, 162, 184, 0.03) 0%, rgba(23, 162, 184, 0.01) 100%);
    border-left: 3px solid #17a2b8;
    padding-left: calc(1.25rem - 3px);
}

/* Search Item Image */
.search-item-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

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

/* Search Item Content */
.search-item-content {
    flex: 1;
    min-width: 0;
}

.search-item-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 0.25rem 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-item-business,
.search-item-owner {
    font-size: 0.8rem;
    color: #28a745;
    margin: 0 0 0.25rem 0;
    font-weight: 500;
}

.search-item-description {
    font-size: 0.8rem;
    color: #6c757d;
    margin: 0 0 0.5rem 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-item-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-item-price {
    font-size: 0.85rem;
    font-weight: 700;
    color: #28a745;
}

.search-item-category,
.search-item-products,
.search-item-disability {
    font-size: 0.75rem;
    color: #6c757d;
    background: #f8f9fa;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.search-item-products {
    color: #17a2b8;
    background: rgba(23, 162, 184, 0.1);
    border-color: rgba(23, 162, 184, 0.2);
}

.search-item-products i {
    margin-right: 0.25rem;
}

/* Search Item Actions */
.search-item-actions {
    flex-shrink: 0;
}

.search-item-actions .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.search-item-actions .btn:hover {
    transform: translateY(-1px);
}

/* Search States */
.search-loading,
.search-no-results,
.search-error {
    padding: 2rem;
    text-align: center;
    color: #6c757d;
}

.search-loading-spinner {
    margin-bottom: 1rem;
}

.search-loading-text {
    font-size: 0.9rem;
    color: #28a745;
    font-weight: 500;
}

.search-no-results-icon,
.search-error-icon {
    font-size: 2.5rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.search-no-results h6,
.search-error h6 {
    color: #495057;
    margin-bottom: 0.5rem;
}

.search-no-results p,
.search-error p {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.search-suggestions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.search-suggestions .btn {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
}

/* Highlight Search Terms */
mark {
    background: linear-gradient(120deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    font-weight: 600;
}

/* Enhanced Search Input Styling */
.search-box {
    position: relative;
    z-index: 1;
    pointer-events: auto;
}

.search-input {
    transition: all 0.3s ease;
    border: 2px solid #e9ecef;
    pointer-events: auto !important;
    cursor: text !important;
    position: relative;
    z-index: 1;
}

.search-input:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
    outline: none;
}

.search-box.search-active .search-input {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: #f0f0f0;
}

/* Hero Search Specific Styling */
.hero-search .search-box {
    position: relative;
    z-index: 9999;
}

.hero-search .search-results-dropdown {
    position: fixed;
    z-index: 99999;
    margin-top: 8px;
    left: auto;
    right: auto;
    width: auto;
    min-width: 500px;
    max-width: 90vw;
}

/* Filters Search Specific Styling */
.filters-section .search-box {
    position: relative;
    z-index: 9999;
}

.filters-section .search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10000;
    margin-top: 8px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .search-results-dropdown {
        left: -1rem;
        right: -1rem;
        margin-top: 0.5rem;
        max-height: 70vh;
        border-radius: 12px;
    }
    
    .search-result-item {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    
    .search-item-image {
        width: 50px;
        height: 50px;
    }
    
    .search-item-title {
        font-size: 0.9rem;
    }
    
    .search-item-description {
        font-size: 0.75rem;
        -webkit-line-clamp: 1;
    }
    
    .search-item-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .search-suggestions {
        flex-direction: column;
    }
    
    .search-suggestions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .search-results-header {
        padding: 0.75rem 1rem;
    }
    
    .search-results-header h6 {
        font-size: 0.85rem;
    }
    
    .search-result-item {
        padding: 0.5rem 1rem;
    }
    
    .search-loading,
    .search-no-results,
    .search-error {
        padding: 1.5rem 1rem;
    }
}

/* Animation for smooth loading */
@keyframes searchPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.search-loading-spinner .spinner-border {
    animation: searchPulse 1.5s ease-in-out infinite;
}

/* Search Dropdown Portal - Positioned outside containers */
.search-dropdown-portal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99999;
    background: transparent;
}

.search-dropdown-portal .search-results-dropdown {
    position: absolute;
    pointer-events: all;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.25), 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    max-height: 500px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-15px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(20px);
}

/* Focus trap for accessibility */
.search-results-dropdown {
    outline: none;
}

.search-results-dropdown:focus-within {
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.25), 0 10px 25px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(40, 167, 69, 0.1);
}
