Statistical limits of dictionary learning: random matrix theory and the spectral replica method