<?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 = array(
			// Core Widgets & Components
			array(
				'Feature' => 'Access to All Basic Widgets',
				'Free'    => true,
				'Pro'     => true,
				'Agency'  => true,
			),
			array(
				'Feature' => 'Widgets (250+)',
				'Free'    => '30',
				'Pro'     => '250+',
				'Agency'  => '250+',
			),
			array(
				'Feature' => 'Loop Widgets (Post Grids)',
				'Free'    => '5',
				'Pro'     => '20+',
				'Agency'  => '20+',
			),
			array(
				'Feature' => 'WooCommerce Widgets',
				'Free'    => false,
				'Pro'     => true,
				'Agency'  => true,
			),
			array(
				'Feature' => 'Form Styler',
				'Free'    => true,
				'Pro'     => true,
				'Agency'  => true,
			),
			array(
				'Feature' => 'Slider & Carousel Widgets',
				'Free'    => 'Limited',
				'Pro'     => true,
				'Agency'  => true,
			),

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

			// Templates & Prebuilts
			array(
				'Feature' => 'Prebuilt Website Templates',
				'Free'    => false,
				'Pro'     => '100+',
				'Agency'  => '500+',
			),
			array(
				'Feature' => 'Reusable Templates',
				'Free'    => true,
				'Pro'     => '250+',
				'Agency'  => 'Unlimited',
			),
			array(
				'Feature' => 'One-Click Demo Import',
				'Free'    => false,
				'Pro'     => true,
				'Agency'  => true,
			),
			array(
				'Feature' => 'Starter Site Templates',
				'Free'    => false,
				'Pro'     => true,
				'Agency'  => true,
			),

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

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

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

			// Licensing & Commercial
			array(
				'Feature' => 'Commercial License',
				'Free'    => false,
				'Pro'     => true,
				'Agency'  => true,
			),
			array(
				'Feature' => 'Client Site Unlimited',
				'Free'    => '1',
				'Pro'     => 'Unlimited',
				'Agency'  => 'Unlimited',
			),
			array(
				'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 ( array( '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.com/sifency-addons" target="_blank" class="sifency-upgrade-btn sifency-admin-btn">Upgrade Now →</a>';
		echo '</div>';

		echo '</div>';
	}

}
