Terahertz Josephson plasma waves in layered superconductors: spectrum, generation, nonlinear and quantum phenomena