<nav class="bg-white dark:bg-gray-900 shadow-lg fixed w-full z-50 top-0 transition-colors duration-300">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="flex justify-between h-16">
            <div class="flex items-center">
                <!-- Logo -->
                <a href="/" class="flex-shrink-0 flex items-center">
                    <img class="h-8 w-auto" src="<%= settings && settings.logo ? settings.logo : '/images/logo.png' %>" alt="SmartSolTech">
                    <span class="ml-2 text-xl font-bold text-gray-900 dark:text-white">SmartSolTech</span>
                </a>
            </div>
            
            <!-- Desktop Navigation -->
            <div class="hidden md:flex items-center space-x-6">
                <!-- Navigation Links -->
                <a href="/" class="<%= currentPage === 'home' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-gray-700 dark:text-gray-300 hover:text-blue-600' %> px-3 py-2 text-sm font-medium transition-colors nav-link">
                    <%= __('navigation.home') %>
                </a>
                <a href="/about" class="<%= currentPage === 'about' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-gray-700 dark:text-gray-300 hover:text-blue-600' %> px-3 py-2 text-sm font-medium transition-colors nav-link">
                    <%= __('navigation.about') %>
                </a>
                <a href="/services" class="<%= currentPage === 'services' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-gray-700 dark:text-gray-300 hover:text-blue-600' %> px-3 py-2 text-sm font-medium transition-colors nav-link">
                    <%= __('navigation.services') %>
                </a>
                <a href="/portfolio" class="<%= currentPage === 'portfolio' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-gray-700 dark:text-gray-300 hover:text-blue-600' %> px-3 py-2 text-sm font-medium transition-colors nav-link">
                    <%= __('navigation.portfolio') %>
                </a>
                <a href="/calculator" class="<%= currentPage === 'calculator' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-gray-700 dark:text-gray-300 hover:text-blue-600' %> px-3 py-2 text-sm font-medium transition-colors nav-link">
                    <%= __('navigation.calculator') %>
                </a>
                <a href="/contact" class="<%= currentPage === 'contact' ? 'text-blue-600 border-b-2 border-blue-600' : 'text-gray-700 dark:text-gray-300 hover:text-blue-600' %> px-3 py-2 text-sm font-medium transition-colors nav-link">
                    <%= __('navigation.contact') %>
                </a>
                
                <!-- Language Dropdown -->
                <div class="relative group">
                    <button class="flex items-center text-gray-700 dark:text-gray-300 hover:text-blue-600 px-3 py-2 text-sm font-medium transition-colors" id="language-dropdown">
                        <% 
                        let currentFlag = '🇰🇷';
                        let languageKey = 'korean';
                        if (currentLanguage === 'en') {
                            currentFlag = '🇺🇸';
                            languageKey = 'english';
                        } else if (currentLanguage === 'ru') {
                            currentFlag = '🇷🇺';
                            languageKey = 'russian';
                        } else if (currentLanguage === 'kk') {
                            currentFlag = '🇰🇿';
                            languageKey = 'kazakh';
                        }
                        %>
                        <span class="mr-2"><%= currentFlag %></span>
                        <%= __('language.' + languageKey) %>
                        <i class="fas fa-chevron-down ml-1 text-xs"></i>
                    </button>
                    <div class="absolute right-0 mt-2 w-40 bg-white dark:bg-gray-800 rounded-lg shadow-lg border dark:border-gray-700 opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200">
                        <a href="/lang/ko" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-t-lg">
                            🇰🇷 <%= __('language.korean') %>
                        </a>
                        <a href="/lang/en" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700">
                            🇺🇸 <%= __('language.english') %>
                        </a>
                        <a href="/lang/ru" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700">
                            🇷🇺 <%= __('language.russian') %>
                        </a>
                        <a href="/lang/kk" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-b-lg">
                            🇰🇿 <%= __('language.kazakh') %>
                        </a>
                    </div>
                </div>

                <!-- Animated Theme Toggle -->
                <div class="relative inline-block" title="<%= __('theme.toggle') %>">
                    <input type="checkbox" id="theme-toggle" class="sr-only">
                    <label for="theme-toggle" class="flex items-center cursor-pointer">
                        <div class="relative w-14 h-7 bg-gradient-to-r from-blue-200 to-yellow-200 dark:from-gray-700 dark:to-gray-600 rounded-full transition-all duration-300 shadow-inner">
                            <div class="absolute top-0.5 left-0.5 w-6 h-6 bg-white dark:bg-gray-800 rounded-full shadow-lg transform transition-all duration-300 flex items-center justify-center theme-toggle-slider overflow-hidden">
                                <div class="relative w-full h-full flex items-center justify-center">
                                    <!-- Sun Icon -->
                                    <i class="fas fa-sun absolute text-yellow-500 text-sm theme-sun-icon transition-all duration-300 transform"></i>
                                    <!-- Moon Icon -->
                                    <i class="fas fa-moon absolute text-blue-400 text-sm theme-moon-icon transition-all duration-300 transform"></i>
                                </div>
                            </div>
                        </div>
                    </label>
                </div>
            </div>
            
            <!-- Mobile menu button -->
            <div class="md:hidden flex items-center space-x-2">
                <!-- Hamburger Menu -->
                <button id="mobile-menu-toggle" class="p-2 text-gray-700 dark:text-gray-300 hover:text-blue-600 transition-colors">
                    <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path>
                    </svg>
                </button>
            </div>
        </div>
    </div>

    <!-- Mobile Navigation Menu -->
    <div id="mobile-menu" class="md:hidden hidden bg-white dark:bg-gray-900 border-t dark:border-gray-700">
        <div class="px-2 pt-2 pb-3 space-y-1">
            <a href="/" class="<%= currentPage === 'home' ? 'bg-blue-50 dark:bg-blue-900 text-blue-600' : 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700' %> block px-3 py-2 rounded-md text-base font-medium">
                <%= __('navigation.home') %>
            </a>
            <a href="/about" class="<%= currentPage === 'about' ? 'bg-blue-50 dark:bg-blue-900 text-blue-600' : 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700' %> block px-3 py-2 rounded-md text-base font-medium">
                <%= __('navigation.about') %>
            </a>
            <a href="/services" class="<%= currentPage === 'services' ? 'bg-blue-50 dark:bg-blue-900 text-blue-600' : 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700' %> block px-3 py-2 rounded-md text-base font-medium">
                <%= __('navigation.services') %>
            </a>
            <a href="/portfolio" class="<%= currentPage === 'portfolio' ? 'bg-blue-50 dark:bg-blue-900 text-blue-600' : 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700' %> block px-3 py-2 rounded-md text-base font-medium">
                <%= __('navigation.portfolio') %>
            </a>
            <a href="/calculator" class="<%= currentPage === 'calculator' ? 'bg-blue-50 dark:bg-blue-900 text-blue-600' : 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700' %> block px-3 py-2 rounded-md text-base font-medium">
                <%= __('navigation.calculator') %>
            </a>
            <a href="/contact" class="<%= currentPage === 'contact' ? 'bg-blue-50 dark:bg-blue-900 text-blue-600' : 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700' %> block px-3 py-2 rounded-md text-base font-medium">
                <%= __('navigation.contact') %>
            </a>
        </div>
    </div>
</nav>

<script>
document.addEventListener('DOMContentLoaded', function() {
    // Mobile Menu Management
    const mobileMenuToggle = document.getElementById('mobile-menu-toggle');
    const mobileMenu = document.getElementById('mobile-menu');
    
    if (mobileMenuToggle && mobileMenu) {
        mobileMenuToggle.addEventListener('click', function() {
            mobileMenu.classList.toggle('hidden');
        });
    }
    
    // Desktop Language Dropdown Management
    const languageDropdown = document.getElementById('language-dropdown');
    const languageMenu = languageDropdown ? languageDropdown.nextElementSibling : null;
    
    if (languageDropdown && languageMenu) {
        languageDropdown.addEventListener('click', function(e) {
            e.preventDefault();
            languageMenu.classList.toggle('opacity-0');
            languageMenu.classList.toggle('invisible');
        });
        
        // Close language menu when clicking outside
        document.addEventListener('click', function(event) {
            if (!languageDropdown.contains(event.target) && !languageMenu.contains(event.target)) {
                languageMenu.classList.add('opacity-0');
                languageMenu.classList.add('invisible');
            }
        });
    }
    
    // Handle language change clicks
    document.querySelectorAll('a[href^="/lang/"]').forEach(link => {
        link.addEventListener('click', function(e) {
            const newLang = this.href.split('/lang/')[1];
            sessionStorage.setItem('expectedLanguage', newLang);
            console.log('Setting expected language:', newLang);
        });
    });
});
</script>