“你怎么了”and "你没事吧"
you will say them after something happened, but I think, "你怎么了" : you dont know what happened
"你没事吧" you know what happened, and maybe attendant.
ahah`~~ it is almost same... I think... even I dont divide them at all in anytime... in my daily life