<!-- Vertical Layout with Left Sidebar Navigation -->
<div class="nk-app-root">
    <div class="nk-main">
        <!-- Sidebar -->
        <div class="nk-sidebar nk-sidebar-fixed is-dark" data-content="sidebarMenu">
            <div class="nk-sidebar-element nk-sidebar-head">
                <div class="nk-sidebar-brand">
                    <a href="<?php echo getCleanUrl('index'); ?>" class="logo-link nk-sidebar-logo">
                        <?php if (defined('USE_LOGO') && USE_LOGO && defined('LOGO_URL') && !empty(LOGO_URL)): ?>
                            <img class="logo-img" src="<?php echo LOGO_URL; ?>" alt="<?php echo SITE_NAME; ?>"
                                <?php echo (defined('LOGO_WIDTH') && LOGO_WIDTH) ? 'width="' . LOGO_WIDTH . '"' : ''; ?>>
                        <?php else: ?>
                            <span class="text-white fw-bold"><?php echo SITE_NAME; ?></span>
                        <?php endif; ?>
                    </a>
                </div>
            </div><!-- .nk-sidebar-element -->
            
            <div class="nk-sidebar-element nk-sidebar-body">
                <div class="nk-sidebar-content">
                    <div class="nk-sidebar-menu" data-simplebar>
                        <ul class="nk-menu">
                            <!-- Home/Dashboard -->
                            <li class="nk-menu-item <?php echo (basename($_SERVER['PHP_SELF']) == 'index.php') ? 'active current-page' : ''; ?>">
                                <a href="<?php echo getCleanUrl('index'); ?>" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-house-door"></i></span>
                                    <span class="nk-menu-text"><?php echo $lang_navigation['NAV_HOME'] ?? 'Home'; ?></span>
                                </a>
                            </li>
                            
                            <!-- Main Navigation Section -->
                            <li class="nk-menu-heading">
                                <h6 class="overline-title text-primary-alt"><?php echo $lang_navigation['NAV_HEADING_SUPPORT'] ?? 'Support'; ?></h6>
                            </li>
                            
                            <!-- Tickets - Always displayed -->
                            <li class="nk-menu-item <?php echo (strpos($_SERVER['PHP_SELF'], 'ticket') !== false) ? 'active' : ''; ?>">
                                <a href="<?php echo getCleanUrl('tickets'); ?>" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-ticket-detailed"></i></span>
                                    <span class="nk-menu-text"><?php echo $lang_navigation['NAV_TICKETS'] ?? 'Tickets'; ?></span>
                                </a>
                            </li>
                            
                            <?php if (defined('LIVE_CHAT') && LIVE_CHAT): ?>
                            <li class="nk-menu-item <?php echo (basename($_SERVER['PHP_SELF']) == 'livechat.php') ? 'active' : ''; ?>">
                                <a href="<?php echo getCleanUrl('livechat'); ?>" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-chat-dots"></i></span>
                                    <span class="nk-menu-text"><?php echo $lang_navigation['NAV_LIVE_CHAT'] ?? 'Live Chat'; ?></span>
                                </a>
                            </li>
                            <?php endif; ?>
                            
                            <?php if (isLoggedIn() && defined('ENABLE_PROJECTS') && ENABLE_PROJECTS): ?>
                            <li class="nk-menu-item <?php echo (strpos($_SERVER['PHP_SELF'], 'project') !== false) ? 'active' : ''; ?>">
                                <a href="<?php echo getCleanUrl('projects'); ?>" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-kanban"></i></span>
                                    <span class="nk-menu-text"><?php echo $lang_navigation['NAV_PROJECTS'] ?? 'Projects'; ?></span>
                                </a>
                            </li>
                            <?php endif; ?>
                            
                            <?php if (isLoggedIn() && defined('ENABLE_PROJECTS') && ENABLE_PROJECTS && defined('ENABLE_FILES') && ENABLE_FILES): ?>
                            <li class="nk-menu-item <?php echo (basename($_SERVER['PHP_SELF']) == 'project_files.php') ? 'active' : ''; ?>">
                                <a href="<?php echo getCleanUrl('project_files'); ?>" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-files"></i></span>
                                    <span class="nk-menu-text"><?php echo $lang_navigation['NAV_FILES'] ?? 'Files'; ?></span>
                                </a>
                            </li>
                            <?php endif; ?>
                            
                            <!-- Resources Section -->
                            <li class="nk-menu-heading">
                                <h6 class="overline-title text-primary-alt"><?php echo $lang_navigation['NAV_HEADING_RESOURCES'] ?? 'Resources'; ?></h6>
                            </li>
                            
                            <?php if (defined('ENABLE_FAQS') && ENABLE_FAQS): ?>
                            <li class="nk-menu-item <?php echo (basename($_SERVER['PHP_SELF']) == 'faq.php') ? 'active' : ''; ?>">
                                <a href="<?php echo getCleanUrl('faq'); ?>" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-question-circle"></i></span>
                                    <span class="nk-menu-text"><?php echo $lang_navigation['NAV_FAQS'] ?? 'FAQs'; ?></span>
                                </a>
                            </li>
                            <?php endif; ?>
                            
                            <?php if (defined('ENABLE_NEWS') && ENABLE_NEWS): ?>
                            <li class="nk-menu-item <?php echo (basename($_SERVER['PHP_SELF']) == 'news.php') ? 'active' : ''; ?>">
                                <a href="<?php echo getCleanUrl('news'); ?>" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-newspaper"></i></span>
                                    <span class="nk-menu-text"><?php echo $lang_navigation['NAV_NEWS'] ?? 'News'; ?></span>
                                </a>
                            </li>
                            <?php endif; ?>
                            
                            <?php if (defined('ENABLE_CONTACT') && ENABLE_CONTACT): ?>
                            <li class="nk-menu-item <?php echo (basename($_SERVER['PHP_SELF']) == 'contact.php') ? 'active' : ''; ?>">
                                <a href="<?php echo getCleanUrl('contact'); ?>" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-envelope"></i></span>
                                    <span class="nk-menu-text"><?php echo $lang_navigation['NAV_CONTACT'] ?? 'Contact'; ?></span>
                                </a>
                            </li>
                            <?php endif; ?>
                            
                             <?php if (defined('ENABLE_STORE') && ENABLE_STORE): ?>
                            <li class="nk-menu-item <?php echo (basename($_SERVER['PHP_SELF']) == 'store.php') ? 'active' : ''; ?>">
                                <a href="<?php echo getCleanUrl('store'); ?>" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-cart"></i></span>
                                    <span class="nk-menu-text"><?php echo $lang_navigation['NAV_STORE'] ?? 'Store'; ?></span>
                                </a>
                            </li>
                            <?php endif; ?>
                            
                            
                            <?php // Custom Header Link
                            if (defined('CUSTOM_HEADER') && CUSTOM_HEADER && defined('CUSTOM_HEADER_URL') && !empty(CUSTOM_HEADER_URL) && defined('CUSTOM_HEADER_NAME') && !empty(CUSTOM_HEADER_NAME)): ?>
                            <li class="nk-menu-item">
                                <a href="<?php echo htmlspecialchars(CUSTOM_HEADER_URL); ?>" target="_blank" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-link-45deg"></i></span>
                                    <span class="nk-menu-text"><?php echo htmlspecialchars(CUSTOM_HEADER_NAME); ?></span>
                                </a>
                            </li>
                            <?php endif; ?>

                            <?php if (isLoggedIn()): ?>
                            
                            <?php else: ?>
                            <!-- Guest Section -->
                            <li class="nk-menu-heading">
                                <h6 class="overline-title text-primary-alt"><?php echo $lang_navigation['NAV_HEADING_ACCOUNT'] ?? 'Account'; ?></h6>
                            </li>
                            
                            <li class="nk-menu-item <?php echo (basename($_SERVER['PHP_SELF']) == 'login.php') ? 'active' : ''; ?>">
                                <a href="<?php echo getCleanUrl('login'); ?>" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-box-arrow-in-right"></i></span>
                                    <span class="nk-menu-text"><?php echo $lang_navigation['NAV_LOGIN'] ?? 'Login'; ?></span>
                                </a>
                            </li>
                            
                            <?php if (ALLOW_REGISTER): ?>
                            <li class="nk-menu-item <?php echo (basename($_SERVER['PHP_SELF']) == 'register.php') ? 'active' : ''; ?>">
                                <a href="<?php echo getCleanUrl('register'); ?>" class="nk-menu-link">
                                    <span class="nk-menu-icon"><i class="bi bi-person-plus"></i></span>
                                    <span class="nk-menu-text"><?php echo $lang_navigation['NAV_REGISTER'] ?? 'Register'; ?></span>
                                </a>
                            </li>
                            <?php else: ?>
                                <?php // Custom Registration Link
                                if (defined('CUSTOM_REGISTRATION') && CUSTOM_REGISTRATION && defined('CUSTOM_REGISTRATION_URL') && !empty(CUSTOM_REGISTRATION_URL)): ?>
                                <li class="nk-menu-item">
                                    <a href="<?php echo htmlspecialchars(CUSTOM_REGISTRATION_URL); ?>" target="_blank" class="nk-menu-link">
                                        <span class="nk-menu-icon"><i class="bi bi-person-plus"></i></span>
                                        <span class="nk-menu-text"><?php echo $lang_navigation['NAV_REGISTER'] ?? 'Register'; ?></span>
                                    </a>
                                </li>
                                <?php endif; ?>
                            <?php endif; ?>
                            <?php endif; ?>
                        </ul><!-- .nk-menu -->
                    </div><!-- .nk-sidebar-menu -->
                </div><!-- .nk-sidebar-content -->
            </div><!-- .nk-sidebar-element -->
        </div>
        <!-- Sidebar End -->

        <!-- Main Header for Mobile -->
        <div class="nk-header nk-header-fixed is-light">
            <div class="container-fluid">
                <div class="nk-header-wrap">
                    <div class="nk-menu-trigger d-xl-none ms-n1">
                        <a href="#" class="nk-nav-toggle nk-quick-nav-icon" data-target="sidebarMenu">
                            <i class="bi bi-list"></i>
                        </a>
                    </div>
                    <div class="nk-header-brand d-xl-none">
                        <a href="<?php echo getCleanUrl('index'); ?>" class="logo-link">
                            <?php if (defined('USE_LOGO') && USE_LOGO && defined('LOGO_URL') && !empty(LOGO_URL)): ?>
                                <img class="logo-img" src="<?php echo LOGO_URL; ?>" alt="<?php echo SITE_NAME; ?>"
                                    <?php echo (defined('LOGO_WIDTH') && LOGO_WIDTH) ? 'width="' . LOGO_WIDTH . '"' : ''; ?>>
                            <?php else: ?>
                                <span class="fw-bold"><?php echo SITE_NAME; ?></span>
                            <?php endif; ?>
                        </a>
                    </div><!-- .nk-header-brand -->
                    
                    <div class="nk-header-news d-none d-xl-block">
                        <div class="nk-news-list">
                            <div class="nk-news-item">
                                
                                <div class="nk-news-text">
                                    <br><b><?php if (isLoggedIn()): ?>
                                        <h4><?php echo sprintf($lang_frontend['HEADER_WELCOME_BACK'] ?? 'Welcome back, %s!', htmlspecialchars($_SESSION['name'])); ?></h4>
                                    <?php else: ?>
                                        <h4><?php echo SITE_NAME; ?></h4>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                    </div><!-- .nk-header-news -->
                    
                    <div class="nk-header-tools">
                        <?php if (defined('SITE_MULTI_LANGUAGE') && SITE_MULTI_LANGUAGE): 
                            $languages = getAvailableLanguages();
                            if (count($languages) > 1): // Only show if more than one language available
                            $currentLang = defined('SITE_LANGUAGE') ? SITE_LANGUAGE : 'English-US';
                        ?>
                        <div class="dropdown">
                            <a href="#" class="dropdown-toggle" data-bs-toggle="dropdown">
                                <i class="bi bi-flag"></i>
                            </a>
                            <div class="dropdown-menu dropdown-menu-end">
                                <?php foreach ($languages as $langCode => $langName): ?>
                                    <li>
                                        <?php 
                                            // For non-current language, append language code after BASE_URL
                                            $langUrl = $langCode === $currentLang ? 
                                                BASE_URL : 
                                                rtrim(BASE_URL, '/') . '/' . strtolower(explode('-', $langCode)[1]);
                                        ?>
                                        <a class="dropdown-item <?php echo $langCode === $currentLang ? 'fw-bold' : ''; ?>" 
                                           href="<?php echo $langUrl; ?>">
                                            <?php echo $langName; ?>
                                        </a>
                                    </li>
                                <?php endforeach; ?>
                            </div>
                        </div>
                        <?php endif; endif; ?>
                        <?php if (isLoggedIn()): ?>
                        <div class="dropdown">
                            <a href="#" class="dropdown-toggle d-flex align-items-center" data-bs-toggle="dropdown">
                                <?php if (!empty($_SESSION['avatar'])): ?>
                                    <img src="<?php echo getCleanUrl('uploads/avatars/' . $_SESSION['avatar']); ?>" class="avatar-sm me-2" alt="Profile">
                                <?php else: ?>
                                    <i class="bi bi-person-circle fs-4 me-2"></i>
                                <?php endif; ?>
                                <span class="d-none d-md-inline"><?php echo htmlspecialchars($_SESSION['name']); ?></span>
                            </a>
                            <div class="dropdown-menu dropdown-menu-right">
                                <div class="dropdown-header">
                                    <span class="fw-bold"><?php echo htmlspecialchars($_SESSION['name']); ?></span>
                                    <small class="text-muted d-block"><?php echo htmlspecialchars($_SESSION['email']); ?></small>
                                </div>
                                <div class="dropdown-divider"></div>
                                
                                <!-- Dashboard Link -->
                                <?php if (isAdmin()): ?>
                                <a class="dropdown-item" href="<?php echo getCleanUrl('admin/dashboard'); ?>">
                                    <i class="bi bi-speedometer2 me-2"></i> <?php echo $lang_navigation['NAV_DROPDOWN_DASHBOARD_ADMIN'] ?? 'Dashboard'; ?>
                                </a>
                                <?php else: ?>
                                <a class="dropdown-item" href="<?php echo getCleanUrl('account'); ?>">
                                    <i class="bi bi-speedometer2 me-2"></i> <?php echo $lang_navigation['NAV_DROPDOWN_DASHBOARD_USER'] ?? 'Dashboard'; ?>
                                </a>
                                <?php endif; ?>
                                
                                <!-- Profile -->
                                <a class="dropdown-item" href="<?php echo getCleanUrl('profile'); ?>">
                                    <i class="bi bi-person me-2"></i> <?php echo $lang_navigation['NAV_DROPDOWN_PROFILE'] ?? 'Profile'; ?>
                                </a>
                                
                                <?php if (isAdmin()): ?>
                                <div class="dropdown-divider"></div>
                                <div class="dropdown-header">
                                    <span class="text-muted small"><?php echo $lang_navigation['NAV_DROPDOWN_SUBHEADER_ADMINISTRATION'] ?? 'Administration'; ?></span>
                                </div>
                                
                                <!-- Admin Links -->
                                <a class="dropdown-item" href="<?php echo getCleanUrl('admin/users'); ?>">
                                    <i class="bi bi-people me-2"></i> <?php echo $lang_navigation['NAV_DROPDOWN_ADMIN_USERS'] ?? 'Users'; ?>
                                </a>
                                
                                <a class="dropdown-item" href="<?php echo getCleanUrl('admin/tickets'); ?>">
                                    <i class="bi bi-gear me-2"></i> <?php echo $lang_navigation['NAV_DROPDOWN_ADMIN_TICKET_MANAGEMENT'] ?? 'Ticket Management'; ?>
                                </a>
                                
                                <a class="dropdown-item" href="<?php echo getCleanUrl('admin/tickets_categories'); ?>">
                                    <i class="bi bi-tags me-2"></i> <?php echo $lang_navigation['NAV_DROPDOWN_ADMIN_CATEGORIES'] ?? 'Categories'; ?>
                                </a>
                                
                                <a class="dropdown-item" href="<?php echo getCleanUrl('admin/snippets'); ?>">
                                    <i class="bi bi-bookmarks me-2"></i> <?php echo $lang_navigation['NAV_DROPDOWN_ADMIN_SNIPPETS'] ?? 'Snippets'; ?>
                                </a>
                                
                                <a class="dropdown-item" href="<?php echo getCleanUrl('admin/settings'); ?>">
                                    <i class="bi bi-sliders me-2"></i> <?php echo $lang_navigation['NAV_DROPDOWN_ADMIN_SETTINGS'] ?? 'Settings'; ?>
                                </a>
                                
                                <a class="dropdown-item" href="<?php echo getCleanUrl('admin/license'); ?>">
                                    <i class="bi bi-shield-check me-2"></i> <?php echo $lang_navigation['NAV_DROPDOWN_ADMIN_LICENSE'] ?? 'License'; ?>
                                </a>
                                
                                <a class="dropdown-item" href="<?php echo getCleanUrl('debug_info'); ?>">
                                    <i class="bi bi-info-circle me-2"></i> <?php echo $lang_navigation['NAV_DROPDOWN_ADMIN_SYSTEM_INFO'] ?? 'System Info'; ?>
                                </a>
                                <?php endif; ?>
                                
                                <div class="dropdown-divider"></div>
                                <a class="dropdown-item" href="<?php echo getCleanUrl('logout'); ?>">
                                    <i class="bi bi-box-arrow-right me-2"></i> <?php echo $lang_navigation['NAV_DROPDOWN_LOGOUT'] ?? 'Logout'; ?>
                                </a>
                            </div>
                        </div>
                        <?php endif; ?>
                    </div><!-- .nk-header-tools -->
                </div><!-- .nk-header-wrap -->
            </div><!-- .container-fluid -->
        </div>
        <!-- Main Header End -->

        <!-- Mobile Sidebar Overlay -->
        <div class="nk-sidebar-overlay" id="sidebarOverlay"></div>

        <!-- Page Content Wrapper -->
        <div class="nk-wrap">
            <div class="nk-content">
                <div class="container-fluid">
                    <div class="nk-content-inner">
                        <div class="nk-content-body">

<script>
// Sidebar toggle functionality
document.addEventListener('DOMContentLoaded', function() {
    const sidebarToggle = document.querySelector('[data-target="sidebarMenu"]');
    const sidebar = document.querySelector('.nk-sidebar');
    const overlay = document.getElementById('sidebarOverlay');
    const body = document.body;
    
    if (sidebarToggle && sidebar) {
        sidebarToggle.addEventListener('click', function(e) {
            e.preventDefault();
            
            if (window.innerWidth < 1200) {
                // Mobile: Show/hide sidebar with overlay
                sidebar.classList.toggle('is-shown');
                overlay.classList.toggle('active');
                body.classList.toggle('sidebar-active');
            } else {
                // Desktop: Toggle compact mode
                sidebar.classList.toggle('is-compact');
                body.classList.toggle('sidebar-compact');
            }
        });
    }
    
    // Collapsible menu functionality
    const menuToggles = document.querySelectorAll('.nk-menu-toggle');
    menuToggles.forEach(toggle => {
        toggle.addEventListener('click', function(e) {
            e.preventDefault();
            
            const menuItem = this.closest('.nk-menu-item');
            const isActive = menuItem.classList.contains('active');
            
            // Close all other submenus
            document.querySelectorAll('.nk-menu-item.has-sub.active').forEach(item => {
                if (item !== menuItem) {
                    item.classList.remove('active');
                }
            });
            
            // Toggle current submenu
            menuItem.classList.toggle('active', !isActive);
        });
    });
    
    // Close sidebar when clicking overlay
    if (overlay) {
        overlay.addEventListener('click', function() {
            sidebar.classList.remove('is-shown');
            overlay.classList.remove('active');
            body.classList.remove('sidebar-active');
        });
    }
    
    // Handle window resize
    window.addEventListener('resize', function() {
        if (window.innerWidth >= 1200) {
            sidebar.classList.remove('is-shown');
            overlay.classList.remove('active');
            body.classList.remove('sidebar-active');
        }
    });
    
    // Add body classes for layout
    body.classList.add('nk-body', 'bg-lighter', 'npc-general', 'light-mode');
    
    // Auto-expand menu if current page is in submenu
    const currentPath = window.location.pathname;
    const menuLinks = document.querySelectorAll('.nk-menu-sub .nk-menu-link');
    
    menuLinks.forEach(link => {
        const href = link.getAttribute('href');
        if (href && currentPath.includes(href.split('/').pop())) {
            // Mark submenu item as active
            link.closest('.nk-menu-item').classList.add('active');
            // Expand parent menu
            const parentMenu = link.closest('.nk-menu-item.has-sub');
            if (parentMenu) {
                parentMenu.classList.add('active');
            }
        }
    });
});
</script> 