I know a family friend who had the same problem...
What her child do is being the worst at home and good outside...
This all happen after that she felt many things I had few time to get near her without she know who am I (and coz. I was smaller then her mother she accept to talk(was difficult but worked at end)) the problems are:
1- There is no family she can trust every thing her parents do is terrible,
2- She can't accept them they tell her lies only(they don't keep some promises),
3- Once she want they never accept and f itz for them they 'll do it,
with time her believe in the family was near 00% and so she started to think as if they are just a use till she can get rid of them,,,
once she is out she feel that there is nothing interrupting her and everything is OK and shiny and not as the dark whole of home,,,
she made connection between home and the lose of what she want, they don't give her her wishes as what the other families do to their child.........so many ideas comes after she lost the believe that she had got a trust able family,,,
surprising me she said "I wish I had another family who can feel my presence and don't need me to be anxious" ...
I was that young to not treat alone and so told her mom to start some ideas me and my mom suggest and the 3rd is what worked for her...
1st, u must search for what she needs and just give her all she may need and keep to close to her that let her feel the warm of ur real presence
2nd, make a real block of ur gentle being with her and make her responsible take her to live with ur brother family then he'll make her work and nothing is acceptable for him without a pay by hard work so she 'll understand the mean of life and then take a control of being like that and since he is strong and a male he can help to make a force by his presence itself...
3rd, to look for her in school what she do and what they think about her (without letting her find out at all) and her B\friend for sure, she 'll understand her a little and then go to make changes in her act (not to be a detective and to let her child feel that she is not in a jail)...
and then her child looked for her mother really with no care but as an added advice was to stop uncaring about herself and care more about her child coz. they feel that she is nothing but annoy and can't do anything...
the use of some anti-anxiety was refused by her mom and so she can't use them or f she told her child that she'll give her medication so no way she 'll keep silent...
the stay in a real danger and getting in and her mom being of a help was a thing done later and completely changed...
Another thing is that she feel like written above in the other answers she feel that this way is of a help to have what she need as her father do,,,and that she can do what she like no one can punish (no one has that strength, and no one can do it the right way),,,and the punish of harm made her undrestand her weakness and humanity being,,,
Those may not help really, but this is what I found in a similar state so I told,,,