<?php
if (!defined('ABSPATH')) {
    exit;
}

add_action('stakmv_auctions_settings_tabs', function ($current_tab) {
    printf(
        '<a href="?page=stakmv-auctions&tab=pro_features" class="nav-tab %s">Pro Features</a>',
        $current_tab === 'pro_features' ? 'nav-tab-active' : ''
    );
}, 1000);

add_action('stakmv_auctions_render_tab_pro_features', function () {
    $pro_url = 'https://stak.ng/multivendor';

    $feature_groups = array(
        'Advanced Bidding' => array(
            'Reserve Price',
            'Auto-Bid / Proxy Bidding',
            'Anti-Sniping Auction Extensions',
            'Buyer Offer Workflows (accept/decline/counter)',
            'Saved Search Alerts',
        ),
        'Vendor Operations' => array(
            'Wallet Ledger',
            'Vendor Withdrawals',
            'Vendor Messaging',
            'Buyer Watchlist',
            'Vendor Support Tickets',
        ),
        'Marketplace Management' => array(
            'Vendor Analytics',
            'Escrow Automation Rules',
            'Vendor Auto-Approval',
            'Role Manager and Access Controls',
            'Pro REST API Endpoints',
        ),
    );
    ?>
    <div class="wcmv-pro-features">
        <h2><?php esc_html_e('Pro Features Add-on', 'stak-multivendor'); ?></h2>
        <p class="description" style="max-width:860px;">
            <?php esc_html_e('Stak Multivendor works as a complete free plugin. If you need advanced automation, vendor finance tools, and higher-scale marketplace operations, you can add Pro Features as an optional extension.', 'stak-multivendor'); ?>
        </p>

        <div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:16px;margin-top:16px;">
            <?php foreach ($feature_groups as $group_title => $items) : ?>
                <div style="background:#fff;border:1px solid #dcdcde;border-radius:8px;padding:14px;">
                    <h3 style="margin:0 0 10px;"><?php echo esc_html($group_title); ?></h3>
                    <ul style="margin:0 0 12px 18px;">
                        <?php foreach ($items as $item) : ?>
                            <li><?php echo esc_html($item); ?></li>
                        <?php endforeach; ?>
                    </ul>
                    <a
                        class="button button-primary"
                        href="<?php echo esc_url($pro_url); ?>"
                        target="_blank"
                        rel="noopener noreferrer"
                    >
                        <?php esc_html_e('Get Pro Features', 'stak-multivendor'); ?>
                    </a>
                </div>
            <?php endforeach; ?>
        </div>

        <p class="description" style="margin-top:16px;">
            <?php esc_html_e('Use the free plugin by itself, or add Pro Features when your marketplace needs advanced workflows.', 'stak-multivendor'); ?>
        </p>
    </div>
    <?php
});
