                </div>
            </main>
        </div>
    {if !$isAuthPage && !$isStandaloneContactPage && !$isOrderFocusPage}
    </div>
    {/if}

    <div id="fullpage-overlay" class="w-hidden">
        <div class="outer-wrapper">
            <div class="inner-wrapper">
                <img src="{$WEB_ROOT}/assets/img/overlay-spinner.svg" alt="">
                <br>
                <span class="msg"></span>
            </div>
        </div>
    </div>
    <div class="modal system-modal fade" id="modalAjax" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"></h5>
                    <button type="button" class="close" data-dismiss="modal">
                        <span aria-hidden="true">&times;</span>
                        <span class="sr-only">{lang key='close'}</span>
                    </button>
                </div>
                <div class="modal-body">
                    {lang key='loading'}
                </div>
                <div class="modal-footer">
                    <div class="float-left loader">
                        <i class="fas fa-circle-notch fa-spin"></i>
                        {lang key='loading'}
                    </div>
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        {lang key='close'}
                    </button>
                    <button type="button" class="btn btn-primary modal-submit">
                        {lang key='submit'}
                    </button>
                </div>
            </div>
        </div>
    </div>
    <form method="get" action="{$currentpagelinkback}">
        <div class="modal modal-localisation" id="modalChooseLanguage" tabindex="-1" role="dialog">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">

                    <div class="modal-body">
                        <button type="button" class="close dashboard-localisation-close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>

                        <h5 class="h5 pt-5 pb-3">{$LANG.chooselanguage}</h5>

                        <div class="row item-selector" data-language-selector>
                            <input type="hidden" name="language" data-current="{$language}" value="{$language}" />

                            {assign var="hasRenderedLocaleOption" value=false}
                            {if $locales}
                                {foreach $locales as $locale}
                                    {if $locale.language|strlen > 2}
                                        {assign var="hasRenderedLocaleOption" value=true}
                                        <div class="col-12 col-md-6">
                                            <a href="#" class="item{if $language eq $locale.language} active{/if}" data-value="{$locale.language}">
                                                {$locale.localisedName}
                                            </a>
                                        </div>
                                    {/if}
                                {/foreach}
                            {/if}

                            {if !$hasRenderedLocaleOption}
                                <div class="col-12">
                                    <a href="#" class="item active" data-value="{$language}">
                                        {$language}
                                    </a>
                                </div>
                            {/if}
                        </div>

                        {if $currencies}
                            <p class="h5 pt-5 pb-3">{lang key='choosecurrency'}</p>
                            <div class="row item-selector">
                                <input type="hidden" name="currency" data-current="{$activeCurrency.id}" value="">
                                {foreach $currencies as $selectCurrency}
                                    <div class="col-4">
                                        <a href="#" class="item{if $activeCurrency.id == $selectCurrency.id} active{/if}" data-value="{$selectCurrency.id}">
                                            {$selectCurrency.prefix} {$selectCurrency.code}
                                        </a>
                                    </div>
                                {/foreach}
                            </div>
                        {/if}
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-language-apply>{$LANG.apply}</button>
                    </div>

                </div>
            </div>
        </div>
    </form>
    {if !$loggedin && $adminLoggedIn}
        <a href="{$WEB_ROOT}/logout.php?returntoadmin=1" class="btn btn-return-to-admin" data-toggle="tooltip" data-placement="bottom" title="{if $adminMasqueradingAsClient}{lang key='adminmasqueradingasclient'} {lang key='logoutandreturntoadminarea'}{else}{lang key='adminloggedin'} {lang key='returntoadminarea'}{/if}">
            <i class="fas fa-redo-alt"></i>
            <span class="d-none d-md-inline-block">{lang key="admin.returnToAdmin"}</span>
        </a>
    {/if}
    {include file="$template/includes/generate-password.tpl"}
<script>
document.addEventListener('click', function (e) {
    var openTrigger = e.target.closest('[data-target="#modalChooseLanguage"]');
    if (openTrigger) {
        var targetSelector = openTrigger.getAttribute('data-target');
        var targetModal = targetSelector ? document.querySelector(targetSelector) : null;
        if (!targetModal) return;

        e.preventDefault();
        targetModal.style.display = 'block';
        targetModal.classList.add('show');
        targetModal.setAttribute('aria-modal', 'true');
        targetModal.removeAttribute('aria-hidden');
        document.body.classList.add('modal-open');
        return;
    }

    var activeModal = document.querySelector('#modalChooseLanguage.show');
    var closeTrigger = e.target.closest('#modalChooseLanguage [data-dismiss="modal"], #modalChooseLanguage .dashboard-localisation-close');
    if (activeModal && (closeTrigger || e.target === activeModal)) {
        e.preventDefault();
        activeModal.classList.remove('show');
        activeModal.style.display = 'none';
        activeModal.setAttribute('aria-hidden', 'true');
        activeModal.removeAttribute('aria-modal');
        document.body.classList.remove('modal-open');
        return;
    }

    var item = e.target.closest('#modalChooseLanguage .item-selector .item');
    if (item) {
        e.preventDefault();
        var selector = item.closest('.item-selector');
        var input = selector ? selector.querySelector('input[type="hidden"]') : null;

        if (selector) {
            selector.querySelectorAll('.item').forEach(function (el) {
                el.classList.remove('active');
            });
        }

        item.classList.add('active');

        if (input) {
            input.value = item.getAttribute('data-value');
        }
        return;
    }

    var applyTrigger = e.target.closest('#modalChooseLanguage [data-language-apply]');
    if (applyTrigger) {
        e.preventDefault();

        var applyModal = applyTrigger.closest('.modal');
        var form = applyModal ? applyModal.closest('form') : null;
        if (!form) return;

        var action = form.getAttribute('action') || window.location.href;
        var targetUrl = new URL(action, window.location.origin);
        var languageInput = form.querySelector('input[name="language"]');
        var currencyInput = form.querySelector('input[name="currency"]');

        if (languageInput && languageInput.value) {
            targetUrl.searchParams.set('language', languageInput.value);
        }

        if (currencyInput && currencyInput.value) {
            targetUrl.searchParams.set('currency', currencyInput.value);
        }

        window.location.assign(targetUrl.pathname + targetUrl.search + targetUrl.hash);
    }
});

document.addEventListener('keydown', function (e) {
    if (e.key !== 'Escape') return;

    var modal = document.querySelector('#modalChooseLanguage.show');
    if (!modal) return;

    modal.classList.remove('show');
    modal.style.display = 'none';
    modal.setAttribute('aria-hidden', 'true');
    modal.removeAttribute('aria-modal');
    document.body.classList.remove('modal-open');
});
</script>
<script src="{$WEB_ROOT}/templates/{$template}/assets/js/custom.js?v=20260615-16"></script>
    {$footeroutput}
</body>
</html>
