I'm not familiar with Mallorca's hydrogeology, but I've done some cenote (cavern) diving in Mexico's Yucatan peninsula. The caves are inland, but sea water infiltrates through the porous and channel-filled rock. The water nearer the surface is rainwater.
The narrow region where freshwater and seawater intermingle is called the halocline, it creates a cool optical distortion which reminds me of the "oil paint" filter in photoshop.
If there is no convection or wave-action to mix the saltwater with the fresh, they can coexist in the same vessel, with very slow diffusion of salt into the fresh layer. If the fresh layer is refreshed by rainfall or fresh outflows of groundwater, the top may always be drinkable, even as the bottom is not.
Can someone explain this phenomena? How can the water in a sea-cave become potable?