NYPD detective fatally shot, officer injured in gunfight