I don't see why you wouldn't be able to take 20.
Nothing states that rolling a 1 on a stealth check is an automatic failure. A 1 is just a 1. For example, lets say you're just rolling under normal circumstances. You have a +20 and you roll a 1. Your total is 21. Unless someone makes a perception check that beats your 21 stealth they do not see you. Even if they roll a nat 20 they will not see you unless they have a bonus.
Additionally, there is no penalty for failure. If in the above scenario someone beats your dc 21 check. There is nothing preventing you from creating a distraction and hiding again. What's more when you make that second check you do not suffer any sort of penalty to your check. If you failed at your bluff check to create a distraction you just don't get to hide.
As for duration to take 20. It takes 20 times the normal length of time. Normally it takes a move action to hide. 1 round is 6 seconds and you get 2 move actions a round. So, it would take 10 rounds or 1 minute to take 20 on the stealth check.
Provided of course that you meet the pre-requistes for taking 20.
When you have plenty of time, you are faced with no threats or distractions, and the skill being attempted carries no penalties for failure, you can take 20. In other words, if you roll a d20 enough times, eventually you will get a 20. Instead of rolling 1d20 for the skill check, just calculate your result as if you had rolled a 20.
So, if no one is threatening or observing you for the 1 minute it takes then you are good to go. If battle is going on next door then you should be fine. Unless someone next door takes the time to make a perception check then that might allow them to detect you. It doesn't prevent you from taking 20. But in that case taking 20 probably wouldn't help as they noticed you over the combat through a closed door.
Distance to the source, object, or creature +1/10 feetThrough a closed door +5
Unfavorable conditions +2
Creature making the check is distracted +5
Assuming you're not trying to hide right next to the door the enemy is probably at least 50 feet away from you meaning they need to make a perception check against
1+Your modifer+5(for distance)+5(closed door)+2(because of fighting)+5(because they are distracted) = 1+your mod+17.
Your 1 at that point is the same as if you'd rolled an 18.