Mahindra agrees to buy Pininfarina in deal worth $185 million