I haven't ferried in that area for 35 years. For the buses, I imagine you generally don't need to buy in advance (certainly not more than a few days in advance), but international buses are a special case. They are usually rather infrequent, and in my experience they typically head out full or nearly so. Even if they don't look full, there may be a slew of people waiting with pre-purchased tickets at the very next stop.
I do not lay out a day-by-day itinerary ahead of time. My practice is to check the outbound bus schedule as soon as practical after arrival. If I'm firm on my departure plans and taking a long-haul bus, I might go ahead and buy the ticket right then--but I do like to maintain as much flexibility as possible.
Keep in mind that lines at bus-ticket windows are unpredictable; you can't show up 15 minutes before departure and be certain of making the bus. The person in front of uou may be organizing a family's tickets to Istanbul. It's much more relaxing to have the ticket already in hand.
You should definitely explore your options for getting to Ljubljana now. It will probably take more time than you'd expect from just looking at a map. There are both buses and trains connecting Zagreb (which I like a lot, but which is not in the coast) and Ljubljana. I traveled by bus between Ljubljana and Rovinj, in Croatian Istria. I've had no personal experience with other routes. If you know what your last stop will be in Croatia, Rome2Rio.com will probably suggest some possible transportation links. Do not trust its information on duration, frequency or fares, but it usually provides links to the websites of the appropriate bus company/companies.
Do mot be surprised if you are asked to pony up an extra fee (in the $1 range as of 2015) to stow a bag in the hold of the bus. That is pretty standard procedure in that part of Europe.