Thank you for the detail information.
There can be a number of causes for cramps of the legs at night.
Irritation of nerve or impingement can be possible.
Dehydration, deficiency of calcium, magnesium, potassium, sodium-electrolytes, vitamins etc. are frequent causes.
Peripheral artery disease causing circulation abnormalities also can cause muscle spasm.
Systemic diseases like diabetes, low thyroid can be associated with it.
Sometimes no cause can be apparent too.
I would advise to have an examination by doctor.
Doctor can take a few tests like blood metabolic panel, doppler ultrasound, NCV, EMG etc.
You can try some home measures-
Please take plenty of fluid, fresh fruits, vegetables.
Electrolyte solution like gatorade can be tried.
Please avoid coffee, alcohol, tobacco
now, if you take any.
Stretching, warm bath can be taken before going to bed.
Vitamin and minerals, calcium supplements can be taken if there is any deficiency detected on testing.
Sometimes muscle relaxants are prescribed.
I hope this information helps.
I will be happy to assist, if you need any clarification.
Please feel free for any follow up query.