"Buenas noches" can be used as a greeting or a farewell. The singular, "Buena noche," is usually used only in farewells or to describe a night, e.g. "Hace una buena noche" (It's a nice night).
It literally means "Good nights." This may come from "Buenas noches nos dé Dios," translated as, "May God give us good nights."
Buenas noches! Cómo has estado?
(Good evening! How have you been?)
Buenas noches! Qué duermas con los angelitos!
(Good night! Sleep tight!) (Literally: Good night! May you dream with the little/precious angels!)
Quería desearte solo buenas noches y recordarte que en mi corazón siempre estas tu. Buenas noches, mi único amor.
(I would like to wish you only good nights and remind you that you'll always be in my heart. Good night, my one and only love.)