Lindsay Lohan is in custody ... after Judge Elden Fox shockingly denied her bail ... and Lindsay could be sitting there until October 22. But LiLo's lawyer just told us, the judge was dead wrong.
Lindsay was in court because she failed two drug tests -- in one she tested positive for cocaine and the other for Adderall.
Judge Fox did not hear any arguments from the lawyers before making his ruling. Lindsay's lawyer, Shawn Chapman Holley, told TMZ on the way out of court ... the judge had no legal basis for denying her client bail.
Lindsay was handcuffed in court before being taken into custody.
It's shocking because the underlying offense is a misdemeanor, and people connected with the case were telling us the judge had to offer Lindsay bail.
As for Lindsay's reaction ... she was shocked when the judge remanded her into custody. Lindsay looked at her lawyer, Shawn Chapman Holley, before being taken out of the courtroom. She was taken from court in a single Sheriff's vehicle, covered by a blanket.
Lindsay Lohan fun fact: She was hauled off to jail in a pair of $1,195 Christian Louboutin shoes. Fancy!
UPDATE: Los Angeles County sheriff's spokesman Steve Whitmore told reporters Lindsay will be housed in "administrative segregation" because of her celebrity status for her safety and the safety of the jail system. He also said the only way she could be released before her probation hearing on Oct 22 is if the judge issues another order.