Mazda Tech here, Saw this a lot more with 3rd gear. 2 most common causes: 1)Broken Engine mount (the one between the block and the front bumper. 2)Hub/synchro assembly is damaged. This was caused by a poor choice in metals used to build them.
Fix: it'sgonna be about 10-13 hours in labor alone. Cost of parts, well I didn't deal with prices much, so you'll have to research that. If the repair shop is good, they will rebuild 5th gear assembly (new hub and synchros, maybe the gear too if it's damaged. Usually they don't get damaged.) Also, you may want them to rebuild 3rd gear while they are in there as a precautionary measure. Make certain they inspect all the engine and transmission mounts. The gear repair is useless if the mounts remain broken, becasue it will just cause the gears to wear out again, very fast too. The new gears that superceed the originals are better quality. Cork sport and Protege Garage sell the updated parts if you want to compare prices. GOOD LUCK!!