/* =============================================
   components/search/search.css
============================================= */
/* Remove o botão de limpar nativo do Chrome, Safari, Edge e WebViews */
input#campo-busca.search-bar__input::-webkit-search-cancel-button,
input#campo-busca.search-bar__input::-webkit-search-decoration,
input#campo-busca.search-bar__input::-webkit-search-results-button,
input#campo-busca.search-bar__input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
.search-bar {
  display: flex;
  align-items: center;
  background: var(--branco);
  border-radius: 100px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 0.6rem 0.8rem 0.6rem 1.2rem;
  gap: 0.5rem;
  transition: background-color 0.2s, box-shadow 0.2s;
}
@media (width: 480px) {
  .search-bar {
    padding: 0.5rem 0.7rem 0.5rem 1rem !important;
    gap: 0.4rem;
  }
}
.search-bar:focus-within {
  background: var(--branco);
  box-shadow: 0 4px 12px rgba(30, 95, 194, 0.12), 0 2px 4px rgba(0, 0, 0, 0.04);
}

.search-bar--full {
  width: 100%;
}
.search-bar__icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  color: var(--azul-medio);
}
.search-bar__input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  color: var(--texto);
  background: transparent;
  min-width: 0;
}
.search-bar__input::placeholder {
  color: var(--cinza);
  opacity: 0.8;
}
.search-bar__btn-submit {
  background: none;
  border: none;
  padding: 0.5rem;
  color: var(--azul-medio);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.2s, background-color 0.2s;
}
.search-bar__btn-submit:active {
  background-color: var(--azul-ultraclaro);
  color: var(--azul-medio);
}

.search-bar__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  background: transparent;
  color: var(--texto-suave, #888);
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
}
.search-bar__clear:hover,
.search-bar__clear:focus-visible {
  background: rgba(0, 0, 0, 0.06);
}
.search-bar__clear.hidden {
  display: none;
}

.filtros {
  background: var(--cinza-claro);
  border: 1px solid var(--azul-suave);
  border-radius: var(--raio);
  padding: 1.25rem;
}
.filtros__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.filtro-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.filtro-item--check {
  justify-content: flex-end;
}
.filtro-item__label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--azul-escuro);
}
.filtro-item__select,
.filtro-item__input {
  padding: 0.55rem 0.9rem;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--raio-sm);
  font-size: 0.92rem;
  color: var(--texto);
  background: var(--branco);
  outline: none;
  transition: border-color 0.2s;
}
.filtro-item__select:focus,
.filtro-item__input:focus {
  border-color: var(--azul-medio);
}

.resultado-area__placeholder {
  text-align: center;
  color: var(--texto-suave);
  padding: 4rem 1rem;
  font-size: 1rem;
}

html.dark .search-bar {
  background: #1e293b;
  border-color: #334155;
}
html.dark .search-bar__input {
  color: #f1f5f9;
}
html.dark .filtros {
  background: #1e293b;
  border-color: #334155;
}
html.dark .filtro-item__select,
html.dark .filtro-item__input {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

/* ── Filtros profissionais ────────────────────────────────────────── */
.filtros-pro {
  background: var(--branco);
  border: none; /* Remove a borda rígida antiga */
  border-radius: var(--raio-lg); /* Cantos mais suaves combinando com o app */
  padding: 1rem 1.125rem;
  margin-top: -0.5rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  /* Mesma sombra leve e profissional usada na barra de busca */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
}

.filtros-pro__section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filtros-pro__label {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--texto-suave);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.filtros-pro__label i {
  color: var(--azul-medio);
}

.filtros-pro__row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem; /* Aumentado ligeiramente para os elementos respirarem */
  align-items: center; /* Alinha o input e o toggle horizontalmente de forma limpa */
  padding-top: 0.85rem;
  border-top: 1px solid var(--azul-ultraclaro); /* Divisor suave em vez de cinza escuro */
}

.filtros-pro__group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1 1 auto;
  min-width: 0;
}

.filtros-pro__group--input {
  flex: 0 1 150px;
}

.filtros-pro__group--check {
  flex: 0 0 auto;
  justify-content: flex-end;
  padding-bottom: 0.05rem;
}

/* Chips */
.filtros-pro__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filtros-pro__chips--sm {
  gap: 0.3rem;
}

/* Input de preço */
.filtros-pro__input {
  width: 100%;
  padding: 0.55rem 1rem;
  border: 1.5px solid var(--azul-suave); /* Borda muito discreta */
  border-radius: 100px; /* Transforma em pílula para casar com a busca */
  font-size: 0.88rem;
  color: var(--texto);
  background: var(--branco);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filtros-pro__input:focus {
  border-color: var(--azul-medio);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Toggle switch CSS puro */
.filtros-pro__toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.filtros-pro__toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.filtros-pro__toggle-track {
  position: relative;
  width: 40px; /* 36 e 20px Ligeiramente mais largo para um visual fluido */
  height: 22px;
  background: var(--cinza);
  border-radius: 100px;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.filtros-pro__toggle input:checked + .filtros-pro__toggle-track {
  background: var(--sucesso);
}

.filtros-pro__toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--branco);
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.filtros-pro__toggle
  input:checked
  + .filtros-pro__toggle-track
  .filtros-pro__toggle-thumb {
  transform: translateX(18px);
}

.filtros-pro__toggle-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--texto, #0f172a);
}

/* Rodapé de resumo */
.filtros-pro__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f1f5f9;
  flex-wrap: wrap;
}

.filtros-pro__resumo-texto {
  font-size: 0.76rem;
  color: var(--texto-suave, #64748b);
  font-weight: 500;
}

.filtros-pro__limpar {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: #dc2626;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 0.3rem;
  transition: background 0.15s;
  white-space: nowrap;
}
/* =============================================
   [FIX SE29/SE30] Barra compacta: carrossel de
   categorias + botão de filtros avançados
============================================= */

.filtros-pro__barra {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Carrossel horizontal — substitui o "wrap" multi-linha, libertando
   espaço vertical na primeira dobra do mobile. */
.filtros-pro__chips--scroll {
  display: flex;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden; /* Evita qualquer quebra ou scroll vertical fantasma */

  /* CORREÇÃO CRÍTICA PARA MOBILE: Força o navegador a aceitar apenas o arrasto horizontal */
  touch-action: pan-x;

  /* Ajuste no Snap: Se mantiveres, 'mandatory' funciona melhor no mobile que 'proximity' */
  scroll-snap-type: x mandatory;

  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.15rem 0.1rem -0.1rem;

  /* Máscara preservada (apenas do lado direito) */
  mask-image: linear-gradient(
    to right,
    #000 0%,
    #000 calc(100% - 16px),
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to right,
    #000 0%,
    #000 calc(100% - 16px),
    transparent 100%
  );
}
.filtros-pro__chips--scroll::-webkit-scrollbar {
  display: none;
}
.filtros-pro__chips--scroll .filtro-chip {
  flex-shrink: 0;
  /* Alinhado com o 'mandatory' para um deslize suave e preciso */
  scroll-snap-align: start;
}

/* Botão de filtros avançados */
.btn-filtros-toggle {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 1.5px solid var(--azul-suave);
  border-radius: var(--raio-sm);
  background: var(--branco);
  color: var(--azul-medio);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}
.btn-filtros-toggle:hover,
.btn-filtros-toggle:focus-visible {
  border-color: var(--azul-medio);
  background: rgba(37, 99, 235, 0.08);
}
.btn-filtros-toggle i {
  transition: transform 0.2s ease;
}
.btn-filtros-toggle[aria-expanded="true"] i {
  transform: rotate(180deg);
}
.btn-filtros-toggle--ativo {
  border-color: var(--azul-medio);
  color: var(--azul-escuro);
  background: rgba(37, 99, 235, 0.08);
}
.btn-filtros-toggle__badge {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--azul-medio);
  color: var(--branco);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
}
.btn-filtros-toggle__badge.hidden {
  display: none;
}

/* Painel colapsável (distância / preço / estoque) */
.filtros-pro__avancados {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  visibility: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease,
    visibility 0.25s step-end;
}
.filtros-pro__avancados--aberto {
  max-height: 600px; /* margem confortável para o conteúdo do painel */
  opacity: 1;
  visibility: visible;
  margin-top: 0.75rem;
  transition: max-height 0.25s ease, opacity 0.2s ease, visibility 0s;
}

/* Nova row que obriga os dois elementos a ficarem lado a lado */
.filtros-pro__row-inline {
  display: flex;
  align-items: flex-end; /* Alinha a base do input com a base do switch */
  justify-content: space-between; /* Empurra o preço para a esquerda e o stock para a direita */
  gap: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--azul-ultraclaro);
  width: 100%;
}

/* Controla o tamanho do campo de preço na esquerda */
.filtros-pro__group-inline {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1; /* Ocupa o espaço disponível na esquerda */
  max-width: 140px; /* Define o tamanho máximo compacto para o input de preço */
}

/* Garante o comportamento correto do input pílula */
.filtros-pro__group-inline .filtros-pro__input {
  width: 100%;
  padding: 0.5rem 0.85rem; /* Padding ligeiramente menor para ecrãs pequenos */
}

/* Alinha o switch perfeitamente à direita */
.filtros-pro__group-inline-check {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0; /* Impede o switch de encolher ou quebrar o texto */
  padding-bottom: 0.45rem; /* Ajuste fino para alinhar verticalmente com o input ao lado */
}

@media (prefers-reduced-motion: reduce) {
  .filtros-pro__avancados,
  .filtros-pro__avancados--aberto,
  .btn-filtros-toggle i {
    transition: none;
  }
}

html.dark .btn-filtros-toggle {
  background: #1e293b;
  border-color: #334155;
}
html.dark .btn-filtros-toggle--ativo,
html.dark .btn-filtros-toggle:hover,
html.dark .btn-filtros-toggle:focus-visible {
  background: rgba(37, 99, 235, 0.18);
}
