OP, I'm so sorry to hear about your losses and your diagnosis. Things like this can put you under tremendous stress and anxiety, causing ADHD like symptoms.
As a teen I was just like you, I always got good grades but I flip flopped wildly between diligently revising for 6 hours a day and then doing no revision until the last 3 days before an exam. My mum called me useless, a dud... she didn't understand that I couldn't help it.
I would honestly get checked for ADHD just to be sure, it can manifest in very surprising ways. And then, whether or not you have a positive diagnosis, try to get Cognitive Behavioural Therapy for your compulsion to use social media and other distractions when you should be working.
What you have is essentially a coping mechanism to deal with stress, and it's a kind of addiction. To beat it, you need real professional help. Don't suffer alone. I'm hesitant to suggest psychotropic medication for such a young and developing brain, but I do take a supplement called magnolia bark which helps my anxiety and focus somewhat. It could be worth looking into. Your anxiety is the big problem here, and no wonder, what with all the stress you've been under!
Take care of yourself OP, have a nice hot bath and give yourself a break. Be honest with your parents and tell them frankly that you need real help. Bereavement and infertility are no joke! Wishing you luck x