/* ==================================================
   Product Filters Frontend Styles
   ================================================== */

/* Reset y base */
.wc-product-filters-wrapper * {
    box-sizing: border-box;
}

.wc-product-filters-wrapper {
    width: 100%;
    margin: 20px 0;
    display: block;
    overflow: visible;
}

/* NUEVO: Ajustes específicos para el contenedor Elementor que envuelve el shortcode */
.elementor-element.catalog_container {
    position: relative;
    width: 100%;
    min-height: auto !important;
    height: auto !important;
    overflow: visible !important;
}

/* El wrapper del filtro dentro del container debe crecer libremente */
.elementor-element.catalog_container .wc-product-filters-wrapper {
    width: 100%;
    min-height: auto !important;
    height: auto !important;
    overflow: visible;
}

/* Asegurar que columna y grid respeten el alto automático dentro del container */
.elementor-element.catalog_container .pf-products-column,
.elementor-element.catalog_container .pf-products-grid {
    min-height: auto !important;
    height: auto !important;
}

/* ==================================================
   GRID SYSTEM
   ================================================== */

.pf-grid {
    display: grid;
    gap: 30px;
    align-items: start;
}

/* 2 columnas */
.pf-grid-2 {
    grid-template-columns: 300px 1fr;
}

/* 3 columnas */
.pf-grid-3 {
    grid-template-columns: 300px 1fr;
}

/* 4 columnas */
.pf-grid-4 {
    grid-template-columns: 300px 1fr;
}

/* 5 columnas */
.pf-grid-5 {
    grid-template-columns: 300px 1fr;
}

/* Filtro a la derecha */
.pf-filter-right {
    direction: rtl;
}

.pf-filter-right > * {
    direction: ltr;
}

/* ==================================================
   COLUMNA DE FILTROS
   ================================================== */

.pf-filters-column {
    position: relative;
}

/* Botón móvil (oculto en desktop) */
.pf-mobile-filter-toggle {
    display: none;
    width: 100%;
    padding: 12px 16px;
    background: #0071eb;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.pf-mobile-filter-toggle:hover {
    background: #0056b3;
}

/* Panel de filtros */
.pf-filters-panel {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
}

/* Header móvil (oculto en desktop) */
.pf-filters-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.pf-filters-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.pf-mobile-filter-close {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #666;
}

.pf-mobile-filter-close:hover {
    color: #000;
}

/* Contenido de filtros */
.pf-filters-content {
    /* Estilos base */
}

/* ==================================================
   GRUPOS DE FILTROS
   ================================================== */

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

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

.pf-filter-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.pf-toggle-icon {
    font-size: 20px;
    transition: transform 0.3s ease;
}

.pf-filter-group.collapsed .pf-toggle-icon {
    transform: rotate(180deg);
}

.pf-filter-group.collapsed .pf-filter-options {
    display: none;
}

.pf-filter-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ==================================================
   BÚSQUEDA
   ================================================== */

.pf-search-box {
    display: flex;
    gap: 8px;
}

.pf-search-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.pf-search-input:focus {
    outline: none;
    border-color: #0071eb;
    box-shadow: 0 0 0 3px rgba(0, 113, 235, 0.1);
}

.pf-search-button {
    padding: 10px 16px;
    background: #0071eb;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pf-search-button:hover {
    background: #0056b3;
}

/* ==================================================
   CHECKBOXES
   ================================================== */

.pf-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.pf-checkbox-label:hover {
    background: #f5f5f5;
}

.pf-filter-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.pf-checkbox-label span {
    font-size: 14px;
    color: #333;
}

/* Subcategorías */
.pf-subcategories {
    margin-left: 20px;
    margin-top: 5px;
    padding-left: 15px;
    border-left: 2px solid #e0e0e0;
}

.pf-subcategory span {
    font-size: 13px;
    color: #666;
}

/* ==================================================
   FILTRO DE PRECIO
   ================================================== */

.pf-price-range {
    position: relative;
    height: 40px;
    margin-bottom: 10px;
}

.pf-price-range input[type="range"] {
    position: absolute;
    width: 100%;
    pointer-events: none;
    appearance: none;
    background: transparent;
}

.pf-price-range input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: #0071eb;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.pf-price-range input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #0071eb;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.pf-price-range input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
}

.pf-price-range input[type="range"]::-moz-range-track {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
}

.pf-price-values {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.pf-price-separator {
    color: #999;
}

/* ==================================================
   ACCIONES DE FILTRO
   ================================================== */

.pf-filter-actions {
    margin-top: 20px;
}

.pf-clear-filters {
    width: 100%;
    padding: 10px;
    background: #fff;
    color: #0071eb;
    border: 2px solid #0071eb;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pf-clear-filters:hover {
    background: #0071eb;
    color: #fff;
}

/* ==================================================
   COLUMNA DE PRODUCTOS
   ================================================== */

/* CRÍTICO: Asegurar que el contenedor se ajuste dinámicamente */
.pf-products-column {
    position: relative;
    display: block;
    width: 100%;
    min-height: auto !important; /* No forzar altura mínima */
    height: auto !important; /* Altura automática basada en contenido */
}

/* Loading */
.pf-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.pf-loading.active {
    display: flex;
}

.pf-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0071eb;
    border-radius: 50%;
    animation: pf-spin 1s linear infinite;
}

@keyframes pf-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pf-loading p {
    margin-top: 15px;
    color: #666;
    font-size: 14px;
}

/* Grid de productos - Debe ajustarse al contenido */
.pf-products-grid {
    display: grid;
    gap: 25px;
    width: 100%;
    height: auto; /* Altura automática */
    min-height: 0; /* Remover cualquier min-height que pueda estar aplicado */
}

/* 1 columna de productos (2 columnas totales) */
.pf-products-grid-1 {
    grid-template-columns: repeat(1, 1fr);
}

/* 2 columnas de productos (3 columnas totales) */
.pf-products-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* 3 columnas de productos (4 columnas totales) */
.pf-products-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* 4 columnas de productos (5 columnas totales) */
.pf-products-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ==================================================
   TARJETA DE PRODUCTO - CON ESTILOS PERSONALIZABLES
   ================================================== */

/* Tarjeta de producto - Usando variables CSS */
.pf-product-card {
    background: var(--pf-card-bg-color, #fff);
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    display: block;
}

.pf-product-card:hover {
    border-color: var(--pf-card-border-color-hover, #0071eb);
    border-width: var(--pf-card-border-width-hover, 1px);
    box-shadow: 0 4px 12px var(--pf-card-shadow-color-hover, rgba(0, 0, 0, 0.1));
    transform: translateY(-2px);
}

.pf-product-image {
    position: relative;
    width: 100%;
    padding-top: 100%; /* Aspect ratio 1:1 */
    overflow: hidden;
    background: #f5f5f5;
}

.pf-product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pf-sale-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 12px;
    background: #ff4444;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
}

.pf-product-info {
    padding: 15px;
}

.pf-product-title {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--pf-card-title-color, #333);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pf-product-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

.pf-stars {
    color: #ffa500;
    font-size: 14px;
}

.pf-reviews {
    font-size: 13px;
    color: #666;
}

.pf-product-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--pf-card-price-color, #0071eb);
}

/* Categoría del producto dentro de la tarjeta
   (se inyecta antes del precio desde AJAX) */
.pf-product-price .pf-product-categories {
    margin-bottom: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pf-product-price .pf-product-category {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    /* Colores en reposo: ahora usando variables CSS
       con valores por defecto iguales a los actuales */
    color: var(--pf-category-pill-text-color, #00a699);
    background: var(--pf-category-pill-bg-color, rgba(0, 166, 153, 0.06));
    transition: all 0.2s ease;
}

/* Hover: cuando el usuario pasa el mouse por la tarjeta,
   cambiamos los colores de la categoría */
.pf-product-card:hover .pf-product-price .pf-product-category {
    color: var(--pf-category-pill-text-color-hover, #008c7f);
    background: var(--pf-category-pill-bg-color-hover, rgba(0, 140, 127, 0.08));
}



/* Sin resultados */
.pf-no-results {
    padding: 60px 20px;
    text-align: center;
    color: #666;
}

.pf-no-results p {
    font-size: 16px;
}

/* ==================================================
   PAGINACIÓN
   ================================================== */

.pf-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid #e0e0e0;
}

.pf-pagination button {
    padding: 10px 16px;
    background: #fff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pf-pagination button:hover:not(:disabled) {
    background: #f5f5f5;
    border-color: #ccc;
}

.pf-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pf-pagination button.active {
    background: #0071eb;
    color: #fff;
    border-color: #0071eb;
}

.pf-pagination span {
    padding: 10px;
    color: #666;
    font-size: 14px;
}

/* ==================================================
   RESPONSIVE - MÓVIL
   ================================================== */

@media (max-width: 768px) {
    /* CRÍTICO: Asegurar que el wrapper respete el flujo del documento */
    .wc-product-filters-wrapper {
        display: block;
        position: relative;
        z-index: 1;
        min-height: auto !important;
        height: auto !important;
    }

    /* NUEVO: el container Elementor también debe empujar al footer */
    .elementor-element.catalog_container {
        padding-bottom: 40px;
        margin-bottom: 40px;
        min-height: auto !important;
        height: auto !important;
    }
    
    .elementor-element.catalog_container .pf-products-column {
        margin-bottom: 60px;
        padding-bottom: 40px;
    }
    
    /* Grid en una sola columna */
    .pf-grid {
        grid-template-columns: 1fr;
        gap: 0;
        display: block;
    }
    
    /* CRÍTICO: Columna de productos debe empujar el footer */
    .pf-products-column {
        display: block;
        position: relative;
        width: 100%;
        min-height: auto !important;
        height: auto !important;
        clear: both;
        margin-bottom: 40px;
    }
    
    /* Mostrar botón de filtro móvil */
    .pf-mobile-filter-toggle {
        display: flex;
        margin-bottom: 20px;
    }
    
    /* Panel de filtros como overlay */
    .pf-filters-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9999;
        border: none;
        border-radius: 0;
        padding: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        pointer-events: auto; /* CRÍTICO: El panel SÍ debe capturar eventos */
    }
    
    .pf-filters-panel.active {
        transform: translateX(0);
        pointer-events: auto; /* Asegurar que capture eventos cuando está activo */
    }
    
    /* Mostrar header móvil */
    .pf-filters-header {
        display: flex;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 10;
        padding: 15px 20px;
        margin-bottom: 0;
    }
    
    .pf-filters-content {
        padding: 20px;
    }
    
    /* Grid de productos en móvil */
    .pf-products-grid-1,
    .pf-products-grid-2,
    .pf-products-grid-3,
    .pf-products-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        margin-bottom: 40px;
        display: grid;
    }
    
    /* Ajustar tarjetas */
    .pf-product-info {
        padding: 12px;
    }
    
    .pf-product-title {
        font-size: 14px;
    }
    
    .pf-product-price {
        font-size: 16px;
    }
    
    /* Paginación más compacta con espacio inferior */
    .pf-pagination {
        gap: 5px;
        flex-wrap: wrap;
        margin-bottom: 60px;
        padding-bottom: 40px;
    }
    
    .pf-pagination button {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    /* Sin resultados con espacio inferior */
    .pf-no-results {
        padding: 60px 20px 100px 20px;
        margin-bottom: 60px;
    }
    
    /* Loading con espacio inferior */
    .pf-loading {
        padding: 60px 20px 100px 20px;
    }
}

/* Móvil muy pequeño */
@media (max-width: 480px) {
    /* Más espacio en pantallas pequeñas */
    .wc-product-filters-wrapper {
        padding-bottom: 100px;
        margin-bottom: 60px;
    }
    
    .pf-products-column {
        margin-bottom: 80px;
        padding-bottom: 60px;
    }
    
    .pf-products-grid-1,
    .pf-products-grid-2,
    .pf-products-grid-3,
    .pf-products-grid-4 {
        grid-template-columns: 1fr;
        margin-bottom: 60px;
    }
    
    .pf-pagination {
        margin-bottom: 80px;
        padding-bottom: 60px;
    }
}

/* ==================================================
   OVERLAY PARA FILTROS MÓVILES
   ================================================== */

.pf-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    pointer-events: none; /* CRÍTICO: No bloquea interacción con el panel por defecto */
}

.pf-overlay.active {
    display: block;
    pointer-events: auto; /* Solo cuando está activo puede capturar clicks */
}

/* En escritorio ocultamos explícitamente el overlay
   y el botón de filtros móviles */
@media (min-width: 769px) {
    .pf-overlay {
        display: none !important;
        pointer-events: none !important;
    }

    .pf-mobile-filter-toggle {
        display: none !important;
    }
}

/* ==================================================
   FIX ESPECÍFICO PÁGINA CATÁLOGO (ID 631) EN MÓVIL
   Evitar que el contenedor Elementor del catálogo
   use display:flex y permita que el footer baje
   ================================================== */

@media screen and (max-width: 767px) {

    /* Forzamos el contenedor del catálogo a comportarse como bloque */
    .elementor-631 .elementor-element.elementor-element-c1f4b11.catalog_container.e-con {
        /* Sobrescribe la variable que usa Elementor para el display */
        --display: block !important;

        /* Y por seguridad también la propiedad final */
        display: block !important;

        /* Aseguramos que se estire y deje crecer a su contenido */
        width: 100%;
        min-height: auto !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* La columna interna del contenedor también debe empujar al footer */
    .elementor-631 .elementor-element.elementor-element-c1f4b11.catalog_container.e-con .wc-product-filters-wrapper,
    .elementor-631 .elementor-element.elementor-element-c1f4b11.catalog_container.e-con .pf-products-column,
    .elementor-631 .elementor-element.elementor-element-c1f4b11.catalog_container.e-con .pf-products-grid {
        min-height: auto !important;
        height: auto !important;
        display: block;
        clear: both;
        margin-bottom: 40px;
    }
}

