/* Filter Sidebar Styles */
.products-layout {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

.filter-sidebar {
    width: 300px;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow-x: hidden;
}

.products-main {
    flex: 1;
    min-width: 0;
}

/* Mobile Filter Toggle */
.mobile-filter-toggle {
    display: none;
    margin: 20px 0;
}

.filter-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #007cba;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 100%;
    justify-content: center;
}

.filter-toggle-btn:hover {
    background: #005a87;
}

.filter-icon {
    transition: transform 0.3s ease;
}

.filter-toggle-btn.active .filter-icon {
    transform: rotate(180deg);
}

/* Filter Header */
.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.filter-header h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
    font-weight: 600;
}

.clear-filters-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.clear-filters-btn:hover {
    background: #c82333;
}

/* Active Filters */
.active-filters {
    margin-bottom: 20px;
}

.active-filter-tag {
    display: inline-flex;
    align-items: center;
    background: #e3f2fd;
    color: #1976d2;
    padding: 4px 8px;
    margin: 2px;
    border-radius: 16px;
    font-size: 12px;
    gap: 6px;
}

.active-filter-tag .remove-filter {
    background: none;
    border: none;
    color: #1976d2;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.active-filter-tag .remove-filter:hover {
    background: rgba(25, 118, 210, 0.1);
}

/* Filter Sections */
.filter-sections {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 15px;
    margin-right: -15px;
}

.filter-section {
    margin-bottom: 25px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 20px;
}

.filter-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.filter-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 12px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.filter-title::after {
    content: '+';
    font-size: 18px;
    transition: transform 0.3s ease;
}

.filter-section.collapsed .filter-title::after {
    content: '−';
    transform: none;
}

.filter-section.collapsed .filter-options {
    display: none;
}

/* Filter Title with Toggle (for size) */
.filter-title-with-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.filter-title-with-toggle .filter-title {
    margin: 0;
}

.filter-title-with-toggle .filter-title::after {
    display: none;
}

/* Unit Toggle */
.unit-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
}

.unit-label {
    color: #666;
    transition: color 0.3s ease;
}

.unit-label.active {
    color: #007cba;
    font-weight: 600;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 20px;
}

.toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 20px;
}

.toggle-label:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-input:checked+.toggle-label {
    background-color: #007cba;
}

.toggle-input:checked+.toggle-label:before {
    transform: translateX(20px);
}

/* Filter Options */
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 0;
    transition: background-color 0.2s ease;
    border-radius: 4px;
    padding-left: 8px;
    padding-right: 8px;
}

.filter-option:hover {
    background-color: #f8f9fa;
}

.filter-option input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 3px;
    margin-right: 10px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.filter-option input[type="checkbox"]:checked+.checkmark {
    background-color: #007cba;
    border-color: #007cba;
}

.filter-option input[type="checkbox"]:checked+.checkmark::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 12px;
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.option-text {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.option-count {
    font-size: 12px;
    color: #666;
    margin-left: auto;
}

.filter-option.no-results {
    opacity: 0.5;
    pointer-events: none;
}

.filter-option.no-results .option-text {
    color: #999;
}

/* Products Header */
.products-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-select-wrapper select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.results-info {
    font-size: 14px;
    color: #666;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.product-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.product-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.product-title {
    padding: 15px;
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    line-height: 1.4;
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .mobile-filter-toggle {
        display: block;
    }

    .products-layout {
        flex-direction: column;
        gap: 20px;
    }

    .filter-sidebar {
        width: 100%;
        position: static;
        background: white;
        border-radius: 8px;
        padding: 0;
        height: auto;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        transition: all 0.3s ease;
        max-height: 0;
        opacity: 0;
    }

    .filter-sidebar.active {
        max-height: 2000px;
        opacity: 1;
        padding: 20px;
    }

    .filter-sidebar .filter-header {
        position: static;
        background: transparent;
        z-index: auto;
        margin: 0;
        padding: 0 0 15px 0;
    }

    .products-main {
        width: 100%;
    }

    .products-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }

    .filter-sections {
        max-height: none;
        padding-right: 0;
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .product-card .product-title {
        font-size: 14px;
        padding: 12px;
    }

    .filter-sidebar {
        padding: 15px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for accessibility */
.filter-option:focus-within,
.toggle-label:focus-within,
.filter-toggle-btn:focus,
.clear-filters-btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}