If you are doing the full transit of the canal, you will not be allowed off the ship to do a shore excursion in Panama.....and this the decision of the PCA (Panama Canal Authority) - not the cruise line. If you stop in Costa Rica, I do recommend just hiring a taxi to take you around to the local highlights and a restaurant for lunch. Make sure to negotiate the price in advance, then add a tip at the end.