>> My wife and I have Swiss Travel Pass Flex for our trip. I have already booked and reserved 1st class seats on the Gotthard Panorama Express and I know I need to buy an upgrade for this specific trip. My questions are: Is there a discount on the upgrade with my pass? If so, I'm not quite sure on how to link it to our passes.
Yes, you get the upgrade at 50% of the difference in cost between the 1st and 2nd class fares. If buying at a ticket window, just present your Swiss Travel Pass Flex.
>> Can I buy it online? Is it better to buy it at any station in Switzerland?
Yes, you can also buy online or in the SBB App. Buying online, you will need to print it out. Buying in the App, you will need to show it on screen to the conductor when asked.
If using the app, to pay the right price, you need to set the status of the travellers to 1/2 (half fare) instead of 1/1 (full fare) before buying the upgrade. Remember to reset it to 1/1 if you later buy any point-to-point tickets for travel not covered by your Swiss Travel Pass Flex!
I assume you can do something similar online (i.e. use the half-fare option), but I have not done that myself.
Buying at a staffed station is always an option.
>> Is it better to buy it ahead of time?
As long as you buy it before the train departs, that is sufficient, but you can buy it earlier if you like, as you already know the exact train you will be taking.
>> Is First Class applicable only on the train portion (I remember reading that the boat portion doesn't have First Class anymore)?
No, the boat will have a 1st class section as well, usually upstairs. You can buy an upgrade on the boat, but you must buy your upgrade before entering the first class section. You can't buy a reservation for the boat though.
>> If it's the case, as we will be leaving from Bellinzona, I will only need an upgrade from there to Flüelen, is this accurate?
This is certainly an option - just get an upgrade for the train, for which you have booked a first class reservation. There's no need to get an upgrade for the boat as well, if you are happy to travel on the lower deck. Views are just as good on the lower deck in my opinion.
However, I believe you are travelling in June/July, which will probably be pretty busy. If the boat is crowded, you might find first class more congenial. However, as you can buy your upgrade on the boat, you can wait and see how busy it is, and just buy the upgrade if you find 2nd class too crowded.