Louis XIV's wife Maria Theresa is the oldest, so she is now Queen of Spain.
I highly doubt this. Louis XIV and Maria Theresa where wed in June 1660, so it depends on if this has already happened by the time of Felipe IV's death. If he dies before, then all bets are off. The Spanish are going to break off the betrothal as soon as possible, proclaim Maria Theresa queen and find her a new husband. This will also mean repudiating the Treaty of the Pyrenees, signed the year before, by which Maria Theresa was to wed Louis XIV to secure peace, so France will then have a
very convenient
casus belli for the upcoming war (and there will most definitely be a war, given the state of contemporary politics and the balance of power after the Thirty Years' War).
If, however, Louis XIV is already wed to Maria Theresa when Felipe IV dies, he'll probably try to advance her claims, but realistically, he'll probably just want to secure the Spanish Netherlands in her right, as in the OTL War of Devolution. The problem is, the terms of the marriage explicitly required Maria Theresa to renounce her rights to Spanish Crown. This all hinged on the ability of her father to pay her massive dowry in compensation for the loss, though I'm unsure as to the specified time frame by the treaty (the fact that it was not paid was a factor in advancing the claims of Felipe V in OTL during the War of Spanish Succession).
Leopold I's future wife is next in line and many will want t6o put her (Margaret Theresa) on the throne insted.
As I said above, if Maria Theresa has already married Louis XIV at this time, then Margarita Teresa will be proclaimed queen.
So, the question is, can a suitable suitor be found who will marry Margaret Theresa and keep France happy. Were there any good Catholic WIttelsbachs around for her to marry instead?
The best compromise would probably be Philippe (Louis' brother) wedding Margarita Teresa in this scenario. Alternatively, the Spanish may see the ambitions of France as too threatening (or the idea of a Bourbon king too hard to swallow) and instead go with a lesser Habsburg prince.
Louis XIII of France has a strong claim being the nephew of Philip IV - son of Phillip's sister Anna. At the very least he'd want his younger brother Philip king.
Ana of Austria was required to renounce her rights as well when she wed Louis XIII, if memory serves. Of course, Louis XIV could easily find some convenient legal impediment to nullify this, and offer his brother, Philippe, as a candidate for the throne.
Leopold of Austria has a claim behind Louis & Philip - being the son of Anna's younger sister.
Leopold I will be unacceptable as King of Spain, given he is also Holy Roman Emperor--remember, that in OTL, Karl VI's election to the Imperial Crown after his brother's premature death basically ruined any further chances he had of getting Spain. No one was going to allow another Charles V to rise up again at this time. However, you are right in that he may be offered the Italian domains of the Habsburgs (Milan, Naples, Sicily) as compensation.
Didn't the Emperor have a younger brother at this point?
Interestingly enough, yes, Leopold I does have a surviving, younger half-brother at this time:
Karl Joseph. It's worth noting, however, that he died at the age of 15 in OTL, and I must confess that I know nothing more of him or of the circumstances of his early death.
The Cortés can still elect an heir/monarch, correct? If so, Juan is in prime position to take the reins of the realm and fight off the French with help from everyone else I should imagine.
Yes, the Cortes was empowered to do so in all the realms of the Spanish Crown. I can't see Don Juan likely being elected, though, due to the established precedent for female succession. Then again, I may be wrong.