/* =====================================================
   WC Filter Bar v2.5 – SarpiDesign
   ===================================================== */

/* ── Wrapper ── */
.wcfb-wrapper { width: 100%; font-family: inherit; }


/* ── Reset defensivo: neutraliza estilos globales del tema ── */
.wcfb-wrapper button,
.wcfb-wrapper input,
.wcfb-wrapper select {
    box-sizing: border-box;
    line-height: 1;
    vertical-align: middle;
    font-family: inherit;
    margin: 0;
}
.wcfb-wrapper button {
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    text-align: center;
}

/* ── Barra de filtros ── */
.wcfb-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #fff;
    border-radius: 10px;
    margin-bottom: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
}

/* ─── LAYOUT VERTICAL (sidebar) ─────────────────────────
   La barra se convierte en sidebar izquierdo y el grid
   aparece a su derecha en un layout de dos columnas.
   ──────────────────────────────────────────────────────── */
.wcfb-layout-vertical-wrap {
    display: flex;
    align-items: flex-start;
    gap: 24px;
}
.wcfb-layout-vertical-wrap .wcfb-filter-bar {
    flex-direction: column;
    align-items: stretch;
    flex: 0 0 220px;
    min-width: 180px;
    max-width: 260px;
    margin-bottom: 0;
    position: sticky;
    top: 20px;
}
.wcfb-layout-vertical-wrap .wcfb-results-wrapper {
    flex: 1;
    min-width: 0;
}
.wcfb-layout-vertical-wrap .wcfb-filter-field {
    flex: 1 1 100%;
    min-width: 0;
}
.wcfb-layout-vertical-wrap .wcfb-btn-filter,
.wcfb-layout-vertical-wrap .wcfb-btn-reset {
    width: 100%;
}
.wcfb-layout-vertical-wrap .wcfb-btn-reset {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Separador visual entre filtros en modo vertical */
.wcfb-layout-vertical-wrap .wcfb-filter-field + .wcfb-filter-field {
    padding-top: 4px;
    border-top: 1px solid #f3f4f6;
}

.wcfb-filter-bar.wcfb-layout-horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Campos ── */
.wcfb-filter-field { display: flex; align-items: center; flex: 1 1 160px; min-width: 140px; }

.wcfb-filter-bar input,
.wcfb-filter-bar select {
    width: 100%; height: 40px; padding: 0 12px;
    font-size: 14px; border: 1px solid #ddd; border-radius: 6px;
    background: #f8f8f8; color: #333;
    transition: border-color .2s, box-shadow .2s;
    appearance: none; -webkit-appearance: none; outline: none;
}
.wcfb-filter-bar input:focus,
.wcfb-filter-bar select:focus { border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.15); }

/* ── Precio ── */
.wcfb-price-inputs { display: flex; align-items: center; gap: 6px; width: 100%; }
.wcfb-price-inputs .wcfb-input-price { flex: 1; }
.wcfb-price-sep { color: #aaa; font-size: 16px; }

/* ── Botón oferta ── */
.wcfb-field-onsale { flex: 0 1 auto; }
.wcfb-btn-onsale {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 40px; min-height: 40px; padding: 0 14px;
    box-sizing: border-box; line-height: 1;
    background: #fff7ed; color: #c2410c;
    border: 1.5px solid #fed7aa; border-radius: 8px;
    font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background .2s, color .2s, border-color .2s, transform .1s;
    vertical-align: middle;
}
.wcfb-btn-onsale:hover { background: #ffedd5 !important; border-color: #fb923c !important; color: #c2410c !important; }
.wcfb-btn-onsale:active { transform: scale(.97); }
.wcfb-btn-onsale.wcfb-onsale-active { background: #ea580c !important; color: #fff !important; border-color: #ea580c !important; box-shadow: 0 2px 8px rgba(234,88,12,.35); }
.wcfb-btn-onsale.wcfb-onsale-active:hover { background: #c2410c !important; color: #fff !important; border-color: #c2410c !important; }
.wcfb-onsale-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 5px;
    background: #dc2626; color: #fff;
    font-size: 11px; font-weight: 700; border-radius: 20px;
    animation: wcfb-pop .25s ease;
}
.wcfb-btn-onsale.wcfb-onsale-active .wcfb-onsale-count { background: rgba(255,255,255,.25); }

/* ── Botones barra ── */
.wcfb-btn-filter {
    display: inline-flex; align-items: center; justify-content: center;
    height: 40px; min-height: 40px; padding: 0 22px;
    box-sizing: border-box; line-height: 1;
    background: #7c3aed; color: #fff;
    border: none; border-radius: 6px;
    font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background .2s, transform .1s; flex-shrink: 0;
    vertical-align: middle;
}
.wcfb-btn-filter:hover { background: #5b21b6; }
.wcfb-btn-filter:active { transform: scale(.97); }

.wcfb-btn-reset {
    height: 36px; min-height: 36px; width: 36px;
    box-sizing: border-box; line-height: 1;
    border: 1px solid #e5e7eb; border-radius: 6px;
    background: #fff; color: #9ca3af; font-size: 16px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: color .2s, border-color .2s; flex-shrink: 0;
    vertical-align: middle;
    padding: 0;
}
.wcfb-btn-reset:hover { color: #ef4444; border-color: #ef4444; }

/* ── Resultados info ── */
.wcfb-results-info { font-size: 13px; color: #6b7280; margin-bottom: 12px; }

/* ── Grid ── */
.wcfb-products-grid { display: grid; gap: 20px; transition: opacity .25s; }
.wcfb-products-grid.wcfb-loading { opacity: .45; pointer-events: none; }
.wcfb-grid-cols-1 { grid-template-columns: 1fr; }
.wcfb-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.wcfb-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.wcfb-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.wcfb-grid-cols-5 { grid-template-columns: repeat(5, 1fr); }

/* ══════════════════════════════════════════
   TARJETA DE PRODUCTO — ZONA DIVIDIDA
   ══════════════════════════════════════════ */
.wcfb-product-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    opacity: 0;
    transform: translateY(12px);
    transition: transform .25s ease, box-shadow .25s ease, opacity .35s ease;
    will-change: transform;
}
.wcfb-product-card.wcfb-card-visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
}
/* Hover: !important necesario para superar estilos inline de Elementor */
.wcfb-product-card.wcfb-card-visible:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,.15) !important;
    cursor: pointer;
}

/* ── Zona superior: imagen ── */
.wcfb-product-img {
    position: relative; overflow: hidden;
    aspect-ratio: 1/1; background: #f3f4f6;
}
.wcfb-product-img img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform .4s ease;
}
.wcfb-product-card:hover .wcfb-product-img img { transform: scale(1.04); }

/* ── Badges ── */
.wcfb-badge-wrap {
    position: absolute; top: 10px; left: 10px;
    display: flex; flex-direction: column; gap: 4px;
}
.wcfb-badge {
    display: inline-block;
    font-size: 11px; font-weight: 700;
    padding: 3px 9px; border-radius: 20px;
    letter-spacing: .4px; text-transform: uppercase;
    line-height: 1.4;
}
.wcfb-badge--sale     { background: #ef4444; color: #fff; }
.wcfb-badge--featured { background: #f59e0b; color: #fff; }
.wcfb-badge--pct      { background: #16a34a; color: #fff; }

/* ── Zona superior: info ── */
.wcfb-product-info {
    padding: 12px 14px 14px;
    display: flex; flex-direction: column; gap: 6px;
    flex: 1; /* empuja el footer hacia abajo */
}

.wcfb-product-cat {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .6px; color: #6b7280;
}
.wcfb-product-name {
    font-size: 14px; font-weight: 700; color: #111827;
    margin: 0; line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}
.wcfb-product-desc { font-size: 13px; color: #6b7280; line-height: 1.5; margin: 0; }
.wcfb-product-meta { display: flex; align-items: center; gap: 5px; font-size: 13px; color: #6b7280; }
.wcfb-meta-icon    { flex-shrink: 0; }
.wcfb-meta-label   { font-weight: 500; }
.wcfb-meta-value   { font-weight: 600; color: #374151; }

/* ── Estrellas ── */
.wcfb-stars        { font-size: 13px; letter-spacing: 1px; color: #f59e0b; }
.wcfb-star-empty   { color: #d1d5db; }

/* ══════════════════════════════════════════
   ZONA FOOTER — color independiente
   ══════════════════════════════════════════ */
.wcfb-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px 14px;
    background: #f5f3ff;        /* color por defecto, sobreescribible desde Elementor */
    border-top: 1px solid #ede9fe;
    margin-top: 0;              /* pegado a la info, sin gap */
}

/* ── Precio ── */
.wcfb-product-price { font-size: 16px; font-weight: 700; color: #7c3aed; }
.wcfb-product-price del { color: #9ca3af; font-size: 12px; font-weight: 400; margin-right: 4px; }
.wcfb-product-price ins { text-decoration: none; }

/* ── Botón tarjeta ── */
.wcfb-card-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px;
    background: #7c3aed; color: #fff;
    font-size: 13px; font-weight: 600; border-radius: 6px;
    text-decoration: none; white-space: nowrap;
    transition: background .2s; cursor: pointer; border: none; flex-shrink: 0;
}
.wcfb-product-card:hover .wcfb-card-btn { background: #5b21b6; }

/* ── Estados vacíos ── */
.wcfb-no-results,
.wcfb-error {
    grid-column: 1/-1; text-align: center;
    padding: 40px 20px; font-size: 15px; color: #6b7280;
}
.wcfb-error { color: #ef4444; }

/* ── Spinner ── */
.wcfb-loading-spinner {
    grid-column: 1/-1; display: flex; align-items: center;
    justify-content: center; gap: 10px; padding: 40px;
    color: #9ca3af; font-size: 14px;
}
.wcfb-spinner {
    width: 22px; height: 22px;
    border: 3px solid #e5e7eb; border-top-color: #7c3aed;
    border-radius: 50%; animation: wcfb-spin .7s linear infinite; display: inline-block;
}
.wcfb-spinner--sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes wcfb-spin { to { transform: rotate(360deg); } }
@keyframes wcfb-pop  { 0%{transform:scale(.6)} 70%{transform:scale(1.15)} 100%{transform:scale(1)} }

/* ── Paginación ── */
.wcfb-pagination { margin-top: 24px; display: flex; justify-content: center; }
.wcfb-pages { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.wcfb-page-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    box-sizing: border-box; line-height: 1;
    border: 1px solid #e5e7eb; border-radius: 6px;
    background: #fff; color: #374151; font-size: 14px; cursor: pointer;
    transition: all .2s;
    vertical-align: middle;
}
.wcfb-page-btn:hover,
.wcfb-page-btn.wcfb-page-active { background: #7c3aed; border-color: #7c3aed; color: #fff; }

/* ══════════════════════════════════════════
   AUTOCOMPLETE — BÚSQUEDA EN VIVO
   ══════════════════════════════════════════ */
.wcfb-field-search { position: relative; }
.wcfb-search-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,.12); z-index: 9999;
    overflow: hidden; min-width: 280px;
}
.wcfb-sd-list { list-style: none; margin: 0; padding: 6px 0; }
.wcfb-si {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; cursor: pointer; transition: background .15s;
}
.wcfb-si:hover, .wcfb-si--active { background: #f5f3ff; }
.wcfb-si img {
    width: 44px; height: 44px; object-fit: cover;
    border-radius: 6px; flex-shrink: 0; border: 1px solid #f3f4f6;
}
.wcfb-si-name { font-size: 13px; font-weight: 500; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wcfb-si-name mark { background: transparent; color: #7c3aed; font-weight: 700; }
.wcfb-sd-loading { padding: 14px; display: flex; justify-content: center; }
.wcfb-sd-empty  { padding: 14px 16px; font-size: 13px; color: #6b7280; }

/* ══════════════════════════════════════════
   EDITOR ELEMENTOR — badge de aviso
   ══════════════════════════════════════════ */
.wcfb-editor-badge {
    display: inline-block; background: #ede9fe; color: #5b21b6;
    font-size: 11px; padding: 4px 12px; border-radius: 20px;
    border: 1px dashed #a78bfa;
}

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */
@media (max-width: 1024px) {
    .wcfb-grid-cols-5 { grid-template-columns: repeat(4,1fr); }
}
@media (max-width: 768px) {
    .wcfb-filter-bar { flex-direction: column; align-items: stretch; }
    .wcfb-filter-field { flex: 1 1 100%; }
    .wcfb-btn-filter  { width: 100%; justify-content: center; }
    .wcfb-btn-reset   { width: 100%; }
    .wcfb-grid-cols-4,
    .wcfb-grid-cols-5 { grid-template-columns: repeat(2,1fr); }
    .wcfb-grid-cols-3 { grid-template-columns: repeat(2,1fr); }
    /* Vertical: apilar en móvil */
    .wcfb-layout-vertical-wrap { flex-direction: column; }
    .wcfb-layout-vertical-wrap .wcfb-filter-bar {
        flex: 1 1 100%; max-width: 100%;
        position: static;
    }
}
@media (max-width: 480px) {
    .wcfb-grid-cols-2,
    .wcfb-grid-cols-3,
    .wcfb-grid-cols-4,
    .wcfb-grid-cols-5 { grid-template-columns: 1fr; }
}
