A First-Principles Approach for Treating Dye Wastewater