Alaikumassalam wa rahmatullah,
There are no texts in the Quran and the Sunnah that apply exactly to having “friends” of the opposite sex. Technically interacting with and talking to people of the opposite sex is not forbidden, and there is nothing wrong with having professional relationships with people of the opposite sex, or having acquaintances of the opposite sex.
But if by “friend” you mean someone with whom you feel an emotional bond (since otherwise they would just be an acquaintance), then even when a friendship is platonic, it is very common for love or sexual attraction to develop, if not in both people then at least in one of them, and this can have many sinful consequences.
We are designed to feel sexually and emotionally attracted to attractive people of the opposite sex. There can never be safety from this attraction. If today you feel that you have full control over your faculties so that there is no way that things could develop beyond a platonic friendship, you cannot guarantee that you will feel this way tomorrow, especially if the friendship develops and you start to like the person more and more. To keep such a relationship within the lawful bounds, you have to defeat your ego’s desires every single time, while it is sufficient for your ego to defeat you just once to fall into sin.
Think of a woman who has recently married and is very happy in her marriage and is totally in love with her husband. Would she risk developing an emotional connection with a man other than her husband? A woman who is not happy in her marriage may be able to justify it to herself, but a woman who thinks she has everything in the world, fears losing it and wants absolutely nothing that could possibly threaten her relationship with her husband will stay away from all other men, even if she thinks that chances are high she can have male friends without it doing harm to her marriage. Since she wants to be absolutely certain that her relationship with her husband continues to be perfect, she will not risk having male friends, in case she starts to feel attracted to one of them, or one of them does something or behaves in a way that harms her relationship with her husband.
In the same way, one whose relationship with God is very close, who loves and fears Him, will not want anything that could possibly threaten this relationship, and friendship with people of the opposite sex is a potential threat, even if they think it has a low chance of doing harm. They value their relationship with God too much to engage in anything that could possibly threaten it.
I have looked at the rulings of many respected scholars and they either strongly discourage such friendships or say that it is forbidden, due to the potential for harm that is involved.
There are various forms of relationships that can exist between an unrelated man and a woman, and most of these fall on a spectrum from prohibited, to questionable, to acceptable and lawful. If by friendship you mean having a male friend that you treat like any of your female friends, in constant contact with them and sharing with them your thoughts and emotions, then that is much closer to the prohibited side and is bound to affect your faith and your life negatively.
As for having polite small talk with a coworker, then there is nothing necessarily wrong with this, although context matters. A 25-year-old man can have a long and comfortable conversation with a 70-year-old female coworker, while if he fears God, he will keep his interactions with a highly attractive 18-year-old female coworker short and polite.