this has really got to be one of the toughest things to happen to a parent. My mom always used to say that it's easy to be a good parent when your kid is being good, it's when they're in trouble that they need you the most. (in response to other parents' comments about my... ahem... unexpected first pregnancy).
You have to walk a fine line, and it's hard to predict ahead of time how your kid will react to any particular action you take. And if you "come at her like gale force winds", and worse yet "Baker Act" her, you run a very strong risk of completely alienating her. This will mean that she will turn from you and nothing you do will have any effect. Doesn't always happen, but it could.
Here are my suggestions:
1. Read "Hold On to Your Kids" by Gordon Neufeld and Gabor Mate. Will explain to you what went wrong (orienting to peers instead of adults), and suggest things that will fix it. The focus is the attachment of the child to the parent. Without that attachment, the parent doesn't have the innate authority to parent the child. Some of their suggestions may be too late to implement, but not all of it. Most of it will take lots of time, though, and you don't have that right now. It definitely sounds like drugs are an issue here, and the longer you wait, the more likely she is to fall further into addiction.
2. Make a break with her current situation, and put yourself as the person in charge. One suggestion is to go out into the wilderness with her. Definitely take her out of school, at least for now. If you can't do that sort of thing with her, maybe your spouse, or a trusted connection (like a youth pastor or something) could. Or maybe travel to somewhere that you know but she doesn't. You might have to be gone for a week or two. At least. The important things are to remove her from her peers and for an adult to be in a position of authority, able to take charge and "orient" the child - tell them what's going on and when, and where you're going, etc. If it was me, and I had to miss work, and even if I had to quit my job, I would do it. (Easy to say, I know.) Minimize her interactions with other kids until she is oriented to you or another adult you trust.
Find support and help. Preferably help that will enhance/support your relationship with your daughter and not contribute to its further deterioration.
4. Say as little to her as possible beyond "This is what we're doing" - avoid getting drawn into arguments.
Those who've been through this as the child or the parent, how does this sound to you? Although I'm familiar with the ravages of addiction (I live in Vancouver!) from the experiences of family friends, it hasn't yet happened to me personally, so I wonder what you all think. I'm using the book above to hopefully prevent any of this, but there are no guarantees.