document.addEventListener('DOMContentLoaded', () => {
    fetch('assets/sidebar.html', { credentials: 'same-origin' })
        .then(r => r.text())
        .then(html => {
            document.getElementById('sidebar-container').innerHTML = html;
            highlightActiveLink();
        });
});

function highlightActiveLink() {
    const current = location.pathname.split('/').pop();
    document.querySelectorAll('.sidebar a').forEach(a => {
        if (a.getAttribute('href') === current) {
            a.style.color = '#ffffff';
            a.style.fontWeight = 'bold';
        }
    });
}
