Perfect absorption in uniform and nanostructured media