/* =========================================================================
   Sidebar de filtros faceted — /loja/ e /product-category/
   Estilo: clean (fornecedor) + denso (Inspire Home)
   Tokens usados: --cor-preto, --cor-branco,
                  --cor-cinza-100, --cor-cinza-300, --cor-cinza-500
   Sem uso de --cor-verde (decisão 2026-04-26 — escala preto/cinza)
   ========================================================================= */

.filter-sidebar {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--cor-cinza-700, #3D3D3D); /* texto cinza escuro 2026-04-28 */
  padding-right: 8px;
}

/* ---------- Header (Filtrar + Limpar) ---------- */
.filter-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--cor-cinza-100, #E2E0DB);
}

.filter-sidebar__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--cor-cinza-700, #3D3D3D);
}

.filter-sidebar__clear {
  background: none;
  border: none;
  color: var(--cor-cinza-500, #717171);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  transition: color var(--transition-fast);
}

.filter-sidebar__clear:hover {
  text-decoration: none;
  color: var(--cor-cinza-700, #3D3D3D);
}

.filter-sidebar__close {
  display: none; /* apenas mobile */
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--cor-cinza-500, #717171);
  line-height: 1;
  padding: 0 0 0 4px;
}

/* ---------- Form ---------- */
.filter-sidebar__form {
  display: flex;
  flex-direction: column;
}

/* ---------- Grupo de filtro ---------- */
.filter-group {
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--cor-cinza-100, #E2E0DB);
}

.filter-group:last-of-type {
  border-bottom: none;
}

.filter-group__header {
  margin: 0 0 12px 0;
  padding: 0;
  font-family: inherit; /* força Inter — sobrescreve regra global de h3 (Playfair) */
  font-size: 14px;
  font-weight: 600;
  color: var(--cor-cinza-700, #3D3D3D);
  letter-spacing: 0;
  line-height: 1.3;
}

.filter-group__options {
  display: flex;
  flex-direction: column;
}

/* Container das opções ocultas: quando visível usa display:contents
   para não quebrar o flex-direction do pai */
.filter-group__hidden {
  display: contents;
}

.filter-group__hidden[hidden] {
  display: none;
}

/* ---------- Opção (checkbox + label + count) ---------- */
/* 2026-04-28: paleta suavizada — texto cinza escuro, hover off-white,
   selecionado em vermelho desbotado (#EB263F), checkbox sem fundo (so o V). */
.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  padding-left: 4px;
  padding-right: 4px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--cor-cinza-700, #3D3D3D);
  line-height: 1.4;
  user-select: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.filter-option:hover {
  color: var(--cor-cinza-900, #1A1A1A);
  background: var(--cor-cinza-050, #F7F6F3);
}

/* Hierarquia (filhas vs netas vs bisnetas) — indentação visual */
.filter-option--depth-1 { padding-left: 22px; font-size: 13px; color: var(--cor-cinza-600, #5A5A5A); }
.filter-option--depth-2 { padding-left: 40px; font-size: 12.5px; color: var(--cor-cinza-600, #5A5A5A); }
.filter-option--depth-1 .filter-option__name::before { content: '↳ '; opacity: 0.5; margin-right: 2px; }
.filter-option--depth-2 .filter-option__name::before { content: '↳ '; opacity: 0.5; margin-right: 2px; }

/* Selecionada: vermelho desbotado herdado pelos filhos via currentColor */
.filter-option:has(input:checked) {
  color: #EB263F;
}

.filter-option input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--cor-cinza-300, #B8B8B8);
  border-radius: 2px;
  background: var(--cor-branco, #FFFFFF);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
  position: relative;
  transition: border-color 0.15s ease;
}

.filter-option input[type="checkbox"]:hover {
  border-color: var(--cor-cinza-500, #717171);
}

/* Checked: SEM fundo preto/colorido — apenas borda + V na cor do texto (currentColor)
   herdado do .filter-option:has(input:checked) que pinta tudo em vermelho desbotado */
.filter-option input[type="checkbox"]:checked {
  background: var(--cor-branco, #FFFFFF);
  border-color: currentColor;
}

.filter-option input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 4px;
  height: 8px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  color: #EB263F; /* fallback caso :has() nao seja suportado — mantem o V vermelho desbotado */
}

.filter-option__name {
  flex: 1;
  font-weight: 400;
}

.filter-option__count {
  font-size: 12px;
  color: var(--cor-cinza-500, #717171);
  font-weight: 400;
  flex-shrink: 0;
}

/* ---------- Mostrar mais ---------- */
.filter-group__more {
  background: none;
  border: none;
  color: var(--cor-cinza-500, #717171);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0 2px;
  margin-top: 4px;
  text-align: left;
  align-self: flex-start;
  transition: color var(--transition-fast);
}

.filter-group__more:hover {
  text-decoration: none;
  color: var(--cor-cinza-700, #3D3D3D);
}

/* ---------- Faixa de preço ---------- */
.filter-group--price .filter-price-range {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.filter-price-range input[type="number"] {
  flex: 1;
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--cor-cinza-100, #E2E0DB);
  border-radius: 2px;
  background: var(--cor-branco, #FFFFFF);
  color: var(--cor-preto);
  font-family: var(--font-body);
}

.filter-price-range input[type="number"]:focus {
  outline: none;
  border-color: var(--cor-preto);
}

.filter-price-range input[type="number"]::-webkit-inner-spin-button,
.filter-price-range input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.filter-price-range input[type="number"] {
  -moz-appearance: textfield;
}


/* ─── Filtro Categoria: arvore collapsible (decisao 2026-05-06) ──────────── */
/* Estado inicial: maes fechadas. Click expande. Chevron rotaciona. */
.filter-cat-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}
.filter-cat-tree .filter-cat-tree {
  margin: 4px 0 4px 14px;          /* indentacao das filhas */
  padding-left: 6px;
  border-left: 1px solid var(--cor-cinza-100, #E2E0DB);
}
.filter-cat-children {
  list-style: none;
  margin: 4px 0 4px 14px;
  padding-left: 6px;
  border-left: 1px solid var(--cor-cinza-100, #E2E0DB);
}
.filter-cat-node {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Toggle da MAE: linha clicavel inteira (categoria-mae nao filtra, so navega) */
.filter-cat-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 7px 4px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--cor-cinza-700, #3D3D3D);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
  text-align: left;
  line-height: 1.4;
}
.filter-cat-toggle:hover {
  color: var(--cor-cinza-900, #1A1A1A);
  background: var(--cor-cinza-050, #F7F6F3);
}
.filter-cat-name { flex: 1 1 auto; }
.filter-cat-chevron {
  flex-shrink: 0;
  transition: transform 200ms ease;
  color: var(--cor-cinza-500, #717171);
}
.filter-cat-toggle[aria-expanded="true"] .filter-cat-chevron,
.filter-cat-toggle--inline[aria-expanded="true"] .filter-cat-chevron {
  transform: rotate(90deg);
  color: var(--cor-cinza-700, #3D3D3D);
}

/* Linha de FILHA com netas: checkbox + chevron-toggle separados */
.filter-cat-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.filter-cat-row .filter-option--cat {
  flex: 1 1 auto;
  padding: 6px 4px;
}
.filter-cat-toggle--inline {
  flex-shrink: 0;
  width: 24px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  color: var(--cor-cinza-500, #717171);
  transition: color 150ms ease;
}
.filter-cat-toggle--inline:hover {
  color: var(--cor-cinza-900, #1A1A1A);
}

/* Filha-direta do tree-root: nao precisa do indentation extra do
   'filter-cat-tree .filter-cat-tree' — ela ja eh filha da root. */
.filter-group--cat-tree .filter-cat-tree { margin-left: 0; padding-left: 0; border-left: 0; }

/* Acessibilidade: focus-visible mantem contraste */
.filter-cat-toggle:focus-visible,
.filter-cat-toggle--inline:focus-visible {
  outline: 2px solid var(--cor-azul);
  outline-offset: 1px;
}

/* ---------- Loading state (preparacao FASE 6) ---------- */
.shop-grid.is-loading {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* ---------- Toolbar refinada ---------- */
.shop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--cor-cinza-100, #E2E0DB);
  font-size: 13px;
}

.shop-toolbar__count {
  margin: 0;
  color: var(--cor-cinza-500, #717171);
  font-size: 13px;
}

/* ───── Toolbar desktop — Ordenar por ─────
   Wrappers manuais removidos: substituídos pelo componente ark-select.
   O <select> agora tem data-ark-select e ark-select.css cuida do visual.
   ──────────────────────────────────────────── */

/* ---------- TOP bar mobile (oculto em desktop) ---------- */
.shop-mobile-top-bar { display: none; }

/* ---------- Aplicar Filtros mobile (oculto em desktop) ---------- */
.filter-sidebar__apply-mobile { display: none; }

/* Backdrop do drawer (oculto por padrão) */
.shop-filter-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 290;
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* ---------- Mobile (drawer + bottom bar) ---------- */
@media (max-width: 1024px) {
  /* Ocultar wrapper sort desktop em mobile (top/bottom bar já cobrem ordenação).
     ark-select envolve o <select name="orderby"> num .ark-select — ocultamos esse wrapper. */
  .shop-toolbar .ark-select {
    display: none;
  }

  /* Sidebar vira drawer fixo lateral esquerdo */
  .filter-sidebar {
    display: block;
    position: fixed;
    inset: 0 30% 0 0;
    max-width: 360px;
    background: var(--cor-branco, #FFF);
    z-index: 300;
    overflow-y: auto;
    padding: 20px 16px 24px;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 24px rgba(0, 0, 0, 0.18);
  }

  .filter-sidebar.is-open {
    transform: translateX(0);
  }

  /* Backdrop visível quando drawer aberto */
  .filter-sidebar.is-open ~ .shop-filter-backdrop,
  body.has-filter-open .shop-filter-backdrop {
    display: block;
    opacity: 1;
  }

  /* Botão X de fechar — visível só mobile */
  .filter-sidebar__close {
    display: block;
  }

  /* Bloqueia scroll do body quando drawer aberto */
  body.has-filter-open {
    overflow: hidden;
  }

  /* ---------- TOP bar mobile (acima da grade) ---------- */
  .shop-mobile-top-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
    /* Sticky: fica colado logo abaixo do header fixo ao rolar */
    position: sticky;
    top: var(--header-height-total, 116px);
    z-index: 50;
    background: var(--cor-branco, #FFF);
    padding: 12px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  }
  .shop-mobile-top-bar > * {
    flex: 1 1 50%;
    min-width: 0; /* permite shrink */
    max-width: calc(50% - 4px); /* 4px = metade do gap de 8px */
    height: 40px;
    font-size: 13px;
    background: var(--cor-branco, #FFF);
    border: 1px solid var(--cor-cinza-100, #E2E0DB);
    border-radius: 2px;
    font-family: var(--font-body);
    color: var(--cor-preto);
  }
  .shop-mobile-top-bar__filter {
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
  }
  /* rc1097 — "celular impecável" (gestor 16/09): em 360px o gatilho do Ordenar tem 160px e
     "Ordenar por:" + "A → Z" + seta + preenchimento pedem 166 — o valor saía cortado com
     reticências. Preenchimento e espaço menores só na barra do celular: sobram 12px. */
  .shop-mobile-top-bar .ark-select__trigger { padding: 0 8px; gap: 4px; }
  .shop-mobile-top-bar .ark-select__label { font-size: 12px; }
  .shop-mobile-top-bar .ark-select__value { min-width: 0; overflow: hidden; text-overflow: clip; } /* cabe: 160 − 16 − 72 − 8 − 10 = 54px ≥ 36 */
  /* Wrapper manual removido — ark-select cuida do visual do sort mobile top bar.
     O .ark-select herda flex: 1 1 50% do seletor .shop-mobile-top-bar > * abaixo. */

  /* Anular border/background herdados de .shop-mobile-top-bar > *
     no wrapper .ark-select — a border real fica no .ark-select__trigger interno
     (evita "borda dupla" reportada pelo usuário) */
  .shop-mobile-top-bar > .ark-select {
    border: none;
    background: transparent;
    padding: 0;
    height: auto;
  }

  /* ---------- Drawer: botão "Aplicar Filtros" no rodapé ---------- */
  .filter-sidebar__apply-mobile {
    display: block;
    margin-top: 24px;
    width: 100%;
    padding: 14px 16px;
    background: var(--cor-preto);
    color: var(--cor-branco, #FFF);
    border: none;
    border-radius: 2px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    font-family: var(--font-body);
    transition: background 0.15s ease;
  }
  .filter-sidebar__apply-mobile:hover {
    background: var(--cor-cinza-500, #717171);
  }
}
