/**
 * BDV Filtro - Estilos Clean & Minimal + Mobile Drawer
 */

:root {
    --bdv-primary: #FF6B35;
    --bdv-text-dark: #1e293b;
    --bdv-text-gray: #64748b;
    --bdv-border: #e2e8f0;
    --bdv-bg-light: #f8fafc;
    --bdv-radius: 12px;
}

/* =========================================
   1. ESTRUCTURA GENERAL (Escritorio)
   ========================================= */
.bdv-filtro-panel {
    background: #fff;
    border-radius: var(--bdv-radius);
    padding: 24px;
    margin-bottom: 30px;
    border: 1px solid rgba(0,0,0,0.04);
    position: relative;
    /* Importante para que no se pise en desktop */
    z-index: 10;
}

.bdv-filtro-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--bdv-border);
}

.bdv-filtro-panel__counter {
    font-size: 15px;
    font-weight: 800;
    color: var(--bdv-text-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.bdv-filtro-panel__counter-number { display: none; }

/* Botón Papelera */
.bdv-filtro-panel__reset {
    background: #fee2e2;
    color: #dc2626;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #fecaca;
    font-size: 0;
    cursor: pointer;
    transition: all 0.2s;
}
.bdv-filtro-panel__reset::before { content: '🗑️'; font-size: 14px; }
.bdv-filtro-panel__reset:hover { background: #dc2626; color: #fff; border-color: #dc2626; }

/* Ocultar elementos extra */
.bdv-filtro-view-toggle,
.bdv-filtro-theme-toggle,
.bdv-filtro-saved-filters-toggle,
#bdv-filtro-save-current,
.bdv-filtro-smart-suggestions,
#bdv-filtro-smart-suggestions { display: none !important; }

/* =========================================
   2. FILTROS ACTIVOS
   ========================================= */
.bdv-filtro-active.is-visible {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: none;
}

.bdv-filtro-active-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff5f0;
    border: 1px solid #ffdecb;
    color: var(--bdv-primary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}

.bdv-filtro-active-tag-remove {
    background: transparent;
    border: none;
    color: var(--bdv-primary);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
}

/* =========================================
   3. BÚSQUEDA Y SECCIONES
   ========================================= */
.bdv-filtro-search {
    position: relative;
    margin-bottom: 12px;
    width: 100%;
}

.bdv-filtro-search-input {
    width: 100%;
    padding: 10px 34px 10px 12px;
    background: var(--bdv-bg-light);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    color: var(--bdv-text-dark);
    transition: all 0.2s;
    position: relative;
    z-index: 1;
}

.bdv-filtro-search-input:focus {
    background: #fff;
    border-color: var(--bdv-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.bdv-filtro-search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #94a3b8;
    z-index: 2;
    pointer-events: none;
}

/* Acordeón */
.bdv-filtro-section {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--bdv-border);
    padding-bottom: 20px;
}
.bdv-filtro-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.bdv-filtro-section__toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: none;
    border: none;
    padding: 0;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--bdv-text-dark);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Checkboxes */
.bdv-filtro-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    cursor: pointer;
    padding: 4px 0;
}

.bdv-filtro-item input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    margin-right: 10px;
    cursor: pointer;
    background: #fff;
    transition: all 0.2s;
    flex-shrink: 0;
}

.bdv-filtro-item input[type="checkbox"]:checked {
    background-color: var(--bdv-primary);
    border-color: var(--bdv-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white' width='14px' height='14px'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
}

.bdv-filtro-item input[type="checkbox"]:checked::after { display: none; }
.bdv-filtro-item-text { font-size: 14px; color: var(--bdv-text-gray); }
.bdv-filtro-count { font-size: 11px; color: #94a3b8; margin-left: auto; }

/* =========================================
   4. PRECIO & EXTRAS
   ========================================= */
.bdv-filtro-price-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bdv-bg-light);
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 12px;
    border: 1px solid var(--bdv-border);
}
.bdv-price-label { display: none; }
.bdv-price-value { font-size: 13px; font-weight: 700; color: var(--bdv-text-dark); }
.bdv-price-separator { color: #94a3b8; font-size: 12px; }

.bdv-filtro-price-slider-wrapper {
    position: relative;
    height: 24px;
    margin-top: 10px;
}
.bdv-price-slider {
    position: absolute;
    width: 100%;
    height: 4px;
    background: transparent;
    appearance: none;
    pointer-events: none;
    z-index: 2;
    top: 50%;
    transform: translateY(-50%);
}
.bdv-filtro-price-slider-wrapper::before {
    content: ''; position: absolute; left: 0; right: 0; top: 50%;
    height: 4px; background: #e2e8f0; border-radius: 4px; transform: translateY(-50%); z-index: 1;
}
.bdv-price-slider::-webkit-slider-thumb {
    pointer-events: auto; appearance: none; width: 18px; height: 18px;
    border-radius: 50%; background: #fff; border: 2px solid var(--bdv-primary); cursor: grab; margin-top: 0;
}
.bdv-filtro-price-inputs-hidden { display: none; }

/* Funcionalidad colapsar */
.bdv-filtro-section.is-collapsed .bdv-filtro-section__body { display: none !important; }
.bdv-filtro-section.is-collapsed .bdv-filtro-section__icon { transform: rotate(-90deg); }
.bdv-filtro-item-hidden { display: none !important; }

/* Mostrar más */
.bdv-filtro-show-more {
    width: 100%; text-align: left; background: none; border: none;
    color: var(--bdv-primary); font-size: 12px; font-weight: 600; padding: 8px 0; cursor: pointer; margin-top: 4px;
}
.bdv-filtro-show-more:hover { text-decoration: underline; }
.bdv-filtro-show-less-text { display: none; }
.bdv-filtro-show-more.bdv-filtro-expanded .bdv-filtro-show-more-text { display: none; }
.bdv-filtro-show-more.bdv-filtro-expanded .bdv-filtro-show-less-text { display: inline !important; }

/* Empty State */
#bdv-filtro-empty-state {
    grid-column: 1 / -1; width: 100%; display: none; text-align: center;
    padding: 40px; background: #fff; border: 1px dashed var(--bdv-border); margin-top: 20px; border-radius: var(--bdv-radius);
}
#bdv-filtro-empty-state.active { display: block; }

/* =========================================
   MOBILE: STICKY BAR & DRAWER
   ========================================= */
.bdv-mobile-sticky-bar { display: none; }
.bdv-mobile-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 9998; backdrop-filter: blur(2px);
}
.bdv-mobile-overlay.active { display: block; }

@media (max-width: 992px) { /* Cambiado a 992px para tablets */
    .bdv-mobile-sticky-bar {
        display: flex; position: fixed; bottom: 20px; left: 50%;
        transform: translateX(-50%); z-index: 9999; gap: 10px; width: max-content;
    }

    .bdv-mobile-btn {
        background: #1e293b; color: #fff; border: none; border-radius: 8px;
        padding: 12px 20px; font-size: 14px; font-weight: 600;
        display: flex; align-items: center; gap: 8px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3); cursor: pointer;
    }

    .bdv-mobile-btn:active { transform: scale(0.95); }
    .bdv-mobile-icon { font-size: 18px; line-height: 1; }

    .bdv-mobile-badge {
        background: #fff; color: #1e293b; font-size: 11px; font-weight: 800;
        padding: 2px 6px; border-radius: 4px; min-width: 20px; text-align: center;
    }

    /* Panel DRAWER */
.bdv-filtro-panel {
        display: block !important;
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 350px;
        height: 100vh;
        background: #fff;
        /* Z-INDEX AUMENTADO AL MÁXIMO */
        z-index: 999999; 
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        box-shadow: 4px 0 20px rgba(0,0,0,0.2);
        margin: 0;
        border-radius: 0;
        padding-bottom: 80px;
    }

    .bdv-mobile-overlay {
        /* Z-INDEX AUMENTADO PARA ESTAR DEBAJO DEL PANEL PERO ENCIMA DEL RESTO */
        z-index: 999998; 
    }

    .bdv-filtro-panel.is-open { left: 0; }

    /* Ajustes internos del panel en móvil */
    .bdv-filtro-panel__header {
        position: sticky; top: 0; background: #fff; z-index: 10;
        padding-top: 20px; margin-top: -24px; /* Compensar padding */
    }
    
    /* Botón antiguo fuera */
    .bdv-filtro-apply { display: none; }
}