Tuning of dye optical properties by environmental effects: a QM/MM and experimental study