/**
 * CMW Product Filters v1.1.2
 * Colores de marca: #A7144C (burdeos), #434343 (texto), #FFFFFF (fondo)
 */

/* =================================================================
   Barra de filtros
   ================================================================= */
.cmw-filter-bar {
  margin: 0 auto 1.5rem;
  text-align: center;
}

/* =================================================================
   Dropdowns (fila centrada)
   ================================================================= */
.cmw-dropdowns {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.cmw-filter-group {
  position: relative;
}

.cmw-filter-select {
  appearance: none;
  -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23434343' stroke-width='1.5' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 36px 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: #434343;
  cursor: pointer;
  min-width: 160px;
  transition: border-color 0.15s;
}

.cmw-filter-select:hover,
.cmw-filter-select:focus {
  border-color: #A7144C;
  outline: none;
}

/* Badge de conteo activo */
.cmw-filter-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #A7144C;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* =================================================================
   Toggle "Ofertas"
   ================================================================= */
.cmw-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #434343;
  user-select: none;
}

.cmw-toggle-wrap input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  background: #d1d5db;
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.cmw-toggle-wrap input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.cmw-toggle-wrap input[type="checkbox"]:checked {
  background: #A7144C;
}

.cmw-toggle-wrap input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

/* =================================================================
   Filtros activos (chips)
   ================================================================= */
.cmw-active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
}

.cmw-active-filters > * {
  vertical-align: middle;
}

.cmw-active-label {
  font-weight: 700;
  color: #434343;
}

.cmw-chip,
.cmw-reset-btn {
  display: inline-flex;
  align-items: center;
  height: 30px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  font-size: 13px;
  line-height: 1;
  box-sizing: border-box;
  vertical-align: middle;
  margin: 0;
}

.cmw-chip {
  gap: 6px;
  background: #f3f4f6;
  padding: 0 10px 0 12px;
  color: #434343;
}

.cmw-chip-text {
  line-height: 1;
}

.cmw-chip-remove {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 0;
  margin: 0;
  line-height: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.cmw-chip-remove svg {
  display: block;
}

.cmw-chip-remove:hover {
  color: #A7144C;
}

/* =================================================================
   Botón Restablecer
   ================================================================= */
.cmw-result-count {
  font-size: 13px;
  color: #6b7280;
  font-style: italic;
}

.cmw-reset-btn {
  background: none;
  padding: 0 14px;
  font-family: inherit;
  color: #434343;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.cmw-reset-btn:hover {
  border-color: #A7144C;
  color: #A7144C;
}

/* =================================================================
   Grid de productos
   ================================================================= */
.cmw-products-grid {
  margin-top: 1.5rem;
  text-align: left;
}

.cmw-products-grid ul.products {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* =================================================================
   Loading state
   ================================================================= */
.cmw-products-grid.cmw-loading {
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.15s;
}

.cmw-products-grid .woocommerce-info {
  text-align: center;
  padding: 2rem;
  color: #6b7280;
  font-size: 15px;
}

/* =================================================================
   DESKTOP: ocultar elementos de modal
   ================================================================= */
.cmw-modal-trigger {
  display: none;
}

.cmw-modal-header,
.cmw-modal-footer {
  display: none;
}

/* Badge en el botón trigger (móvil) */
.cmw-trigger-badge {
  background: #A7144C;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}

.cmw-trigger-badge.is-visible {
  display: inline-flex;
}

/* =================================================================
   MÓVIL
   ================================================================= */
@media (max-width: 767.98px) {

  /* Trigger visible */
  .cmw-modal-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: #434343;
    cursor: pointer;
    width: 100%;
    transition: border-color 0.15s;
  }

  .cmw-modal-trigger:hover {
    border-color: #A7144C;
  }

  .cmw-modal-trigger svg {
    flex-shrink: 0;
  }

  /* Modal: panel desde arriba, ajustado al contenido */
  .cmw-filter-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    background: #fff;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s;
    display: flex;
  }

  .cmw-filter-modal.is-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  /* Overlay detrás del modal */
  .cmw-filter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s;
  }

  .cmw-filter-overlay.is-open {
    opacity: 1;
    visibility: visible;
  }

  /* Header — fijo arriba */
  .cmw-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
  }

  .cmw-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2937;
  }

  .cmw-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0 4px;
  }

  /* Contenido — scrolleable */
  .cmw-filter-modal .cmw-dropdowns {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    background: #fff;
    overflow-y: auto;
    flex: 1;
    min-height: 0; /* clave para que flex+overflow funcione */
    align-items: stretch;
  }

  .cmw-filter-modal .cmw-filter-select {
    width: 100%;
    min-width: unset;
  }

  .cmw-filter-modal .cmw-toggle-wrap {
    justify-content: space-between;
    padding: 4px 0;
  }

  .cmw-filter-modal .cmw-active-filters {
    padding: 12px 20px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    justify-content: flex-start;
  }

  /* Footer — fijo abajo */
  .cmw-modal-footer {
    display: flex;
    gap: 10px;
    padding: 12px 20px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
  }

  .cmw-modal-apply {
    flex: 1;
    background: #A7144C;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
  }

  .cmw-modal-apply:hover {
    background: #8c1040;
  }

  .cmw-modal-reset {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    color: #434343;
    cursor: pointer;
  }

  /* Chips debajo del trigger (fuera del modal) */
  .cmw-filter-bar > .cmw-active-filters {
    margin-top: 8px;
    justify-content: center;
  }
}
