/* global window */
(function (window) {
	'use strict';

	const app = window.MailDoctorAdminApp;

	if (!app) {
		return;
	}

	app.register(() => {
		// Basic in-page guide navigation: scroll to section anchors.
		document.addEventListener('click', (event) => {
			const trigger = event.target.closest('[data-guide-nav]');
			if (!trigger) {
				return;
			}

			const href = trigger.getAttribute('href');
			if (!href || !href.startsWith('#')) {
				return;
			}

			event.preventDefault();
			const target = document.querySelector(href);
			if (target && typeof target.scrollIntoView === 'function') {
				target.scrollIntoView({ behavior: 'smooth', block: 'start' });
			}
		});
	});
})(window);
