I'd consider a trip into the Pyrenees. I think you may be able to see some of the coastal towns during your work time. A rental car would be handy for the Pyrenees, but there's stuff you can get to via public transportation. If you can reach places at some altitude, you will probably have a break from the heat you're likely to encounter elsewhere in July. I'd guess the coastal towns will feel a bit better because of sea breezes, but altitude is probably your only hope for pleasant temperatures. If you can plan some of your trips at the last minute, you may be able to avoid spending the worst days in places where you'd be outdoors a lot.
In any case, here are some options for shorter trips:
- Girona: city with walled medieval core and much to see; worth an overnight if possible.
- Figueres: Dali Theatre-Museum (prebook, and don't miss the jewelry collection), but not much else to see (do not a bad destination on a hot day). Fast-train tickets cheaper if bought in advance; slow train would be OK if going only to see the Dali Theatre-Museum. Figueres has two train stations. Ask here for info if you decide to go.
- Cadaques: cute former fishing village, by bus from Figueres train station (not Figueres Vilafant).
- Port Lligat: Dali Home; walk 15-20 minutes from Cadaques. Book well ahead.
- Besalu: medieval town with fortified bridge (by bus from Barcelona, but quicker by bus from Girona).
- Tarragona: coastal city with some Roman ruins (I haven't been there).
You can find a one-day bus tour going to multiple medieval villages (probably including Besalu).
Zaragoza, which is between Barcelona and Madrid on the AVE line, is very interesting but truly miserably hot during the summer. Given that you have limited free time on this trip, I'd give it a pass and choose places that are a lot less likely to be 90F- 105F. Here's the sad story for July 2022: https://www.timeanddate.com/weather/spain/zaragoza/historic?month=7&year=2022
Barcelona has a number of art museums; check their hours, because some may be open late enough that you can pop in after work. In addition to the Picasso Museum (if you like his early work; otherwise consider skipping because it is often a mob scene), I especially liked the Miro Museum and MNAC on Montjuic. The MNAC has two special collections in addition to the usual painting and sculpture: medieval frescoes rescued from churches in the Pyrenees and modernist jewelry/furniture/decorative arts.
If you're interested in the modernista architecture in Barcelona, it's worth getting the guidebook (with discount coupon booklet) from the Ruta del Modernisme folks. It's likely to be impractical to use the discount coupons at the very most popular covered sites, because I think you have to buy the discounted tickets at the ticket booth. That will consign you to a very long wait in line. But the discounts are nice if you have time for some of the secondary buildings, the book is very handy, and the map marks all sorts of places you can arrange to walk past during your time in the city. https://rutadelmodernisme.com/en/modernisme-route/#guia-preus