Unfortunately, ground transportation links between Spain and Portugal are limited and often inconvenient. Although there msy be possibilities I did not uncover, my quick check turned up just one bus on July 8. It departs at 11 or 11:30 PM (depending on which station you use) and arrives at 4:30 or 5:30 AM (again, depending on the station). The two countries are in different time zones; the actual travel time is 7 to 8-1/2 hours. Sounds miserable to me.
I'd go to Skyscanner.com and look for flights. If you can't find something workable, I suggest skipping Seville. There are some great side-trips to be made from Madrid (Toledo and Segovia are the two biggest), and you could spend the first part of your trip all at one hotel. I assume there will be more flights between Madrid and Lisbon, though I haven't checked. I think the only train is an overnighter.
It's going to be hot in Madrid and way beyond hot in Seville in July. Seville's average July high temperature is 38.5 C (101.3 F).