If you meet someone who is traveling in your country by chance and have a nice conversation, do you say "have a nice trip." or " enjoy your stay." when you finish your conversation ? I assumed you say "have a nice trip" before someone goes on a trip , but is this correct?
It depends on whether they are coming to your country, where you currently live, or if you are talking to them in another country and they are going away to your country.
"Have a nice trip" implies that they are traveling away from you to somewhere else. For example, you could say:
I hope you have a nice trip to Spain, I hear it's really nice this time of year.
However, this would be confusing if I am already in Spain.
A: I hope you have a good trip to Spain!
B: Wait, don't you live in Madrid?
A: No, not any more. I'm in Paris now.
Instead if someone is already in your own country, it is hospitable to say something like, "Enjoy your stay (here)!" or "Enjoy your time (here)!"