Terri,
Been to Morocco several times, across all the places you've mentioned. Wonderful stuff to see there, you will like it.
First, smart choice to fly in and out, skipping the ferry (and ferry port) experience. To your questions...
I'm assuming you have not yet bought your tickets in and out. Do check carefully on your dates aligning with date of flights - the flights on low cost airlines don't go every day, so make sure your dates align.
3 nights in Marrakech should be fine. Don't be intimidated by the medina, you do not need a guide, you can navigate it with a little common sense, a good memory (take note of visual landmarks as you wander); I found a small, cheap pocket compass helpful (to know which way you want to go to get back out).
It's been years since I went to Essaouira, but I found it lovely and utterly delightful. I understand it has become a lot more popular and developed in recent years, so some of its charms may have been eroded, but it's worth a visit. I recall the bus ride being more than just a short trip, so I'm not sure that doing it as a day trip is reasonable; consider an overnight.
The train between Marrakech and Fes is easy and pleasant, more-or-less direct, but takes pretty much the whole day (unless they've finished the high-speed rail line they are building, but I don't think that's imminent).
Fes is wonderful. In some ways similar to Marrakech but not exactly the same. Bigger and more chaotic medina, like stepping through a time machine and popping out in the middle ages. Both cities are worth doing.
Meknes is also nice but, if you have days in both Marrakech and Fes might be overkill.
I would not recommend Casablanca. There ain't that much to see there (one big mosque, which is modern, and that's about it). I'd skip it and spend that time elsewhere. Fly back from Fes if you can.
If you have 2 more nights to spend, and you skip Casablanca (I assume that gives you one more night) - then I would suggest you skip Meknes (that gives you 4 nights)...with that much time, I'd rent a car in Fes, drive out over the Atlas Mountains, and get to the deep desert, spend a night out there. You could actually do this to connect Marrakech and Fes, rather than taking the train (the train is fine, it's just slow so it burns a day). Consider this: rent a car in Marrakech. Drive up and over the High Atlas, spend the next night in Ait Benhaddou (google it for photos). Explore the old citadel there, then head onward to Ouarzazate and beyond, to one of the Grand Ergs near Zagora (the sand seas, on the edge of the Sahara). Spend the night out on the dunes. On your way back, head for Fes, stopping at Todra Gorge. Finish your trip in Fes, fly back to Barcelona from there. There are lots of options, this is just one.
You're in for quite the adventure. :)