For years I treated leggings as the thing you wear when you've given up, the outfit equivalent of eating cereal for dinner. Then I had a week where every proper pair of trousers was in the wash and I had to actually dress leggings up for a day that mattered, and I realised the problem was never the leggings. It was that I'd never once tried.
Before you buy, check the gusset seam and the waistband construction properly, not just the length on the model. A lot of cheaper pairs have a seam that sits too low and announces itself under anything fitted, and a waistband that's genuinely wide enough to roll once without digging in is rarer than it should be. Hold the fabric up to the light in the shop, actual daylight if you can get near a window, because that's the only honest test for see through panels at the back. Pockets, if they exist, are usually decorative rather than useful, so don't plan your life around one holding a phone. And length matters more than people admit: full length should clear the ankle bone without pooling, and anything cropped needs to hit at a flattering point on the calf rather than the widest bit, or you'll spend the day tugging.
Once you've got a decent pair, the outfit building is where most of us go wrong. Avoid anything with a horizontal seam or pattern at hip height, it draws the eye exactly where you don't want it lingering, and skip tops that stop precisely at the widest part of your bottom, because that line with no break underneath reads as nothing but legging. A longer top, an open shirt, a blazer that hits mid thigh, any of these break the silhouette into sections instead of leaving it as one long shape. Trainers generally work better than heels, which look like they've wandered in from a different outfit entirely and are having a lovely time being wrong there.
The honest limit is that leggings are not trousers, whatever certain brands would like you to believe, and for anything with even a mild dress code they're the wrong call unless they're paired with something structured enough to do the formal work for them. Thin, pale, or very light fabric is also a gamble in bright light that I wouldn't take on a day involving a lot of walking or standing.
The detail that makes a good pair worth the fuss is a waistband that still feels secure after you've sat down for two hours, no digging, no rolling, no checking.