Is it ok to take zolpidem 5mg and melatonin 30mg together?

Yes you can. There is no drug interaction and you might get an additive effect since these medication are used for sleep disorder (insomnia).
Zolpidem/Melatonin. I would not advise that high dose mixture. Please talk to your doctor first.
Yes. Should have minimum 6 hours prior to needing to drive / focus when taking, 8 preferred.