President Donald Trump's ambitious agenda appeared to take a severe hit Monday night when the Senate healthcare bill hit a wall and threw into doubt Republican efforts to repeal and replace the Affordable Care Act.

Trump was caught off guard by the move from Sens. Mike Lee and Jerry Moran to oppose the Better Care Reconciliation Act (BCRA), which ultimately doomed it.

"I was very surprised when the two folks came out last night because we thought they were in fairly good shape but they did," Trump told reporters Tuesday.

Trump's response also vacillated wildly in the hours after the BCRA's collapse. First, he advocated for immediate repeal with no set replacement. Then, he suggested early Tuesday that Republicans should leave Obamacare in place and come back around when it "fails."

Greg Valliere, chief strategist at Horizon Investments said the defeat of the bill would be devastating for Trump's legislative priorities.

"Last night's death of the health bill is an unmitigated disaster for Trump, who said last year that it would be easy to replace Obamacare with 'something terrific,'" Valliere wrote in a note to clients on Tuesday.

Trump's apparently shifting priorities aligned with a monthslong push from Trump that oftentimes seemed uncoordinated at best.

Trump frequently appeared disengaged in the talks, with reports suggesting senators were confused by the policy topics he brought up in meetings.

For instance, during a dinner with Republican senators Monday, Trump reportedly brought up selling insurance across state lines — one of the priorities for which he advocated in the campaign — and bringing down drug prices. Neither of these issues could be dealt with in the bill due to Senate rules, however.

Additionally, some public-relations missteps cost the White House dearly in its attempts to sell the healthcare overhaul. Perhaps most glaringly, Trump called the House version of its healthcare bill "mean" just a few weeks after its passage, frustrating Republican lawmakers who voted for a bill that had been shown to be unpopular.

Analysts said, though, that perhaps Trump's biggest mistake was attempting to do healthcare first at all. Valliere said addressing such a delicate matter out of the gate instead of an issue where he could find more bipartisan support was a misstep.

"It's an understatement that Donald Trump badly miscalculated on his legislative agenda; moving first on Obamacare repeal and replacement was a disastrous — and hubristic — decision." the analyst wrote.

Some Republican members have also lamented the choice to move straight to healthcare at the beginning of the term. Sen. Susan Collins of Maine, who opposed the BCRA, expressed her disappointment in overall strategy after an initial false start on the bill.

"This president is the first president in our history who has had neither political nor military experience," Collins said. "Thus, it has been a challenge to him to learn how to interact with Congress and how to push his agenda forward. I also believe it would have been better had the president started with infrastructure, which has bipartisan support, rather than tackling a political divisive and technically complicated issue like healthcare."

A good thing for tax reform?

The healthcare debacle could loom large for the rest of the president's legislative agenda, as the cracks in the GOP conference that emerged during the healthcare debate could again emerge in fights over the budget, the need to raise the debt ceiling, and a push for tax reform.

To wit, reports Tuesday suggested the Treasury Department was preparing drastic measures in case the debt ceiling is not raised. The department called bond traders on Tuesday to reassure them that was not the case.

The degree to which Trump will be able to influence these debates after the healthcare debacle remains to be seen.

"The bottom line is there are members here who understood the president’s preference and were willing to vote against it anyway," Sen. Marco Rubio of Florida said Tuesday.

But some analysts said the healthcare failure could be a good thing for Trump and the GOP's push to cut taxes.

Given the time and resources swallowed up by healthcare (not to mention pushback on the Russia investigation), the Republican party is desperate for a win, so pressuring holdouts on tax reform could come easier.

Issac Boltansky, an analyst at Compass Point, said in a note to clients to Tuesday that the near-term embarrassment of the healthcare failure will give way to a renewed push for tax reform.

"The collapse of the Senate’s healthcare strategy is a near-term negative for the GOP’s broader legislative agenda, but we contend that failing to pass health care legislation dramatically increases the sense of urgency surrounding the tax reform conversation," Boltansky wrote. "Our sense is that the political embarrassment of health care failing will serve as a driver for the GOP to redouble its efforts to enact tax relief in this Congress."

That strategy seemed to be confirmed by McConnell, who told reporters at a Tuesday press conference that the GOP would move forward after healthcare.

"We'll be moving on to comprehensive tax reform and infrastructure," McConnell said. "There's much work to be done for the American people, and we're ready to tackle it."