UPDATE 2-Mazda logs surprise Q2 operating loss, cuts outlook on floods and costs jump

* First quarterly operating loss in seven years

* Floods hit production and hurt vehicle sales

* Full-year profit outlook slash, now sees profit halving (Adds graphic, flood impact details)

TOKYO, Oct 31 (Reuters) - Mazda Motor Corp posted its first quarterly operating loss in seven years, hit hard by flood damage to factories in Japan as well as a jump in costs to comply with environmental regulations and to cover quality-related issues.

The downbeat result prompted Japan’s No. 5 automaker to slash its earnings estimates for the full year. It is now predicting a 52 percent decline in operating income, also hurt by slowing demand for its vehicles in the United States.

The unexpected operating loss of 2.2 billion yen ($19.4 million) for the July-September quarter compares with an average Refinitiv estimate for a profit of 12.9 billion yen and 36.6 billion yen in profit made in the same period a year earlier.

(Click here for an interactive chart on Mazda's operating profits for the second-quarter

In July, massive flooding occurred in Hiroshima, home to the automaker’s headquarters and production hub, which has hurt output and sales.

For the year to March, Mazda predicts operating profit to tumble to 70 billion yen, down from an earlier estimate for 105 billion yen. It expects the impact of the flooding to knock around 15 billion yen off full-year operating profit.

During the quarter, global sales fell 3 percent to 392,000 vehicles, led by a 17 percent tumble in sales in China, a top market for automakers globally that is seeing a sharp slowdown. Sales in the United States, another key market, fell 7 percent.

Mazda now expects annual global vehicle sales to fall to 1.62 million units from a record-high of 1.63 million units, snapping its five-year run of rising vehicle sales.

The United States is a key source of revenue for Mazda, but it imports all of its vehicles sold in the U.S. market, exposing it to a threatened hike in U.S. tariffs on imported cars from Japan. U.S. steel tariffs are also muddying projections for the sector globally.

To limit its vulnerability to possible tariffs and currency fluctuations, Mazda is investing in a new plant in the U.S. state of Alabama, a joint project with Toyota Motor Corp .

Its earnings projections were based on an assumption that the yen will trade around 110 yen to the U.S. dollar, from a previous forecast for 107 yen. ($1 = 113.2200 yen) (Reporting by Naomi Tajitsu; Editing by Edwina Gibbs)