// static/js/ui-status.js – Status-Badge & Reconnect

function updateStatus(connected, message = '') {
  const badge = document.getElementById('connection-status');
  const reconnect = document.getElementById('reconnect-section');

  if (!badge) return;

  if (connected) {
    badge.className = 'badge bg-success px-3 py-2 fs-6';
    badge.innerHTML = '<i class="bi bi-circle-fill me-2"></i> Verbunden' + (message ? ` – ${message}` : '');
    if (reconnect) reconnect.style.display = 'none';
  } else {
    badge.className = 'badge bg-danger px-3 py-2 fs-6';
    badge.innerHTML = '<i class="bi bi-circle-fill me-2"></i> Getrennt' + (message ? ` – ${message}` : '');
    if (reconnect) reconnect.style.display = 'block';
  }
}

function showReconnect() {
  const control = document.getElementById('control-section');
  const reconnect = document.getElementById('reconnect-section');
  if (control && reconnect) {
    control.style.display = 'none';
    reconnect.style.display = 'block';
  }
}

window.updateStatus = updateStatus;
window.showReconnect = showReconnect;

// Am Ende
window.initStatus = function() {
  // Dein Status-Init-Code, falls vorhanden
  console.log('ui-status.js → Status initialisiert');
};