// Auto-extracted from apps-manager.js (verbatim) — augments AppsManager.prototype. Loaded after the base.
Object.assign(AppsManager.prototype, {
  // Terminal logging functions with old styling
  addLogMessage(message, type = 'info') {
    const messageLog = document.getElementById('message-log');
    if (!messageLog) return;
    
    const timestamp = new Date().toLocaleTimeString();
    const messageLine = document.createElement('div');
    messageLine.className = `log-entry ${type}`;
    messageLine.innerHTML = `<span class="log-timestamp">[${timestamp}]</span> ${message}`;
    
    messageLog.appendChild(messageLine);
    // Only scroll to bottom if user hasn't scrolled up
    if (messageLog.scrollTop >= messageLog.scrollHeight - messageLog.clientHeight - 50) {
      messageLog.scrollTop = messageLog.scrollHeight;
    }
  },
  addSuccessLog(message) {
    this.addLogMessage(message, 'success');
  },
  addErrorLog(message) {
    this.addLogMessage(message, 'error');
  },
  addWarningLog(message) {
    this.addLogMessage(message, 'warning');
  },
  addInfoLog(message) {
    this.addLogMessage(message, 'info');
  },
  clearConsole() {
    const messageLog = document.getElementById('message-log');
    if (!messageLog) return;
    
    messageLog.innerHTML = '<div class="log-entry info"><span class="log-timestamp">[' + new Date().toLocaleTimeString() + ']</span> Console cleared...</div>';
    messageLog.scrollTop = 0; // Force to top
  },
  initializeConsole() {
    const messageLog = document.getElementById('message-log');
    if (messageLog) {
      messageLog.scrollTop = 0; // Force scroll to top
      messageLog.innerHTML = ''; // Clear any existing content
      // Add initial message after a tiny delay to ensure it renders at top
      setTimeout(() => {
        this.addInfoLog('Application configuration loaded successfully');
      }, 100);
    }
  },
});
