/* ==========================================================
   1. OCULTAR EN ESCRITORIO
   ========================================================== */
@media (min-width: 992px) {
    .fo-toolbar-left,
    #fo-shop-toolbar-flex,
    #fo-tablet-drawer,
    #fo-tablet-overlay {
        display: none !important;
    }
}

/* ==========================================================
   2. REGLAS GENERALES Y ALINEACIÓN (Solo botón principal de la barra)
   ========================================================== */
@media (max-width: 991px) {
    .fo-toolbar-left {
        display: inline-flex !important;
        align-items: center !important;
    }

    .fo-toolbar-left .wc-block-product-filters {
        margin: 0 !important;
    }

    /* Ocultar el botón "Aplicar" nativo dentro del modal en móvil/responsive */
    .wc-block-product-filters__overlay-footer,
    .wc-block-product-filters__apply {
        display: none !important;
    }

    /* Aplicar estilo únicamente al botón principal de la barra, excluyendo el contenido del modal/drawer */
    .fo-toolbar-left .wc-block-product-filters__open-overlay,
    .fo-toolbar-left .fo-tablet-btn,
    .fo-toolbar-left #fo-toggle-filters.fo-filter-btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        background-color: #ffffff !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 6px !important;
        padding: 8px 14px !important;
        height: 38px !important;
        margin: 0 !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
        cursor: pointer !important;
        box-sizing: border-box !important;
    }

    /* Ocultar iconos SVG nativos solo en el botón principal de la barra */
    .fo-toolbar-left .wc-block-product-filters__open-overlay > svg,
    .fo-toolbar-left #fo-toggle-filters.fo-filter-btn svg,
    .fo-toolbar-left .fo-tablet-btn svg {
        display: none !important;
    }

    /* Inyectar icono de filtros personalizado solo en el botón principal */
    .fo-toolbar-left .wc-block-product-filters__open-overlay::before,
    .fo-toolbar-left .fo-tablet-btn::before,
    .fo-toolbar-left #fo-toggle-filters.fo-filter-btn::before {
        content: "" !important;
        display: inline-block !important;
        width: 16px !important;
        height: 16px !important;
        background-color: #374151 !important;
        mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="21" x2="4" y2="14"></line><line x1="4" y1="10" x2="4" y2="3"></line><line x1="12" y1="21" x2="12" y2="12"></line><line x1="12" y1="8" x2="12" y2="3"></line><line x1="20" y1="21" x2="20" y2="16"></line><line x1="20" y1="12" x2="20" y2="3"></line><line x1="1" y1="14" x2="7" y2="14"></line><line x1="9" y1="8" x2="15" y2="8"></line><line x1="17" y1="16" x2="23" y2="16"></line></svg>') no-repeat center / contain !important;
        -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="21" x2="4" y2="14"></line><line x1="4" y1="10" x2="4" y2="3"></line><line x1="12" y1="21" x2="12" y2="12"></line><line x1="12" y1="8" x2="12" y2="3"></line><line x1="20" y1="21" x2="20" y2="16"></line><line x1="20" y1="12" x2="20" y2="3"></line><line x1="1" y1="14" x2="7" y2="14"></line><line x1="9" y1="8" x2="15" y2="8"></line><line x1="17" y1="16" x2="23" y2="16"></line></svg>') no-repeat center / contain !important;
    }

    /* Tipografía limpia para el texto "Filtrar" en el botón principal */
    .fo-toolbar-left .wc-block-product-filters__open-overlay > span,
    .fo-toolbar-left .fo-tablet-btn > span,
    .fo-toolbar-left #fo-toggle-filters.fo-filter-btn > span {
        visibility: hidden !important;
        position: relative !important;
        width: 38px !important;
        display: inline-block !important;
        font-size: 0 !important;
    }
    
    .fo-toolbar-left .wc-block-product-filters__open-overlay > span::after,
    .fo-toolbar-left .fo-tablet-btn > span::after,
    .fo-toolbar-left #fo-toggle-filters.fo-filter-btn > span::after {
        content: "Filtrar" !important;
        visibility: visible !important;
        position: absolute !important;
        left: 0 !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        font-size: 14px !important;
        color: #374151 !important;
        font-weight: 400 !important;
        line-height: 1 !important;
        font-family: inherit !important;
    }
}

/* ==========================================================
   3. ESTILOS DE DRAWER, OVERLAY Y OCULTAR BOTÓN INTERNO
   ========================================================== */
@media (min-width: 768px) and (max-width: 991px) {
    /* Ocultar cualquier botón de apertura duplicado que aparezca dentro del drawer */
    #fo-tablet-drawer .wc-block-product-filters__open-overlay,
    #fo-tablet-drawer .fo-tablet-btn {
        display: none !important;
    }

    #fo-tablet-drawer {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        width: 320px !important;
        max-width: 85% !important;
        height: 100vh !important;
        background: #ffffff !important;
        z-index: 999999 !important;
        padding: 25px 20px !important;
        overflow-y: auto !important;
        transition: left 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2) !important;
        box-sizing: border-box !important;
    }

    #fo-tablet-drawer.fo-active {
        left: 0 !important;
    }

    .fo-drawer-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 20px !important;
        padding-bottom: 12px !important;
        border-bottom: 1px solid #eeeeee !important;
    }

    .fo-drawer-title {
        font-weight: 700 !important;
        font-size: 18px !important;
        color: #000000 !important;
    }

    .fo-drawer-close {
        background: none !important;
        border: none !important;
        font-size: 24px !important;
        cursor: pointer !important;
        color: #000000 !important;
        line-height: 1 !important;
        padding: 0 5px !important;
    }

    .fo-overlay {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(0, 0, 0, 0.6) !important;
        z-index: 999998 !important;
    }

    .fo-overlay.fo-active {
        display: block !important;
    }
}