/**
 * Typesense Search v5 - Enhanced Search Results CSS
 * Doofinder-inspired modern design with advanced features
 */

/* Search Results Header */
.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 24px;
}

.results-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.results-count {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.search-time {
    font-size: 14px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 4px 8px;
    border-radius: 12px;
}

.results-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* View Toggle */
.view-toggle {
    display: flex;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 2px;
}

.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.view-btn:hover {
    background: #e5e7eb;
}

.view-btn.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

/* Sort Select */
.sort-select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    min-width: 160px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

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

/* Products Container */
.products-container {
    margin-bottom: 32px;
}

.products-container.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.products-container.products-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Enhanced Product Cards */
.product-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.product-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.product-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* Product Card Image */
.product-card-image {
    position: relative;
    aspect-ratio: 1;
    background: #f8fafc;
    overflow: hidden;
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 16px;
    transition: transform 0.3s ease;
}

.product-card:hover .product-card-image img {
    transform: scale(1.05);
}

/* Stock Overlay */
.stock-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

/* Product Actions - Doofinder style hover buttons */
.product-card-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transform: translateX(8px);
    transition: all 0.3s ease;
}

.product-card:hover .product-card-actions {
    opacity: 1;
    transform: translateX(0);
}

.quick-view-btn,
.add-to-cart-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.quick-view-btn:hover {
    background: #3b82f6;
    color: white;
    transform: scale(1.1);
}

.add-to-cart-btn:hover {
    background: #10b981;
    color: white;
    transform: scale(1.1);
}

/* Product Card Content */
.product-card-content {
    padding: 20px;
}

.product-card-header {
    margin-bottom: 12px;
}

.product-brand {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.product-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: #1f2937;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 44px;
}

/* Product Meta */
.product-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 12px;
}

.product-sku {
    color: #6b7280;
    font-family: monospace;
}

.product-stock {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.stock-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.product-stock.high-stock .stock-indicator {
    background: #10b981;
}

.product-stock.high-stock .stock-text {
    color: #10b981;
}

.product-stock.low-stock .stock-indicator {
    background: #f59e0b;
}

.product-stock.low-stock .stock-text {
    color: #f59e0b;
}

.product-stock.out-of-stock .stock-indicator {
    background: #ef4444;
}

.product-stock.out-of-stock .stock-text {
    color: #ef4444;
}

/* Product Description */
.product-description {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.4;
    margin: 0 0 16px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Product Footer */
.product-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid #f3f4f6;
}

.product-price {
    display: flex;
    flex-direction: column;
}

.price-current {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
}

.price-original {
    font-size: 14px;
    color: #9ca3af;
    text-decoration: line-through;
}

/* Product Rating */
.product-rating {
    display: flex;
    align-items: center;
}

.rating-stars {
    display: flex;
    gap: 2px;
}

.star {
    font-size: 14px;
    color: #d1d5db;
}

.star.filled {
    color: #fbbf24;
}

.star.half {
    color: #fbbf24;
}

/* List View Styles */
.products-container.products-list .product-card {
    border-radius: 8px;
}

.products-container.products-list .product-card-link {
    display: flex;
    align-items: center;
}

.products-container.products-list .product-card-image {
    width: 120px;
    height: 120px;
    aspect-ratio: 1;
    flex-shrink: 0;
}

.products-container.products-list .product-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Enhanced Pagination */
.search-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    padding: 20px 0;
}

.pagination-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
}

.pagination-btn:hover:not(.disabled) {
    border-color: #3b82f6;
    background: #f8fafc;
}

.pagination-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.pagination-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-numbers {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn.number {
    min-width: 40px;
    justify-content: center;
}

.pagination-ellipsis {
    padding: 0 8px;
    color: #9ca3af;
}

/* Enhanced Facets */
.search-facets {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
}

.facets-header {
    padding: 20px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.facets-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.facet-group {
    border-bottom: 1px solid #f3f4f6;
}

.facet-group:last-child {
    border-bottom: none;
}

.facet-title {
    padding: 16px 20px 12px;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    background: #fafbfc;
}

.facet-content {
    padding: 0 20px 16px;
}

.facet-values {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.facet-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.facet-option:hover {
    background: #f3f4f6;
}

.facet-option.selected {
    background: #eff6ff;
    border: 1px solid #dbeafe;
}

.facet-option input[type="checkbox"] {
    margin-right: 8px;
}

.facet-label {
    flex: 1;
    color: #374151;
}

.facet-count {
    color: #6b7280;
    font-size: 13px;
}

/* Clear Filters */
.facets-actions {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.clear-filters-btn {
    width: 100%;
    padding: 10px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.clear-filters-btn:hover {
    background: #dc2626;
}

/* No Results */
.no-results-content {
    text-align: center;
    padding: 60px 40px;
    color: #6b7280;
}

.no-results-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.no-results-content h3 {
    font-size: 24px;
    color: #1f2937;
    margin-bottom: 12px;
}

.no-results-content p {
    font-size: 16px;
    margin-bottom: 32px;
}

.no-results-suggestions {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    text-align: left;
    max-width: 400px;
    margin: 0 auto;
}

.no-results-suggestions h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #1f2937;
}

.no-results-suggestions ul {
    margin: 0;
    padding: 0 0 0 20px;
}

.no-results-suggestions li {
    margin: 6px 0;
    font-size: 14px;
}

/* Search Highlights */
.search-highlight {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .search-results-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 16px 0;
    }
    
    .results-info {
        justify-content: center;
    }
    
    .results-controls {
        justify-content: space-between;
    }
    
    .products-container.products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .product-card-content {
        padding: 16px;
    }
    
    .product-title {
        font-size: 14px;
        min-height: 38px;
    }
    
    .price-current {
        font-size: 16px;
    }
    
    .product-card-actions {
        position: static;
        opacity: 1;
        transform: none;
        flex-direction: row;
        justify-content: center;
        padding: 12px;
        background: #f8fafc;
        border-top: 1px solid #e5e7eb;
        margin-top: 12px;
    }
    
    .quick-view-btn,
    .add-to-cart-btn {
        position: static;
        margin: 0;
    }
    
    .pagination-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .pagination-btn.prev,
    .pagination-btn.next {
        flex-shrink: 0;
    }
    
    .search-facets {
        margin: 16px 0;
    }
    
    .products-container.products-list .product-card-link {
        flex-direction: column;
    }
    
    .products-container.products-list .product-card-image {
        width: 100%;
        height: 200px;
    }
}

@media (max-width: 480px) {
    .products-container.products-grid {
        grid-template-columns: 1fr;
    }
    
    .view-toggle {
        display: none;
    }
    
    .results-count {
        font-size: 16px;
    }
    
    .sort-select {
        font-size: 13px;
        min-width: 140px;
    }
}

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

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

.product-card.loading .product-card-image,
.product-card.loading .product-title,
.product-card.loading .product-description {
    background: #f3f4f6;
    border-radius: 4px;
}

/* Accessibility Improvements */
.product-card:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.pagination-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.facet-option:focus-within {
    background: #f3f4f6;
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Enhanced Categorized Results */
.categorized-results {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.result-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #f1f5f9;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
}

.section-icon {
    font-size: 24px;
}

.section-count {
    background: #3b82f6;
    color: white;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 600;
    margin-left: auto;
}

/* Category Cards */
.category-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.category-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.category-card:hover {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.15);
}

.category-name {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

.category-count {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 16px;
}

.view-category-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-category-btn:hover {
    background: #2563eb;
    transform: translateX(4px);
}

/* Brand Cards */
.brand-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.brand-card {
    background: white;
    border: 2px solid #f1f5f9;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.brand-card:hover {
    border-color: #10b981;
    background: #f0fdf4;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.15);
}

.brand-name {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.brand-count {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 16px;
}

.view-brand-btn {
    background: #10b981;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.view-brand-btn:hover {
    background: #059669;
}

/* Enhanced Products Grid */
.products-grid-enhanced {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.show-more-products {
    text-align: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #f1f5f9;
}

.show-all-products-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.show-all-products-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

/* Mobile Responsive for Categorized Results */
@media (max-width: 768px) {
    .categorized-results {
        gap: 24px;
    }
    
    .result-section {
        padding: 16px;
    }
    
    .section-title {
        font-size: 18px;
        flex-wrap: wrap;
    }
    
    .category-cards {
        grid-template-columns: 1fr;
    }
    
    .brand-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .products-grid-enhanced {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .brand-cards {
        grid-template-columns: 1fr;
    }
    
    .products-grid-enhanced {
        grid-template-columns: 1fr;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .product-card {
        border-width: 2px;
    }
    
    .search-highlight {
        background: #000;
        color: #fff;
    }
}
