J.C.
I don't know if you have tried this or not, but have you considered outpatient counseling/behavior therapy?
They would help both your daughter and you work on her attitude and issues with your ex-husband. Out patient counseling isn't just for mental heath problems and especially since it sounds like your ex is encouraging her inappropriate attitude and behavior, this sounds like the best way to go because the counselor/therapist would be impartial and your daughter wouldn't be able to play you against her father.
I have my daughter in counseling because of attitude and behavior issues at home and school and she is only in the 4th grade. She doesn't have any mental health problems, just major attitudes that cause major problems in the family and at school. Her therapist has really helped and made a difference for us in dealing with whatever is causing her to have these attitude problems.
Good luck and I really hope that everything works out for you.