Light harvesting with metasurfaces: applications to sensors and energy generation