<?php
// Multi-language Template Functions
require_once __DIR__ . '/language_manager.php';

function getPageTitle($page) {
    $titles = [
        'dashboard' => t('page_title_dashboard'),
        'brands' => t('page_title_brands'),
        'reports' => t('page_title_reports'),
        'seo_analysis' => t('page_title_seo_analysis'),
        'content' => t('page_title_content'),
        'analytics' => t('page_title_analytics'),
        'settings' => t('page_title_settings'),
        'help' => t('page_title_help'),
        'profile' => t('page_title_profile'),
        'article_editor' => t('page_title_article_editor')
    ];
    return $titles[$page] ?? 'SEO AI 自動化系統';
}

function getNavItems() {
    return [
        'dashboard' => [
            'icon' => 'fas fa-tachometer-alt',
            'text' => t('nav_dashboard'),
            'url' => 'dashboard.php'
        ],
        'brands' => [
            'icon' => 'fas fa-building',
            'text' => t('nav_brands'),
            'url' => 'brands.php'
        ],
        'reports' => [
            'icon' => 'fas fa-chart-bar',
            'text' => t('nav_reports'),
            'url' => 'reports.php'
        ],
        'seo_analysis' => [
            'icon' => 'fas fa-search',
            'text' => t('nav_seo_analysis'),
            'url' => 'seo_analysis.php'
        ],
        'content' => [
            'icon' => 'fas fa-edit',
            'text' => t('nav_content'),
            'url' => 'content.php'
        ],
        'analytics' => [
            'icon' => 'fas fa-analytics',
            'text' => t('nav_analytics'),
            'url' => 'analytics.php'
        ],
        'settings' => [
            'icon' => 'fas fa-cog',
            'text' => t('nav_settings'),
            'url' => 'settings.php'
        ],
        'help' => [
            'icon' => 'fas fa-question-circle',
            'text' => t('nav_help'),
            'url' => 'help.php'
        ],
        'profile' => [
            'icon' => 'fas fa-user',
            'text' => t('nav_profile'),
            'url' => 'profile.php'
        ]
    ];
}

function renderSidebar($current_page = '') {
    $nav_items = getNavItems();
    echo '<nav class="sidebar-nav">';
    echo '<ul>';
    
    foreach ($nav_items as $key => $item) {
        $active_class = ($current_page === $key) ? ' class="active"' : '';
        echo '<li' . $active_class . '>';
        echo '<a href="' . $item['url'] . '">';
        echo '<i class="' . $item['icon'] . '"></i>';
        echo '<span>' . $item['text'] . '</span>';
        echo '</a>';
        echo '</li>';
    }
    
    echo '</ul>';
    echo '</nav>';
}

function renderLogoutButton() {
    echo '<div class="sidebar-footer">';
    echo '<a href="logout.php" class="logout-btn">';
    echo '<i class="fas fa-sign-out-alt"></i>';
    echo '<span>' . t('nav_logout') . '</span>';
    echo '</a>';
    echo '</div>';
}
?>
