<?php
$page_title = 'Market Intelligence';
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-binoculars" style="color:#6366f1; margin-right:10px;"></i>Market Intelligence</h2>
        <p style="color:#64748b; font-size:0.95rem; margin-top:5px;">Competitor monitoring, pricing watch, demand sensing, and sentiment AI.</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 #6366f1;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">COMPETITORS TRACKED</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">24</div>
        <div style="color:#6366f1; font-size:0.8rem; margin-top:5px;"><i class="fas fa-eye"></i> Real-time Monitoring</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;">MARKET SHARE</div>
        <div style="font-size:1.6rem; font-weight:700; color:#10b981;">14.2%</div>
        <div style="color:#10b981; font-size:0.8rem; margin-top:5px;"><i class="fas fa-arrow-up"></i> +0.8% YoY</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;">DEMAND INDEX</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">78.4</div>
        <div style="color:#f59e0b; font-size:0.8rem; margin-top:5px;"><i class="fas fa-chart-line"></i> Rising Trend</div>
    </div>
    <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;">SENTIMENT SCORE</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">4.2/5</div>
        <div style="color:#ec4899; font-size:0.8rem; margin-top:5px;"><i class="fas fa-smile"></i> Customer + Dealer</div>
    </div>
</div>
<div class="grid-2">
    <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-eye" style="color:#6366f1; margin-right:8px;"></i>Competitor Pricing Watch</h3>
        <?php
        $competitors = [
            ['Jindal Stainless', '₹248/kg', '+2%', '#ef4444'],
            ['SAIL', '₹232/kg', '-1%', '#10b981'],
            ['Tata Steel', '₹245/kg', '+1.5%', '#ef4444'],
            ['JSW Steel', '₹238/kg', '0%', '#64748b'],
            ['Balimeen (You)', '₹240/kg', '+0.5%', '#3b82f6'],
        ];
        foreach ($competitors as $c): ?>
        <div style="display:flex; justify-content:space-between; align-items:center; padding:10px 0; border-bottom:1px solid #f1f5f9;<?= $c[0]==='Balimeen (You)' ? ' background:#eff6ff; margin:0 -20px; padding:10px 20px; border-radius:6px;' : '' ?>">
            <div style="font-weight:<?= $c[0]==='Balimeen (You)' ? '700' : '500' ?>; font-size:0.9rem;"><?= $c[0] ?></div>
            <div style="display:flex; gap:15px; align-items:center;">
                <span style="font-size:0.85rem;"><?= $c[1] ?></span>
                <span style="color:<?= $c[3] ?>; font-weight:bold; font-size:0.8rem;"><?= $c[2] ?></span>
            </div>
        </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-hashtag" style="color:#ec4899; margin-right:8px;"></i>Social Listening</h3>
            <div style="display:grid; grid-template-columns:1fr 1fr; gap:12px;">
                <div style="background:#f8fafc; padding:12px; border-radius:8px; text-align:center;">
                    <div style="font-size:1.3rem; font-weight:700; color:#10b981;">82%</div>
                    <div style="font-size:0.7rem; color:#94a3b8;">Positive Mentions</div>
                </div>
                <div style="background:#f8fafc; padding:12px; border-radius:8px; text-align:center;">
                    <div style="font-size:1.3rem; font-weight:700; color:#3b82f6;">1.2K</div>
                    <div style="font-size:0.7rem; color:#94a3b8;">Brand Mentions/Mo</div>
                </div>
            </div>
        </div>
        <div style="background:linear-gradient(135deg,#6366f1,#4f46e5); color:#fff; padding:20px; border-radius:12px;">
            <h3 style="margin:0 0 8px; font-size:1.1rem;"><i class="fas fa-chart-area"></i> Demand Sensing AI</h3>
            <p style="margin:0 0 10px; font-size:0.85rem; opacity:0.85;">AI-predicted demand signals for next quarter.</p>
            <div style="display:flex; justify-content:space-between; font-size:0.85rem; margin-bottom:8px;">
                <span>SS 304 Demand</span><span style="font-weight:bold;">↗ +12%</span>
            </div>
            <div style="display:flex; justify-content:space-between; font-size:0.85rem; margin-bottom:8px;">
                <span>MS Pipes</span><span style="font-weight:bold;">→ Stable</span>
            </div>
            <div style="display:flex; justify-content:space-between; font-size:0.85rem;">
                <span>HR Coils</span><span style="font-weight:bold;">↘ -5%</span>
            </div>
        </div>
    </div>
</div>
<?php require_once __DIR__ . '/footer.php'; ?>
