First-principles modeling of the magneto-optical response in inhomogeneous systems