I was a terrible, awful teenager. I don't feel comfortable going into the details in a public forum, but I was a bad, bad kid for while there. It breaks my heart now, thinking of what I put my mom through. And somehow, through some crazy miracle, I turned out to be this highly respectable adult (I think). Managing editor of a prestigious academic journal. Loving, vigilant mom. Etc.
I recount all this because I can tell you exactly what I needed (though I would have disagreed at the time): Structure.
First of all, if your daughter is acting inappropriately online, disable your internet connection. Disable the function that enables any computer or iPad in the house to access the Internet. Yes, that will be a huge inconvenience for the rest of you, but you have a teenage girl in serious danger here. Do it. If you work from home or something, start working from the library when she's in school. The home computer can be for word processing, and that is it.
Second, for every minute of every day when she is not in school or under your direct supervision, she needs to be signed up for an activity. The key here is that these activities should not be boring or punitive. They should be interesting and engaging, she should have a hand in picking them out, and most importantly, they should be full of good kids -- not the kids she's hanging out with now. She will resist these activities like holy hell. Just tell her, "Either you pick something out, or I am going to pick something out for you, and your personal enjoyment is not my top priority right now, young lady." Super bonus points if you can find her an activity where she helps others. Kids who can't act responsibly "upwards" (toward parents or other authority figures) can often act responsibly "downwards" (toward younger children or animals), and this is key to their finding a constructive place for themselves in society. What's most important here, though, is that it will give her a new crowd of kids, and with enough time, she will start to model her behavior around them.
Finally, when she's home, sit her down in front of her homework. Make sure the stuff gets done, and gets done well. If she starts getting good grades, she will be motivated to keep that up. Good grades are a great motivator to do still better. Bad grades don't work nearly as well as a motivator to improve.
My family DID put me into counseling, and honestly, it didn't do a damn bit of good. I was then, and am today, a private person who resents prying -- even in a therapeutic context. I was just swept up in a bad crowd and didn't have a strong internal compass or good self-discipline. I had been terribly, severely bullied all through grade school, and had never developed the ability to choose my friends wisely, since I'd never really had friends before high school.
Oh, and if there's a concern about her running away from school, notify the school authorities. They may be able to have someone escort her to her first class in the morning and to make sure she's in some kind of structured space during free periods and lunch.
Hope that helps.
Mira