:host {
  display: block;
  min-width: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.filters-card {
  border: 1px solid var(--pg-border, #dbe3ef);
  border-radius: var(--pg-radius-md, 14px);
  padding: 16px;
  display: grid;
  gap: 14px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--pg-shadow-sm, 0 8px 18px rgba(15, 23, 42, 0.08));
  overflow: hidden;
}

.filters-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.filters-head > * {
  min-width: 0;
}

.filters-title-wrap {
  display: grid;
  gap: 6px;
  flex: 1 1 360px;
  min-width: 0;

  small {
    color: var(--pg-text-soft, #64748b);
    font-size: 12px;
    font-weight: 600;
  }
}

.filters-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--pg-text, #0f172a);
  font-weight: 800;

  i {
    color: var(--pg-primary, #1f4fd6);
  }
}

.filters-actions {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.btn-primary,
.btn-ghost {
  height: 38px;
  border-radius: var(--pg-radius-sm, 10px);
  border: 1px solid transparent;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;

  &:focus-visible {
    outline: none;
    box-shadow: var(--pg-focus-ring, 0 0 0 3px rgba(31, 79, 214, 0.22));
  }

  &:disabled {
    opacity: 0.62;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
  }
}

.btn-primary {
  color: #fff;
  border-color: var(--pg-primary-strong, #153caa);
  background: linear-gradient(140deg, var(--pg-primary, #1f4fd6), var(--pg-primary-strong, #153caa));
  box-shadow: 0 10px 20px rgba(31, 79, 214, 0.25);
}

.btn-ghost {
  color: var(--pg-text, #0f172a);
  background: #fff;
  border-color: var(--pg-border-strong, #c8d4e4);
}

.btn-primary:hover,
.btn-ghost:hover {
  transform: translateY(-1px);
}

.btn-ghost:hover {
  border-color: var(--pg-primary, #1f4fd6);
  color: var(--pg-primary-strong, #153caa);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.filter-field {
  display: grid;
  gap: 6px;
  min-width: 0;

  label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 800;
    color: var(--pg-text-soft, #64748b);
  }

  input {
    width: 100%;
    height: 40px;
    border-radius: var(--pg-radius-sm, 10px);
    border: 1px solid var(--pg-border-strong, #c8d4e4);
    background: #fff;
    color: var(--pg-text, #0f172a);
    padding: 0 12px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;

    &:focus {
      outline: none;
      border-color: var(--pg-primary, #1f4fd6);
      box-shadow: var(--pg-focus-ring, 0 0 0 3px rgba(31, 79, 214, 0.22));
    }

    &:disabled {
      background: #f5f8fd;
      color: var(--pg-text-soft, #64748b);
      cursor: not-allowed;
    }
  }
}

.competencia-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.competencia-row > * {
  min-width: 0;
  width: 100%;
}

.filters-meta {
  border-top: 1px dashed var(--pg-border, #dbe3ef);
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.search-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: min(420px, 100%);
  min-width: 0;
  border: 1px solid var(--pg-border-strong, #c8d4e4);
  border-radius: var(--pg-radius-sm, 10px);
  background: #fff;
  padding: 0 12px;
  height: 40px;

  i {
    color: var(--pg-text-soft, #64748b);
  }

  input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 13px;
    color: var(--pg-text, #0f172a);
    background: transparent;
  }

  &:focus-within {
    border-color: var(--pg-primary, #1f4fd6);
    box-shadow: var(--pg-focus-ring, 0 0 0 3px rgba(31, 79, 214, 0.22));
  }
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  border: 1px solid rgba(31, 79, 214, 0.2);
  background: rgba(31, 79, 214, 0.1);
  padding: 4px 10px;
  color: var(--pg-text-muted, #475569);
  font-size: 11px;
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  strong {
    color: var(--pg-primary-strong, #153caa);
  }
}

.hint {
  font-size: 12px;
  color: var(--pg-text-muted, #475569);
}

.hint.warn {
  color: var(--pg-warning, #b4690e);
  font-weight: 700;
}

.select-glass {
  display: block;
  width: 100%;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--pg-border-strong, #c8d4e4);
  border-radius: var(--pg-radius-sm, 10px);
  color: var(--pg-text, #0f172a);
  font-weight: 700;
}

@media (max-width: 1100px) {
  .filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .filters-actions {
    width: 100%;
  }

  .filters-actions .btn-primary,
  .filters-actions .btn-ghost {
    flex: 1;
  }

  .filters-grid {
    grid-template-columns: 1fr;
  }

  .filters-meta {
    align-items: stretch;
  }

  .search-box {
    width: 100%;
    min-width: 0;
  }

  .filter-chips {
    justify-content: flex-start;
  }
}
