X-ray magnetic and natural circular dichroism from first principles: Calculation of K- and L-1-edge spectra