I’m in the US but I’m pretty sure they aren’t allowed to hold you more than 72 hours without good reason.
They do it all the time. Every mental hospital has a "mini-courtroom" that has cameras/microphones and a judge hops on a zoom call and patients are presented to be kept longer than 72 hours. If the doctor says "this patient is a risk to himself and/or others, we need to keep him here" the judge signs off 99.999% of the time.
What's the judge gonna do instead -- disagree with the doctor (who has spent time with the actual patient) because the judge feels like letting a random innocent person go free who he has never interacted with?