/* =============================================================================
   WC Divi Filters — Estilos
   Compatibles con Divi Builder / WooCommerce
   ============================================================================= */

:root {
    --wcdf-primary      : #1a1a1a;
    --wcdf-accent       : #c8a96e;       /* dorado — cambia al color de tu marca */
    --wcdf-accent-hover : #b0904f;
    --wcdf-muted        : #6b7280;
    --wcdf-border       : #e5e7eb;
    --wcdf-bg           : #f9fafb;
    --wcdf-white        : #ffffff;
    --wcdf-error        : #ef4444;
    --wcdf-success      : #10b981;
    --wcdf-radius       : 8px;
    --wcdf-radius-sm    : 4px;
    --wcdf-shadow       : 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --wcdf-shadow-lg    : 0 4px 16px rgba(0,0,0,.10);
    --wcdf-transition   : 200ms ease;
    --wcdf-font         : inherit;
}

/* ============================================================
   Reset mínimo (no pisar Divi)
   ============================================================ */
.wcdf-filters *,
.wcdf-active-filters *,
.wcdf-products * {
    box-sizing: border-box;
}

/* ============================================================
   PANEL DE FILTROS  [wcdf_filters]
   ============================================================ */
.wcdf-filters {
    font-family: var(--wcdf-font);
    color: var(--wcdf-primary);
}

.wcdf-filters__title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 1.25rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--wcdf-border);
    letter-spacing: .02em;
    text-transform: uppercase;
}

.wcdf-filters__empty {
    color: var(--wcdf-muted);
    font-size: .875rem;
}

/* Grupos de atributo */
.wcdf-filters__groups {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.wcdf-filter-group {
    border: 1px solid var(--wcdf-border);
    border-radius: var(--wcdf-radius);
    overflow: hidden;
    background: var(--wcdf-white);
}

.wcdf-filter-group__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: .875rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: .875rem;
    font-weight: 600;
    color: var(--wcdf-primary);
    transition: background var(--wcdf-transition);
    text-align: left;
    gap: .5rem;
}

.wcdf-filter-group__toggle:hover {
    background: var(--wcdf-bg);
}

.wcdf-filter-group__name {
    flex: 1;
}

.wcdf-chevron {
    width: 16px;
    height: 16px;
    color: var(--wcdf-muted);
    flex-shrink: 0;
    transition: transform var(--wcdf-transition);
}

.wcdf-filter-group--collapsed .wcdf-chevron {
    transform: rotate(-90deg);
}

.wcdf-filter-group__body {
    padding: .5rem 1rem 1rem;
    border-top: 1px solid var(--wcdf-border);
}

/* Lista de términos */
.wcdf-filter-group__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .375rem;
}

.wcdf-filter-group__list.wcdf-cols-1 { grid-template-columns: 1fr; }
.wcdf-filter-group__list.wcdf-cols-2 { grid-template-columns: repeat(2, 1fr); }
.wcdf-filter-group__list.wcdf-cols-3 { grid-template-columns: repeat(3, 1fr); }
.wcdf-filter-group__list.wcdf-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Checkbox personalizado */
.wcdf-checkbox {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    font-size: .8125rem;
    color: var(--wcdf-primary);
    transition: color var(--wcdf-transition);
    user-select: none;
    padding: .25rem 0;
}

.wcdf-checkbox:hover { color: var(--wcdf-accent); }

.wcdf-checkbox__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.wcdf-checkbox__box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--wcdf-border);
    border-radius: var(--wcdf-radius-sm);
    background: var(--wcdf-white);
    flex-shrink: 0;
    transition: border-color var(--wcdf-transition), background var(--wcdf-transition);
}

.wcdf-checkbox__box svg {
    width: 12px;
    height: 10px;
    color: var(--wcdf-white);
    opacity: 0;
    transition: opacity var(--wcdf-transition);
}

.wcdf-checkbox__input:checked + .wcdf-checkbox__box {
    background: var(--wcdf-accent);
    border-color: var(--wcdf-accent);
}

.wcdf-checkbox__input:checked + .wcdf-checkbox__box svg {
    opacity: 1;
}

.wcdf-checkbox__input:focus-visible + .wcdf-checkbox__box {
    outline: 2px solid var(--wcdf-accent);
    outline-offset: 2px;
}

.wcdf-checkbox__label {
    line-height: 1.3;
}

.wcdf-checkbox__count {
    color: var(--wcdf-muted);
    font-size: .75rem;
    margin-left: auto;
}

/* Acciones */
.wcdf-filters__actions {
    display: flex;
    gap: .75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

/* ============================================================
   BOTONES GLOBALES
   ============================================================ */
.wcdf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    padding: .625rem 1.25rem;
    border: 1.5px solid transparent;
    border-radius: var(--wcdf-radius);
    font-family: inherit;
    font-size: .8125rem;
    font-weight: 600;
    letter-spacing: .02em;
    cursor: pointer;
    transition: background var(--wcdf-transition), color var(--wcdf-transition),
                border-color var(--wcdf-transition), transform var(--wcdf-transition);
    text-decoration: none;
    white-space: nowrap;
}

.wcdf-btn:active { transform: scale(.97); }

.wcdf-btn--apply {
    background: var(--wcdf-accent);
    color: var(--wcdf-white);
    flex: 1;
}

.wcdf-btn--apply:hover {
    background: var(--wcdf-accent-hover);
}

.wcdf-btn--clear {
    background: transparent;
    border-color: var(--wcdf-border);
    color: var(--wcdf-muted);
}

.wcdf-btn--clear:hover {
    border-color: var(--wcdf-muted);
    color: var(--wcdf-primary);
}

.wcdf-btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--wcdf-muted);
    font-size: .75rem;
    padding: .25rem .5rem;
    text-decoration: underline;
}

.wcdf-btn--ghost:hover { color: var(--wcdf-error); }

/* ============================================================
   FILTROS ACTIVOS  [wcdf_active_filters]
   ============================================================ */
.wcdf-active-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    min-height: 2rem;
}

.wcdf-active-filters--empty {
    display: none;
}

.wcdf-active-filters__label {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--wcdf-muted);
    white-space: nowrap;
}

.wcdf-active-filters__tags {
    display: flex;
    flex-wrap: wrap;
    gap: .375rem;
}

/* Tags */
.wcdf-tag {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .625rem .3rem .75rem;
    background: var(--wcdf-bg);
    border: 1px solid var(--wcdf-border);
    border-radius: 999px;
    font-family: inherit;
    font-size: .75rem;
    color: var(--wcdf-primary);
    cursor: pointer;
    transition: background var(--wcdf-transition), border-color var(--wcdf-transition);
}

.wcdf-tag:hover {
    background: #fee2e2;
    border-color: var(--wcdf-error);
    color: var(--wcdf-error);
}

.wcdf-tag__attr {
    color: var(--wcdf-muted);
    font-weight: 500;
}

.wcdf-tag__name {
    font-weight: 600;
}

.wcdf-tag__remove {
    width: 12px;
    height: 12px;
    opacity: .5;
    flex-shrink: 0;
}

.wcdf-tag:hover .wcdf-tag__remove { opacity: 1; }

/* ============================================================
   PRODUCTOS  [wcdf_products]
   ============================================================ */
.wcdf-products {
    position: relative;
}

/* Toolbar */
.wcdf-products__toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.wcdf-products__count {
    flex: 1;
    margin: 0;
    font-size: .8125rem;
    color: var(--wcdf-muted);
}

.wcdf-products__sort-label {
    font-size: .8125rem;
    color: var(--wcdf-muted);
    white-space: nowrap;
}

.wcdf-products__sort {
    font-family: inherit;
    font-size: .8125rem;
    border: 1px solid var(--wcdf-border);
    border-radius: var(--wcdf-radius-sm);
    padding: .375rem .625rem;
    color: var(--wcdf-primary);
    background: var(--wcdf-white);
    cursor: pointer;
}

.wcdf-products__sort:focus {
    outline: 2px solid var(--wcdf-accent);
    outline-offset: 2px;
}

/* Grid */
.wcdf-products__grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1.5rem;
}

.wcdf-products__grid.wcdf-cols-1 { grid-template-columns: 1fr; }
.wcdf-products__grid.wcdf-cols-2 { grid-template-columns: repeat(2, 1fr); }
.wcdf-products__grid.wcdf-cols-3 { grid-template-columns: repeat(3, 1fr); }
.wcdf-products__grid.wcdf-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Tarjeta de producto */
.wcdf-product-card {
    border: 1px solid var(--wcdf-border);
    border-radius: var(--wcdf-radius);
    background: var(--wcdf-white);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--wcdf-shadow);
    transition: box-shadow var(--wcdf-transition), transform var(--wcdf-transition);
}

.wcdf-product-card:hover {
    box-shadow: var(--wcdf-shadow-lg);
    transform: translateY(-2px);
}

.wcdf-product-card__inner {
    text-decoration: none;
    color: inherit;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Imagen */
.wcdf-product-card__image {
    position: relative;
    background: var(--wcdf-bg);
    aspect-ratio: 4/3;
    overflow: hidden;
}

.wcdf-product-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 350ms ease;
}

.wcdf-product-card:hover .wcdf-product-card__image img {
    transform: scale(1.04);
}

/* Badge */
.wcdf-product-card__badge {
    position: absolute;
    top: .625rem;
    left: .625rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.wcdf-product-card__badge--sale {
    background: var(--wcdf-error);
    color: var(--wcdf-white);
}

.wcdf-product-card__badge--featured {
    background: var(--wcdf-accent);
    color: var(--wcdf-white);
}

/* Info */
.wcdf-product-card__info {
    padding: .875rem 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .375rem;
}

.wcdf-product-card__title {
    margin: 0;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--wcdf-primary);
}

.wcdf-product-card__price {
    font-size: .9375rem;
    font-weight: 700;
    color: var(--wcdf-primary);
}

.wcdf-product-card__price del {
    color: var(--wcdf-muted);
    font-weight: 400;
    font-size: .8125rem;
    margin-right: .25rem;
}

.wcdf-product-card__price ins {
    text-decoration: none;
    color: var(--wcdf-error);
}

/* Botón añadir */
.wcdf-product-card__add {
    display: block;
    text-align: center;
    padding: .625rem 1rem;
    background: var(--wcdf-accent);
    color: var(--wcdf-white);
    font-family: inherit;
    font-size: .8125rem;
    font-weight: 600;
    text-decoration: none;
    border-top: 1px solid rgba(0,0,0,.06);
    transition: background var(--wcdf-transition);
}

.wcdf-product-card__add:hover {
    background: var(--wcdf-accent-hover);
    color: var(--wcdf-white);
    text-decoration: none;
}

.wcdf-product-card__out-of-stock {
    display: block;
    text-align: center;
    padding: .625rem 1rem;
    background: var(--wcdf-bg);
    color: var(--wcdf-muted);
    font-size: .8125rem;
    border-top: 1px solid var(--wcdf-border);
}

/* No resultados */
.wcdf-products__no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--wcdf-muted);
}

/* Paginación */
.wcdf-pagination {
    display: flex;
    justify-content: center;
    gap: .375rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.wcdf-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 .5rem;
    border: 1.5px solid var(--wcdf-border);
    border-radius: var(--wcdf-radius-sm);
    background: var(--wcdf-white);
    font-family: inherit;
    font-size: .875rem;
    font-weight: 500;
    color: var(--wcdf-primary);
    cursor: pointer;
    transition: border-color var(--wcdf-transition), background var(--wcdf-transition);
}

.wcdf-page-btn:hover {
    border-color: var(--wcdf-accent);
    background: var(--wcdf-bg);
}

.wcdf-page-btn--active {
    background: var(--wcdf-accent);
    border-color: var(--wcdf-accent);
    color: var(--wcdf-white);
}

/* ============================================================
   LOADING STATE
   ============================================================ */
.wcdf-products--loading {
    opacity: .5;
    pointer-events: none;
    transition: opacity var(--wcdf-transition);
}

.wcdf-products__loading {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.7);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: .75rem;
    z-index: 10;
    border-radius: var(--wcdf-radius);
}

.wcdf-products--loading .wcdf-products__loading {
    display: flex;
}

.wcdf-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--wcdf-border);
    border-top-color: var(--wcdf-accent);
    border-radius: 50%;
    animation: wcdf-spin .7s linear infinite;
}

@keyframes wcdf-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .wcdf-products__grid.wcdf-cols-3,
    .wcdf-products__grid.wcdf-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .wcdf-filter-group__list.wcdf-cols-3,
    .wcdf-filter-group__list.wcdf-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .wcdf-products__grid.wcdf-cols-2,
    .wcdf-products__grid.wcdf-cols-3,
    .wcdf-products__grid.wcdf-cols-4 {
        grid-template-columns: 1fr;
    }

    .wcdf-filters__actions {
        flex-direction: column;
    }

    .wcdf-btn--apply {
        flex: none;
        width: 100%;
    }
}

/* ============================================================
   INTEGRACIÓN CON MÓDULO DIVI
   ============================================================ */

/**
 * Agrega la clase CSS que indiques en native_class="..." al
 * módulo de productos de Divi. El plugin la ocultará cuando
 * haya filtros activos y la mostrará al limpiarlos.
 *
 * Ejemplo de uso en Divi → Configuración del módulo → Avanzado → CSS:
 *   Clase CSS: wcdf-native-products
 */
.wcdf-native--hidden {
    display: none !important;
}

/* El bloque [wcdf_products] empieza oculto */
.wcdf-products--hidden {
    display: none !important;
}

/* Animación de aparición al mostrar los productos filtrados */
.wcdf-products:not(.wcdf-products--hidden) {
    animation: wcdf-fadein 250ms ease;
}

@keyframes wcdf-fadein {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
