Your detergent probably isn't broken - what's happened is actually pretty normal 😅 Bathrooms can experience extreme temperature swings, especially once heating kicks in after summer. Liquid detergents contain dissolved substances, and when the temperature drops sharply, these substances can crystallize out - particularly if the product also contains surfactants and salts. It's like when hot sugar water cools down and crystals form.
Whether you can still use it depends on how severe the crystallization is. Give it a try: if you can shake the detergent gently and the crystals dissolve again, you're all good and the chemical composition is intact. The washing power should be preserved. But if it's totally hardened or you notice it's not distributing anymore, I probably wouldn't use it - it could clog up your washing machine.
To prevent it next time: detergent really shouldn't be stored in the bathroom because the temperature swings there are intense 🚿 Best to keep it somewhere with relatively constant, not-too-warm conditions. Avoid storing it right next to the heating or in direct sunlight if you have anywhere else. That way you'll get a lot of use out of it!