$("#themeToggle").on("click", function() {
    const currentTheme = $("body").attr("data-bs-theme");
    const newTheme = currentTheme === "light" ? "dark" : "light";
    updateTheme(newTheme);
});

function updateTheme(theme) {
    $("body").attr("data-bs-theme", theme);
    localStorage.setItem("theme", theme);
}

$(document).ready(function() {
    // Activate all tooltips
    $('[data-bs-toggle="tooltip"]').tooltip();

    // Load theme
    var theme = localStorage.getItem("theme");
    if (theme === null)
        theme = "light";

    updateTheme(theme);
});