<?php

namespace VulnTitan\Admin\Pages;

class TemplateParts
{
    public static function header()
    {
        $screenId = self::get_current_screen_id();
        ?>
        <div class="vulntitan-topbar">
            <div class="vulntitan-topbar-left">
                <div class="vulntitan-logo">
                    <img src="<?php echo esc_url(VULNTITAN_PLUGIN_URL); ?>/assets/img/vulntitan-logo-2.png" alt="VulnTitan" class="vulntitan-logo-img">
                    <div class="vulntitan-brand">
                        <h1 class="vulntitan-brand-title">
                            <span class="vulntitan-text-white">Vuln</span><span class="vulntitan-text-sky">Titan</span>
                        </h1>
                    </div>
                </div>
            </div>
            <div class="vulntitan-topbar-right">
                <nav class="vulntitan-nav-links">
                    <a href="<?php echo esc_url( admin_url('admin.php?page=vulntitan') ); ?>"
                        class="<?php echo $screenId === 'toplevel_page_vulntitan' ? 'active' : ''; ?>">
                        <?php esc_html_e('Dashboard', 'vulntitan'); ?>
                    </a>
                    <a href="<?php echo esc_url( admin_url('admin.php?page=vulntitan-firewall') ); ?>"
                        class="<?php echo $screenId === 'vulntitan_page_vulntitan-firewall' ? 'active' : ''; ?>">
                        <?php esc_html_e('Firewall', 'vulntitan'); ?>
                    </a>
                    <a href="<?php echo esc_url( admin_url('admin.php?page=vulntitan-live-feed') ); ?>"
                        class="<?php echo $screenId === 'vulntitan_page_vulntitan-live-feed' ? 'active' : ''; ?>">
                        <?php esc_html_e('Live Feed', 'vulntitan'); ?>
                    </a>
                </nav>
                <div class="vulntitan-topbar-status">
                    <span class="vulntitan-topbar-pill"><?php esc_html_e('Active', 'vulntitan'); ?></span>
                </div>
            </div>
        </div>
        <?php
    }

    public static function footer()
    { ?>
        <p class="vulntitan-version">
            <span class="vulntitan-badge">VulnTitan v<?php echo esc_html(self::get_plugin_version()); ?></span>
        </p>
    <?php
    }

    public static function get_current_screen_id(): string
    {
        if (!function_exists('get_current_screen')) {
            return '';
        }

        $screen = get_current_screen();

        return is_object($screen) && isset($screen->id) ? (string) $screen->id : '';
    }

    public static function get_plugin_version()
    {
        if (!function_exists('get_plugin_data')) {
            return defined('VULNTITAN_PLUGIN_VERSION') ? VULNTITAN_PLUGIN_VERSION : '1.0.0';
        }

        $pluginData = get_plugin_data(VULNTITAN_PLUGIN_DIR . '/vulntitan.php');
        
        return $pluginData['Version'] ?? '1.0.0'; 
    }
}
