.wowplatter-top-filter {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 0; /* Removed padding, now handled by content */
    margin: 16px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    overflow: hidden; /* Important for clean collapse */
}

.wowplatter-top-filter:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Toggle Header */
.top-filter-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    background: #f8f9fa; /* Match filter background */
    font-weight: 600;
    font-size: 13px;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
    border-bottom: 1px solid transparent; /* Prepare for expanded state */
    transition: background-color 0.2s ease, color 0.2s ease;
}

.top-filter-toggle:hover {
    background-color: #e9ecef;
    color: #212529;
}

.top-filter-toggle i {
    transition: transform 0.3s ease;
    font-size: 12px;
}

/* Expanded State for Toggle */
.top-filter-toggle[aria-expanded="true"] {
    background-color: #e9ecef;
    border-bottom-color: #dee2e6;
    color: #212529;
}

.top-filter-toggle[aria-expanded="true"] i {
    transform: rotate(180deg);
}

/* Content Container - Hidden by default */
.top-filter-content {
    display: none;
    padding: 16px;
    background: #ffffff; /* Slightly lighter inner background */
}

/* Show content when toggled open */
.top-filter-content.expanded {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Rest of the existing CSS (adapted) */
.top-filter-dropdowns {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    margin-bottom: 12px;
}

.top-filter-dropdown-wrapper {
    display: flex;
    flex-direction: column;
    min-width: 140px;
    flex: 1 1 calc(33.333% - 16px);
}

.top-filter-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.top-filter-label i {
    font-size: 11px;
    color: #6c757d;
}

.top-filter-select {
    background-color: #ffffff !important;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    color: #333333 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 32px;
}

.top-filter-select option {
    background-color: #ffffff;
    color: #333333;
}

.top-filter-select:hover {
    border-color: #80bdff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

.top-filter-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.2);
}

.top-filter-select:not([value=""]) {
    background-color: #e3f2fd;
    border-color: #2196f3;
    font-weight: 500;
}

.top-filter-active-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    min-height: 32px;
    padding: 8px 0;
    border-top: 1px solid #e9ecef;
    margin-top: 12px;
}

.top-filter-active-tags:empty {
    display: none;
}

.top-filter-tag {
    display: inline-flex;
    align-items: center;
    background: #0056b3;
    color: white;
    padding: 3px 8px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,123,255,0.2);
    transition: all 0.2s ease;
    animation: slideInUp 0.25s ease;
}

.top-filter-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.3);
}

.top-filter-tag .tag-label {
    margin-right: 4px;
    opacity: 0.9;
}

.top-filter-tag .tag-value {
    font-weight: 600;
}

.top-filter-tag .tag-remove {
    background: none;
    border: none;
    color: white;
    margin-left: 8px;
    padding: 1px;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.top-filter-tag .tag-remove:hover {
    background: rgba(255,255,255,0.2);
    opacity: 1;
    transform: scale(1.1);
}

.top-filter-tag .tag-remove i {
    font-size: 10px;
}

.top-filter-clear-all {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(220,53,69,0.2);
}

.top-filter-clear-all:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220,53,69,0.3);
}

.top-filter-clear-all i {
    font-size: 10px;
}

.top-filter-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e9ecef;
}

.top-filter-info .filter-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #6c757d;
    font-weight: 500;
}

.top-filter-info .filter-count i {
    color: #007bff;
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.8); }
}

.top-filter-tag.removing {
    animation: fadeOut 0.2s ease forwards;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .wowplatter-top-filter {
        /* Remove padding top that was previously there for absolute positioning */
        padding: 0; 
        margin: 12px 0;
        width: 100%;
        max-width: 100%;
    }

    .top-filter-toggle {
        padding: 10px 12px; /* Slightly smaller on mobile */
    }

    .top-filter-content {
        padding: 12px;
    }

    .top-filter-dropdowns {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        align-items: stretch;
    }

    .top-filter-dropdown-wrapper {
        min-width: auto;
        flex: 0 0 auto;
        width: 100%;
    }

    /* Override previous mobile styles that hid selects */
    .top-filter-dropdown-wrapper .top-filter-select {
        display: block !important; /* Always show select in dropdown */
    }

    /* Hide label if desired, or keep it */
    .top-filter-label {
        font-size: 11px;
        justify-content: flex-start; /* Reset from center */
        text-align: left;
        width: auto;
    }
    
    .top-filter-select {
        padding: 6px 10px;
        font-size: 13px;
        padding-right: 28px;
        background-size: 14px;
    }

    .top-filter-active-tags {
        gap: 6px;
        display: flex; /* Reset grid if it was grid */
        flex-wrap: wrap;
    }

    .top-filter-tag {
        padding: 2px 6px;
        padding-right: 24px; /* Space for X */
        font-size: 10px;
    }

    .top-filter-tag .tag-remove {
        position: absolute;
        right: 4px;
        margin: 0;
    }

    .top-filter-price-range .top-filter-price {
        flex-wrap: wrap; /* allow wrapping on small screens */
    }
    
    .top-filter-sort-controls {
        width: 100%;
        justify-content: space-between;
        margin-top: 8px;
        margin-left: 0;
    }
    
    .sort-toggle {
        flex: 1;
        text-align: center;
        justify-content: center;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .wowplatter-top-filter {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .top-filter-toggle {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .top-filter-toggle:hover,
    .top-filter-toggle[aria-expanded="true"] {
        background: #4a5568;
        color: #ffffff;
    }
    
    .top-filter-content {
        background: #2d3748; /* Match or slightly lighter */
    }

    .top-filter-label {
        color: #cbd5e0;
    }

    .top-filter-select {
        background: #4a5568 !important;
        border-color: #718096;
        color: #e2e8f0 !important;
    }
    
    .top-filter-select option {
        background-color: #4a5568;
        color: #e2e8f0;
    }

    .top-filter-select:hover {
        border-color: #63b3ed;
    }

    .top-filter-select:focus {
        border-color: #3182ce;
        box-shadow: 0 0 0 3px rgba(49,130,206,0.2);
    }

    .top-filter-active-tags {
        border-color: #4a5568;
    }

    .top-filter-info {
        border-color: #4a5568;
    }

    .top-filter-info .filter-count {
        color: #a0aec0;
    }
}

/* Price Range Styles */
.top-filter-price-range .top-filter-price {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: space-between;
}

.top-filter-price-range .price-values {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #6c757d;
}

.top-filter-price-range .top-filter-input {
    background: #ffffff;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    width: auto;
    flex: 1 1 0;
    min-width: 60px;
}

.top-filter-price-range .price-sep {
    color: #6c757d;
    flex: 0 0 10px;
    text-align: center;
}

/* Sort Controls */
.top-filter-sort-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.sort-toggle {
    background: #ffffff;
    border: 1px solid #ced4da;
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 12px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.top-filter-sort-controls .sort-toggle[data-direction="asc"]::after {
    content: " ↑";
}

.top-filter-sort-controls .sort-toggle[data-direction="desc"]::after {
    content: " ↓";
}

.sort-toggle:hover {
    border-color: #80bdff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

.sort-toggle[aria-pressed="true"] {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #0b5ed7;
    font-weight: 600;
}

.sort-toggle.inactive {
    opacity: 0.6;
}

@media (prefers-color-scheme: dark) {
    .sort-toggle {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    .sort-toggle[aria-pressed="true"] {
        background: #2b6cb0;
        border-color: #2b6cb0;
        color: #e2e8f0;
    }
}