Try to get the full 24 days. I'm sure you'll be glad to have all of that time as you continue your pre-trip research.
No comments from me on Budapest and Prague because I was last there in 1972 (!), but based on others' posts, I think you'll want at least 3 days in Budapest.
Zagreb needs more than one night and I think you'd be happy to have two full days there. The historic district is pretty large and very good for strolling (though hilly), and Zagreb has more museums than you might expect. The naïve art museum, though small, is really worthwhile, and there are other art and decorative art museums. Be aware that it's not a small city and there's a good bit of modern sprawl before you hit the historic core. It's all worthwhile when you get there.
Istria is very nice. I think five days will be good. I didn't get to Pula (Roman ruins), but I enjoyed the coastal towns of Rovinj, Porec and the tiny Vrsar. They are quite different from each other; Rovinj is all medieval stone; Porec is very colorful. I had no car so could only see the interior of Istria via a bus tour, which I quite enjoyed. There's some nice countryside there, plus at least two significant historic towns (Motovun and Groznjan). I am not a wine person, but there was a stop at a winery, which the other travelers seemed to enjoy. If you are driving, research the parking situation ahead of time. The historic areas tend to be pedestrianized.
Ljubljana's historic district is charming. There's quite a lot of interesting early 20th century architecture outside the medieval core as well. There's something about a city built along the banks of a narrow rivers with lots of bridges you can easily cross. I think at least 1-1/2 days would be good here; I spent twice that much time wandering around. You have the castle, which is somewhat time-consuming to visit though I'd say it's not essential, and there are some museums as well. The market area right along the river is fun, and on weekends (at least in high season) there's often an art or craft market, also along the river.
I didn't get beyond Lake Bohinj, but I'm sure your drive through the Julian Alps will be more than worthwhile.
You didn't mention Plitvice Lakes National Park in Croatia, which I think you might be able to squeeze in, assuming you have a car, on the way from Zagreb to Istria. It's a lovely, lovely place, but it's very important to spend the night before your visit near the park so you can get a very early start the next day, before the day-trippers clog all the walkways. I would skip it if the weather was really rainy, though. Slovenia has a couple of interesting cave systems not too far from Istria (Skocjan and the more touristy Postojna), but--though definitely worthwhile--they don't hold a candle to Plitvice unless you get a heavy rain.
Which brings up the issue of weather. At some point toward the end of your trip the weather may change from summer-like to fallish. It happened to me the last week of September 2015 when I was in Bulgaria, and I continued to experience rain about one out of every two or three days for the remaining 3 weeks of my trip through Montenegro and Croatia. At the very end I had one rather raw day with a drenching rain in Zagreb, the only day when I was actually chilly. I mention this so you can consider whether there's anything you might want to do to push the more outdoor-oriented destinations to the earlier part of your trip.