Internal method: Update file metadata after writing.
Updates last_modified, saves to database, updates last_viewed, and notifies ProjectManager that file contents have changed (triggers background scanning).