It's a local expression. A West Coast thing...
A girl is not a dude but can be referred to like, "Dude, that sucks you lost your job." "Thanks, dude!" "Dude...not cool."
"Dude" in this case can be substituted with "Man" as well with all but the second example. That one might sound strange. Dude is a word that has more meaning by the way it is spoken. If somebody starts messing with your armor without asking you would say "Dude!"
and they would immediately get that what they were doing wasn't cool. Your friend start flirting with a girl that's half his age (in front of her mother maybe) You could just say, "Dude..." with a disgusted tone and he instantly knows what a dirtbag he is. It is the Swiss Army Knife of words!