 function generateTOC(tabId, tocContainerId) {
    const tabContent = document.querySelector(tabId);
    const tocContainer = document.querySelector(tocContainerId);
    tocContainer.innerHTML = ''; // Clear previous TOC content

    console.log(`Generating TOC for: ${tabId}`);

    // Add "Table of Contents" heading
    const tocHeading = document.createElement("h6");
    tocHeading.textContent = "Table of Contents";
    tocContainer.appendChild(tocHeading);

    // Select only h2 headers, including nested