Upvote:1
Looking at https://www.openrailwaymap.org/ it's clear that the coastal area of Croatia is not well served well by trains. The main options seem to be: Split, Sibenik, Zadar, Rijeka and Pula. The first 3 all in the southern end of Croatia and branch lines of the main line to Split.
So that leaves Pula and Rijeka, for later if these is on the mainline and multiple trains per day direct from Zagreb. It might then be possible to travel direct from Rijeka to Ljubljana, some sources show a train (including the man in seat 61 https://www.seat61.com/Croatia.htm and https://rail.cc/en/rijeka/rijeka-main-railway-station/l1218) but I can't find it on any of the usual ticket booking site.
Whereas Pula is not actually linked in with the rest of the rail network in Croatia, you must travel to Slovenia and back, however, you seem to be planning to go to Slovenia anyway so it could be worth reordering your route to go to Pula in-between Ljubljana and Bled, and get the direct train between Zagreb and Ljubljana.
Google searches for beaches in Rijeka and Pula turn up a number of results. Personally I had a great time staying near Pula a few years ago, but I'm not a beach person and don't remember much of the beaches.