Sorry, Tibsy, I don't have the answer but just wanted you to know you're not alone.
My ds is also 12 and sounds a lot like yours in that although he had a very close friend from the first day of primary, this friendship ended on the last day of primary when the friend started touching my ds "down there" and kept trying to grope him on further occasions. My ds is now worried that he may be gay and it's had a devastating effect on his self esteem and confidence.
All that on top of starting secondary has not been easy and although he is starting to make a little group of friends, now has no best friend, like your ds.
It sounds like you're doing everything you can, but I know I've started wondering if my ds would benefit by talking to a counsellor and I've heard hypnotherapy or selfhypnosis can be helpful. Getting my ds to agree to go may be a struggle!
I think there is a tendency for even the sunniest tempered boys to go through this phase of lacking in confidence and all we can really do is point out all the good things, praise them when they do something good (eg this morning, my ds behaved sensitively to a friend's relative poverty by avoiding telling him about some new stuff he'd bought, and I praised him for that).
Also, as others have said on this section, pick your battles. It's all to easy to criticise them 20 times a day, some of them (certainly my ds) are such airheads.
I'm finding teenage angst much harder to deal with that any of the toddler tantrums, and feel that the main thing is to let them know that you're always there for them, and nothing they say can shock you.
Good luck.