This paper introduces an energy management system that incorporates a model for managing urban and rural alternating current (AC) microgrids (MGs), integrating renewable energy sources and energy storage systems. The proposed model aims to improve key technical, economic, and environmental performance indicators. It employs a mono-objective optimization framework, focusing on the independent minimization of operating costs, power losses, and CO2 emissions. To solve the optimization problem, seven bio-inspired algorithms are implemented and compared: Black Hole Optimizer (BHO), Crow Search Algorithm (CSA), Salp Swarm Algorithm (SSA), Equilibrium Optimizer (EO), Generalized Normal Distribution Optimizer (GNDO), Particle Swarm Optimization (PSO), and Grasshopper Optimization Algorithm (GOA). The effectiveness of the proposed model is validated through a comparative analysis against a baseline scenario that represents conventional MG operation without optimization. This baseline scenario includes photovoltaic distributed generators and energy storage systems operating under static dispatch strategies. The results demonstrate that EO, SSA, and GNDO are the most effective algorithms for optimizing the specified objectives. For urban MGs, the proposed model achieves reductions of up to 7.16% in power losses, 0.163% infixed costs, 1.436% invariable costs, and 0.165% in CO2 emissions when compared to the baseline. Similarly, for rural MGs, the proposed approach yields reductions of 10.938% in power losses, 0.095% in energy costs, and 0.145% in CO2 emissions relative to the baseline scenario. These findings confirm the innovation and effectiveness of the proposed energy management model and its optimization algorithms. The study highlights the model's capability to ensure technical efficiency while significantly reducing economic and environmental impacts. Moreover, the adaptability of the model to both urban and rural settings demonstrates its potential as a robust framework for sustainable energy management in AC MGs.