(CN) – The filthy and overcrowded detention cells in the U.S. Border Patrol’s Tucson Sector are unconstitutional, a federal judge ruled Wednesday, ordering all pretrial detainees held at processing centers for more than two days be given food, blankets and showers.

“The court finds that the conditions of detention in CBP holding cells, especially those that preclude sleep over several nights, are presumptively punitive and violate the Constitution,’ U.S. District Judge David C. Bury wrote in his 40-page ruling. “Detention may not extend into a third night under the ‘no longer than 48 hours’ rule, unless and until [Customs and Border Patrol] can provide conditions of confinement that meet detainees’ basic human needs for sleeping in a bed with a blanket, a shower, food that meets acceptable dietary standards, potable water, and medical assessment performed by a medical professional.”

Bury’s ruling follows a seven-day bench trial in January during which immigrants caught crossing the U.S.-Mexico border testified about being held for days in packed detention cells without medical attention, showers or adequate food.

People picked up by Border Patrol are held in processing centers until they are transferred to the U.S. Immigration and Customs Enforcement, Office of Enforcement and Removal Operations, the Office of Refugee Resettlement, the U.S. Marshals Service or another agency.

Detention centers which aren’t meant to house people for more than a couple of days are currently acting as “ICE overflow,” one attorney said, because “there is so little capacity in other areas of the [Department of Homeland Security].”

The cells are so crowded some detainees said they were forced to sleep next to the toilet – a situation that appalled the judge, who enjoined the CBP from packing the cells to such an extent.

“Regardless of whether a detainee is sleeping on a mat or directly on the concrete floor, being forced to sleep in a toilet area due to overcrowding offends the notions of common decency; it is unsanitary and degrading for all detainees who either have to sleep in the toilet area or try to use the toilet when others are sleeping there,” Bury wrote.

Bree Bernwanger, an attorney with the Lawyers Committee Civil Rights SF Bay Area, said on a press call with reporters that Bury’s ruling builds on a preliminary injunction he issued in 2016. His order was meant to improve conditions at various processing centers, following a lawsuit filed by three people in 2015 that later became a class action.

Reasoning that “defendants could not side-step the reality that over half the detainees were being held longer than 12 hours and, therefore, physiologically had the human need to lie down and sleep,” Bury required Border Patrol to give detainees held for more than 12 hours a sleeping mat and Mylar blanket, and a shower or body wipe if a shower was not available.

“What the court recognized today is that order did not go far enough to bring the Border Patrol in line with the constitutional standards to which they are bound,” Bernwanger said.

Lead trial attorney Collette Mayer with Morrison & Foerster LLP said Bury’s ruling sets a constitutional standard for how civil detainees held in immigration-detention type facilities should be treated.

“Prior to todays’ decision we had no clear holding from any federal court for the constitutional minimums for Border Patrol processing facilities,” Mayer said, adding the case took so long to adjudicate because the government argued forcefully that detention facilities did not need to provide showers, blankets or medical care because they aren’t prisons, which are required to meet these basic human needs.

She noted that Bury mentioned in his ruling that civil detainees in these centers, who are not convicted of any crimes, are treated far worse than prisoners.

A Honduran woman identified at trial only as “Witness B” said Wednesday that she is happy about the outcome of the trial.

“I know all the people who have to go to the detention center aren’t going to have to experience the same thing I did and knowing they’ll get adequate medical care makes me feel good,” she said.

Witness B, who was 19 at the time she was picked up by Border Patrol in April 2019, arrived at a Tucson Sector detention center pregnant and nauseous.

“An official saw me vomiting and he told me his wife also vomited when she was pregnant and that was normal. I told him, ‘Maybe it’s normal but that I hadn’t eaten in a day.’ When he heard me respond and say that he just smiled and laughed at me,” she said.

Though the woman was eventually taken to a hospital and given food and medicine, back at the detention center she said she wasn’t given anything for her nausea and had to sleep on the floor of cell crammed with other women.

Another woman, who did not testify at trial but was a member of the class said she was repeatedly denied milk for her infant son. The woman from El Salvador, now 27, said she was unable to bathe despite not showering for four days after arriving at the center in April 2019.

“They said I could bathe my son but I couldn’t take a bath,” she said. “I wanted milk for my son but they wouldn’t give me any milk. I asked for an extra burrito for him and they wouldn’t give me any either.” She also had only one blanket for the two of them, she said.

The woman said the cell where she stayed for five days was freezing. “Most of the children were sick and the air was so cold. When we asked them to turn down the cold air they said they had to keep it cold to kill the virus that was getting everyone sick,” she said.

But she also said she is hopeful that conditions will improve because of Bury’s order.

“Everyone is going to have better conditions, most of all the children,” the woman said.