<?php
namespace ZS_SEO\AuditOptimization\Admin;

defined( 'ABSPATH' ) || exit;

class Menu {

    public function __construct() {
        add_action( 'admin_menu', [ $this, 'register_menus' ] );
    }

    public function register_menus(): void {
        $icon = 'data:image/svg+xml;base64,' . base64_encode(
            '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white">'
            . '<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/></svg>'
        );

        add_menu_page(
            __('ZS_SEO', 'zs-seo-audit-optimization'),
            __('ZS_SEO', 'zs-seo-audit-optimization'),
            'manage_options',
            'zs-seo-audit-optimization',
            [ $this, 'page_dashboard' ],
            $icon,
            80
        );

        add_submenu_page( 'zs-seo-audit-optimization', __('Dashboard', 'zs-seo-audit-optimization'), __('Dashboard', 'zs-seo-audit-optimization'), 'manage_options', 'zs-seo-audit-optimization',           [ $this, 'page_dashboard'  ] );
        add_submenu_page( 'zs-seo-audit-optimization', __('Audit', 'zs-seo-audit-optimization'), __('Audit', 'zs-seo-audit-optimization'), 'manage_options', 'zs-seo-audit-optimization-audit',     [ $this, 'page_audit'      ] );
        add_submenu_page( 'zs-seo-audit-optimization', __('Images', 'zs-seo-audit-optimization'), __('Images 🖼', 'zs-seo-audit-optimization'), 'manage_options', 'zs-seo-audit-optimization-images',    [ $this, 'page_images'     ] );
        add_submenu_page( 'zs-seo-audit-optimization', __('Redirects', 'zs-seo-audit-optimization'), __('Redirects', 'zs-seo-audit-optimization'), 'manage_options', 'zs-seo-audit-optimization-redirects', [ $this, 'page_redirects'  ] );
        add_submenu_page( 'zs-seo-audit-optimization', __('Settings', 'zs-seo-audit-optimization'), __('Settings', 'zs-seo-audit-optimization'), 'manage_options', 'zs-seo-audit-optimization-settings',  [ $this, 'page_settings'   ] );

        // Upgrade to Pro menu item (only for free users)
        if ( ! zs_seo_is_pro() ) {
            add_submenu_page(
                'zs-seo-audit-optimization',
                __('Upgrade to Pro', 'zs-seo-audit-optimization'),
                '<span style="color:#f39c12;font-weight:700;">⚡ Upgrade to Pro</span>',
                'manage_options',
                'zs-seo-audit-optimization-pricing',
                [ $this, 'page_pricing' ]
            );
        }
    }

    public function page_dashboard(): void { require_once ZS_SEO_DIR . 'templates/admin-dashboard.php'; }
    public function page_audit():     void { require_once ZS_SEO_DIR . 'templates/admin-audit.php';     }
    public function page_images():    void { require_once ZS_SEO_DIR . 'templates/admin-images.php';    }
    public function page_redirects(): void { require_once ZS_SEO_DIR . 'templates/admin-redirects.php'; }
    public function page_settings():  void { require_once ZS_SEO_DIR . 'templates/admin-settings.php';  }
    public function page_pricing():   void { require_once ZS_SEO_DIR . 'templates/admin-pricing.php';   }
}
