Effects of thickness on the structural, electronic, and optical properties of MgF2 thin films: The first-principles study