/* =========================================
   1. VARIABLES Y COLORES
   ========================================= */
:root {
    --waf-primary: #333;
    --waf-accent: #3b82f6;
    --waf-bg: #fff;
    --waf-border: #e5e7eb;
    --waf-text: #4b5563;
}

/* =========================================
   2. ESTILOS GENERALES (BASE)
   ========================================= */
.waf-widget-container {
    background: var(--waf-bg);
    border: 1px solid var(--waf-border);
    border-radius: 8px;
    padding: 20px;
    font-family: inherit;
    position: relative;
    box-sizing: border-box;
    color: var(--waf-text);
}

/* Secciones */
.waf-section { margin-bottom: 20px; border-bottom: 1px solid #f3f4f6; padding-bottom: 15px; }
.waf-section:last-of-type { border-bottom: none; }
.waf-section h4 { margin: 0 0 10px 0; font-size: 14px; font-weight: 700; color: var(--waf-primary); text-transform: uppercase; letter-spacing: 0.5px; }

/* Inputs */
.waf-widget-container input[type="text"], 
.waf-widget-container input[type="number"] {
    width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 5px; font-size: 14px; background: #f9fafb; box-sizing: border-box;
}
.waf-price-inputs { display: flex; align-items: center; gap: 8px; }

/* Listas */
.waf-cat-ul { list-style: none; padding: 0; margin: 0; }
.waf-cat-ul li { margin-bottom: 6px; }
.waf-cat-ul .waf-cat-ul { margin-left: 18px; padding-left: 10px; border-left: 2px solid #f3f4f6; margin-top: 6px; }
.waf-checkbox, .waf-cat-ul label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--waf-text); }
.waf-checkbox:hover, .waf-cat-ul label:hover { color: var(--waf-accent); }

/* Ocultos por defecto (Elementos Móviles) */
.waf-mobile-toggle, .waf-close-btn, .waf-overlay, .waf-mobile-title { display: none; }


/* =========================================
   3. LÓGICA DE VISIBILIDAD (EL CORAZÓN DEL PROBLEMA)
   ========================================= */

/* --- ESCRITORIO (> 992px) --- */
@media (min-width: 993px) {
    /* En PC: Ocultamos el widget móvil de arriba */
    .waf-context-mobile { display: none !important; }
}

/* --- MÓVIL (<= 992px) --- */
@media (max-width: 992px) {
    
    /* 1. OCULTAR DUPLICADOS DEL TEMA (Sidebar de Astra) */
    #secondary, .widget-area, .sidebar-main, .ast-right-sidebar #secondary {
        display: none !important;
    }
    /* Ocultar también la versión sidebar del plugin por si acaso */
    .waf-context-sidebar { display: none !important; }

    /* 2. MOSTRAR EL WIDGET MÓVIL */
    .waf-context-mobile {
        display: block !important;
        margin-bottom: 20px;
        width: 100%;
        background: transparent; border: none; padding: 0;
        position: relative; z-index: 100;
    }

    /* 3. BOTÓN FILTRAR (Siempre visible) */
    .waf-mobile-toggle {
        display: flex; align-items: center; justify-content: center; gap: 8px;
        width: 100%; padding: 12px; background: var(--waf-primary); color: #fff;
        border: none; border-radius: 30px; cursor: pointer; font-weight: 700;
        box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    }

    /* 4. EL FORMULARIO DESLIZANTE (El arreglo clave) */
    /* Usamos solo 'form' para que detecte cualquier formulario dentro, tenga ID o Clase */
    .waf-context-mobile form {
        position: fixed;
        top: 0;
        left: -110%; /* Escondido */
        width: 85%; max-width: 320px; height: 100vh;
        background: #fff;
        z-index: 9999999; /* Z-Index extremo para estar encima de todo */
        padding: 25px; overflow-y: auto;
        transition: left 0.3s ease;
        box-shadow: 5px 0 25px rgba(0,0,0,0.2);
        display: block !important; /* Forzar existencia */
        visibility: visible;
    }

    /* 5. ESTADO ABIERTO */
    /* Cuando JS añade la clase .open al contenedor padre, el form se desliza a 0 */
    .waf-widget-container.open form {
        left: 0 !important;
    }
    
    /* Overlay (Fondo oscuro) */
    .waf-overlay {
        display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.7); z-index: 9999998; backdrop-filter: blur(2px);
    }
    .waf-widget-container.open .waf-overlay { display: block !important; }

    /* Botón Cerrar y Título */
    .waf-close-btn { display: block; position: absolute; top: 15px; right: 15px; background: none; border: none; font-size: 30px; cursor: pointer; color: #999; z-index: 10000000; }
    .waf-mobile-title { display: block; font-size: 20px; border-bottom: 2px solid #f3f4f6; padding-bottom: 15px; margin-top: 5px; margin-bottom: 20px; }
}