Spain has battled frequent and severe heatwaves in recent years, with temperatures often exceeding 40°C (104°F).