<?php
$page_title = 'AI Enterprise Brain';
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-brain" style="color:#8b5cf6; margin-right:10px;"></i>Balimeen AI Brain</h2>
        <p style="color:#64748b; font-size:0.95rem; margin-top:5px;">Predictive analytics and smart assistant across the enterprise.</p>
    </div>
</div>

<div class="grid-2">
    <!-- AI CEO Assistant Interface -->
    <div style="background:#fff; border-radius:12px; border:1px solid #e2e8f0; box-shadow:0 4px 6px -1px rgba(0,0,0,0.05); display:flex; flex-direction:column; height:500px;">
        <div style="padding:15px 20px; border-bottom:1px solid #e2e8f0; background:#f8fafc; border-radius:12px 12px 0 0;">
            <h3 style="margin:0; font-size:1.1rem; color:#0f172a;"><i class="fas fa-comment-dots" style="color:#8b5cf6; margin-right:8px;"></i> AI Assistant</h3>
        </div>
        
        <div style="flex:1; padding:20px; overflow-y:auto; background:#f1f5f9; display:flex; flex-direction:column; gap:15px;">
            <div style="align-self:flex-end; background:#2563eb; color:#fff; padding:10px 15px; border-radius:16px 16px 0 16px; font-size:0.9rem; max-width:80%;">
                Can you summarize the expected revenue for next quarter based on current raw material pricing trends?
            </div>
            
            <div style="align-self:flex-start; background:#fff; border:1px solid #e2e8f0; color:#0f172a; padding:15px; border-radius:16px 16px 16px 0; font-size:0.9rem; max-width:85%; box-shadow:0 2px 4px rgba(0,0,0,0.02);">
                <div style="display:flex; align-items:center; gap:8px; margin-bottom:10px; color:#8b5cf6; font-weight:bold; font-size:0.8rem;">
                    <i class="fas fa-robot"></i> AI BRAIN
                </div>
                Based on my analysis of the global steel indices and your current forward contracts:
                <ul style="margin:10px 0 0 20px; padding:0; color:#475569;">
                    <li style="margin-bottom:5px;">Expected Revenue: <strong>₹120.5 Cr</strong> (Up 8%)</li>
                    <li style="margin-bottom:5px;">SS 304 margins are expected to compress slightly due to a 4% spike in Nickel costs.</li>
                </ul>
                <div style="margin-top:10px; padding-top:10px; border-top:1px solid #e2e8f0;">
                    <button style="background:#f1f5f9; border:1px solid #cbd5e1; padding:4px 8px; border-radius:4px; font-size:0.75rem; cursor:pointer; margin-right:5px;">View detailed graph</button>
                    <button style="background:#f1f5f9; border:1px solid #cbd5e1; padding:4px 8px; border-radius:4px; font-size:0.75rem; cursor:pointer;">Optimize pricing</button>
                </div>
            </div>
        </div>
        
        <div style="padding:15px; border-top:1px solid #e2e8f0; background:#fff; border-radius:0 0 12px 12px;">
            <div style="display:flex; gap:10px;">
                <input type="text" placeholder="Ask AI Brain anything about sales, procurement, or HR..." style="flex:1; padding:12px 15px; border:1px solid #e2e8f0; border-radius:24px; font-size:0.9rem; outline:none; background:#f8fafc;">
                <button style="width:45px; height:45px; border-radius:50%; background:#8b5cf6; color:#fff; border:none; cursor:pointer; display:flex; align-items:center; justify-content:center;"><i class="fas fa-paper-plane"></i></button>
            </div>
        </div>
    </div>

    <div style="display:flex; flex-direction:column; gap:24px;">
        <!-- Predictive Models Status -->
        <div style="background:#fff; padding:20px; border-radius:12px; border:1px solid #e2e8f0; box-shadow:0 4px 6px -1px rgba(0,0,0,0.05);">
            <h3 style="margin:0 0 15px; font-size:1.1rem; color:#0f172a;"><i class="fas fa-chart-pie" style="color:#ec4899; margin-right:8px;"></i> Active Prediction Models</h3>
            
            <div style="display:flex; justify-content:space-between; align-items:center; padding-bottom:15px; border-bottom:1px solid #f1f5f9; margin-bottom:15px;">
                <div>
                    <h4 style="margin:0 0 3px; font-size:0.95rem;">Sales Demand Forecasting</h4>
                    <p style="margin:0; font-size:0.8rem; color:#64748b;">Accuracy: 92.4%</p>
                </div>
                <span style="background:#dcfce7; color:#166534; padding:3px 8px; border-radius:4px; font-size:0.7rem; font-weight:bold;">ACTIVE</span>
            </div>
            
            <div style="display:flex; justify-content:space-between; align-items:center; padding-bottom:15px; border-bottom:1px solid #f1f5f9; margin-bottom:15px;">
                <div>
                    <h4 style="margin:0 0 3px; font-size:0.95rem;">Fraud & Anomaly Detection</h4>
                    <p style="margin:0; font-size:0.8rem; color:#64748b;">Monitoring payments & vendor POs</p>
                </div>
                <span style="background:#dcfce7; color:#166534; padding:3px 8px; border-radius:4px; font-size:0.7rem; font-weight:bold;">ACTIVE</span>
            </div>
            
            <div style="display:flex; justify-content:space-between; align-items:center;">
                <div>
                    <h4 style="margin:0 0 3px; font-size:0.95rem;">HR Attrition Prediction</h4>
                    <p style="margin:0; font-size:0.8rem; color:#64748b;">Analyzes employee sentiment & leave patterns</p>
                </div>
                <span style="background:#dbeafe; color:#1d4ed8; padding:3px 8px; border-radius:4px; font-size:0.7rem; font-weight:bold;">TRAINING</span>
            </div>
        </div>
        
        <!-- Personalized Pricing AI -->
        <div style="background:linear-gradient(135deg, #0f172a, #1e293b); color:#fff; padding:20px; border-radius:12px; box-shadow:0 4px 6px -1px rgba(0,0,0,0.1);">
            <div style="display:flex; justify-content:space-between; align-items:flex-start;">
                <div>
                    <h3 style="margin:0 0 5px; font-size:1.1rem; color:#38bdf8;"><i class="fas fa-tags"></i> Personalized Pricing Engine</h3>
                    <p style="margin:0 0 15px; font-size:0.85rem; color:#94a3b8;">AI actively adjusting tier discounts to maximize margin.</p>
                </div>
                <div style="background:rgba(255,255,255,0.1); padding:5px 10px; border-radius:6px; font-size:0.8rem;">
                    Yield: <strong>+1.2%</strong>
                </div>
            </div>
            <button style="background:#3b82f6; color:#fff; border:none; padding:8px 16px; border-radius:6px; font-size:0.85rem; cursor:pointer; width:100%; font-weight:bold;">View Pricing Logic</button>
        </div>
    </div>
</div>

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