I would personally advise to spend one week in Rio (so much to see or just chill on the beach), then fly down to Florianpolis, the magic island, for 4 nights, followed by 3 nights in Iguazu.
Forget about Salvador. It's overrated. The old town is a tourist trap. The rest of the city is dominated by favelas (=unsafe). Rio has a reputation of being unsafe, but Salvador is much more dangerous. In Rio you should stick to the South Zone, use Uber to get around and you will be fine. I have visited Rio for 2 weeks this month and I found it to be the safest ever.