A molecular picture of hydrophilic and hydrophobic interactions from ab initio density functional theory calculations