Electromagnetics of complex media and metamaterials