/* =========================================================
   FILTRO LATERAL — estilo unificado
   Todas as regras de layout da loja + widget do filtro ficam aqui.
   No tema filho (style.css) a seção equivalente foi removida.
   ========================================================= */

/* ---------- Esconde ordenação nativa do WooCommerce ----------
   (o CSS só carrega onde o shortcode [wc_filtro_produtos] existe,
   então isso não afeta outras páginas) */
.woocommerce-ordering { display: none !important; }

/* =========================================================
   LAYOUT DA LOJA (sidebar + produtos)
   ========================================================= */
.loja-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  align-items: flex-start;
}
.loja-layout__sidebar {
  flex: 0 0 260px;
  max-width: 260px;
  width: 100%;
}
.loja-layout__produtos {
  flex: 1 1 500px;
  min-width: 0; /* evita overflow em flex */
}

/* Força largura 100% nos containers do FSE */
.loja-layout__sidebar,
.loja-layout__sidebar > div,
.loja-layout__sidebar .wp-block-group__inner-container {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

/* =========================================================
   SIDEBAR — VISUAL
   ========================================================= */
.wc-filtro-lateral {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 20px;
  font-family: inherit;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden !important;
}
.wc-filtro-lateral * { box-sizing: border-box; }

/* ---------- Título ---------- */
.wc-filtro-lateral .wc-filtro-titulo {
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #eee;
  font-size: 18px;
  font-weight: 700;
  color: #222;
}

/* ---------- Grupos ---------- */
.wc-filtro-lateral .wc-filtro-grupo {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f0f0f0;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}
.wc-filtro-lateral .wc-filtro-grupo:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

/* ---------- H4 ---------- */
.wc-filtro-lateral h4 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ---------- Preço: inputs ---------- */
.wc-filtro-preco-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100% !important;
  max-width: 100% !important;
}
.wc-filtro-preco-inputs input {
  width: 100%;
  min-width: 0 !important;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
  box-sizing: border-box !important;
}
.wc-filtro-preco-inputs input:focus { border-color: #333; }
.wc-filtro-preco-inputs span {
  font-size: 12px;
  color: #999;
  flex-shrink: 0;
}
.wc-filtro-range-info {
  margin-top: 8px;
  color: #666;
}

/* ---------- SELECT / orderby ---------- */
.wc-filtro-lateral select,
.wc-filtro-lateral .wc-filtro-orderby {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  display: block !important;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  background: #fff;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.wc-filtro-lateral select:focus,
.wc-filtro-lateral .wc-filtro-orderby:focus { border-color: #333; }

/* ---------- Checkbox ---------- */
.wc-filtro-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  user-select: none;
}
.wc-filtro-checkbox input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #333;
  flex-shrink: 0;
}

/* ---------- Ações ---------- */
.wc-filtro-acoes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  width: 100% !important;
}
.wc-filtro-btn {
  background: #c4000a;
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background .2s;
  text-transform: uppercase;
  letter-spacing: .5px;
  width: 100% !important;
}
.wc-filtro-btn:hover { background: #a30008; }
.wc-filtro-limpar {
  text-align: center;
  color: #888;
  text-decoration: none;
  font-size: 13px;
  padding: 6px;
  transition: color .2s;
}
.wc-filtro-limpar:hover { color: #222; }

/* ---------- Neutraliza o <p> que o wpautop cria ---------- */
.loja-layout__sidebar .wc-filtro-lateral > p,
.loja-layout__sidebar .wc-filtro-lateral form > p,
.loja-layout__sidebar .wc-filtro-lateral .wc-filtro-grupo > p {
  display: contents !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  font-size: inherit !important;
  line-height: inherit !important;
  color: inherit !important;
  background: transparent !important;
}

/* =========================================================
   TOGGLE / OVERLAY / BOTÃO FECHAR (só aparecem no mobile)
   ========================================================= */
.wc-filtro-toggle  { display: none; }
.wc-filtro-overlay { display: none; }
.wc-filtro-fechar  { display: none; }

/* =========================================================
   MOBILE — sidebar vira drawer deslizante
   As regras aqui usam `!important` para vencer as regras base
   (que também usam `!important`) por ordem de origem.
   ========================================================= */
@media (max-width: 782px) {

  /* ---------- Layout empilhado ---------- */
  .loja-layout {
    flex-direction: column !important;
    gap: 16px !important;
  }
  .loja-layout__sidebar {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  .loja-layout__produtos {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-width: 0;
  }

  /* ---------- Botão "Filtrar" no fluxo normal ---------- */
  .wc-filtro-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #c4000a;
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: background .2s;
  }
  .wc-filtro-toggle:hover,
  .wc-filtro-toggle:focus {
    background: #c4000a;
    outline: none;
  }
  .wc-filtro-toggle svg { flex-shrink: 0; }

  /* ---------- Overlay escuro ---------- */
  .wc-filtro-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
  }
  body.wc-filtro-aberto .wc-filtro-overlay {
    opacity: 1;
    visibility: visible;
  }

  /* ---------- Drawer ---------- */
  .wc-filtro-lateral {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    width: 320px !important;
    max-width: 85vw !important;
    z-index: 99999 !important;
    margin: 0 !important;
    padding: 20px !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.15) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform .3s ease;
  }
  body.wc-filtro-aberto .wc-filtro-lateral {
    transform: translateX(0);
  }

  /* Trava o scroll do body com o drawer aberto */
  body.wc-filtro-aberto { overflow: hidden; }

  /* ---------- Botão ✕ dentro do drawer ---------- */
  .wc-filtro-fechar {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    background: #c4000a;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    color: #fff;
    cursor: pointer;
    z-index: 10;
    transition: background .2s;
  }
  .wc-filtro-fechar:hover { background: #e0e0e0; }

  /* ---------- Ajustes finos do conteúdo dentro do drawer ---------- */
  .wc-filtro-lateral .wc-filtro-titulo {
    font-size: 16px !important;
    margin-bottom: 16px !important;
    padding-bottom: 10px !important;
    padding-right: 44px !important; /* espaço pro ✕ */
  }
  .wc-filtro-lateral h4 {
    font-size: 12px !important;
    margin-bottom: 10px !important;
  }
  .wc-filtro-lateral .wc-filtro-grupo {
    margin-bottom: 16px !important;
    padding-bottom: 16px !important;
  }
  .wc-filtro-preco-inputs {
    flex-wrap: nowrap !important;
  }
  .wc-filtro-preco-inputs input {
    padding: 10px 12px !important;
    font-size: 15px !important;
  }
  .wc-filtro-lateral select,
  .wc-filtro-lateral .wc-filtro-orderby {
    padding: 10px 12px !important;
    font-size: 15px !important;
  }
  .wc-filtro-btn {
    padding: 14px !important;
    font-size: 14px !important;
  }
  .wc-filtro-limpar {
    padding: 10px !important;
    font-size: 13px !important;
  }
}

/* ============================================================
 *  CHIPS DE FILTROS ATIVOS
 * ============================================================ */
.wc-filtro-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    line-height: 1.4;
}

.wc-filtro-chips__label {
    font-weight: 600;
    color: #333;
    margin-right: 2px;
}

.wc-filtro-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 12px;
    background: #c4000a;
    color: #fff;
    border-radius: 20px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    transition: background .2s, color .2s;
    border: 1px solid #c4000a;
}

.wc-filtro-chip:hover,
.wc-filtro-chip:focus {
    background: #a30008;
    border-color: #a30008;
    color: #fff;
    outline: none;
}

.wc-filtro-chip__x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    transition: background .2s;
}

.wc-filtro-chip:hover .wc-filtro-chip__x {
    background: rgba(255, 255, 255, .35);
}

.wc-filtro-chips__limpar {
    color: #888;
    text-decoration: underline;
    font-size: 12px;
    margin-left: 4px;
    transition: color .2s;
}

.wc-filtro-chips__limpar:hover {
    color: #c4000a;
}

/* Ajuste no mobile — permite chips ocuparem toda a largura */
@media (max-width: 782px) {
    .wc-filtro-chips {
        font-size: 12px;
        gap: 6px;
    }
    .wc-filtro-chip {
        font-size: 12px;
        padding: 4px 9px 4px 10px;
    }
}

/* Esconde sempre o "Mostrando X resultados" do WooCommerce
   (o CSS só carrega onde o shortcode [wc_filtro_produtos] existe,
   então não afeta outras páginas da loja) */
.woocommerce-result-count,
p.woocommerce-result-count {
    display: none !important;
}

/* ============================================================
 *  OVERLAY + DRAWER quando movidos para <body> via JS
 *  (mantém ocultos no desktop, garantindo que não interfiram)
 * ============================================================ */
body > .wc-filtro-lateral {
    /* No desktop, o drawer volta a fluir normalmente pelo slot original
       via JS — este seletor só garante que não fique sobreposto */
    position: static;
}

@media (min-width: 783px) {
    body > .wc-filtro-overlay {
        display: none !important;
    }
}