<?php
$page_title = 'Revenue Growth Engine';
require_once __DIR__ . '/../config.php';
if (session_status() === PHP_SESSION_NONE) { session_start(); }
if (!isset($_SESSION['admin_id'])) { redirect(SITE_URL . '/admin/login.php'); }
require_once __DIR__ . '/header.php';
?>

<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:24px;">
    <div>
        <h2 style="font-family:'Outfit', sans-serif; font-size:1.8rem; color:#0f172a; margin:0;"><i class="fas fa-rocket" style="color:#ec4899; margin-right:10px;"></i>Revenue Growth Engine</h2>
        <p style="color:#64748b; font-size:0.95rem; margin-top:5px;">Cross-sell, upsell, dynamic bundles, loyalty, and pricing elasticity.</p>
    </div>
</div>

<div class="grid-4" style="margin-bottom:24px;">
    <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0; border-top:4px solid #ec4899;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">CROSS-SELL REVENUE</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">₹4.8 Cr</div>
        <div style="color:#ec4899; font-size:0.8rem; margin-top:5px;"><i class="fas fa-arrow-up"></i> +24% Growth</div>
    </div>
    <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0; border-top:4px solid #f59e0b;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">UPSELL CONVERSION</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">18.4%</div>
        <div style="color:#f59e0b; font-size:0.8rem; margin-top:5px;"><i class="fas fa-chart-line"></i> Premium Tier</div>
    </div>
    <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0; border-top:4px solid #10b981;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">LOYALTY MEMBERS</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">2,840</div>
        <div style="color:#10b981; font-size:0.8rem; margin-top:5px;"><i class="fas fa-heart"></i> Active Dealers</div>
    </div>
    <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0; border-top:4px solid #3b82f6;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">REFERRAL REVENUE</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">₹1.2 Cr</div>
        <div style="color:#3b82f6; font-size:0.8rem; margin-top:5px;"><i class="fas fa-share-alt"></i> 340 Referrals</div>
    </div>
</div>

<div class="grid-2" style="margin-bottom:24px;">
    <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0;">
        <h3 style="margin:0 0 15px; font-size:1.15rem; color:#0f172a;"><i class="fas fa-magic" style="color:#ec4899; margin-right:8px;"></i>AI Revenue Engines</h3>
        <?php
        $engines = [
            ['Cross-Sell Engine', 'Recommending SS accessories to coil buyers', '₹4.8 Cr impact', '#ec4899', 'fas fa-random'],
            ['Upsell Engine', 'Premium grade migration campaigns active', '18.4% conversion', '#f59e0b', 'fas fa-level-up-alt'],
            ['Dynamic Bundles', 'Seasonal bundle: Sheets + Pipes + Fittings', '₹2.1 Cr revenue', '#3b82f6', 'fas fa-boxes'],
            ['Seasonal Campaign AI', 'Pre-monsoon construction demand surge', '12 campaigns live', '#10b981', 'fas fa-calendar-alt'],
            ['Referral Flywheel', 'Dealer-to-dealer referral program active', '340 new referrals', '#8b5cf6', 'fas fa-share-alt'],
        ];
        foreach ($engines as $e): ?>
        <div style="border:1px solid #e2e8f0; border-radius:8px; padding:15px; margin-bottom:10px; display:flex; align-items:center; gap:15px;">
            <div style="width:45px; height:45px; border-radius:10px; background:<?= $e[3] ?>15; display:flex; align-items:center; justify-content:center; flex-shrink:0;">
                <i class="<?= $e[4] ?>" style="color:<?= $e[3] ?>; font-size:1.1rem;"></i>
            </div>
            <div style="flex:1;">
                <div style="font-weight:600; font-size:0.9rem; color:#0f172a;"><?= $e[0] ?></div>
                <div style="font-size:0.75rem; color:#94a3b8;"><?= $e[1] ?></div>
            </div>
            <span style="background:<?= $e[3] ?>15; color:<?= $e[3] ?>; padding:3px 10px; border-radius:10px; font-size:0.7rem; font-weight:bold; white-space:nowrap;"><?= $e[2] ?></span>
        </div>
        <?php endforeach; ?>
    </div>

    <div style="display:flex; flex-direction:column; gap:24px;">
        <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0;">
            <h3 style="margin:0 0 15px; font-size:1.15rem; color:#0f172a;"><i class="fas fa-chart-area" style="color:#6366f1; margin-right:8px;"></i>Pricing Elasticity</h3>
            <div style="background:#f8fafc; padding:15px; border-radius:8px; margin-bottom:15px;">
                <div style="font-size:0.85rem; font-weight:600; margin-bottom:10px;">Price Sensitivity Index</div>
                <div style="display:flex; justify-content:space-between; font-size:0.8rem; margin-bottom:8px;">
                    <span>SS 304 Sheets</span><span style="color:#10b981;">Low Sensitivity</span>
                </div>
                <div style="display:flex; justify-content:space-between; font-size:0.8rem; margin-bottom:8px;">
                    <span>SS 316 Coils</span><span style="color:#f59e0b;">Medium</span>
                </div>
                <div style="display:flex; justify-content:space-between; font-size:0.8rem;">
                    <span>MS Pipes</span><span style="color:#ef4444;">High Sensitivity</span>
                </div>
            </div>
        </div>

        <div style="background:linear-gradient(135deg,#ec4899,#be185d); color:#fff; padding:20px; border-radius:12px;">
            <h3 style="margin:0 0 8px; font-size:1.1rem;"><i class="fas fa-heart"></i> Loyalty Economics</h3>
            <p style="margin:0 0 15px; font-size:0.85rem; opacity:0.85;">Dealer loyalty program ROI analysis.</p>
            <div style="display:flex; justify-content:space-between; font-size:0.85rem; margin-bottom:8px;">
                <span>Points Distributed</span><span style="font-weight:bold;">4.2M pts</span>
            </div>
            <div style="display:flex; justify-content:space-between; font-size:0.85rem; margin-bottom:8px;">
                <span>Redemption Rate</span><span style="font-weight:bold;">68%</span>
            </div>
            <div style="display:flex; justify-content:space-between; font-size:0.85rem;">
                <span>Loyalty ROI</span><span style="font-weight:bold;">3.4x</span>
            </div>
        </div>
    </div>
</div>

<?php require_once __DIR__ . '/footer.php'; ?>
