/* ========================================
   FIX DEMANDA 23 - Produtos Page
   Correções para filtros de classe
   ======================================== */

/* ========================================
   FILTROS - PREVENÇÃO DE MUDANÇA DE TAMANHO
   ======================================== */

/* Garantir que o botão "Todas as Classes" mantenha tamanho consistente */
.filter-item {
    min-height: 44px; /* Altura mínima consistente */
    margin-bottom: 8px; /* Espaçamento consistente */
}

.filter-item a {
    min-height: 44px !important; /* Mesma altura para todos os links */
    height: 44px !important; /* Altura fixa */
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 10px 12px !important;
    white-space: nowrap; /* Previne quebra de linha */
    box-sizing: border-box !important;
}

.filter-item a span:first-child {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
    line-height: 1.4;
}

.filter-count {
    flex-shrink: 0 !important; /* Previne que o contador encolha */
    min-width: 28px !important;
    width: auto !important;
    text-align: center !important;
    padding: 2px 8px !important;
    height: 20px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ========================================
   TRANSIÇÕES SUAVES PARA FILTROS
   ======================================== */

.filter-item a {
    transition: all 0.2s ease !important;
    will-change: background, color, transform;
}

/* Prevenir mudança de layout ao ativar */
.filter-item.active a {
    box-shadow: 0 2px 8px rgba(202, 142, 20, 0.25);
}

/* ========================================
   BOTÃO "VER TODAS" - FIX
   ======================================== */

.btn-show-all-filters {
    min-height: 44px; /* Altura consistente */
    flex-shrink: 0; /* Não encolhe */
}

/* ========================================
   LISTA DE FILTROS - LAYOUT ESTÁVEL
   ======================================== */

.filter-list {
    width: 100%;
    min-height: 48px; /* Altura mínima para prevenir colapso */
    display: flex;
    flex-direction: column;
    gap: 0 !important; /* Remove gap que pode causar mudanças */
}

/* Garantir que itens escondidos não ocupem espaço */
.filter-item[style*="display: none"],
.filter-item[style*="height: 0"] {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

/* Garantir que itens visíveis mantenham estrutura */
.filter-item:not([style*="display: none"]) {
    display: block !important;
    height: auto !important;
    min-height: 44px !important;
    margin-bottom: 8px !important;
}

/* ========================================
   SCROLLBAR - ESPAÇO RESERVADO
   ======================================== */

.filter-scrollable {
    padding-right: 8px !important; /* Espaço para scrollbar */
    margin-right: -8px !important;
    scrollbar-gutter: stable; /* Mantém espaço para scrollbar */
}

/* ========================================
   RESPONSIVO - MANTER CONSISTÊNCIA
   ======================================== */

@media (max-width: 991px) {
    .filter-item {
        min-height: 42px;
    }
    
    .filter-item a {
        min-height: 42px;
        padding: 9px 11px !important;
    }
}

@media (max-width: 767px) {
    .filter-item {
        min-height: 40px;
    }
    
    .filter-item a {
        min-height: 40px;
        padding: 8px 10px !important;
        font-size: 14px;
    }
    
    .filter-count {
        min-width: 24px !important;
        font-size: 10px;
    }
}

/* ========================================
   ANIMAÇÃO SUAVE NA EXPANSÃO
   ======================================== */

.filter-item {
    animation: filterFadeIn 0.2s ease-out;
}

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

/* Remover animação de itens já visíveis */
.filter-list .filter-item:nth-child(-n+10) {
    animation: none;
}

/* ========================================
   FIX PARA MOBILE - SIDEBAR
   ======================================== */

@media (max-width: 991px) {
    .filters-sidebar {
        overflow-y: auto !important; /* Permitir scroll */
        max-height: 100vh !important;
    }
    
    .filter-section {
        flex-shrink: 0; /* Não encolhe */
    }
}

/* ========================================
   OTIMIZAÇÃO DE PERFORMANCE
   ======================================== */

.filter-item a {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* ========================================
   ESTADOS DISABLED
   ======================================== */

.filter-item.disabled a {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.filter-item.disabled .filter-count {
    background: #e9ecef;
    color: #6c757d;
}
