ABSTRACT Clotrimazole (CTZ), as an antifungal medication, is used to treat dermatological infections in humans, and to remove fungal infections from plants in agriculture, but its widespread usage has led to pharmaceutical pollution and environmental concerns. In this study, a new bromopyrogallol red (BPR) and N i 2 + based colorimetric sensor was developed for the selective and sensitive detection of CTZ. The BPR-Ni complex showed a clear colour change from purple to violet in the presence of CTZ, and a significant change was observed in the UV-Vis spectrum. The stoichiometric ratio of 1:1 between BPR and N i 2 + was determined using the Benesi-Hildebrand method. DFT and time-dependent DFT (TD-DFT) were applied to identify the molecular and electronic structures of the BPR, BPR-Ni, and BPR-Ni-CTZ in ground and excited states. The nature of electronic excitations and charge transfers was evaluated using the natural transition orbitals (NTO). The NTO analysis reveals that the Ni atom facilitates the charge transfer process between BPR and CTZ and improves the sensitivity of the chemosensor. The quantum theory of atoms in molecules (QTAIM) was employed to determine the nature of interactions between BPR, N i 2 + , and CTZ. This study paves the way for the detection of environmentally harmful pharmaceutical pollution using simple but effective colorimetric sensors.