<?php
/**
 * ACC Engine SPA shell — holding home + ERP workspace
 * Cache-bust query params MUST change whenever assets/dist or home CSS changes.
 */
if (!headers_sent()) {
    header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
    header('Pragma: no-cache');
    header('Expires: 0');
}
$assetVer = 'hl20260717e';
?>
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
    <meta charset="utf-8">
    <title>ACC Engine — Holding Operations</title>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="theme-color" content="#0B1220">
    <meta http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">

    <!-- CSS -->
    <link rel="stylesheet" href="/acc-engine/assets/css/base/fonts-local.css?v=hl20260717fonts">
    <link rel="stylesheet" href="/acc-engine/assets/vendor/leaflet/leaflet.css">
    <link rel="stylesheet" href="/acc-engine/assets/css/all.min.css">
    <link rel="stylesheet" href="/acc-engine/tabulator-master/dist/css/tabulator.min.css">
    <link rel="stylesheet" href="/acc-engine/assets/css/app.css">
    <link rel="stylesheet" href="/acc-engine/assets/css/base/landing.css?v=<?= htmlspecialchars($assetVer, ENT_QUOTES, 'UTF-8') ?>">
    <link rel="stylesheet" href="/acc-engine/assets/css/base/erp-applied.css?v=<?= htmlspecialchars($assetVer, ENT_QUOTES, 'UTF-8') ?>">
    <link rel="stylesheet" href="/acc-engine/assets/css/base/home-applied.css?v=<?= htmlspecialchars($assetVer, ENT_QUOTES, 'UTF-8') ?>">

    <script>
        window.ACC_CONFIG = {
            api: '/acc-engine/api.php/acc/v1',
            pluginUrl: '/acc-engine/'
        };

        window.ACC_APP_BOOT = {
            restBase: '/acc-engine/api.php/',
            api: '/acc-engine/api.php/',
            nonce: 'standalone_nonce',
            loginViewVer: '<?= htmlspecialchars($assetVer, ENT_QUOTES, 'UTF-8') ?>'
        };

        /* Drop stale PWA caches that could pin old landing JS */
        if ('serviceWorker' in navigator) {
            navigator.serviceWorker.getRegistrations().then(function (regs) {
                regs.forEach(function (r) { r.unregister(); });
            }).catch(function () {});
        }
        if (window.caches && caches.keys) {
            caches.keys().then(function (keys) {
                keys.forEach(function (k) { caches.delete(k); });
            }).catch(function () {});
        }
    </script>
</head>
<body class="erp-applied-body">
    <div id="acc-spa-root" class="acc-spa-root">
        <header class="erp-shell-header" id="erp-shell-header" hidden>
            <a href="/acc-engine/" class="erp-shell-brand">
                <span class="erp-shell-brand__mark">A</span>
                <span class="erp-shell-brand__text">
                    <span class="erp-shell-brand__name">ACC <em>ERP</em></span>
                    <span class="erp-shell-brand__sub">Holding Operations</span>
                </span>
            </a>
            <nav class="erp-shell-links" aria-label="پورتال‌ها">
                <a href="/acc-engine/service.php">خدمات</a>
                <a href="/acc-engine/shop.php">فروشگاه</a>
                <a href="/acc-engine/melk.php">املاک</a>
                <a href="/acc-engine/education.php">آموزش</a>
                <a href="/acc-engine/election.php">انتخابات</a>
                <a href="/acc-engine/wholesale.php">عمده</a>
            </nav>
            <div class="erp-shell-user">
                <span class="erp-shell-user__name" id="acc-user-name">—</span>
                <span class="erp-shell-user__role" id="acc-user-role"></span>
                <button type="button" class="erp-shell-logout" id="acc-logout-btn">خروج</button>
            </div>
        </header>

        <div class="acc-main-layout">
            <main class="acc-workspace">
                <div class="acc-tabbar" id="acc-tabbar">
                    <!-- تب‌ها توسط TabManager اینجا اضافه می‌شوند -->
                </div>

                <section class="acc-tab-content" id="acc-tab-content"></section>

                <section
                    class="acc-login-container"
                    id="acc-login-container"
                    style="display: none; flex: 1; overflow: auto;"
                ></section>
            </main>
        </div>
    </div>

    <!-- IIFE bundle — do NOT use type=module -->
    <script src="/acc-engine/assets/vendor/leaflet/leaflet.js"></script>
    <script src="/acc-engine/assets/dist/acc-app.js?v=<?= htmlspecialchars($assetVer, ENT_QUOTES, 'UTF-8') ?>" defer></script>

    <?php wp_footer(); ?>
</body>
</html>
