/* ==============================================================
   ESTRUTURA GERAL (CATEGORIAS E PESQUISA)
   ============================================================== */
.cat-wrapper { 
    width: 100%;
    max-width: 1440px;
    padding: 0 1.25rem;
    margin: 0 auto !important; 
    display: grid; 
    grid-template-columns: 300px 1fr; 
    gap: 16px; 
    align-items: start; 
    transition: 0.3s; 
}

.cat-wrapper.hide-filters { 
    grid-template-columns: 0px 1fr; 
    gap: 0; 
}

.cat-wrapper.hide-filters .sidebar { 
    overflow: hidden; 
    opacity: 0; 
    padding: 0; 
    margin: 0; 
    pointer-events: none; 
}

/* SIDEBAR COM LÓGICA DE TOPO ADAPTATIVA */
.sidebar { 
    background: #fff; 
    border-radius: 4px; 
    padding: 25px 20px; 
    «
    position: sticky;
    transition: top 0.3s ease-in-out, max-height 0.3s ease-in-out, opacity 0.3s;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.sidebar-title { 
    font-size: 16px; 
    font-weight: 900; 
    color: #1e293b; 
    margin-top: 0; 
    margin-bottom: 25px; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
}

.filter-group { 
    margin-bottom: 25px; 
    border-bottom: 1px solid #f1f5f9; 
    padding-bottom: 20px; 
}

.filter-group:last-child { 
    border-bottom: none; 
    padding-bottom: 0; 
    margin-bottom: 0; 
}

.f-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    font-size: 14px; 
    font-weight: 800; 
    color: #1e293b; 
    cursor: pointer; 
    margin-bottom: 15px; 
}

.f-header i { color: #94a3b8; width: 16px; }

.f-option { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    margin-bottom: 12px; 
    cursor: pointer; 
    font-size: 13px; 
    font-weight: 500; 
    color: #000; 
    transition: 0.2s; 
}

.f-option:hover { color: #1e293b; }

.f-option input[type="checkbox"] { 
    width: 18px; 
    height: 18px; 
    border-radius: 4px; 
    
    appearance: none; 
    outline: none; 
    cursor: pointer; 
    background: #fff; 
    transition: 0.2s; 
    margin: 0; 
    display: grid; 
    place-content: center; 
    flex-shrink: 0; 
}

.f-option input[type="checkbox"]::before { 
    content: ""; 
    width: 10px; 
    height: 10px; 
    transform: scale(0); 
    transition: 120ms transform ease-in-out; 
    box-shadow: inset 1em 1em white; 
    background-color: white; 
    transform-origin: center; 
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); 
}

.f-option input[type="checkbox"]:checked { background: #e51b15; border-color: #e51b15; }
.f-option input[type="checkbox"]:checked::before { transform: scale(1); }

.f-count { color: #ababab; font-size: 12px; margin-left: 2px; }

.toggle-wrapper { display: flex; align-items: center; gap: 10px; margin: 0; padding: 0; border: none; }
.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; border-radius: 34px; }
.toggle-slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle-switch input:checked + .toggle-slider { background-color: #e31e24; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(16px); }
.toggle-label { font-size: 13px; color: #1e293b; font-weight: 600; cursor: pointer; }

.range-slider-container { position: relative; height: 4px; background: #e2e8f0; border-radius: 4px; margin: 20px 0 15px; }
.slider-range { position: absolute; height: 100%; background: #e51b15; border-radius: 4px; z-index: 1; pointer-events: none; }
.range-input { position: absolute; width: 100%; top: -6px; height: 16px; appearance: none; background: none; pointer-events: none; margin: 0; outline: none; z-index: 2; }
.range-input::-webkit-slider-thumb { appearance: none; pointer-events: auto; width: 18px; height: 18px; background: #fff; border: 2px solid #e51b15; border-radius: 50%; cursor: pointer; transition: 0.2s; }
.range-input::-moz-range-thumb { pointer-events: auto; width: 18px; height: 18px; background: #fff; border: 2px solid #e51b15; border-radius: 50%; cursor: pointer; transition: 0.2s; }
.price-values { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: #475569; }

.main-area { display: flex; flex-direction: column; gap: 20px; }
.list-topbar { background: #fff; border-radius: 4px; padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; }
.topbar-left { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.btn-toggle-filters { background: transparent; border: 1px solid #cbd5e1; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 700; color: #1e293b; display: flex; align-items: center; gap: 8px; cursor: pointer; transition: 0.2s; font-family: 'Sofia Sans'; }
.btn-toggle-filters:hover { background: #f8fafc; border-color: #94a3b8; }

.topbar-right { display: flex; align-items: center; gap: 20px; font-size: 13px; color: #475569; font-weight: 600; }
.topbar-right select { padding: 6px 30px 6px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-family: inherit; font-size: 13px; font-weight: 700; color: #1e293b; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' 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") no-repeat right 10px center; outline: none; appearance: none; cursor: pointer; }

.p-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-bottom: 0px !important; }

/* REGRAS MOBILE */
.m-filter-sort-bar { display: none; }
.m-filter-overlay { display: none; }
.m-apply-filters-btn { display: none; }
.mobile-only-icon { display: none; }

@media (max-width: 1024px) {
    .cat-wrapper { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .list-topbar { flex-direction: column; align-items: flex-start; gap: 15px; display: none !important; }
    .topbar-right { width: 100%; justify-content: space-between; }
    .toggle-wrapper { width: 100%; justify-content: space-between; border-bottom: 1px solid #f1f5f9; padding-bottom: 10px; margin-bottom: 10px; }
    
    .cat-wrapper, #pageWrapper {
        position: static !important;
        z-index: auto !important;
        transform: none !important;
        padding: 12px;
    }

    .m-filter-sort-bar {
        display: grid;
        grid-template-columns: 1fr 1fr; 
        gap: 10px;
        background: #fff; 
        padding: 10px;
        border-radius: 14px;
        margin-bottom: -10px;
        margin-top: -2px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    }

    .m-fs-btn, .m-fs-select {
        background: #f3f3f3;
        color: var(--text-main);
        border: 0px solid #e2e8f0;
        padding: 8px 5px;
        font-family: 'Sofia Sans', sans-serif;
        font-weight: 700;
        font-size: 14px;
        border-radius: 4px;
        text-align: center;
        cursor: pointer;
        width: 100%;
        outline: none;
        text-transform: uppercase;
        box-sizing: border-box;
    }

    .m-fs-btn { display: flex; justify-content: center; align-items: center; gap: 6px; }
    .m-fs-select { appearance: none; text-align-last: center; }
    .m-fs-select-wrap { position: relative; width: 100%; display: flex; }

    .m-filter-overlay {
        display: block; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
        background: rgba(0,0,0,0.6); z-index: 99990 !important; 
        opacity: 0; visibility: hidden; transition: opacity 0.3s ease;
    }
    .m-filter-overlay.active { opacity: 1; visibility: visible; }

    aside#sidebarFilters {
        position: fixed !important; bottom: -120% !important; left: 0 !important; width: 100vw !important;
        height: 85vh !important; max-height: 85vh !important; background: #fff !important; color: var(--text-main) !important;
        z-index: 99991 !important; transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important; border-radius: 20px 20px 0 0 !important;
        padding: 20px 20px 100px 20px !important; overflow-y: auto !important; top: auto !important; 
        box-shadow: 0 -5px 20px rgba(0,0,0,0.1); display: block !important; visibility: visible !important; opacity: 1 !important;
    }
    aside#sidebarFilters.m-open { bottom: 0 !important; }

    .mobile-only-icon { display: block; }
    .sidebar-title { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 15px; margin-bottom: 20px; }
    
    .m-apply-filters-btn {
        display: block; position: fixed; bottom: -120% !important; left: 0 !important; width: 100vw !important;
        background: #fff; padding: 15px 20px; border-top: 1px solid #e2e8f0; z-index: 99992 !important; 
        transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important; margin: 0 !important; box-sizing: border-box;
    }
    .m-apply-filters-btn.m-open { bottom: 0 !important; }
    
    .m-apply-filters-btn button {
        display: block; width: 100%; text-align: center; background: #e51b15; color: #ffffff; padding: 15px; border-radius: 4px;         
        font-size: 16px; font-weight: 800; text-transform: uppercase; border: none; cursor: pointer; font-family: 'Sofia Sans', sans-serif;
    }
}