.ac-filters-apply-btn {
  width: 100%;
  margin-top: 12px;
  background: #39579b;
  color: #fff;
  border: 1px solid #39579b;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ac-filters-apply-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.ac-filters-apply-btn:disabled,
.ac-filters-apply-btn.is-loading {
  opacity: 0.7;
  cursor: not-allowed;
}

.ac-products-loading-host {
  position: relative;
}

ul.products.ac-products-is-loading {
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.ac-products-loader {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.ac-products-loader.is-visible {
  display: flex;
}

.ac-products-loader__spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(57, 87, 155, 0.2);
  border-top-color: #39579b;
  animation: acProductsSpin 0.8s linear infinite;
}

@keyframes acProductsSpin {
  to {
    transform: rotate(360deg);
  }
}

.wc-block-product-filters__overlay-content .ac-filter-section {
  border-top: 1px solid #dbe3f2;
  padding: 14px 0;
}

.wc-block-product-filters__overlay-content .ac-filter-section:last-of-type {
  border-bottom: 1px solid #dbe3f2;
}

.wc-block-product-filters__overlay-content .ac-filter-section__title {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 !important;
}

.wc-block-product-filters__overlay-content .ac-filter-section__title::after {
  content: "+";
  font-size: 22px;
  line-height: 1;
  color: #39579b;
}

.wc-block-product-filters__overlay-content .ac-filter-section.is-open .ac-filter-section__title::after {
  content: "−";
}

.wc-block-product-filters__overlay-content .ac-filter-section .ac-filter-section__content {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin-top 0.2s ease;
  margin-top: 0;
}

.wc-block-product-filters__overlay-content .ac-filter-section.is-open .ac-filter-section__content {
  max-height: 800px;
  opacity: 1;
  margin-top: 12px;
}

/*
 * Contentor onde o JS move o bloco de filtros em mobile (fora da sidebar oculta).
 * Não usar display:none — senão o overlay não desenha.
 */
.ac-mobile-filters-mount {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 0;
  height: 0;
  overflow: visible;
  z-index: 100001;
  pointer-events: none;
}

.ac-mobile-filters-mount .wp-block-woocommerce-product-filters {
  pointer-events: auto;
}

/* Overlay aberto (inclui fallback JS quando o clique nativo não mostra o painel) */
.wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay {
  position: fixed !important;
  inset: 0 !important;
  z-index: 100000 !important;
  display: flex !important;
  align-items: stretch !important;
  justify-content: flex-end !important;
  background: rgba(17, 24, 39, 0.45) !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay-wrapper {
  flex: 1 1 auto;
  display: flex !important;
  justify-content: flex-end;
  max-width: 100%;
}

.wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay-dialog {
  display: block !important;
  visibility: visible !important;
  max-width: min(100%, 420px);
  width: 100%;
  height: 100%;
  overflow-y: auto;
  background: #fff;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
}

/* Mobile: painel entra da esquerda para a direita; header/footer fixos; só o meio faz scroll */
@media (max-width: 999px) {
  .wp-block-woocommerce-product-filters .wc-block-product-filters__open-overlay {
    display: none !important;
  }

  .wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay-wrapper {
    justify-content: flex-start !important;
    align-items: stretch !important;
    align-self: stretch !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
  }

  .wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay {
    align-items: stretch !important;
    animation: acFiltersBackdropIn 0.3s ease forwards;
    min-height: 0 !important;
  }

  @keyframes acFiltersBackdropIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  .wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay-dialog {
    display: flex !important;
    flex-direction: column !important;
    align-self: stretch !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 100dvh !important;
    width: 80vw !important;
    max-width: 80vw !important;
    overflow: hidden !important;
    padding: 0 !important;
    transform: translateX(0);
    animation: acFiltersPanelIn 0.35s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.15);
  }

  @keyframes acFiltersPanelIn {
    from {
      transform: translateX(-100%);
    }
    to {
      transform: translateX(0);
    }
  }

  .ac-filters-overlay-header-bar {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    padding: 14px 16px;
    border-bottom: 1px solid #dbe3f2;
    background: #fff;
    z-index: 5;
  }

  .ac-filters-overlay-close--icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #39579b;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
  }

  .ac-filters-overlay-title {
    margin: 0 !important;
    font-size: 20px;
    font-weight: 600;
    color: #39579b;
    flex: 1;
    text-align: left;
  }

  .ac-filters-overlay-scroll {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 0 16px 16px;
    position: relative;
    z-index: 1;
  }

  /* Evita que o conteúdo Woo force a coluna a crescer sem limite (impede scroll e esconde o rodapé). */
  .ac-filters-overlay-scroll > .wc-block-product-filters__overlay-content {
    min-height: 0 !important;
  }

  .ac-filters-overlay-footer-bar {
    display: flex !important;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid #dbe3f2;
    background: #fff;
    z-index: 6;
    position: relative;
    margin-top: auto;
  }

  .ac-filters-overlay-footer-bar .wc-block-product-filter-clear-button .wp-block-button__link,
  .ac-filters-overlay-footer-bar .wc-block-product-filter-clear-button button,
  .ac-filters-overlay-limpar {
    flex: 1;
    text-align: center;
    border-radius: 8px;
    background: #fff;
    color: #39579b;
    border: 1px solid #39579b;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
  }

  .ac-filters-overlay-footer-bar .ac-filters-apply-btn {
    flex: 1;
    margin-top: 0 !important;
    width: auto !important;
  }

  .wc-block-product-filters__close-overlay {
    display: none !important;
  }
}

@media (min-width: 1000px) {
  .ac-filters-overlay-header-bar {
    display: none !important;
  }

  .ac-filters-overlay-scroll,
  .ac-filters-overlay-footer-bar {
    display: contents !important;
  }

  /* Rodapé do overlay: Limpar tudo + Aplicar lado a lado (montado em JS no desktop) */
  .wc-block-product-filters__overlay-footer {
    display: block !important;
  }

  .wc-block-product-filters__overlay-footer .ac-filters-desktop-footer-bar {
    display: flex !important;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
  }

  .wc-block-product-filters__overlay-footer .ac-filters-desktop-footer-bar .wc-block-product-filter-clear-button {
    flex: 1 1 0;
    min-width: 0;
    margin: 0 !important;
    width: auto !important;
    max-width: none !important;
  }

  .wc-block-product-filters__overlay-footer .ac-filters-desktop-footer-bar .wc-block-product-filter-clear-button .wp-block-button__link,
  .wc-block-product-filters__overlay-footer .ac-filters-desktop-footer-bar .wc-block-product-filter-clear-button button,
  .wc-block-product-filters__overlay-footer .ac-filters-desktop-footer-bar .ac-filters-desktop-clear-fallback .wp-block-button__link {
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    border-radius: 8px;
    background: #fff;
    color: #39579b;
    border: 1px solid #39579b;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
  }

  .wc-block-product-filters__overlay-footer .ac-filters-desktop-footer-bar .ac-filters-apply-btn {
    flex: 1 1 0;
    min-width: 0;
    margin-top: 0 !important;
    width: auto !important;
    max-width: none !important;
  }
  :where(.wc-block-product-filters) .wc-block-product-filters__overlay-footer {
      box-shadow: none !important;
      padding: 0 !important;
  }
}
