/* ===================================
   MODERN FILTERS SYSTEM - Similar to Mercado Livre
   =================================== */

/* Prevent zoom on mobile inputs */
input[type="text"],
input[type="search"],
input[type="number"],
input[type="email"],
input[type="tel"],
textarea,
select {
    font-size: 16px !important;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="search"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Filters Container */
.filters-container {
    display: block;
    margin-top: 24px;
    position: relative;
}

/* Filter Toggle Button - Always visible */
.filter-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid #e0e0e0;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.3s ease;
    margin-bottom: 16px;
}

.filter-toggle-btn:hover {
    background: #f5f5f5;
    border-color: var(--primary-color);
}

.filter-toggle-btn svg {
    width: 20px;
    height: 20px;
}

/* Sidebar Filters - Always as overlay */
.filters-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 380px;
    height: 100vh;
    background: white;
    padding: 24px;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    overflow-y: auto;
    transition: left 0.3s ease;
    border-radius: 0;
}

.filters-sidebar.mobile-open {
    left: 0;
}

/* Filters Header */
.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f0f0f0;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
    margin: -24px -24px 24px -24px;
    padding: 20px 24px 16px 24px;
}

.filters-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.clear-filters-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.clear-filters-btn:hover {
    background: var(--primary-light);
}

.close-filters-btn {
    display: block;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-secondary);
}

.close-filters-btn:hover {
    color: var(--text-primary);
}

/* Filter Group */
.filter-group {
    margin-bottom: 28px;
}

.filter-group-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.filter-group-title svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.filter-group-title.collapsed svg {
    transform: rotate(-90deg);
}

.filter-group-content {
    display: block;
    animation: slideDown 0.3s ease;
}

.filter-group-content.hidden {
    display: none;
}

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

/* Price Range Filter */
.price-range-inputs {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.price-input-wrapper {
    flex: 1;
}

.price-input-wrapper label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.price-input-wrapper input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.price-input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

.price-range-separator {
    color: var(--text-secondary);
    margin-top: 20px;
}

/* Price Range Slider */
.price-range-slider {
    position: relative;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin: 20px 0;
}

.price-range-progress {
    position: absolute;
    height: 100%;
    background: var(--primary-color);
    border-radius: 3px;
}

.price-range-values {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Checkbox Filter Options */
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 0;
    transition: all 0.2s ease;
}

.filter-option:hover {
    padding-left: 4px;
}

.filter-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.filter-option label {
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-option-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Search within filter */
.filter-search {
    margin-bottom: 12px;
}

.filter-search input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.filter-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

/* Show More/Less Button */
.show-more-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
    margin-top: 8px;
    transition: all 0.3s ease;
}

.show-more-btn:hover {
    text-decoration: underline;
}

/* Products Main Content */
.products-main-content {
    flex: 1;
    min-width: 0;
}

/* Active Filters Tags */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.filter-tag button {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    line-height: 1;
}

.filter-tag button:hover {
    opacity: 0.7;
}

/* Products Header */
.products-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.products-count {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.products-sort {
    display: flex;
    align-items: center;
    gap: 12px;
}

.products-sort label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.products-sort select {
    padding: 8px 32px 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    background: white;
    color: var(--text-primary);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: all 0.3s ease;
}

.products-sort select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Products Grid - Updated to work with filters */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

/* Empty State */
.no-products-found {
    text-align: center;
    padding: 60px 20px;
    grid-column: 1 / -1;
}

.no-products-found svg {
    width: 80px;
    height: 80px;
    color: #ccc;
    margin-bottom: 16px;
}

.no-products-found h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.no-products-found p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Filters Overlay - Always available */
.filters-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.filters-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media screen and (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 25px;
    }
}

@media screen and (max-width: 768px) {
    .filters-sidebar {
        max-width: 320px;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }

    .products-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .products-sort {
        width: 100%;
    }

    .products-sort select {
        flex: 1;
    }
}

@media screen and (max-width: 480px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .price-range-inputs {
        flex-direction: column;
        gap: 12px;
    }

    .price-range-separator {
        display: none;
    }
}

/* Loading State */
.filters-loading,
.products-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
