// Scut Absolut pentru rotirea ecranului (funcțional pe Zebra Scanner)
(function protectOrientation() {
function fixOrientation() {
// Nu aplicăm pe desktop
if (Math.max(window.innerWidth, window.innerHeight) > 950) {
document.body.style.cssText = '';
document.documentElement.style.overflow = '';
return;
}
const angle = (screen.orientation || {}).angle || window.orientation || 0;
let rot = 0;
let isLandscape = false;
if (angle === 90) { rot = -90; isLandscape = true; }
else if (angle === -90 || angle === 270) { rot = 90; isLandscape = true; }
else if (angle === 180) { rot = 180; isLandscape = false; }
if (isLandscape) {
document.documentElement.style.overflow = 'hidden';
document.documentElement.style.width = '100vw';
document.documentElement.style.height = '100vh';
document.body.style.cssText = `
width: 100vh !important;
height: 100vw !important;
position: absolute !important;
top: 50% !important;
left: 50% !important;
margin-top: -50vw !important;
margin-left: -50vh !important;
transform: rotate(${rot}deg) !important;
transform-origin: center center !important;
overflow-y: auto !important;
overflow-x: hidden !important;
`;
} else if (rot === 180) {
document.documentElement.style.overflow = 'hidden';
document.body.style.cssText = `
width: 100vw !important;
height: 100vh !important;
position: absolute !important;
top: 0 !important;
left: 0 !important;
margin-top: 0 !important;
margin-left: 0 !important;
transform: rotate(180deg) !important;
transform-origin: center center !important;
overflow-y: auto !important;
overflow-x: hidden !important;
`;
} else {
document.documentElement.style.overflow = '';
document.body.style.cssText = '';
}
}
// Executăm instant pentru a elimina acel "refresh/clipire" observabil
window.addEventListener('orientationchange', () => {
fixOrientation();
// Lăsăm și un mic fallback invizibil în caz că senzorul raportează unghiul târziu
setTimeout(fixOrientation, 100);
});
window.addEventListener('resize', fixOrientation);
document.addEventListener('DOMContentLoaded', fixOrientation);
fixOrientation();
})();
lucide.createIcons();
// Mobile menu toggle
(function() {
var btn = document.getElementById('mobile-menu-btn');
var sidebar = document.getElementById('app-sidebar');
var overlay = document.getElementById('mobile-sidebar-overlay');
if (btn && sidebar && overlay) {
btn.addEventListener('click', function() {
sidebar.classList.toggle('mobile-open');
overlay.classList.toggle('active');
});
overlay.addEventListener('click', function() {
sidebar.classList.remove('mobile-open');
overlay.classList.remove('active');
});
// Close sidebar when a nav item is clicked (mobile)
sidebar.addEventListener('click', function(e) {
if (e.target.closest('.nav-item') && window.innerWidth <= 768) {
sidebar.classList.remove('mobile-open');
overlay.classList.remove('active');
}
});
}
})();
setTimeout(() => {
if (typeof App !== 'undefined' && App.toast) {
App.toast("Sistem OK: Core app.js încărcat v212.", "info");
} else {
const tc = document.getElementById('toast-container');
if (tc) {
tc.innerHTML = '🚨 EROARE FATALĂ SCRIPT: app.js nu s-a încărcat!
';
}
}
}, 1500);