<?php
$page_title = 'Innovation Marketplace';
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-lightbulb" style="color:#f59e0b; margin-right:10px;"></i>Innovation Marketplace</h2>
        <p style="color:#64748b; font-size:0.95rem; margin-top:5px;">Employee ideas, innovation challenges, prototype incubation, and patent filing.</p>
    </div>
    <button style="background:linear-gradient(135deg,#f59e0b,#d97706); color:#fff; border:none; padding:10px 20px; border-radius:8px; font-size:0.9rem; cursor:pointer; font-weight:600;"><i class="fas fa-plus"></i> Submit Idea</button>
</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 #f59e0b;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">IDEAS SUBMITTED</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">342</div>
        <div style="color:#f59e0b; font-size:0.8rem; margin-top:5px;"><i class="fas fa-lightbulb"></i> This Year</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;">IDEAS FUNDED</div>
        <div style="font-size:1.6rem; font-weight:700; color:#10b981;">28</div>
        <div style="color:#10b981; font-size:0.8rem; margin-top:5px;"><i class="fas fa-coins"></i> ₹1.2 Cr Allocated</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;">PROTOTYPES</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">12</div>
        <div style="color:#3b82f6; font-size:0.8rem; margin-top:5px;"><i class="fas fa-flask"></i> In Incubation</div>
    </div>
    <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0; border-top:4px solid #8b5cf6;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">PATENTS FILED</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">5</div>
        <div style="color:#8b5cf6; font-size:0.8rem; margin-top:5px;"><i class="fas fa-scroll"></i> 2 Granted</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-fire" style="color:#ef4444; margin-right:8px;"></i>Active Innovation Challenges</h3>
        <?php
        $challenges = [
            ['Reduce Water Usage by 20%', '₹5L Prize', '42 submissions', '#10b981', '12 days left'],
            ['Next-Gen Packaging Design', '₹3L Prize', '28 submissions', '#3b82f6', '8 days left'],
            ['AI Quality Inspection Enhancement', '₹8L Prize', '15 submissions', '#8b5cf6', '20 days left'],
        ];
        foreach ($challenges as $c): ?>
        <div style="border:1px solid #e2e8f0; border-radius:8px; padding:15px; margin-bottom:10px; border-left:4px solid <?= $c[3] ?>;">
            <div style="display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:8px;">
                <div>
                    <div style="font-weight:600; font-size:0.9rem; color:#0f172a;"><?= $c[0] ?></div>
                    <div style="font-size:0.75rem; color:#94a3b8;"><?= $c[1] ?> · <?= $c[2] ?></div>
                </div>
                <span style="background:#fef3c7; color:#b45309; padding:3px 10px; border-radius:10px; font-size:0.7rem; font-weight:bold;"><?= $c[4] ?></span>
            </div>
        </div>
        <?php endforeach; ?>

        <h3 style="margin:20px 0 15px; font-size:1.15rem; color:#0f172a;"><i class="fas fa-trophy" style="color:#f59e0b; margin-right:8px;"></i>Top Voted Ideas</h3>
        <?php
        $ideas = [
            ['Automated scrap sorting robot', 'Ramesh K. (Plant)', 128, '#10b981'],
            ['Solar-powered truck charging', 'Priya S. (Logistics)', 96, '#3b82f6'],
            ['AR-based quality training', 'Ankit M. (Quality)', 84, '#8b5cf6'],
        ];
        foreach ($ideas as $i): ?>
        <div style="display:flex; justify-content:space-between; align-items:center; padding:10px 0; border-bottom:1px solid #f1f5f9;">
            <div>
                <div style="font-weight:500; font-size:0.9rem; color:#0f172a;"><?= $i[0] ?></div>
                <div style="font-size:0.75rem; color:#94a3b8;"><?= $i[1] ?></div>
            </div>
            <span style="color:<?= $i[3] ?>; font-weight:bold;">👍 <?= $i[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-flask" style="color:#3b82f6; margin-right:8px;"></i>Prototype Incubation</h3>
            <?php
            $protos = [
                ['Smart Corrosion Sensor', 'Testing Phase', '#10b981'],
                ['AI Demand Predictor v2', 'Development', '#3b82f6'],
                ['Zero-Waste Packaging', 'Concept', '#f59e0b'],
            ];
            foreach ($protos as $p): ?>
            <div style="border-left:3px solid <?= $p[2] ?>; padding-left:12px; margin-bottom:15px;">
                <div style="font-weight:600; font-size:0.9rem;"><?= $p[0] ?></div>
                <div style="font-size:0.8rem; color:#64748b;">Stage: <?= $p[1] ?></div>
            </div>
            <?php endforeach; ?>
        </div>

        <div style="background:linear-gradient(135deg,#f59e0b,#d97706); color:#fff; padding:20px; border-radius:12px;">
            <h3 style="margin:0 0 8px; font-size:1.1rem;"><i class="fas fa-scroll"></i> Patent Filing Workflow</h3>
            <p style="margin:0 0 15px; font-size:0.85rem; opacity:0.85;">Track IP protection across innovations.</p>
            <div style="display:flex; justify-content:space-between; font-size:0.85rem; margin-bottom:8px;">
                <span>Filed</span><span style="font-weight:bold;">5</span>
            </div>
            <div style="display:flex; justify-content:space-between; font-size:0.85rem; margin-bottom:8px;">
                <span>Granted</span><span style="font-weight:bold;">2</span>
            </div>
            <div style="display:flex; justify-content:space-between; font-size:0.85rem;">
                <span>Under Review</span><span style="font-weight:bold;">3</span>
            </div>
        </div>
    </div>
</div>

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