/**
 * Catalog Search Styles
 * Styles for the new API-driven product search components
 */

/* ===== SMART AUTOCOMPLETE STYLES ===== */
.nav-autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    max-height: 500px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
    display: none;
}

.nav-autocomplete-list.active {
    display: block;
}

.autocomplete-suggestions {
    padding: 4px 0;
}

.autocomplete-item {
    padding: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
    border-bottom: 1px solid #f3f4f6;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #f9fafb;
}

.autocomplete-item.selected {
    background: #ecfdf5;
}

/* Product image in autocomplete */
.suggestion-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.suggestion-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Product details */
.suggestion-details {
    flex: 1;
    min-width: 0;
}

/* Full width details for no-image layout */
.suggestion-details-full {
    flex: 1;
    min-width: 0;
}

.suggestion-style-number {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Adjust layout when no image */
.autocomplete-item.no-image {
    padding: 10px 12px;
    gap: 0;
}

.autocomplete-item.no-image .suggestion-details-full {
    padding-right: 12px;
}

.suggestion-product-name {
    color: #6b7280;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.suggestion-colors {
    font-size: 11px;
    color: #9ca3af;
}

/* Price display */
.suggestion-price {
    font-weight: 600;
    color: #4cb354;
    font-size: 14px;
    margin-left: auto;
    padding-left: 12px;
}

/* Best match badge */
.suggestion-badge {
    background: #4cb354;
    color: white;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* Footer hint */
.autocomplete-footer {
    padding: 8px 12px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    font-size: 11px;
    color: #6b7280;
    text-align: center;
}

.autocomplete-footer kbd {
    background: white;
    border: 1px solid #d1d5db;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-family: monospace;
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}

/* Loading, error, and no results states */
.autocomplete-loading,
.autocomplete-no-results,
.autocomplete-error {
    padding: 20px;
    text-align: center;
    color: #6b7280;
}

.autocomplete-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top-color: #4cb354;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Make sure search container has position relative for absolute dropdown */
.nav-search {
    position: relative;
}

/* ===== FILTER SIDEBAR ===== */
.filters-sidebar {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.filters-container {
    position: relative;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e5e7eb;
}

.filters-header h3 {
    font-size: 1.25rem;
    color: #1f2937;
    margin: 0;
}

.clear-filters-btn {
    background: none;
    border: none;
    color: #4cb354;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 0.2s;
}

.clear-filters-btn:hover {
    background: #f3f4f6;
}

/* Filter Sections */
.filter-section {
    margin-bottom: 25px;
}

.filter-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 0;
    font-size: 0.875rem;
    color: #374151;
}

.filter-option:hover {
    color: #4cb354;
}

.filter-option input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.filter-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.option-name {
    flex: 1;
}

.option-count {
    color: #9ca3af;
    font-size: 0.75rem;
    margin-left: 4px;
}

/* Price Filter */
.price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.price-inputs input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.875rem;
}

.price-apply-btn {
    padding: 6px 12px;
    background: #4cb354;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.price-apply-btn:hover {
    background: #409a47;
}

.price-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.price-range-btn {
    padding: 4px 8px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.price-range-btn:hover {
    background: #4cb354;
    color: white;
    border-color: #4cb354;
}

/* Color Filter */
.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 8px;
}

.color-option {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: #4cb354;
    box-shadow: 0 0 0 2px rgba(76, 179, 84, 0.2);
}

.color-swatch {
    width: 100%;
    height: 100%;
    border-radius: 2px;
    border: 1px solid #e5e7eb;
}

.color-count {
    position: absolute;
    bottom: -6px;
    right: -6px;
    background: #1f2937;
    color: white;
    font-size: 0.625rem;
    padding: 2px 4px;
    border-radius: 10px;
    line-height: 1;
}

/* Size Filter */
.size-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}

.size-option {
    padding: 8px 4px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    font-size: 0.875rem;
    transition: all 0.2s;
    position: relative;
}

.size-option:hover:not(.disabled) {
    background: #f3f4f6;
    border-color: #4cb354;
}

.size-option.selected {
    background: #4cb354;
    color: white;
    border-color: #4cb354;
}

.size-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.size-count {
    display: block;
    font-size: 0.625rem;
    margin-top: 2px;
    opacity: 0.8;
}

/* Brand Search */
.filter-search {
    margin-bottom: 10px;
}

.brand-search {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.875rem;
}

.filter-options.scrollable {
    max-height: 200px;
    overflow-y: auto;
}

/* ===== PRODUCT GRID ===== */
.product-grid-container {
    flex: 1;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.results-info h2 {
    font-size: 1.5rem;
    margin: 0;
    color: #1f2937;
}

.results-count {
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: 4px;
}

.results-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.sort-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-control label {
    font-size: 0.875rem;
    color: #6b7280;
}

.sort-select {
    padding: 6px 30px 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: white;
    font-size: 0.875rem;
    cursor: pointer;
}

.view-controls {
    display: flex;
    gap: 4px;
}

.view-btn {
    padding: 6px 8px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.view-btn:hover {
    background: #f3f4f6;
}

.view-btn.active {
    background: #4cb354;
    border-color: #4cb354;
    color: white;
}

.view-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Products Grid */
.products-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 40px;
}

.products-grid[data-view="grid"] {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.products-grid[data-view="list"] {
    grid-template-columns: 1fr;
}

/* Product Card */
.product-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.product-image-container {
    position: relative;
    padding-top: 100%; /* 1:1 aspect ratio */
    background: #f9fafb;
    overflow: hidden;
}

.product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

.badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 8px;
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge.top-seller {
    background: #f59e0b;
}

.badge.sale {
    background: #ef4444;
}

.product-quick-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.product-card:hover .product-quick-actions {
    opacity: 1;
}

.quick-view-btn {
    width: 36px;
    height: 36px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-view-btn:hover {
    background: #4cb354;
    border-color: #4cb354;
    color: white;
}

.product-info {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-brand {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.product-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px;
    line-height: 1.4;
}

.product-link {
    color: inherit;
    text-decoration: none;
}

.product-link:hover {
    color: #4cb354;
}

.product-style {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 8px;
}

.product-price {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.price-sale {
    color: #ef4444;
}

.price-original {
    text-decoration: line-through;
    color: #9ca3af;
    font-size: 0.875rem;
    margin-left: 8px;
}

.product-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 10px;
}

.product-colors {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-top: auto;
}

.product-colors .color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
}

.more-colors {
    font-size: 0.75rem;
    color: #6b7280;
    margin-left: 4px;
}

/* List View */
.product-list-item {
    display: flex;
    gap: 20px;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.product-list-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.product-list-item .product-image-container {
    width: 150px;
    height: 150px;
    padding-top: 0;
    flex-shrink: 0;
}

.product-list-item .product-details {
    flex: 1;
}

.product-list-item .product-pricing {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    min-width: 150px;
}

.view-product-btn {
    padding: 8px 16px;
    background: #4cb354;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
}

.view-product-btn:hover {
    background: #409a47;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 40px 0;
    gap: 20px;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-btn {
    padding: 8px 12px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    min-width: 36px;
    text-align: center;
}

.page-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #4cb354;
}

.page-btn.active {
    background: #4cb354;
    color: white;
    border-color: #4cb354;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-ellipsis {
    padding: 0 8px;
    color: #9ca3af;
}

.page-info {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Loading States */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #4cb354;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.infinite-scroll-loader {
    display: flex;
    justify-content: center;
    padding: 20px;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 60px 20px;
}

.no-results-icon {
    color: #d1d5db;
    margin-bottom: 20px;
}

.no-results h3 {
    font-size: 1.25rem;
    color: #4b5563;
    margin: 0 0 8px;
}

.no-results p {
    color: #9ca3af;
    font-size: 0.875rem;
}

/* Color Swatches */
.bg-black { background-color: #000000; }
.bg-white { background-color: #ffffff; border: 1px solid #e5e7eb; }
.bg-grey { background-color: #808080; }
.bg-navy { background-color: #001f3f; }
.bg-blue { background-color: #0074d9; }
.bg-red { background-color: #ff4136; }
.bg-green { background-color: #2ecc40; }
.bg-yellow { background-color: #ffdc00; }
.bg-orange { background-color: #ff851b; }
.bg-purple { background-color: #b10dc9; }
.bg-pink { background-color: #f012be; }
.bg-brown { background-color: #85144b; }
.bg-default { background: linear-gradient(45deg, #e5e7eb 25%, transparent 25%, transparent 75%, #e5e7eb 75%, #e5e7eb), linear-gradient(45deg, #e5e7eb 25%, transparent 25%, transparent 75%, #e5e7eb 75%, #e5e7eb); background-size: 10px 10px; background-position: 0 0, 5px 5px; }

/* Responsive Layout */
.results-section {
    display: flex;
    gap: 20px;
    padding: 20px;
}

.filters-sidebar {
    width: 280px;
    flex-shrink: 0;
}

.products-container {
    flex: 1;
    min-width: 0;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .results-section {
        flex-direction: column;
    }
    
    .filters-sidebar {
        width: 100%;
        position: fixed;
        top: 0;
        left: -100%;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s;
        max-height: 100vh;
    }
    
    .filters-sidebar.filters-open {
        left: 0;
    }
    
    .filters-toggle {
        display: block;
        position: fixed;
        bottom: 20px;
        right: 20px;
        padding: 12px 20px;
        background: #4cb354;
        color: white;
        border: none;
        border-radius: 50px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        z-index: 999;
        cursor: pointer;
    }
    
    .products-grid[data-view="grid"] {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .results-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .product-list-item {
        flex-direction: column;
    }
    
    .product-list-item .product-image-container {
        width: 100%;
        height: 200px;
    }
    
    .product-list-item .product-pricing {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .products-grid[data-view="grid"] {
        grid-template-columns: 1fr;
    }
    
    .color-grid {
        grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    }
    
    .size-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
}

/* Smooth Transitions */
* {
    transition-property: none;
}

.product-card,
.product-list-item,
.filter-option,
.page-btn,
.view-btn,
.color-option,
.size-option {
    transition-property: all;
    transition-duration: 0.2s;
    transition-timing-function: ease-in-out;
}