<?php
namespace ComptaFlowPro\Admin\Screens;

defined('ABSPATH') || exit;

/**
 * Go Pro Screen - Informational page about ComptaFlow Pro
 * 
 * This is a purely informational page that presents the Pro features
 * and links to the external website for purchase.
 * No license management or feature locking is done here.
 */
class PlanScreen
{
    public static function render(): void
    {
        if (!current_user_can('manage_options')) {
            wp_die(esc_html__('You do not have sufficient permissions.', 'comptaflow-by-meetempo'));
        }
        
        echo '<div class="wrap">';
        echo '<h1>💎 ' . esc_html__('ComptaFlow Pro', 'comptaflow-by-meetempo') . '</h1>';
        
        self::showLiteInfo();
        self::showProFeatures();
        
        echo '<div style="display: flex; justify-content: center; gap: 40px; margin: 30px 0; flex-wrap: wrap;">';
        echo '<div style="text-align: center;">';
        echo '<div style="font-size: 32px; font-weight: bold; color: #667eea;">125+</div>';
        echo '<div style="color: #666; font-size: 14px;">' . esc_html__('Downloads in 7 days', 'comptaflow-by-meetempo') . '</div>';
        echo '</div>';
        echo '<div style="text-align: center;">';
        echo '<div style="font-size: 32px; font-weight: bold; color: #667eea;">⭐⭐⭐⭐⭐</div>';
        echo '<div style="color: #666; font-size: 14px;">' . esc_html__('5/5 on WordPress.org', 'comptaflow-by-meetempo') . '</div>';
        echo '</div>';
        echo '<div style="text-align: center;">';
        echo '<div style="font-size: 32px; font-weight: bold; color: #667eea;">0€</div>';
        echo '<div style="color: #666; font-size: 14px;">' . esc_html__('To start your trial', 'comptaflow-by-meetempo') . '</div>';
        echo '</div>';
        echo '</div>';
        
        self::showPricing();
        self::showSupport();
        
        echo '</div>';
    }
    
    /**
     * Show current LITE plan info
     */
    private static function showLiteInfo(): void
    {
        echo '<div style="background: #d4edda; border: 1px solid #c3e6cb; padding: 20px; margin: 20px 0; border-radius: 8px;">';
        echo '<h2 style="margin-top: 0; color: #155724;">✅ ' . esc_html__('You are using ComptaFlow Lite', 'comptaflow-by-meetempo') . '</h2>';
        echo '<p style="color: #155724; margin-bottom: 0;">' . esc_html__('The free version includes: Invoicing, Clients, Sales, Expenses, Journal, Manual Entries, Balance/Journal/Ledger exports, and Backup.', 'comptaflow-by-meetempo') . '</p>';
        echo '</div>';
    }
    
    /**
     * Show Pro features comparison
     */
    private static function showProFeatures(): void
    {
        echo '<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 40px; margin: 30px 0; border-radius: 12px; box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);">';
        echo '<h2 style="margin-top: 0; color: white; font-size: 28px;">🚀 ' . esc_html__('Upgrade to ComptaFlow Pro', 'comptaflow-by-meetempo') . '</h2>';
        echo '<p style="color: rgba(255,255,255,0.95); font-size: 17px; line-height: 1.6; margin: 20px 0;">';
        echo esc_html__('Unlock advanced features for complete accounting management: FEC export, automatic VAT, bank reconciliation, payroll, and more.', 'comptaflow-by-meetempo');
        echo '</p>';
        
        echo '<div style="margin: 30px 0;">';
        echo '<h3 style="color: white; margin-bottom: 20px;">✨ ' . esc_html__('Pro Features', 'comptaflow-by-meetempo') . '</h3>';
        
        echo '<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px;">';
        
        $features = [
    ['icon' => '📄', 'title' => __('Full Invoicing', 'comptaflow-by-meetempo'), 'desc' => __('Invoices, Quotes, Credit Notes with PDF', 'comptaflow-by-meetempo')],
    ['icon' => '🔍', 'title' => __('SIRET API', 'comptaflow-by-meetempo'), 'desc' => __('Auto-fill company info from official database', 'comptaflow-by-meetempo')],
    ['icon' => '📤', 'title' => __('FEC Export', 'comptaflow-by-meetempo'), 'desc' => __('Legal export for tax audits', 'comptaflow-by-meetempo')],
    ['icon' => '🏦', 'title' => __('Bank Reconciliation', 'comptaflow-by-meetempo'), 'desc' => __('Automatic matching with bank statements', 'comptaflow-by-meetempo')],
    ['icon' => '📋', 'title' => __('VAT Management', 'comptaflow-by-meetempo'), 'desc' => __('CA3/CA12 declarations', 'comptaflow-by-meetempo')],
    ['icon' => '🏢', 'title' => __('Fixed Assets', 'comptaflow-by-meetempo'), 'desc' => __('Depreciation and amortization', 'comptaflow-by-meetempo')],
    ['icon' => '👥', 'title' => __('Payroll', 'comptaflow-by-meetempo'), 'desc' => __('Simplified payroll management', 'comptaflow-by-meetempo')],
    ['icon' => '📑', 'title' => __('Tax Return 2031', 'comptaflow-by-meetempo'), 'desc' => __('French fiscal package generation', 'comptaflow-by-meetempo')],
    ['icon' => '📧', 'title' => __('Client Reminders', 'comptaflow-by-meetempo'), 'desc' => __('Email & WhatsApp automatic reminders (VIP)', 'comptaflow-by-meetempo')],
    ['icon' => '💾', 'title' => __('One-click Backup & Restore', 'comptaflow-by-meetempo'), 'desc' => __('Secure your data with one click', 'comptaflow-by-meetempo')],
];
        
        foreach ($features as $feature) {
            echo '<div style="background: rgba(255,255,255,0.1); padding: 15px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2);">';
            echo '<div style="font-size: 24px; margin-bottom: 8px;">' . esc_html($feature['icon']) . '</div>';
            echo '<div style="color: white; font-weight: 600; margin-bottom: 4px;">' . esc_html($feature['title']) . '</div>';
            echo '<div style="color: rgba(255,255,255,0.8); font-size: 13px;">' . esc_html($feature['desc']) . '</div>';
            echo '</div>';
        }
        
        echo '</div>';
        echo '</div>';
        
        echo '<p style="margin: 20px 0; text-align: center;">';
        echo '<span style="background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; padding: 10px 24px; border-radius: 50px; font-weight: 600; font-size: 15px; display: inline-block;">';
        echo '🎁 ' . esc_html__('30-day free trial — No credit card required', 'comptaflow-by-meetempo');
        echo '</span>';
        echo '</p>';

        echo '<p style="margin: 10px 0; text-align: center;">';
        echo '<span style="background: #002395; color: white; padding: 8px 20px; border-radius: 50px; font-weight: 600; font-size: 14px; display: inline-block;">';
        echo '🇫🇷 ' . esc_html__('The Pro version is entirely in French', 'comptaflow-by-meetempo');
        echo '</span>';
        echo '</p>';
        
        echo '<p style="margin: 25px 0; text-align: center;">';
        echo '<a href="https://comptaflow.meetempo.com"
               class="button button-hero" 
               target="_blank"
               rel="noopener noreferrer"
               style="background: white; 
                      color: #667eea;
                      border: none; 
                      text-shadow: none; 
                      box-shadow: 0 4px 12px rgba(0,0,0,0.15);
                      padding: 16px 48px;
                      font-size: 18px;
                      font-weight: 600;
                      height: auto;
                      line-height: 1.5;
                      text-decoration: none;
                      display: inline-block;
                      border-radius: 8px;">';
        echo '🚀 ' . esc_html__('Start Your Free Trial', 'comptaflow-by-meetempo') . ' →';
        echo '</a>';
        echo '</p>';
        
        echo '</div>';
    }

    /**
     * Show pricing comparison
     */
    private static function showPricing(): void
    {
        echo '<div style="margin: 30px 0;">';
        echo '<h2>' . esc_html__('Compare Plans', 'comptaflow-by-meetempo') . '</h2>';
        
        echo '<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px;">';
        
        // LITE (current)
        echo '<div style="background: #f8f9fa; padding: 25px; border-radius: 8px; border: 2px solid #0073aa;">';
        echo '<div style="color: #0073aa; font-size: 18px; font-weight: 600; margin-bottom: 8px;">🆓 LITE</div>';
        echo '<div style="font-size: 28px; font-weight: bold; margin-bottom: 15px;">' . esc_html__('Free', 'comptaflow-by-meetempo') . '</div>';
        echo '<ul style="list-style: none; padding: 0; margin: 0; font-size: 14px; line-height: 1.8;">';
        echo '<li>✓ ' . esc_html__('Unlimited transactions', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('Sales & Expenses', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('Accounting Journal', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('Balance/Journal exports', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('Backup', 'comptaflow-by-meetempo') . '</li>';
        echo '</ul>';
        echo '<p style="margin-top: 15px; padding-top: 15px; border-top: 1px solid #ddd; text-align: center; color: #0073aa; font-weight: 600;">' . esc_html__('Current plan', 'comptaflow-by-meetempo') . '</p>';
        echo '</div>';
        
        // STANDARD
        echo '<div style="background: white; padding: 25px; border-radius: 8px; border: 1px solid #ddd;">';
        echo '<div style="background: #10b981; color: white; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; display: inline-block; margin-bottom: 10px;">🎁 ' . esc_html__('30 days free — No card required', 'comptaflow-by-meetempo') . '</div>';
        echo '<div style="color: #667eea; font-size: 18px; font-weight: 600; margin-bottom: 8px;">🥉 STANDARD</div>';
        echo '<div style="font-size: 28px; font-weight: bold; margin-bottom: 15px;">9,99€<span style="font-size: 14px; font-weight: normal;">/' . esc_html__('month', 'comptaflow-by-meetempo') . '</span></div>';
        echo '<ul style="list-style: none; padding: 0; margin: 0; font-size: 14px; line-height: 1.8;">';
        echo '<li>✓ ' . esc_html__('Everything in LITE', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('FEC Export', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('Bank Reconciliation', 'comptaflow-by-meetempo') . '</li>';
        echo '</ul>';
        echo '</div>';
        
        // PLUS
        echo '<div style="background: white; padding: 25px; border-radius: 8px; border: 1px solid #ddd;">';
        echo '<div style="background: #10b981; color: white; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; display: inline-block; margin-bottom: 10px;">🎁 ' . esc_html__('30 days free — No card required', 'comptaflow-by-meetempo') . '</div>';
        echo '<div style="color: #667eea; font-size: 18px; font-weight: 600; margin-bottom: 8px;">🥈 PLUS</div>';
        echo '<div style="font-size: 28px; font-weight: bold; margin-bottom: 15px;">13,99€<span style="font-size: 14px; font-weight: normal;">/' . esc_html__('month', 'comptaflow-by-meetempo') . '</span></div>';
        echo '<ul style="list-style: none; padding: 0; margin: 0; font-size: 14px; line-height: 1.8;">';
        echo '<li>✓ ' . esc_html__('Everything in STANDARD', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('VAT Management (CA3/CA12)', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('Fixed Assets', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('Payroll', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('Smart Alerts', 'comptaflow-by-meetempo') . '</li>';
        echo '</ul>';
        echo '</div>';
        
        // VIP
        echo '<div style="background: white; padding: 25px; border-radius: 8px; border: 2px solid #ffd700; position: relative;">';
        echo '<div style="position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: #ffd700; color: #333; padding: 4px 12px; border-radius: 12px; font-size: 11px; font-weight: bold;">⭐ ' . esc_html__('RECOMMENDED', 'comptaflow-by-meetempo') . '</div>';
        echo '<div style="background: #10b981; color: white; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; display: inline-block; margin-bottom: 10px; margin-top: 8px;">🎁 ' . esc_html__('30 days free — No card required', 'comptaflow-by-meetempo') . '</div>';
        echo '<div style="color: #667eea; font-size: 18px; font-weight: 600; margin-bottom: 8px;">👑 VIP</div>';
        echo '<div style="font-size: 28px; font-weight: bold; margin-bottom: 4px;">19,90€<span style="font-size: 14px; font-weight: normal;">/' . esc_html__('month', 'comptaflow-by-meetempo') . '</span></div>';
        echo '<div style="color: #667eea; font-size: 13px; margin-bottom: 15px;">' . esc_html__('or 160€/year (4 months free)', 'comptaflow-by-meetempo') . '</div>';
        echo '<ul style="list-style: none; padding: 0; margin: 0; font-size: 14px; line-height: 1.8;">';
        echo '<li>✓ ' . esc_html__('Everything in PLUS', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('Tax Return 2031', 'comptaflow-by-meetempo') . '</li>';
        echo '<li>✓ ' . esc_html__('Priority Support', 'comptaflow-by-meetempo') . '</li>';
        echo '</ul>';
        echo '</div>';
        
        echo '</div>';
        echo '</div>';
    }
    
    /**
     * Show support section
     */
    private static function showSupport(): void
    {
        echo '<div style="background: #fff3cd; padding: 20px; border-left: 4px solid #ffc107; border-radius: 4px; margin-top: 30px;">';
        echo '<p style="margin: 0; color: #856404;">';
        echo '<strong>📧 ' . esc_html__('Need help? Our team responds within 24h.', 'comptaflow-by-meetempo') . '</strong> ';
        echo '<a href="mailto:support@meetempo.com" style="color: #667eea; font-weight: 600;">support@meetempo.com</a>';
        echo '</p>';
        echo '</div>';
    }
}
