U S court rules against migrant detention in courthouses