/* =====================================================
   FRILLO — Filters
   Barra de filtros globais
   ===================================================== */

/* ── Filter Group ── */
.filter-group {
  position: relative; /* Suporte para absolute positioning de dropdown */
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: all var(--transition-base);
}

.filter-group.expandable {
  flex-direction: row;
}

.filter-trigger-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  height: 40px; /* Altura padronizada de 40px */
  box-sizing: border-box;
  border-radius: var(--radius-md); /* Retangular com cantos arredondados */
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.filter-trigger-btn:hover {
  background: var(--bg-chip);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.filter-group.expanded .filter-trigger-btn {
  background: var(--bg-chip-active);
  color: var(--accent);
  border-color: var(--border-accent);
}

.filter-chevron {
  width: 12px;
  height: 12px;
  transition: transform var(--transition-base);
}

.filter-group.expanded .filter-chevron {
  transform: rotate(180deg);
}

/* ── Filter Expandable Content ── */
.filter-expandable-content {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  z-index: 100;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  padding: var(--space-3);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: transform var(--transition-base), opacity var(--transition-base);
  display: flex;
  width: max-content;
}

.filter-group.expanded .filter-expandable-content {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.filter-content-inner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: max-content;
}

.filter-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ── Filter Select ── */
.filter-select {
  appearance: none;
  -webkit-appearance: none;
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-3);
  background: var(--bg-chip);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-family: var(--font-ui);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B8D97' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-2) center;
  padding-right: var(--space-6);
  min-width: 100px;
}

.filter-select:hover {
  border-color: var(--border-default);
  color: var(--text-primary);
}

.filter-select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--shadow-accent);
  color: var(--text-primary);
}

.filter-select.active {
  background-color: var(--bg-chip-active);
  border-color: var(--border-accent);
  color: var(--accent);
}

[data-theme="light"] .filter-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A5E72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* Custom list layout inside Sort dropdown */
.filter-sort-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 180px;
}

.filter-sort-option {
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: all var(--transition-fast);
}

.filter-sort-option:hover {
  background: var(--bg-chip);
  color: var(--text-primary);
}

.filter-sort-option.active {
  background: var(--bg-chip-active);
  color: var(--accent);
  font-weight: 600;
}

/* Stack chips vertically inside filter dropdown content */
.filter-expandable-content .filter-chips {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-1);
  min-width: 150px;
}

.filter-expandable-content .filter-chip {
  text-align: left;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  width: 100%;
}

/* ── Filter Chip Pills (Demand Type & Format) ── */
.filter-chips {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.filter-chip {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md); /* Retangular com cantos arredondados */
  font-size: var(--text-sm);
  font-weight: 500;
  background: var(--bg-chip);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.filter-chip:hover {
  border-color: var(--border-default);
  color: var(--text-primary);
}

.filter-chip.active {
  background: var(--bg-chip-active);
  border-color: var(--border-accent);
  color: var(--accent);
}

/* Status-specific active states */
.filter-chip.active[data-type="Criação"] {
  background: var(--status-criacao-bg);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--status-criacao);
}

.filter-chip.active[data-type="Alteração"] {
  background: var(--status-alteracao-bg);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--status-alteracao);
}

.filter-chip.active[data-type="Refação"] {
  background: var(--status-refacao-bg);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--status-refacao);
}

/* ── Filter Divider ── */
.filter-divider {
  width: 1px;
  height: 20px;
  background: var(--border-default);
  flex-shrink: 0;
}

/* ── Client Search Input ── */
.filter-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.filter-search-wrapper svg {
  position: absolute;
  left: var(--space-3);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.filter-search {
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-8);
  background: var(--bg-chip);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  transition: all var(--transition-fast);
  width: 180px;
}

.filter-search::placeholder { color: var(--text-muted); }

.filter-search:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--shadow-accent);
  width: 220px;
}

.filter-search.active {
  border-color: var(--border-accent);
  background: var(--bg-chip-active);
}

/* ── Clear Button ── */
.filter-clear-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md); /* Retangular com cantos arredondados */
  font-size: var(--text-sm);
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  margin-left: auto;
}

.filter-clear-btn svg { width: 14px; height: 14px; }

.filter-clear-btn:hover {
  border-color: var(--status-refacao);
  color: var(--status-refacao);
  background: var(--status-refacao-bg);
}

/* Active filter indicator on filter bar */
.filter-bar-inner.has-filters {
  background: linear-gradient(
    to right,
    transparent,
    rgba(124, 92, 252, 0.04) 50%,
    transparent
  );
}

/* ── Responsive Filters ── */
@media (max-width: 768px) {
  .filter-bar-inner {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .filter-label { display: none; }
  .filter-divider { display: none; }

  .filter-search {
    width: 130px;
  }
  .filter-search:focus {
    width: 160px;
  }
}
