<?php
$page_title = 'Unified Search';
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-search" style="color:#3b82f6; margin-right:10px;"></i>Unified Search</h2>
        <p style="color:#64748b; font-size:0.95rem; margin-top:5px;">Search everything: documents, orders, people, products & more with AI.</p>
    </div>
</div>

<div style="background:linear-gradient(135deg,#0f172a,#1e293b); border-radius:16px; padding:40px; margin-bottom:24px; position:relative; overflow:hidden;">
    <div style="position:relative; z-index:2; max-width:700px; margin:0 auto; text-align:center;">
        <h3 style="color:#fff; font-size:1.5rem; margin:0 0 20px; font-family:'Outfit', sans-serif;">Ask anything about your enterprise</h3>
        <div style="display:flex; gap:10px;">
            <input type="text" placeholder="Search orders, invoices, customers, documents, products..." style="flex:1; padding:15px 20px; border:1px solid rgba(255,255,255,0.15); border-radius:12px; font-size:1rem; outline:none; background:rgba(255,255,255,0.08); color:#fff;">
            <button style="width:55px; height:55px; border-radius:12px; background:#3b82f6; color:#fff; border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:1.2rem;"><i class="fas fa-search"></i></button>
            <button style="width:55px; height:55px; border-radius:12px; background:rgba(255,255,255,0.1); color:#fff; border:1px solid rgba(255,255,255,0.15); cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:1.2rem;" title="Voice Search"><i class="fas fa-microphone"></i></button>
        </div>
        <div style="display:flex; gap:8px; margin-top:15px; justify-content:center; flex-wrap:wrap;">
            <span style="background:rgba(255,255,255,0.1); padding:4px 12px; border-radius:20px; font-size:0.75rem; color:#94a3b8; cursor:pointer;">📄 OCR Search</span>
            <span style="background:rgba(255,255,255,0.1); padding:4px 12px; border-radius:20px; font-size:0.75rem; color:#94a3b8; cursor:pointer;">🤖 AI Answer</span>
            <span style="background:rgba(255,255,255,0.1); padding:4px 12px; border-radius:20px; font-size:0.75rem; color:#94a3b8; cursor:pointer;">🗣️ Natural Language</span>
            <span style="background:rgba(255,255,255,0.1); padding:4px 12px; border-radius:20px; font-size:0.75rem; color:#94a3b8; cursor:pointer;">🔗 Semantic</span>
        </div>
    </div>
    <div style="position:absolute; top:-30px; right:-30px; opacity:0.05;"><i class="fas fa-search" style="font-size:20rem;"></i></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 #3b82f6;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">INDEXED DOCUMENTS</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">48,250</div>
        <div style="color:#3b82f6; font-size:0.8rem; margin-top:5px;"><i class="fas fa-file"></i> Fully OCR'd</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;">SEARCHES TODAY</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">342</div>
        <div style="color:#10b981; font-size:0.8rem; margin-top:5px;"><i class="fas fa-bolt"></i> Avg 0.3s</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;">AI ANSWERS</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">89</div>
        <div style="color:#8b5cf6; font-size:0.8rem; margin-top:5px;"><i class="fas fa-robot"></i> 94% Accurate</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;">KNOWLEDGE GRAPH</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">12.4K</div>
        <div style="color:#ec4899; font-size:0.8rem; margin-top:5px;"><i class="fas fa-project-diagram"></i> Entities</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-history" style="color:#6366f1; margin-right:8px;"></i>Recent Searches</h3>
        <?php
        $searches = [
            ['Invoice #INV-2024-4521', 'Document', '2 min ago'],
            ['Dealer Rajesh Kumar credit limit', 'Natural Language', '5 min ago'],
            ['SS 304 coil price history', 'Product', '12 min ago'],
            ['Pending purchase orders above 10L', 'AI Answer', '18 min ago'],
            ['ISO certification renewal date', 'OCR Search', '25 min ago'],
        ];
        foreach ($searches as $s): ?>
        <div style="display:flex; justify-content:space-between; align-items:center; padding:10px 0; border-bottom:1px solid #f1f5f9;">
            <div>
                <div style="font-size:0.9rem; font-weight:500; color:#0f172a;"><?= $s[0] ?></div>
                <div style="font-size:0.75rem; color:#94a3b8;"><?= $s[2] ?></div>
            </div>
            <span style="background:#f1f5f9; padding:3px 8px; border-radius:4px; font-size:0.7rem; color:#475569;"><?= $s[1] ?></span>
        </div>
        <?php endforeach; ?>
    </div>

    <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-project-diagram" style="color:#ec4899; margin-right:8px;"></i>Knowledge Graph Explorer</h3>
        <div style="background:#f8fafc; border:1px solid #e2e8f0; border-radius:8px; padding:40px; text-align:center; min-height:200px; display:flex; flex-direction:column; align-items:center; justify-content:center;">
            <i class="fas fa-project-diagram" style="font-size:4rem; color:#e2e8f0; margin-bottom:15px;"></i>
            <p style="color:#94a3b8; font-size:0.9rem; margin:0;">Interactive knowledge graph with 12,400 entities and 48,000 relationships.</p>
            <button style="background:#ec4899; color:#fff; border:none; padding:8px 16px; border-radius:6px; font-size:0.85rem; cursor:pointer; margin-top:15px;">Launch Explorer</button>
        </div>
    </div>
</div>

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