Bam Margera's family has never seen him struggle like this before and they think they know why ... he's not taking his bipolar meds, but Dr. Phil is still pulling for him to keep fighting the good fight.
Sources connected to the family tell TMZ ... the former "Jackass" star is not taking medication for his bipolar disorder, and they believe it's a major factor triggering his recent bizarre behavior.
As we reported, Bam cried out for help a few weeks back ... help from Dr. Phil who convinced him to go to rehab, but he bailed after a week and it was downhill from there.
TMZ broke the story ... Bam was arrested early Wednesday morning when he wouldn't leave the Luxe Hotel on the Sunset Strip. He went off the rails inside the hotel, squared off with police and was ultimately arrested for trespassing.
Bam smiled after being released from jail, but it's clear no one else is ... it's a dire situation.
Dr. Phil -- who helped convince Bam to enter rehab after a 3-hour session -- tells TMZ ... "I hope he can resume treatment. My attitude is NEVER surrender to the disease. It is a tug of war and you just can't ever drop your end of the rope."
The Doc went on ... "Bam is such a charming, hard working and talented guy. You can't help but like and pull for him. Fingers crossed."
We're told the family's had little to no contact with Bam and they're worried sick.