This is from a mix of personal experience and what I've read online:
Generally, it's best to refer to someone by their name. If you don't know someone's name, you'll have to refer to them by a pronoun or a title of some sort (or just avoid referring to them directly through the magic of context). If you know you're going to be acquainted with this person, you might as well ask their name. If you're working at a company, it might also be considered condescending to call a superior あなた (especially your boss). So in general you should put in the effort to remember their name, or if you have to you can use their title. See this little skit:
If you don't know someone well, you should call them by their last name + さん. Once you become friends with someone, they might tell you to drop the さん, or to call them by their first name or a nickname. To be safe, you should wait for them to give you permission or you'll start sounding too over-familiar. Essentially, you both should decide what you are comfortable calling each other. Different people will have different comfort zones when it comes to this, and it may also vary between text messaging / the internet and real life. But try to avoid calling your friends あなた, especially people you are pretty familiar with, as you may accidentally give the impression that you are distancing yourself from them.
As for using あなた, 君 etc between two lovers, I'm pretty sure people have mixed feelings about this. According to one article, couples who don't know refer to each other on a name basis are more likely to break up.
And according to this article, only about 10% of married women (a sample size of 449 women in their 20s to 60s) refer to their husbands as あなた (even though it happens in movies and dramas all the time).
I think the misconception that lovers ought to refer to each other as あなた is widespread, even among Japanese people. Here's a post made by a girl who was bothered by her ex-boyfriend calling her あなた, asking what his reasons might have been:
And finally, here's a long article on the different ways couples call each other:
One last thing is when referring to a general audience, 皆さん is frequently used. あなた is used too, but more as a rhetorical technique (making the reader/listener feel as if you are speaking to them directly). As such in real world presentations, you'll most likely hear 皆さん, but in internet articles あなた is frequently used. Some teachers might use あなたたち as well but it could sound condescending. For an example of a presentation, here's a TED talk. He uses 皆さん to refer to his audience.