How do they compute the Gold and Elixir that can be looted from a base? Is it 100% of the remaining? or the total (including the uncollected from mine)?
There are several factors at work when it comes to available resources that can be looted:
You lose resources, depending on how much the attacker "destroys". If the attacker destroys everything, you can lose up to a maximum of 50% of Elixir/Gold in your collectors, 100% of Elixir/Gold in your Town Hall, and 33% of Elixir/Gold in your storage containers.
That's the worst case, but the amount you can lose is also modified by:
- Your relative Town Hall levels. The more Town Hall levels above you your attacker is, the less they can steal.
- How much destruction they do to your base. Damage to these buildings earns resources, so if you protect your storage buildings, they won't be able to take resources from them. There is no gold/elixir value in things like walls, builder huts, etc.
Note that resources that have been spent can't be stolen. Thus, you can "save" resources by overtraining, a trick we call the Wall Breaker Elixir Bank:
When you queue troops in this way the elixir you need to train them is “spent”, but you can cancel training at no penalty for any queued troop. This means you can queue all of your barracks till they are full, and Elixir spent this way will be “banked” safely away from would-be attackers.
Similarly, resources that have been spent on buildings and upgrades can't ever be raided, so the safest way to preserve resources is to spend them! :)