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

/**
 * Class: Sifency_Addons_Admin_Why_Pro
 * Description: Displays Free vs Pro feature comparison table in the admin panel.
 */
class Sifency_Addons_Admin_Why_Pro {

    /**
     * Render the "Why Pro" admin page content.
     */
    public function render() {

        $features = [
            // Core Widgets & Components
            [ 'Feature' => 'Access to All Basic Widgets',     'Free' => true,  'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Component Widgets (150+)',        'Free' => '30',  'Pro' => '150+', 'Agency' => '150+' ],
            [ 'Feature' => 'Loop Widgets (Post Grids)',       'Free' => '5',   'Pro' => '20+', 'Agency' => '20+' ],
            [ 'Feature' => 'WooCommerce Widgets',             'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Advanced Form Styler',           'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Slider & Carousel Widgets',       'Free' => false, 'Pro' => true,  'Agency' => true ],

            // Theme Builder & Customization
            [ 'Feature' => 'Theme Builder Integration',       'Free' => 'Limited', 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Custom Header & Footer Builder',  'Free' => true, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Breadcrumb/Subheader Builder',  'Free' => true, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Post Page Builder',  'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'ScrollUp Builder',  'Free' => true, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Custom Post Type (CPT) Builder',  'Free' => 'Limited', 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Dynamic Template Engine',         'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Advanced Conditions (If/Else)',   'Free' => 'Limited', 'Pro' => true,  'Agency' => true ],

            // Templates & Prebuilts
            [ 'Feature' => 'Prebuilt Website Templates',      'Free' => false,   'Pro' => '100+', 'Agency' => '500+' ],
            [ 'Feature' => 'Section Templates',               'Free' => true,  'Pro' => '200+', 'Agency' => 'Unlimited' ],
            [ 'Feature' => 'One-Click Demo Import',           'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Starter Site Templates',          'Free' => false, 'Pro' => true,  'Agency' => true ],

            // Advanced Features
            [ 'Feature' => 'Post Duplicator',                 'Free' => true,  'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Animation Effects (Custom)',    'Free' => true,  'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Custom CSS/JS Injection',         'Free' => true,  'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Advanced Query Builder',          'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Conditional Rendering',           'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Multi-language Support',          'Free' => false, 'Pro' => true,  'Agency' => true ],

            // Content Types & Management
            [ 'Feature' => 'Built-in CPT Support (15+ Upcoming)',      'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Team/Portfolio/Services CPT',     'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Events & Career CPT',             'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Testimonials & Clients CPT',      'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Awards & Achievements CPT',       'Free' => false, 'Pro' => true,  'Agency' => true ],

            // Support & Updates
            [ 'Feature' => 'Priority Support',                'Free' => 'Community', 'Pro' => 'Email', 'Agency' => '24/7 Priority' ],
            [ 'Feature' => 'Regular Updates & Bug Fixes',     'Free' => true,  'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Documentation & Video Tutorials', 'Free' => 'Basic', 'Pro' => 'Full', 'Agency' => 'Full + Custom' ],
            [ 'Feature' => 'Community Forum Access',          'Free' => true,  'Pro' => true,  'Agency' => true ],

            // Licensing & Commercial
            [ 'Feature' => 'Commercial License',              'Free' => false, 'Pro' => true,  'Agency' => true ],
            [ 'Feature' => 'Client Site Unlimited',           'Free' => '1',   'Pro' => 'Unlimited', 'Agency' => 'Unlimited' ],
            [ 'Feature' => 'Multi-site Activation',           'Free' => false, 'Pro' => false, 'Agency' => true ],
        ];

        echo '<div class="sifency-pricing-dashboard">';
        
        // Plan headers
        echo '
        <div class="sifency-pricing-header">
            <div class="sifency-plan-card free">
                <h3>Free</h3>
                <p>$0</p>
                <span>Basic access</span>
            </div>
            <div class="sifency-plan-card pro">
                <h3>Pro</h3>
                <p>$49</p>
                <span>For professionals</span>
            </div>
            <div class="sifency-plan-card agency">
                <h3>Agency</h3>
                <p>$199</p>
                <span>Unlimited sites</span>
            </div>
        </div>';

        echo '<table class="sifency-pricing-table">';
        echo '<thead><tr>';
        echo '<th>Feature</th><th>Free</th><th>Pro</th><th>Agency</th>';
        echo '</tr></thead><tbody>';

        foreach ( $features as $item ) {
            echo '<tr>';
            echo '<td>' . esc_html( $item['Feature'] ) . '</td>';

            foreach ( ['Free', 'Pro', 'Agency'] as $plan ) {
                $value = $item[$plan];
                if ( $value === true ) {
                    echo '<td><span class="sifency-icon success">✔</span></td>';
                } elseif ( $value === false ) {
                    echo '<td><span class="sifency-icon muted">✖</span></td>';
                } else {
                    echo '<td><span class="sifency-text">' . esc_html( $value ) . '</span></td>';
                }
            }
            echo '</tr>';
        }

        echo '</tbody></table>';

        echo '<div class="sifency-upgrade-cta">';
        echo '<h2>' . esc_html__( 'Upgrade to Sifency Pro or Agency', 'sifency-addons' ) . '</h2>';
        echo '<p>' . esc_html__( 'Unlock all templates, advanced features, and lifetime updates.', 'sifency-addons' ) . '</p>';
        echo '<a href="https://sifency-addons.sifency.com" target="_blank" class="sifency-upgrade-btn sifency-admin-btn">Upgrade Now →</a>';
        echo '</div>';

        echo '</div>'; // end dashboard
    }

}
