ありがとうございます is the standard polite way to say “thank you.” Use it with strangers, shop staff, coworkers, teachers, customers, and superiors.
The kanji form 有難うございます(ありがとうございます) exists, but ありがとうございます in hiragana is much more common in everyday writing.
Use ありがとうございます for something happening now, just offered, or still connected to the present.
Use ありがとうございました for something finished, such as when leaving a shop, ending a meeting, or closing an interaction.
ありがとう is casual. Use it with family, close friends, or people clearly close to you. In most other situations, ありがとうございます is safer and more respectful.