Theory for the phase behavior of microemulsions