First-principles investigation of structural, electronic, and thermoelectric properties of n- and p-type Mg_2Si