<?php
 
 /**
 * =============================================================================
 * @package			    Blue Raven (Free Version)
 * @Plugin URI			https://enterrahost.com/plugins/blue-raven
 * 
 * @Author			    EnterraHost
 * @Author URI			https://enterrahost.com
 * @License		    	GPL-2.0-or-later
 *  
 * @Copyright			(c) 2025 EnterraHost
 * @File Description	Setting Header
 * 
 * =============================================================================
 * 
 * || INDEX:
 * ||   - Blue_Raven_Admin_Header
 * || 
 * =============================================================================
 */

if ( ! defined( 'ABSPATH' ) ) exit; 

/*
============================================================
    Blue_Raven_Admin_Header
============================================================
*/
class Blue_Raven_Admin_Settings_Header {
    
    private $plugin_url;
    private $plugin_path;
    
    /**
     * Class constructor.
     *
     * Initializes the plugin's URL and file system path by setting the
     * `$plugin_url` and `$plugin_path` properties. These are used for linking
     * assets and including files relative to the plugin base directory.
     */
    public function __construct() {
        $this->plugin_url = BLUERAVEN_PLUGIN_URL;
        $this->plugin_path = BLUERAVEN_PLUGIN_DIR;
    }
    
    /**
     * Renders the admin interface.
     *
     * Creates an instance of the class and calls the `header()` method
     * to output the top section of the admin settings UI. Acts as the
     * public entry point for rendering the plugin settings.
     */
    public static function render() {
        $instance = new self();
        $instance->header();
    }
        
    /**
     * Outputs the plugin header section in the admin panel.
     *
     * Displays the logo, navigation menu, and plugin-related links
     * including system status and documentation. Called internally by `render()`.
     *
     * @access private
     * @return void
     */
    private function header() {
        $this->enqueue_assets();
        
        ?>
       

        <div class="enterra-header">
            <div class='flex-sb'>
                <h1><?php esc_html_e('Blue Raven Settings', 'blue-raven'); ?></h1>
            </div>

            <div class='header-menu'>
                <nav class='flex-sb'>
                    <div class='flex-sb'>
                        <p class='enterra-nav-button spacing-right' id='settings'>
                            <a href="#"><?php esc_html_e('Plugin Settings', 'blue-raven'); ?></a>
                        </p>
                        <p class='enterra-nav-button spacing-right' id='blue-raven-pro'>
                            <a href="#"><?php esc_html_e('Learn More About Blue Raven pro', 'blue-raven'); ?></a>
                        </p>
                    </div>

                    <div class="flex-sb">
                        <p class="spacing-right-small header-text" style="margin-top:0.4em;">
                            <a id="feather-count-display"
                            href="https://enterrahost.com/blue-raven/"
                            style="text-decoration:none;"
                            target="_blank" rel="noopener">
                                <?php echo esc_html(BlueRaven_FeatherCheck('f')); ?>
                            </a>
                        </p>

                        <p class="enterra-square-button spacing-right-small" style="margin-top:0.4em;">
                            <a href="https://portal.enterrahost.com/store/feather-store" target="_blank" rel="noopener">
                                <img class="enterra-menu-icon"
                                    src="<?php echo esc_url($this->plugin_url . '/assets/media/feather-icon-plus.webp'); ?>"
                                    alt="<?php esc_attr_e('Feather Store Icon', 'blue-raven'); ?>">
                            </a>
                        </p>

                        <p class="header-text" style="margin-top:0.4em;">
                            <a href="https://portal.enterrahost.com/serverstatus.php?view=open"
                            title="<?php esc_attr_e('View system status', 'blue-raven'); ?>"
                            target="_blank" rel="noopener">
                                <?php esc_html_e('System', 'blue-raven'); ?>
                                <span id="status-indicator" style="display: inline-block; width: 15px; height: 15px; border-radius: 50%; background-color: gray; margin-left: 5px; vertical-align: middle;"></span>
                            </a>
                        </p>

                        <?php /*
                        <p class="enterra-nav-button spacing-right-small header-text">
                            <a href="#">
                                <i class="fas <?php echo ($notificationCount > 0) ? 'fa-envelope-open enterra-blue-icon' : 'fa-envelope'; ?>" style="font-size: 22px;"></i>
                            </a>
                        </p>
                        */ ?>

                        <p class="enterra-nav-button spacing-right-small header-text">
                            <a href="https://portal.enterrahost.com/knowledgebase/1/Blue-Raven"
                            target="_blank"
                            rel="noopener"
                            style="margin-left: 8px;"
                            title="<?php esc_attr_e('Learn more', 'blue-raven'); ?>">
                                <i class="fas fa-question-circle"></i>
                            </a>
                        </p>
                    </div>
                </nav>
            </div>
        </div>

        <img class='enterra-enterrahost-logo'
            src='<?php echo esc_url($this->plugin_url . '/assets/media/EnterrahostLogo-plugin.webp'); ?>'
            alt='<?php esc_attr_e('Logo', 'blue-raven'); ?>'>
        <?php
    }
    
    private function enqueue_assets() {
        
        wp_enqueue_script('blue-raven-admin-settings', $this->plugin_url . '/assets/js/admin-settings.js',['jquery', 'wp-util'],filemtime($this->plugin_path . 'assets/js/admin-settings.js'),true);
        wp_enqueue_script('blue-raven-settings', $this->plugin_url . '/assets/js/admin-settings-page.js',['jquery', 'wp-util'],filemtime($this->plugin_path . 'assets/js/admin-settings-page.js'),true);
        wp_enqueue_style('blue-raven-fontawesome',$this->plugin_url . '/assets/css/all.min.css',[],'7.0.0');
        
        wp_localize_script('blue-raven-admin-settings','blueRavenAdminSettings',['ajaxurl' => admin_url('admin-ajax.php'),'nonce' => wp_create_nonce('blue_raven_admin_settings_nonce'),'namespace' => 'blueRavenAdminSettings',]);
        wp_localize_script('blue-raven-settings','blueRavenAdminSettingsPage',['ajaxurl' => admin_url('admin-ajax.php'),'nonce' => wp_create_nonce('blue_raven_admin_settings_page_nonce'),'namespace' => 'blueRavenAdminSettingsPage',]);
    }
}

