/**
 * C&M Publicidad - Estilos para Filtros de Categorías (Sidebar Desktop + Offcanvas Móvil)
 * Archivo: cym-shop-filters.css
 * Versión: 1.3.0
 */

/* ==========================================================================
   1. CONTENEDORES PADRES: Garantizar que position: sticky funcione siempre
   ========================================================================== */
body.woocommerce,
body.archive,
body.single-product,
.off-canvas-wrapper,
.st-container,
.st-content,
#st-container,
#primary,
.site-main,
.content-area,
.site-content,
.product_content_wrapper,
.product_content_wrapper .row,
.product_content_wrapper .columns {
  overflow: visible !important;
}

/* ==========================================================================
   2. LAYOUT DESKTOP: Barra lateral fija (Sticky) junto a los productos
   ========================================================================== */
@media (min-width: 1024px) {
  /* Ocultar el botón "FILTRAR" y su icono en versión de escritorio */
  .shop_sidebar_button,
  .shop-sidebar-button,
  .filters-offcanvas-trigger,
  a[data-toggle="offCanvasLeft1"],
  .offcanvas_content_left_trigger,
  [data-off-canvas-toggle="offCanvasLeft1"],
  .cym-filter-trigger-btn {
    display: none !important;
  }

  /* Contenedor principal con Sidebar a la izquierda (tienda y producto individual) */
  .cym-shop-container-desktop,
  .cym-product-container-desktop {
    display: flex !important;
    gap: 32px !important;
    align-items: flex-start !important;
    width: 100% !important;
    max-width: 1300px !important;
    margin: 15px auto 40px auto !important;
    padding: 0 15px !important;
    box-sizing: border-box !important;
    position: relative !important;
  }

  /* Columna izquierda: Sidebar Sticky (permanece fija durante el scroll) */
  .cym-desktop-sidebar-wrapper {
    flex: 0 0 280px !important;
    width: 280px !important;
    max-width: 280px !important;
    background: #ffffff !important;
    border: 1px solid #eef2f6 !important;
    border-radius: 12px !important;
    padding: 22px 18px 18px 18px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05) !important;
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 90px !important;
    align-self: flex-start !important;
    z-index: 99 !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Título y Buscador fijos arriba; solo las categorías tienen scroll interno */
  .widget_product_categories ul.product-categories {
    max-height: calc(100vh - 270px) !important;
    min-height: 180px;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-right: 6px !important;
    scrollbar-width: thin;
    scrollbar-color: #d22b31 #f1f5f9;
  }

  .widget_product_categories ul.product-categories::-webkit-scrollbar {
    width: 4px;
  }
  .widget_product_categories ul.product-categories::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
  }
  .widget_product_categories ul.product-categories::-webkit-scrollbar-thumb {
    background-color: #d22b31;
    border-radius: 4px;
  }

  /* Columna derecha: Productos o Ficha de producto */
  .cym-shop-products-column {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: calc(100% - 312px) !important;
  }

  /* Ajuste para ficha de producto individual en desktop */
  body.single-product .cym-shop-products-column .product,
  body.single-product .cym-shop-products-column .product_content_wrapper {
    margin-top: 0 !important;
    padding-top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ==========================================================================
   3. BOTÓN FLOTANTE EN MÓVIL (A LA IZQUIERDA PARA NO CHOCAR CON WHATSAPP)
   ========================================================================== */
.cym-mobile-floating-filter-btn {
  display: none;
}

@media (max-width: 1023px) {
  .cym-mobile-floating-filter-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: fixed !important;
    bottom: 24px !important;
    left: 20px !important; /* UBICADO A LA IZQUIERDA: LIBRE DE WHATSAPP */
    right: auto !important;
    z-index: 99999 !important;
    background: #d22b31 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 50px !important;
    padding: 11px 20px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    letter-spacing: 0.3px !important;
    box-shadow: 0 4px 18px rgba(210, 43, 49, 0.45) !important;
    cursor: pointer !important;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, background 0.2s ease !important;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    text-transform: uppercase;
  }

  .cym-mobile-floating-filter-btn.cym-visible {
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
    pointer-events: auto !important;
  }

  .cym-mobile-floating-filter-btn:active {
    transform: scale(0.95) !important;
    background: #b52026 !important;
  }

  .cym-mobile-floating-filter-btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
  }

  /* Drawer móvil para página de producto individual */
  .cym-product-mobile-drawer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 84% !important;
    max-width: 320px !important;
    height: 100vh !important;
    background: #ffffff !important;
    z-index: 100000 !important;
    padding: 24px 20px !important;
    box-sizing: border-box !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2) !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    overflow-y: auto !important;
  }

  .cym-product-mobile-drawer.cym-drawer-open {
    transform: translateX(0) !important;
  }

  .cym-product-mobile-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 99999 !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
  }

  .cym-product-mobile-backdrop.cym-drawer-open {
    opacity: 1 !important;
    visibility: visible !important;
  }

  .cym-product-drawer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #64748b;
  }
}

/* ==========================================================================
   4. TÍTULO DEL WIDGET ("FILTRAR CATEGORÍAS DEL PRODUCTO")
   ========================================================================== */
.widget_product_categories .widget-title {
  font-size: 15px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  color: #1e293b !important;
  margin: 0 0 14px 0 !important;
  padding: 0 !important;
  line-height: 1.3 !important;
}

/* ==========================================================================
   5. BUSCADOR EN VIVO DE CATEGORÍAS
   ========================================================================== */
.cym-cat-search-box {
  position: relative !important;
  margin: 0 0 16px 0 !important;
  width: 100% !important;
  display: block !important;
  box-sizing: border-box !important;
}

.cym-cat-search-input {
  display: block !important;
  width: 100% !important;
  height: 42px !important;
  min-height: 42px !important;
  max-height: 42px !important;
  line-height: 42px !important;
  padding: 0 34px 0 38px !important;
  margin: 0 !important;
  background: #ffffff !important;
  border: 1.5px solid #e2e8f0 !important;
  border-radius: 8px !important;
  font-size: 13.5px !important;
  color: #1e293b !important;
  box-shadow: none !important;
  outline: none !important;
  box-sizing: border-box !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.cym-cat-search-input:focus {
  border-color: #d22b31 !important;
  box-shadow: 0 0 0 3px rgba(210, 43, 49, 0.12) !important;
  background: #ffffff !important;
}

.cym-cat-search-icon {
  position: absolute !important;
  left: 12px !important;
  top: 0 !important;
  bottom: 0 !important;
  margin: auto !important;
  height: 16px !important;
  width: 16px !important;
  color: #94a3b8 !important;
  pointer-events: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 2 !important;
}

.cym-clear-search {
  position: absolute !important;
  right: 10px !important;
  top: 0 !important;
  bottom: 0 !important;
  margin: auto !important;
  width: 22px !important;
  height: 22px !important;
  background: #f1f5f9 !important;
  color: #64748b !important;
  border: none !important;
  border-radius: 50% !important;
  font-size: 11px !important;
  font-weight: bold !important;
  cursor: pointer !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  line-height: 1 !important;
  z-index: 2 !important;
  transition: all 0.2s ease !important;
}

.cym-clear-search:hover {
  background: #d22b31 !important;
  color: #ffffff !important;
}

.cym-no-results {
  font-size: 13px;
  color: #888888;
  padding: 10px 0;
  text-align: center;
  display: none;
  font-style: italic;
}

/* ==========================================================================
   6. ESTILOS DE LA LISTA DE CATEGORÍAS (Universal para cualquier widget)
   ========================================================================== */
.widget_product_categories ul.product-categories {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Items de categorías */
.widget_product_categories li.cat-item {
  position: relative !important;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border-bottom: 1px solid #f6f6f6;
}

/* Enlaces */
.widget_product_categories li.cat-item > a {
  display: flex !important;
  align-items: center !important;
  padding: 9px 0 !important;
  color: #334155 !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  transition: color 0.2s ease, transform 0.2s ease !important;
  max-width: calc(100% - 35px);
}

.widget_product_categories li.cat-item > a:hover {
  color: #d22b31 !important;
  transform: translateX(3px);
}

/* Remover absolutamente cualquier círculo o viñeta previa del tema */
.widget_product_categories li.cat-item::before,
.widget_product_categories li.cat-item::after,
.widget_product_categories li.cat-item > a::before,
.widget_product_categories li.cat-item > a::after {
  display: none !important;
  content: none !important;
}

/* ==========================================================================
   7. RESALTE DE CATEGORÍA ACTIVA Y CATEGORÍA PADRE
   ========================================================================== */
/* Categoría padre de la subcategoría seleccionada */
.widget_product_categories li.cat-item.current-cat-parent > a,
.widget_product_categories li.cat-item.current-cat-ancestor > a {
  color: #0f172a !important;
  font-weight: 700 !important;
}

/* Subcategoría o categoría ACTIVA */
.widget_product_categories li.cat-item.current-cat > a {
  color: #d22b31 !important;
  font-weight: 700 !important;
}

/* Indicador rojo que NUNCA se monta sobre la letra (inline con margen derecho) */
.widget_product_categories li.cat-item.current-cat > a::before {
  content: '' !important;
  display: inline-block !important;
  width: 4px !important;
  height: 14px !important;
  min-width: 4px !important;
  background-color: #d22b31 !important;
  border-radius: 3px !important;
  margin-right: 8px !important;
  flex-shrink: 0 !important;
}

/* ==========================================================================
   8. ACORDEÓN: BOTÓN TOGGLE (+ / −) Y SUBCATEGORÍAS UNIVERSAL
   ========================================================================== */
.cym-accordion-toggle {
  position: absolute !important;
  right: 0 !important;
  top: 7px !important;
  width: 26px !important;
  height: 26px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  background: #f1f5f9 !important;
  border-radius: 50% !important;
  color: #64748b !important;
  font-size: 12px !important;
  transition: all 0.25s ease !important;
  user-select: none !important;
  z-index: 5 !important;
}

.cym-accordion-toggle:hover {
  background: #d22b31 !important;
  color: #ffffff !important;
}

.cym-accordion-toggle svg {
  width: 12px !important;
  height: 12px !important;
  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 2.5 !important;
  transition: transform 0.25s ease !important;
}

/* Rotar flechita cuando está abierto */
.cym-accordion-toggle.cym-is-open svg {
  transform: rotate(180deg) !important;
}

/* Subcategorías: Ocultas por defecto universalmente */
.widget_product_categories ul.children {
  display: none;
  list-style: none !important;
  margin: 0 0 8px 12px !important;
  padding-left: 10px !important;
  border-left: 2px solid #e2e8f0 !important;
}

.widget_product_categories ul.children li.cat-item {
  border-bottom: none !important;
}

.widget_product_categories ul.children li.cat-item > a {
  font-size: 13px !important;
  font-weight: 400 !important;
  padding: 5px 0 !important;
  color: #475569 !important;
}

.widget_product_categories ul.children li.cat-item > a:hover {
  color: #d22b31 !important;
}

/* Subcategoría activa dentro de children */
.widget_product_categories ul.children li.cat-item.current-cat > a {
  color: #d22b31 !important;
  font-weight: 700 !important;
}
