Spin Glass Theory and Beyond. An Introduction to the Replica Method and Its Applications