document.addEventListener('DOMContentLoaded', function () {
	const html = document.documentElement;
	const toggle = document.querySelector('.theme-toggle');
	const iconMoon = toggle.querySelector('.icon-moon');
	const iconSun = toggle.querySelector('.icon-sun');

	const defaultMode = typeof sliderSettings !== 'undefined' ? sliderSettings.defaultMode : 'dark';
	const saved = localStorage.getItem('themeMode') || defaultMode;

	if (saved === 'light') {
		html.classList.add('light-mode');
		iconMoon.style.display = 'none';
		iconSun.style.display = 'block';
	} else {
		iconMoon.style.display = 'block';
		iconSun.style.display = 'none';
	}

	toggle.addEventListener('click', function () {
		html.classList.toggle('light-mode');

		if (html.classList.contains('light-mode')) {
			iconMoon.style.display = 'none';
			iconSun.style.display = 'block';
			localStorage.setItem('themeMode', 'light');
		} else {
			iconMoon.style.display = 'block';
			iconSun.style.display = 'none';
			localStorage.setItem('themeMode', 'dark');
		}
	});
});