
      // Background Service Worker for SAL Modular Cryptographic Extension
      // This is a simplified version that only handles messaging
      
      console.log('Background script initialized');
      
      // Store active WebSocket connection
      let activeWebSocket = null;
      let sessionActive = false;
      
      // Listen for messages from popup or content scripts
      chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
        console.log('Background received message:', message.type);
        
        if (message.type === 'SESSION_STATUS') {
          sendResponse({ active: sessionActive });
          return true;
        }
        
        if (message.type === 'SESSION_UNLOCK') {
          sessionActive = true;
          sendResponse({ success: true });
          return true;
        }
        
        if (message.type === 'SESSION_LOCK') {
          sessionActive = false;
          if (activeWebSocket) {
            activeWebSocket.close();
            activeWebSocket = null;
          }
          sendResponse({ success: true });
          return true;
        }
        
        if (message.type === 'CONNECT_WEBSOCKET') {
          // Simplified WebSocket handling
          sendResponse({ success: true });
          return true;
        }
        
        if (message.type === 'DISCONNECT_WEBSOCKET') {
          if (activeWebSocket) {
            activeWebSocket.close();
            activeWebSocket = null;
            sendResponse({ success: true });
          } else {
            sendResponse({ success: false, error: 'No active WebSocket connection' });
          }
          return true;
        }
        
        return false;
      });
      
      // Initialize notification setup
      chrome.notifications.onClicked.addListener((notificationId) => {
        // Open the extension popup when a notification is clicked
        chrome.action.openPopup();
      });
    