I entered a Schengen state (Latvia) with a short-term tourist visa from Latvia, which allows a 90-day stay every 180 days. However I have to stay 96 days here. Additionally, I got a long-term visa from Estonia on my 80th day of stay in Latvia. So if I exit Schengen from Latvia after 96 days, would this be a problem for me? Would the new long-term visa from Estonia allow an extra 90 days to stay in Schengen for me? Should I exit the Schengen area before my previous 90-day visa expires and re-enter with my Estonia long-term visa again for that additional 6 days?
The comment by Andrew Lazarus pointed out that your Estonian visa doesn't allow you to stay in Latvia any longer. With a valid national D visa, you can visit other Schengen states as if you had a Schengen C visa, within the 90/180 limit.
96 days is close to 90 and Estonia is close to Latvia. If you manage to get to Estonia over the weekends, say, leaving Latvia on Friday after work and coming back on Monday morning, you might make it work.
Make sure to keep the tickets, hotel receipts, etc. to document your travels if you try that.