const tokenInput = document.getElementById("bridgeAdminToken");
const saveButton = document.getElementById("save");
const statusText = document.getElementById("status");

document.addEventListener("DOMContentLoaded", async () => {
  if (!tokenInput) return;
  const { bridgeAdminToken } = await chrome.storage.sync.get("bridgeAdminToken");
  tokenInput.value = bridgeAdminToken || "";
});

if (saveButton) {
  saveButton.addEventListener("click", async () => {
    await chrome.storage.sync.set({
      bridgeAdminToken: tokenInput.value.trim()
    });
    statusText.textContent = "Saved.";
    setTimeout(() => {
      statusText.textContent = "";
    }, 1800);
  });
}
