This is something of a gray area under the Fair Labor Standards Act, which governs overtime. The general rule is that an employer does not have to pay for all of the time. Here is the regulation:
On the other hand, the hours are calculated differently if you are on duty for the entire time, and in some cases you are entitled to 24 hours of pay:
You would need to go through all of the facts and circumstances with a local employment lawyer.
I think "grey area" is the best way to describe this practice. They technically didn't imprison you on site, so there is no civil suit for that behavior. They probably don't have to pay you for time you were sleeping in the provided trailers. While it is getting very close to the line, it is probably legal.
There are very specific provisions on jobs where staying on site is a bona fide requirement. There are also provisions on how much can be charged for food and housing.
You need more detailed review than you are going to find in a free online answer.