First-principles calculations of X-ray absorption spectra for warm dense methane