A spectral approach to the Randić index