Britney Spears was super-paranoid that her hair contained traces of the hardcore drugs she was using -- and that's why she SHAVED IT ALL OFF during her infamous 2007 meltdown ... at least according to Sam Lutfi.
Sam's lawyer, Joseph Schleimer, has been telling the court ... Britney was a serious drug-abuser ... who had a penchant for crystal meth.
Schleimer suggested Britney was concerned that a judge would test her hair for drugs -- and when it turned up positive, she would lose custody of her kids.
So, Britney ... being Britney ... believed that if she chopped off her hair, she could beat the drug test ... at least that's what Lutfi's lawyer is implying.
Britney's side has yet to respond.