<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#3F51B5">
<meta name="apple-mobile-web-app-status-bar-style" content="#3F51B5">
<meta name="msapplication-navbutton-color" content="#3F51B5">
<link rel="shortcut icon" sizes="100x100" type="image/x-icon" href="img/comanda.ico">
<link rel="icon" href="img/comanda.ico">
<link rel="stylesheet" href="css/snackbar.min.css">
<link rel="stylesheet" href="css/easy-loading.min.css?v=5">
<link rel="stylesheet" href="css/material.indigo-pink.min.css">
<link rel="stylesheet" href="css/font.css">
<link rel="stylesheet" href="css/sweetalert2.min.css">
<link rel="stylesheet" href="css/bootstrap4-buttons.css">
<link rel="stylesheet" href="css/base.css?v=<?= filemtime('css/base.css') ?>">
<script src="js/jquery.min.js"></script>
<script src="js/material.min.js"></script>
<script src="js/easy-loading.min.js"></script>
<script>
	/* ── Theme Manager ── */
	(function() {
		var saved = localStorage.getItem('wfood-theme') || 'light';
		document.documentElement.setAttribute('data-theme', saved);

		document.addEventListener('DOMContentLoaded', function() {
			var btn = document.getElementById('btnThemeToggle');
			var icon = document.getElementById('themeIcon');
			var label = document.getElementById('themeLabel');

			function updateToggleUI(theme) {
				if (!icon || !label) return;
				if (theme === 'dark') {
					icon.textContent = 'brightness_7';
					label.textContent = 'TEMA CLARO';
				} else {
					icon.textContent = 'brightness_6';
					label.textContent = 'TEMA ESCURO';
				}
			}

			updateToggleUI(saved);

			if (btn) {
				btn.addEventListener('click', function() {
					var current = document.documentElement.getAttribute('data-theme');
					var next = (current === 'dark') ? 'light' : 'dark';
					document.documentElement.setAttribute('data-theme', next);
					localStorage.setItem('wfood-theme', next);
					updateToggleUI(next);
				});
			}
		});
	})();
</script>
<script>
	function loadPagina() {
		ProcessingModal.show({
			text: 'Aguarde, carregando ...'
		});
	}

	/* ── Processing Modal Helper ── */
	var ProcessingModal = {
		_el: null,
		_ensureDOM: function() {
			if (this._el) return;
			var html = '<div class="processing-overlay" id="processingOverlay" role="alert" aria-live="polite">' +
				'<div class="processing-card">' +
				'<div class="processing-ring">' +
				'<svg viewBox="0 0 64 64">' +
				'<defs><linearGradient id="processingGrad" x1="0%" y1="0%" x2="100%" y2="0%">' +
				'<stop offset="0%" stop-color="#3f51b5"/>' +
				'<stop offset="100%" stop-color="#7c4dff"/>' +
				'</linearGradient></defs>' +
				'<circle class="track" cx="32" cy="32" r="28"/>' +
				'<circle class="progress" cx="32" cy="32" r="28"/>' +
				'</svg>' +
				'<i class="material-icons processing-icon-center" id="processingIcon">autorenew</i>' +
				'</div>' +
				'<p class="processing-title" id="processingTitle">Processando</p>' +
				'<p class="processing-text" id="processingText">Aguarde...</p>' +
				'<div class="processing-dots"><span></span><span></span><span></span></div>' +
				'<button class="processing-btn-ok" id="processingBtnOk" type="button">OK</button>' +
				'</div>' +
				'</div>';
			$('body').append(html);
			this._el = $('#processingOverlay');
			var self = this;
			$('#processingBtnOk').on('click', function() {
				self._el.removeClass('active success error has-btn');
				if (typeof self._onOk === 'function') {
					self._onOk();
					self._onOk = null;
				}
			});
		},
		show: function(opts) {
			opts = opts || {};
			this._ensureDOM();
			this._el.removeClass('success error');
			$('#processingTitle').text(opts.title || 'Processando');
			$('#processingText').text(opts.text || 'Aguarde...');
			$('#processingIcon').text(opts.icon || 'autorenew');
			this._el.addClass('active');
		},
		success: function(opts) {
			opts = opts || {};
			this._ensureDOM();
			$('#processingTitle').text(opts.title || 'Sucesso!');
			$('#processingText').text(opts.text || 'Concluído com sucesso.');
			$('#processingIcon').text('check_circle');
			this._el.addClass('success');
		},
		error: function(opts) {
			opts = opts || {};
			this._ensureDOM();
			$('#processingTitle').text(opts.title || 'Erro');
			$('#processingText').text(opts.text || 'Algo deu errado.');
			$('#processingIcon').text('error_outline');
			this._el.addClass('error has-btn');
			if (typeof opts.onOk === 'function') {
				this._onOk = opts.onOk;
			}
		},
		hide: function(delay) {
			var self = this;
			setTimeout(function() {
				if (self._el) self._el.removeClass('active success error has-btn');
			}, delay || 0);
		}
	};
</script>