Hi Ande, awesome question with no quick fix answers. As a Peace Officer with over two decades experience working with "High Risk" youth both in custody and the community I can give you a few suggestions. First everyone is different, what motivates my teenager to stay out of trouble and yours may be completely different. Spend a lot of time talking to your young person about all aspects of their life. I don't mean the general interrogation that teens often get from their parents, nor do I mean the banal half interested questions we sometimes ask without really listening to what they are saying. Communicate with them about everything, ask their opinions on subjects ranging from drugs, sex, gangs, crime etc; you'll be surprised what you'll hear.
Keeping kids active and involved is a great way to keep them from getting into activities that can bring them into conflict with their parents or the law. Although they'll never admit it publicly all kids need and like structure. If they have a clear set of expectations and guidelines most kids are able to stay well clear of trouble. We need to look at the facts that 98% of teens are not involved in any type of trouble or criminal activity. There is a huge public misconception that teens are inherently looking for ways to get into trouble and this is not the case.
Know their friends, what they like to do, the music they listen to and where they hang out. Too many parents make the mistake of trying to be a "buddy" rather than parenting their kids. Our job is not to be their friends, there's plenty of time for that when they become adults. Our role is to guide and mould them into the people we know they are capable of being. Take the time to educate yourself on all of the potential dangers and pitfalls your young person will encounter in their day to day lives. You may be shocked as to what they are exposed to and are required to deal with on a daily basis. Lastly don't be afraid to ask for professional help when it's needed. It's better to deal with a problem proactively than wait until it becomes a real issue.