<?php
/**
 * GT BOGO Engine — Welcome Page
 *
 * @package GT_BOGO_Engine
 * @since   3.10.1
 */
if (!defined('ABSPATH')) exit;

$is_pro = function_exists('gt_bogo_has_pro') ? gt_bogo_has_pro() : false;
$license_expires = get_option('gt_bogo_license_expires', '');

require_once __DIR__ . '/../ui-system/wrapper-start.php';
?>

<div class="gt-page-header gt-animate-in">
    <div>
        <h1 class="gt-page-title">👋 Welcome to GT BOGO Engine</h1>
        <p class="gt-page-subtitle">Enterprise BOGO automation for WooCommerce — you are set up and ready to go</p>
    </div>
    <div style="display:flex;gap:10px;align-items:center">
        <?php if ($is_pro): ?>
            <span style="background:rgba(34,197,94,0.12);border:1px solid rgba(34,197,94,0.3);color:#86efac;font-size:13px;font-weight:700;padding:6px 16px;border-radius:50px">⚡ PRO Active</span>
        <?php else: ?>
            <a href="<?php echo esc_url(admin_url('admin.php?page=gt-bogo-engine&tab=license')); ?>" class="gt-btn gt-btn-primary">🔑 Activate PRO — $19.99/yr</a>
        <?php endif; ?>
    </div>
</div>

<!-- Hero Banner -->
<div class="gt-card gt-animate-in" style="margin-bottom:24px;background:linear-gradient(135deg,rgba(225,0,0,0.08) 0%,var(--gt-navy-mid) 60%,rgba(59,130,246,0.05) 100%);border:1px solid rgba(225,0,0,0.2);overflow:hidden;position:relative">
    <div style="padding:36px 40px;position:relative;z-index:1">
        <div style="max-width:620px">
            <div style="display:inline-flex;align-items:center;gap:8px;background:rgba(34,197,94,0.1);border:1px solid rgba(34,197,94,0.25);border-radius:50px;padding:5px 14px;margin-bottom:20px">
                <span style="width:7px;height:7px;background:#22c55e;border-radius:50%;display:inline-block;animation:gtlive-dot 2s ease infinite"></span>
                <span style="font-size:12px;font-weight:700;color:#86efac;letter-spacing:0.5px">ENGINE INSTALLED &amp; RUNNING</span>
            </div>
            <h2 style="font-size:28px;font-weight:900;color:#ffffff;margin:0 0 14px;line-height:1.2">The Most Powerful BOGO Plugin<br>for WooCommerce</h2>
            <p style="font-size:15px;color:#94a3b8;line-height:1.7;margin:0 0 28px">GT BOGO Engine gives you complete control over Buy X Get Y promotions. From simple sitewide deals to complex multi-tier rule stacks — every strategy, every deal type, all in one plugin.</p>
            <div style="display:flex;gap:12px;flex-wrap:wrap">
                <a href="<?php echo esc_url(admin_url('admin.php?page=gt-bogo-engine&tab=free-rule')); ?>" class="gt-btn gt-btn-primary">⚙️ Configure Free Rule →</a>
                <a href="<?php echo esc_url(admin_url('admin.php?page=gt-bogo-engine&tab=pro-rules')); ?>" class="gt-btn gt-btn-secondary">💎 Browse PRO Packs →</a>
            </div>
        </div>
    </div>
    <div style="position:absolute;right:-40px;top:-40px;width:300px;height:300px;background:radial-gradient(circle,rgba(225,0,0,0.08) 0%,transparent 70%);pointer-events:none"></div>
</div>

<!-- Get Started in 3 Steps -->
<div class="gt-card gt-animate-in" style="margin-bottom:24px">
    <div class="gt-card-header" style="padding:24px 28px 20px;border-bottom:1px solid var(--gt-border)">
        <h2 class="gt-card-title" style="font-size:20px">🚀 Get Started in 3 Steps</h2>
        <span style="font-size:13px;color:var(--gt-slate)">You can be live in under 5 minutes</span>
    </div>
    <div style="display:grid;grid-template-columns:repeat(3,1fr);gap:24px;padding:24px 28px 28px">
        <?php
        $steps = [
            ['num'=>'1','icon'=>'⚙️','title'=>'Configure Your Free Rule','desc'=>'Your plugin ships with a ready-to-use Buy X Get Y rule. Customise it — set the buy quantity, get quantity, discount amount, and which products qualify. No coding required.','btn'=>'Configure Free Rule →','url'=>admin_url('admin.php?page=gt-bogo-engine&tab=free-rule'),'color'=>'#22c55e'],
            ['num'=>'2','icon'=>'🛒','title'=>'Test in Your Cart','desc'=>'Add qualifying products to your cart and confirm the discount applies automatically. No coupon codes, no friction — just seamless automatic discounting at cart time.','btn'=>'Visit Your Shop →','url'=>function_exists('wc_get_page_id') ? get_permalink(wc_get_page_id('shop')) : home_url('/shop/'),'color'=>'#3b82f6','external'=>true],
            ['num'=>'3','icon'=>'💎','title'=>$is_pro ? 'Purchase PRO Packs' : 'Upgrade to PRO','desc'=>$is_pro ? 'You have PRO active. Browse 15 expert-built rule pack templates — each one is a complete campaign strategy ready to import with one click.' : 'Unlock unlimited rules, all 15 PRO packs, and every enterprise feature. Just $19.99/year — less than $2/month.','btn'=>$is_pro ? 'Browse PRO Packs →' : 'Activate PRO — $19.99/yr →','url'=>admin_url('admin.php?page=gt-bogo-engine&tab='.($is_pro ? 'pro-rules' : 'license')),'color'=>'#E10000'],
        ];
        foreach ($steps as $step): ?>
        <div style="background:var(--gt-glass);border:1px solid var(--gt-border);border-radius:14px;padding:24px;display:flex;flex-direction:column;transition:all 0.2s">
            <div style="display:flex;align-items:center;gap:12px;margin-bottom:16px">
                <div style="width:40px;height:40px;background:<?php echo $step['color']; ?>;border-radius:50%;display:flex;align-items:center;justify-content:center;color:#fff;font-size:18px;font-weight:900;flex-shrink:0"><?php echo $step['num']; ?></div>
                <span style="font-size:24px"><?php echo $step['icon']; ?></span>
            </div>
            <h3 style="font-size:17px;font-weight:800;color:#ffffff;margin:0 0 10px;line-height:1.3"><?php echo esc_html($step['title']); ?></h3>
            <p style="font-size:13.5px;color:#94a3b8;line-height:1.65;margin:0 0 20px;flex:1"><?php echo esc_html($step['desc']); ?></p>
            <a href="<?php echo esc_url($step['url']); ?>"
               <?php echo !empty($step['external']) ? 'target="_blank" rel="noopener"' : ''; ?>
               style="display:inline-flex;align-items:center;padding:10px 20px;background:<?php echo $step['color']; ?>;color:#fff;font-size:14px;font-weight:700;border-radius:50px;text-decoration:none;box-shadow:0 4px 14px rgba(0,0,0,0.25);transition:all 0.2s;align-self:flex-start">
                <?php echo esc_html($step['btn']); ?>
            </a>
        </div>
        <?php endforeach; ?>
    </div>
</div>

<!-- What You Can Do -->
<div class="gt-card gt-animate-in" style="margin-bottom:24px">
    <div class="gt-card-header" style="padding:24px 28px 20px;border-bottom:1px solid var(--gt-border)">
        <h2 class="gt-card-title" style="font-size:20px">💡 What You Can Do With GT BOGO Engine</h2>
    </div>
    <div style="display:grid;grid-template-columns:repeat(3,1fr);gap:16px;padding:24px 28px 28px">
        <?php
        $capabilities = [
            ['🎯','Category Targeting','Apply BOGO deals to specific product categories only — not sitewide.'],
            ['📅','Date Scheduling','Set promotions to run on specific dates or recurring weekly schedules.'],
            ['📊','Analytics','Track revenue influenced, orders, and discounts granted in real time.'],
            ['🏷️','Product Badges','Display "BOGO Deal" badges on eligible products across your shop.'],
            ['📈','Cart Progress Bar','Show customers a progress bar — how close they are to unlocking a deal.'],
            ['⚡','Multiple Rules','Stack up to 15 simultaneous rules with priority-based execution order.'],
            ['👑','VIP Tiers','Give your best customers exclusive deals based on lifetime spend.'],
            ['🎁','Free Gifts','Auto-add a free gift product to qualifying carts — no coupon needed.'],
            ['🔄','Import / Export','Back up your entire rule configuration and restore it anywhere.'],
        ];
        foreach ($capabilities as $cap): ?>
        <div style="display:flex;align-items:flex-start;gap:12px;background:rgba(255,255,255,0.02);border:1px solid rgba(255,255,255,0.05);border-radius:10px;padding:14px 16px">
            <span style="font-size:22px;flex-shrink:0;margin-top:1px"><?php echo $cap[0]; ?></span>
            <div>
                <div style="font-size:14px;font-weight:700;color:#ffffff;margin-bottom:4px"><?php echo esc_html($cap[1]); ?></div>
                <div style="font-size:12.5px;color:#64748b;line-height:1.5"><?php echo esc_html($cap[2]); ?></div>
            </div>
        </div>
        <?php endforeach; ?>
    </div>
</div>

<!-- Quick Navigation -->
<div class="gt-card gt-animate-in" style="margin-bottom:24px">
    <div class="gt-card-header" style="padding:24px 28px 20px;border-bottom:1px solid var(--gt-border)">
        <h2 class="gt-card-title" style="font-size:20px">⚡ Jump To</h2>
    </div>
    <div style="display:grid;grid-template-columns:repeat(4,1fr);gap:12px;padding:20px 28px 24px">
        <?php
        $jumps = [
            ['🎁','Free Core Rule','free-rule'],
            ['💎','PRO Rules / Packs','pro-rules'],
            ['📈','Analytics','analytics'],
            ['⚙️','Settings','settings'],
            ['🔑','License','license'],
            ['📅','Campaign Scheduler','scheduler'],
            ['🎯','Segments','segments'],
            ['📚','Documentation','documentation'],
        ];
        foreach ($jumps as $j): ?>
        <a href="<?php echo esc_url(admin_url('admin.php?page=gt-bogo-engine&tab='.$j[2])); ?>"
           style="display:flex;align-items:center;gap:10px;background:var(--gt-glass);border:1px solid var(--gt-border);border-radius:10px;padding:12px 16px;text-decoration:none;color:var(--gt-white);font-size:14px;font-weight:600;transition:all 0.2s">
            <span style="font-size:20px"><?php echo $j[0]; ?></span>
            <?php echo esc_html($j[1]); ?>
        </a>
        <?php endforeach; ?>
    </div>
</div>

<?php require_once __DIR__ . '/../ui-system/wrapper-end.php'; ?>
