<?php
/**
 * Get Started Page
 */

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

// Add menu under Appearance
function business_office_add_theme_info_page() {
    add_theme_page(
        esc_html__('Get Started', 'business-office'),
        esc_html__('Get Started', 'business-office'),
        'manage_options',
        'business-office-info',
        'business_office_render_theme_info_page'
    );
}
add_action('admin_menu', 'business_office_add_theme_info_page');


// Enqueue styles only on this page
function business_office_admin_assets($business_office_hook) {

    if ( $business_office_hook !== 'appearance_page_business-office-info' ) {
        return;
    }

    wp_enqueue_style(
        'business-office-theme-info',
        get_template_directory_uri() . '/assets/css/theme-info.css',
        array(),
        wp_get_theme()->get('Version')
    );
}
add_action('admin_enqueue_scripts', 'business_office_admin_assets');


// Render Page
function business_office_render_theme_info_page() {

    $business_office_theme = wp_get_theme();
    $business_office_version = $business_office_theme->get('Version');
    $business_office_import_completed = (bool) get_option( 'business_office_demo_import_completed', false );

    ?>
    <div class="wrap business-office-dashboard">
		<h1 class="main-head-hidden"><?php echo esc_html( $business_office_theme->get('Name') ); ?></h1>

        <!-- Header -->
        <div class="business-office-header">
            <div class="business-office-title">
                <h1><?php echo esc_html( $business_office_theme->get('Name') ); ?></h1>
                <span><?php esc_html_e('Version', 'business-office'); ?> <?php echo esc_html($business_office_version); ?></span>
            </div>

            <div class="business-office-header-buttons">
                <a href="<?php echo esc_url('https://www.apexthemes.net/products/business-firm-wordpress-theme/'); ?>" target="_blank" rel="noopener noreferrer" class="btn-outline">
                    <?php esc_html_e('Get Premium', 'business-office'); ?>
                </a>
                <a href="<?php echo esc_url('https://trial.apexthemes.net/business-office/'); ?>" target="_blank" rel="noopener noreferrer" class="btn-outline">
                    <?php esc_html_e('Live Demo', 'business-office'); ?>
                </a>
                <a href="<?php echo esc_url('https://trial.apexthemes.net/docs/business-office-pro/'); ?>" target="_blank" rel="noopener noreferrer" class="btn-outline">
                    <?php esc_html_e('Documentation', 'business-office'); ?>
                </a>
            </div>
        </div>

        <!-- Content -->
        <div class="business-office-main">

            <!-- Left -->
            <div class="business-office-left">
                <img src="<?php echo esc_url( get_template_directory_uri() . '/screenshot.png' ); ?>" alt="theme">

                <div class="business-office-buttons">
                    <a href="<?php echo esc_url('https://www.apexthemes.net/products/business-firm-wordpress-theme/'); ?>" target="_blank" rel="noopener noreferrer" class="btn-gradient">
                        <?php esc_html_e('Get Premium', 'business-office'); ?>
                    </a>
                    <a href="<?php echo esc_url('https://trial.apexthemes.net/business-office/'); ?>" target="_blank" rel="noopener noreferrer" class="btn-gradient">
                        <?php esc_html_e('Live Demo', 'business-office'); ?>
                    </a>
                    <a href="<?php echo esc_url('https://trial.apexthemes.net/docs/business-office-pro/'); ?>" target="_blank" rel="noopener noreferrer" class="btn-gradient">
                        <?php esc_html_e('Documentation', 'business-office'); ?>
                    </a>
                </div>
            </div>

            <!-- Right -->
            <div class="business-office-right">

                <h2>
                    <?php echo esc_html($business_office_theme->get('Name')); ?>
                </h2>
                <div class="business-office-default-content">

                    <p>
                        <?php echo esc_html($business_office_theme->get('Description')); ?>
                    </p>

                    <?php if ( ! $business_office_import_completed ) : ?>
                        <a href="#" id="business-office-import-btn" class="btn-gradient">
                            <?php esc_html_e('Import Demo Now', 'business-office'); ?>
                        </a>
                    <?php else : ?>
                        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="btn-gradient" target="_blank" rel="noopener noreferrer">
                            <?php esc_html_e('Visit Site', 'business-office'); ?>
                        </a>
                    <?php endif; ?>
                </div>

                <div class="business-office-import-content">
                    <?php
                    require_once get_template_directory() . '/apex-library/dashboard/dashboard-contents.php';
                    
                    global $business_office_config;
                    
                    if ( class_exists( 'Business_Office_Whizzie' ) ) {
                        $business_office_wiz = new Business_Office_Whizzie( $business_office_config );
                    
                        // NOTE: Only render the wizard UI — NOT header/wrapper/tabs
                        $business_office_wiz->wizard_page();
                    }
                    ?>
                </div>
                    
			</div>

        </div>
    </div>
    <?php
}