<?php
// phpcs:ignoreFile WordPress.NamingConventions.PrefixAllGlobals

defined( 'ABSPATH' ) || exit;

// Get Freemius pricing URL
$upgrade_url = '#';
if ( function_exists( 'zs_seo_fs' ) ) {
    try {
        $upgrade_url = zs_seo_fs()->get_upgrade_url();
    } catch ( \Exception $e ) {
        $upgrade_url = '#';
    }
}
?>
<div class="wrap zs-seo-wrap">
    <div class="zs-seo-header">
        <h1>⚡ <?php esc_html_e('Upgrade to ZS_SEO Pro', 'zs-seo-audit-optimization'); ?></h1>
        <p class="zs-seo-tagline"><?php esc_html_e('Unlock auto-fixes, bulk tools, and advanced SEO features.', 'zs-seo-audit-optimization'); ?></p>
    </div>

    <!-- Pricing Cards -->
    <div class="zs-seo-pricing-grid">

        <!-- Free -->
        <div class="zs-seo-pricing-card">
            <div class="zs-seo-pricing-badge zs-seo-badge-free">Current Plan</div>
            <h2>Free</h2>
            <div class="zs-seo-pricing-price">$0<span>/forever</span></div>
            <ul class="zs-seo-pricing-features">
                <li class="yes">✅ Full SEO Audit (all pages)</li>
                <li class="yes">✅ On-Page SEO meta fields</li>
                <li class="yes">✅ Heading structure checker</li>
                <li class="yes">✅ Image alt text manager</li>
                <li class="yes">✅ GEO / AI Search schema</li>
                <li class="yes">✅ Redirect manager (301/302)</li>
                <li class="yes">✅ JSON-LD Schema injection</li>
                <li class="no">❌ Auto PNG → WebP conversion</li>
                <li class="no">❌ Auto inject loading="lazy"</li>
                <li class="no">❌ Auto fix image dimensions</li>
                <li class="no">❌ One-click bulk issue fix</li>
                <li class="no">❌ Scheduled SEO scans</li>
                <li class="no">❌ PDF audit reports</li>
                <li class="no">❌ White-label reports</li>
                <li class="no">❌ Multi-site support</li>
                <li class="no">❌ WP-CLI commands</li>
                <li class="no">❌ Priority support</li>
            </ul>
            <button class="button zs-seo-pricing-btn-free" disabled>Current Plan</button>
        </div>

        <!-- Pro -->
        <div class="zs-seo-pricing-card zs-seo-pricing-card--pro">
            <div class="zs-seo-pricing-badge zs-seo-badge-pro">⚡ Most Popular</div>
            <h2>Pro</h2>
            <div class="zs-seo-pricing-price">$49<span>/year</span></div>
            <p class="zs-seo-pricing-sub">or $9/month &nbsp;·&nbsp; <strong>14-day money-back guarantee</strong></p>
            <ul class="zs-seo-pricing-features">
                <li class="yes">✅ Everything in Free</li>
                <li class="yes pro">⚡ Auto PNG → WebP conversion</li>
                <li class="yes pro">⚡ Auto inject loading="lazy"</li>
                <li class="yes pro">⚡ Auto fix image dimensions (CLS)</li>
                <li class="yes pro">⚡ One-click bulk fix all issues</li>
                <li class="yes pro">⚡ Scheduled SEO scans</li>
                <li class="yes pro">⚡ PDF audit reports</li>
                <li class="yes pro">⚡ White-label reports (agencies)</li>
                <li class="yes pro">⚡ Multi-site support</li>
                <li class="yes pro">⚡ WP-CLI commands</li>
                <li class="yes pro">⚡ REST API access</li>
                <li class="yes pro">⚡ Priority email support</li>
            </ul>
            <a href="<?php echo esc_url( $upgrade_url ); ?>" class="button button-primary zs-seo-pricing-btn-pro" target="_blank">
                🚀 Upgrade to Pro — $49/year
            </a>
            <p style="margin-top: 10px; font-size: 13px; text-align: center;">
                Already have a license? 
                <a href="<?php echo esc_url( function_exists( 'zs_seo_fs' ) ? zs_seo_fs()->get_reconnect_url() : admin_url( 'admin.php?page=zs-seo-audit-optimization' ) ); ?>" style="color: var(--zen-primary); font-weight: 600; text-decoration: underline;">
                    Activate License
                </a>
            </p>
            <p class="zs-seo-pricing-guarantee">🔒 Secure payment via Freemius · Cancel anytime</p>
        </div>

    </div>

    <!-- Feature Comparison Table -->
    <div class="zs-seo-box" style="margin-top:32px;">
        <h2>📊 <?php esc_html_e('Detailed Feature Comparison', 'zs-seo-audit-optimization'); ?></h2>
        <table class="wp-list-table widefat fixed striped zs-seo-compare-table">
            <thead>
                <tr>
                    <th><?php esc_html_e('Feature', 'zs-seo-audit-optimization'); ?></th>
                    <th style="text-align:center;width:120px;">Free</th>
                    <th style="text-align:center;width:120px;color:#6c5ce7;">Pro ⚡</th>
                </tr>
            </thead>
            <tbody>
                <?php
                $features = [
                    [ 'Full SEO Audit',              true,  true  ],
                    [ 'Heading structure check',     true,  true  ],
                    [ 'Meta title / description',    true,  true  ],
                    [ 'OG tags & Twitter cards',     true,  true  ],
                    [ 'Canonical URL management',    true,  true  ],
                    [ 'Robots noindex/nofollow',     true,  true  ],
                    [ 'FAQ Schema (GEO)',             true,  true  ],
                    [ 'JSON-LD Schema injection',    true,  true  ],
                    [ 'Image alt text manager',      true,  true  ],
                    [ 'Redirect manager',            true,  true  ],
                    [ 'Site-wide SEO scan',          true,  true  ],
                    [ 'SEO score per page',          true,  true  ],
                    [ 'Auto PNG → WebP',             false, true  ],
                    [ 'Auto loading="lazy" inject',  false, true  ],
                    [ 'Auto image dimensions fix',   false, true  ],
                    [ 'Bulk one-click fix',          false, true  ],
                    [ 'Scheduled scans',             false, true  ],
                    [ 'PDF audit export',            false, true  ],
                    [ 'White-label reports',         false, true  ],
                    [ 'Multi-site support',          false, true  ],
                    [ 'WP-CLI support',              false, true  ],
                    [ 'Priority support',            false, true  ],
                ];
                foreach ( $features as $f ) :
                ?>
                <tr>
                    <td><?php echo esc_html( $f[0] ); ?></td>
                    <td style="text-align:center;"><?php echo $f[1] ? '<span style="color:#00b894;font-size:18px;">✓</span>' : '<span style="color:#dfe6e9;">—</span>'; ?></td>
                    <td style="text-align:center;"><?php echo $f[2] ? '<span style="color:#6c5ce7;font-size:18px;font-weight:700;">✓</span>' : '<span style="color:#dfe6e9;">—</span>'; ?></td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>

    <!-- FAQ -->
    <div class="zs-seo-box">
        <h2>❓ <?php esc_html_e('Frequently Asked Questions', 'zs-seo-audit-optimization'); ?></h2>
        <div class="zs-seo-faq-static">
            <div class="zs-seo-faq-item">
                <h4><?php esc_html_e('Can I cancel anytime?', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('Yes. Cancel anytime from your account. No questions asked.', 'zs-seo-audit-optimization'); ?></p>
            </div>
            <div class="zs-seo-faq-item">
                <h4><?php esc_html_e('Is there a money-back guarantee?', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('14-day full refund policy. If you\'re not satisfied, we\'ll refund 100%.', 'zs-seo-audit-optimization'); ?></p>
            </div>
            <div class="zs-seo-faq-item">
                <h4><?php esc_html_e('Does Pro work on unlimited sites?', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('Pro plan supports multi-site installations. One license covers your network.', 'zs-seo-audit-optimization'); ?></p>
            </div>
            <div class="zs-seo-faq-item">
                <h4><?php esc_html_e('Will my data be safe after upgrading?', 'zs-seo-audit-optimization'); ?></h4>
                <p><?php esc_html_e('All your existing SEO settings, FAQs, and redirects are preserved when upgrading.', 'zs-seo-audit-optimization'); ?></p>
            </div>
        </div>
    </div>
</div>
