This article presents an innovative active and reactive energy management system (AR-EMS) specifically designed for residential buildings in Morocco, seamlessly integrated with a Smart Microgrid (SMG) and the Electrical Power Grid (EPG) supplier. The considered SMG incorporates a Photovoltaic system (PV) and an Energy Storage System (ESS). In Morocco, the EPG utilizes a Range Tariff System (RTS), where the tariff structure depends on the total energy consumed at the end of each month. Hence, the proposed AR-EMS is designed to computes optimal active and reactive power setpoints of each source at 15-minute intervals for the next 30 days, based on forecasts of energy consumption and PV power production. The AR-EMS consists of two distinct layers: the Long-Term Optimization Layer (LTOL) and the Short-Term Optimization Layer (STOL). The LTOL focuses on optimizing active and reactive power flow over an extended time horizon of 30 days, relying on forecasted data. In contrast, the STOL involves short-term forecasting and energy optimization over the next 24-hour horizon, addressing the LTOL forecasting uncertainties. The proposed strategy emphasizes a multi-objective problem aiming at minimizing both active and reactive energy bill, ESS degradation cost, Peak-to-Average Ratio (PAR) and carbon emissions. The considered problem is solved using a metaheuristic algorithm, specifically the Lexicographic approach within the Particle Swarm Optimization (PSO) method. To validate the effectiveness of the proposed approach, two comparative analyses are conducted. The first involves the impact of time horizons on the energy cost and the management performances within the Moroccan context. The second comparison, highlights the benefits and shortfalls of using simultaneous active and reactive power management, comparing it with a system exclusively managing active power (A-EMS). Both compared strategies are evaluated using the Moroccan tariff RTS and real world data. The comparative analysis highlights the advantages of the proposed AR-EMS, demonstrating benefits in terms of active and reactive energy bill reduction by 58.9% and 83.2%, respectively, and showcases a 49.3% reduction in carbon emissions while improving the EPG power factor by 6% compared to A-EMS, In conclusion, the optimization results are encouraging the Moroccan government to further develop the installation of SMGs.