/**
 * Phase 3: Advanced Listing Enhancements
 * Modern filtering, search, and comparison features
 */

/* ===========================
   ADVANCED FILTER PANEL
   =========================== */

.filter-panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: var(--space-5);
    margin-bottom: var(--space-5);
}

.filter-section {
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-5);
    border-bottom: 1px solid #f1f5f9;
}

.filter-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.filter-section-title {
    font-size: var(--text-base);
    font-weight: 700;
    color: #1e293b;
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.filter-section-title .icon {
    font-size: 18px;
}

/* Multi-select checkboxes */
.filter-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: background-color 0.2s;
}

.filter-checkbox:hover {
    background-color: #f8fafc;
}

.filter-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3b82f6;
}

.filter-checkbox label {
    cursor: pointer;
    flex: 1;
    font-size: var(--text-sm);
    color: #475569;
}

.filter-checkbox .count {
    font-size: var(--text-xs);
    color: #94a3b8;
    margin-left: auto;
}

/* Range Sliders */
.range-filter {
    padding: var(--space-3) 0;
}

.range-slider {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.range-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.range-values {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: #64748b;
}

.range-value {
    font-weight: 600;
    color: #3b82f6;
}

/* ===========================
   SMART SEARCH WITH AUTOCOMPLETE
   =========================== */

.search-wrapper {
    position: relative;
    margin-bottom: var(--space-4);
}

.search-input-enhanced {
    width: 100%;
    height: 50px;
    padding: 0 50px 0 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: var(--text-base);
    transition: all 0.2s;
}

.search-input-enhanced:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
    position: absolute;
    right: 2px;
    top: 54%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 20px;
    pointer-events: none;
}

/* Autocomplete Dropdown */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    margin-top: 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.search-suggestions.active {
    display: block;
}

.suggestion-section {
    padding: var(--space-3);
    border-bottom: 1px solid #f1f5f9;
}

.suggestion-section:last-child {
    border-bottom: none;
}

.suggestion-header {
    font-size: var(--text-xs);
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-2);
}

.suggestion-item {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    transition: background-color 0.15s;
}

.suggestion-item:hover {
    background-color: #f8fafc;
}

.suggestion-item.active {
    background-color: #eff6ff;
}

.suggestion-icon {
    font-size: 16px;
    color: #94a3b8;
}

.suggestion-text {
    flex: 1;
    font-size: var(--text-sm);
    color: #334155;
}

.suggestion-meta {
    font-size: var(--text-xs);
    color: #94a3b8;
}

/* ===========================
   VIEW OPTIONS & SORTING
   =========================== */

.listing-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.view-toggle {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    border-radius: var(--radius-md);
    padding: 4px;
}

.view-btn {
    height: 36px;
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

.view-btn.active {
    background: white;
    color: #3b82f6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.sort-dropdown {
    position: relative;
    display: inline-block;
}

.sort-button {
    height: 36px;
    padding: 0 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    transition: all 0.2s;
}

.sort-button:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.sort-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    min-width: 200px;
    display: none;
    z-index: 50;
}

.sort-menu.active {
    display: block;
}

.sort-option {
    padding: var(--space-2) var(--space-4);
    cursor: pointer;
    font-size: var(--text-sm);
    color: #334155;
    transition: background-color 0.15s;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.sort-option:hover {
    background-color: #f8fafc;
}

.sort-option.active {
    background-color: #eff6ff;
    color: #3b82f6;
    font-weight: 600;
}

/* ===========================
   COMPARISON FEATURE
   =========================== */

.compare-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid #e2e8f0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    padding: var(--space-4);
    z-index: var(--z-sticky);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.compare-bar.active {
    transform: translateY(0);
}

.compare-bar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.compare-items {
    display: flex;
    gap: var(--space-3);
    flex: 1;
    overflow-x: auto;
}

.compare-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: #f8fafc;
    border-radius: var(--radius-md);
    min-width: 200px;
}

.compare-item-name {
    flex: 1;
    font-size: var(--text-sm);
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-item-remove {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    font-size: 18px;
    transition: color 0.2s;
}

.compare-item-remove:hover {
    color: #ef4444;
}

.compare-actions {
    display: flex;
    gap: var(--space-2);
}

/* Comparison checkbox on cards */
.compare-checkbox-wrapper {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
}

.compare-checkbox-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.compare-checkbox-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.compare-checkbox-label:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.compare-checkbox-input:checked + .compare-checkbox-label {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.compare-checkbox-label::before {
    content: '✓';
    font-size: 16px;
    font-weight: bold;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s;
}

.compare-checkbox-input:checked + .compare-checkbox-label::before {
    opacity: 1;
    transform: scale(1);
}

/* List View Mode */
.manufacturer-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.manufacturer-grid.list-view .manufacturer-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: var(--space-4);
}

.manufacturer-grid.list-view .card-media {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.manufacturer-grid.list-view .card-body {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: var(--space-4);
}

/* Active Filter Pills */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 6px 12px;
    background: #eff6ff;
    color: #3b82f6;
    border-radius: 20px;
    font-size: var(--text-sm);
    font-weight: 600;
}

.filter-pill-remove {
    background: none;
    border: none;
    color: #3b82f6;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-size: 16px;
    transition: color 0.2s;
}

.filter-pill-remove:hover {
    color: #2563eb;
}

/* ===========================
   RESPONSIVE
   =========================== */

@media (max-width: 768px) {
    .filter-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s;
        overflow-y: auto;
        border-radius: 0;
        max-width: 100%;
    }
    
    .filter-panel.active {
        transform: translateX(0);
    }
    
    .compare-bar-inner {
        flex-direction: column;
        align-items: stretch;
    }
    
    .compare-items {
        flex-direction: column;
    }
    
    .listing-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .manufacturer-grid.list-view .manufacturer-card {
        flex-direction: column;
    }
    
    .manufacturer-grid.list-view .card-media {
        width: 100%;
        height: 200px;
    }
}
