Find all pairs $( m, n)$ of nonnegative integers for which $$m^2+2\cdot3^n=m\big(2^{n+1}-1\big).\quad(1)$$ Please provide the sum of all values of $m + n$ for each pair $(m, n)$.

Let's think step by step and output the final answer within \boxed{}.
user