BP warns of hit to earnings from weak refining margins and lower output