I ended the process and lost work on a couple of occasions. I'm not sure I understand the saving part of things

When I File -> Save in the Code Editor does that save changes in all source files I have open or just the current tab?
When I File -> Save in the main menu does that save all files including the UI design?
Is there an autosave or background save option I can configure?
Also, what is the function of the 'apply' button in the code editor - does that have any impact on 'save' ?