<!DOCTYPE html>
<html>

<head>
<?
include "layout_header.inc.php";
?>
</head>

<?
if(!isset($content)) $content = $incpath."contents/404.php";
?>
<body class="<? if($_gui == 'modern') { ?>layout-modern<? } ?>">
<?
if($_gui == 'modern') {
    $pageTitle = !empty($xtitlepage) ? $xtitlepage : (!empty($_titlews) ? $_titlews : "Dashboard");
    $pageSubtitle = !empty($_description) ? strip_tags($_description) : "Area amministrativa";
?>
    <div class="app" id="appShell">
        <aside id="menuleft" class="sidebar menuleft_<?=$_tema?>">

            <?php
            #echo Get_TXTArea('header_dashboard', $language);
            ?>

            <!--div class="sidebar__section-title">Navigazione</!--div-->
            <? include "./main/contents/menuleft.php"; ?>
        </aside>

        <div class="shell">
            <header class="topbar">
                <div class="topbar__inner">
                    <div class="topbar__left">
                        <button class="icon-btn mobile-toggle" id="menuToggle" aria-label="Apri menu">
                            <i class="bi bi-list"></i>
                        </button>
                        <div class="page-title">
                            <h1><?= htmlspecialchars($pageTitle, ENT_QUOTES, 'UTF-8') ?></h1>
                            <p><?= htmlspecialchars($pageSubtitle, ENT_QUOTES, 'UTF-8') ?></p>
                        </div>
                    </div>

                    <div class="topbar__right">
                        <? if($logged == '1') { ?>
                        <a href="javascript:logout()" class="topbar__action is-danger">
                            <i class="bi bi-box-arrow-right"></i>
                            <span><?= $lang['Esci'] ?? 'Logout' ?></span>
                        </a>
                        <? } ?>
                    </div>
                </div>
            </header>

            <main class="page">
                <div class="page-shell">
                    <?
                    if($_szalias == "cms") {
                        include "".$baseDir."main/contents/cms.php";
                    } else {
                        include $content;
                    }
                    ?>
                </div>
            </main>
        </div>
    </div>

    <script>
        (function() {
            var appShell = document.getElementById('appShell');
            var menuToggle = document.getElementById('menuToggle');
            if (!appShell || !menuToggle) return;

            menuToggle.addEventListener('click', function() {
                appShell.classList.toggle('sidebar-open');
            });
        })();
    </script>
<?
} else {
?>
    <div id="menuleft" class="menuleft_<?=$_tema?>">

        <? include "./main/contents/menuleft.php"; ?>
    </div>
<?
    if($_szalias == "cms") {
        include "".$baseDir."main/contents/cms.php";
    } else {
        include $content;
    }
    /*
?>
    <script>
        function initScreen()
        {
            var elleft  = document.getElementById('menuleft');
            var elright = document.getElementById('right2');
            var body    = document.getElementsByTagName('body');
            if (!elleft || !elright || !body || !body.length) return;

            var abswidth = body[0].offsetWidth;
            var mwidth   = elleft.offsetWidth;

            elright.style.width = (abswidth - mwidth)+'px';
        }

        addEvent(window, 'load', initScreen);
        addEvent(window, 'resize', initScreen);
    </script>
<?
*/
}

include "layout_common.inc.php";
?>

</body>
</html>
