/**
 * ReliableGun Theme - Search & Filter Styles
 */

/* ============= ENHANCED INSTANT SEARCH ============= */

#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 500px;
    overflow-y: auto;
    z-index: 1000;
}

#search-results .results {
    padding: 0;
}

#search-results .loading,
#search-results .error,
#search-results .no-results p {
    padding: 20px;
    text-align: center;
    color: #666;
}

#search-results .result {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

#search-results .result:hover,
#search-results .result.selected {
    background: #f5f5f5;
}

#search-results .result figure {
    display: flex;
    align-items: center;
    flex: 1;
    margin: 0;
}

#search-results .result-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    margin-right: 12px;
    overflow: hidden;
    background: #f9f9f9;
    border-radius: 4px;
}

#search-results .result-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#search-results figcaption {
    flex: 1;
}

#search-results .result-title {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}

#search-results .result-title mark {
    background: #ffd700;
    padding: 0 2px;
    font-weight: 700;
}

#search-results .result-sku {
    display: block;
    font-size: 0.85em;
    color: #888;
}

#search-results .price {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--reliable-red, #c41e3a);
    margin-left: 15px;
}

#search-results .result-group {
    border-top: 2px solid #eee;
}

#search-results .result-group:first-child {
    border-top: none;
}

#search-results .group-title {
    padding: 10px 15px;
    margin: 0;
    background: #f9f9f9;
    font-size: 0.9em;
    font-weight: 700;
    text-transform: uppercase;
    color: #666;
    border-bottom: 1px solid #eee;
}

#search-results .search-footer {
    padding: 12px 15px;
    background: #f9f9f9;
    border-top: 2px solid #eee;
    text-align: center;
}

#search-results .view-all {
    display: inline-block;
    padding: 8px 20px;
    background: var(--reliable-red, #c41e3a);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: background 0.3s;
}

#search-results .view-all:hover {
    background: #a01828;
}

#search-results .recent-searches {
    padding: 15px;
}

#search-results .recent-searches h4 {
    margin: 0 0 10px 0;
    font-size: 0.9em;
    text-transform: uppercase;
    color: #888;
}

#search-results .recent-search-item {
    display: block;
    padding: 8px 12px;
    margin-bottom: 5px;
    background: #f5f5f5;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    transition: background 0.2s;
}

#search-results .recent-search-item:hover {
    background: #e8e8e8;
}

#search-results .recent-search-item i {
    color: #999;
    margin-right: 8px;
}

/* ============= CATALOG FILTERS ============= */

.catalog-filters {
    background: #fff;
    border-radius: 4px;
    padding: 20px 20px 0 20px;
}

.filter-group {
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.filter-group:last-child {
    border-bottom: none;
}

.filter-group legend {
    font-weight: 700;
    font-size: 1.1em;
    margin-bottom: 12px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.filter-group legend::after {
    content: '−';
    font-size: 1.3em;
    color: #999;
    transition: transform 0.3s;
}

.filter-group.collapsed legend::after {
    transform: rotate(90deg);
}

.filter-group.collapsed .filter-options,
.filter-group.collapsed .filter-search-box {
    display: none !important;
}

.filter-search-toggle {
    background: none;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
    margin-left: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filter-search-toggle:hover,
.filter-search-toggle.active {
    background: var(--reliable-red, #c41e3a);
    border-color: var(--reliable-red, #c41e3a);
    color: #fff;
}

.filter-search-box {
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95em;
}

.filter-search-box:focus {
    outline: none;
    border-color: var(--reliable-red, #c41e3a);
    box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
}

.filter-options {
    max-height: 250px;
    overflow-y: auto;
}

.filter-options label {
    display: block;
    padding: 8px 0;
    cursor: pointer;
    transition: color 0.2s;
}

.filter-options label:hover {
    color: var(--reliable-red, #c41e3a);
}

.filter-options input[type="checkbox"],
.filter-options input[type="radio"] {
    margin-right: 8px;
}

.filter-no-results {
    padding: 12px;
    text-align: center;
    color: #999;
    font-style: italic;
}

.apply-filters,
.clear-filters {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-right: 10px;
}

.apply-filters {
    background: var(--reliable-red, #c41e3a);
    color: #fff;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.3s;
}

.apply-filters.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.apply-filters:hover:not(:disabled) {
    background: #a01828;
}

.apply-filters:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.clear-filters {
    background: #f5f5f5;
    color: #333;
}

.clear-filters:hover {
    background: #e8e8e8;
}

/* ============= PRICE RANGE FILTER ============= */

.price-range-filter {
    padding: 15px 0;
}

.price-range-display {
    display: block;
    text-align: center;
    font-weight: 700;
    font-size: 1.1em;
    margin-bottom: 15px;
    color: var(--reliable-red, #c41e3a);
}

.price-range-filter input[type="range"] {
    width: 100%;
    margin: 8px 0;
}

.price-range-filter input[type="number"] {
    width: calc(50% - 10px);
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-right: 10px;
}

.price-range-filter input[type="number"]:last-of-type {
    margin-right: 0;
}

/* ============= ACTIVE FILTER CHIPS ============= */

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.9em;
}

.filter-chip .remove-filter {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    margin-left: 8px;
    padding: 0;
    font-size: 1.2em;
    line-height: 1;
    transition: color 0.2s;
}

.filter-chip .remove-filter:hover {
    color: var(--reliable-red, #c41e3a);
}

/* ============= LOADING OVERLAY ============= */

.filter-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    text-align: center;
}

.loading-spinner::before {
    content: '';
    display: block;
    width: 50px;
    height: 50px;
    margin: 0 auto 15px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--reliable-red, #c41e3a);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner span {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
}

/* ============= MOBILE RESPONSIVE ============= */

@media (max-width: 768px) {
    .catalog-filters {
        position: fixed;
        top: 0;
        left: -100%;
        bottom: 0;
        width: 80%;
        max-width: 320px;
        z-index: 1000;
        transition: left 0.3s;
        overflow-y: auto;
    }
    
    .catalog-filters.open {
        left: 0;
    }
    
    .filter-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        display: none;
        z-index: 999;
    }
    
    .filter-overlay.show {
        display: block;
    }
    
    #search-results {
        max-height: 70vh;
    }
}
