<?php
$page_title = 'Enterprise Commerce API';
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-code" style="color:#06b6d4; margin-right:10px;"></i>Enterprise Commerce API</h2>
        <p style="color:#64748b; font-size:0.95rem; margin-top:5px;">Open APIs for catalog, orders, payments, inventory, quotes, and partners.</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 #06b6d4;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">API ENDPOINTS</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">86</div>
        <div style="color:#06b6d4; font-size:0.8rem; margin-top:5px;"><i class="fas fa-code"></i> RESTful + GraphQL</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;">UPTIME</div>
        <div style="font-size:1.6rem; font-weight:700; color:#10b981;">99.99%</div>
        <div style="color:#10b981; font-size:0.8rem; margin-top:5px;"><i class="fas fa-check-circle"></i> Last 90 Days</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;">API CONSUMERS</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">42</div>
        <div style="color:#3b82f6; font-size:0.8rem; margin-top:5px;"><i class="fas fa-users"></i> Registered Apps</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;">CALLS/DAY</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">248K</div>
        <div style="color:#f59e0b; font-size:0.8rem; margin-top:5px;"><i class="fas fa-bolt"></i> Avg 32ms Latency</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-cube" style="color:#06b6d4; margin-right:8px;"></i>API Catalog</h3>
        <?php
        $apis = [
            ['Catalog API', '/api/v2/catalog', 'Product search, filtering, pricing', '#06b6d4', 'v2.1'],
            ['Order API', '/api/v2/orders', 'Create, track, cancel orders', '#10b981', 'v2.0'],
            ['Payment API', '/api/v2/payments', 'Process, refund, reconcile', '#f59e0b', 'v2.0'],
            ['Inventory API', '/api/v2/inventory', 'Stock levels, reservations', '#3b82f6', 'v2.1'],
            ['Quote API', '/api/v2/quotes', 'RFQ, negotiation, approval', '#8b5cf6', 'v1.5'],
            ['Partner API', '/api/v2/partners', 'Dealer/vendor integration', '#ec4899', 'v1.8'],
        ];
        foreach ($apis as $a): ?>
        <div style="border:1px solid #e2e8f0; border-radius:8px; padding:12px 15px; margin-bottom:8px; display:flex; justify-content:space-between; align-items:center;">
            <div>
                <div style="font-weight:600; font-size:0.9rem; color:#0f172a;"><?= $a[0] ?></div>
                <div style="font-size:0.75rem; color:#94a3b8; font-family:monospace;"><?= $a[1] ?></div>
            </div>
            <span style="background:<?= $a[3] ?>15; color:<?= $a[3] ?>; padding:3px 8px; border-radius:6px; font-size:0.7rem; font-weight:bold;"><?= $a[4] ?></span>
        </div>
        <?php endforeach; ?>
    </div>
    <div style="background:linear-gradient(135deg,#0f172a,#1e293b); color:#fff; padding:25px; border-radius:12px;">
        <h3 style="margin:0 0 15px; font-size:1.1rem; color:#38bdf8;"><i class="fas fa-terminal"></i> API Console</h3>
        <div style="background:#0d1117; border:1px solid #30363d; border-radius:8px; padding:15px; font-family:monospace; font-size:0.8rem; margin-bottom:15px;">
            <div style="color:#8b949e;">// Sample API call</div>
            <div style="color:#c9d1d9;">GET /api/v2/catalog/products</div>
            <div style="color:#c9d1d9;">Authorization: Bearer &lt;token&gt;</div>
            <div style="color:#7ee787; margin-top:10px;">// 200 OK — 4,750 products</div>
        </div>
        <div style="display:flex; justify-content:space-between; font-size:0.85rem; margin-bottom:8px;">
            <span style="color:#94a3b8;">Rate Limit</span><span>10K req/min</span>
        </div>
        <div style="display:flex; justify-content:space-between; font-size:0.85rem; margin-bottom:8px;">
            <span style="color:#94a3b8;">Auth</span><span>OAuth 2.0 + API Key</span>
        </div>
        <div style="display:flex; justify-content:space-between; font-size:0.85rem;">
            <span style="color:#94a3b8;">Docs</span><span>Swagger + Postman</span>
        </div>
        <button style="background:#3b82f6; color:#fff; border:none; padding:10px 16px; border-radius:6px; font-size:0.85rem; cursor:pointer; width:100%; margin-top:15px; font-weight:600;">Open API Documentation</button>
    </div>
</div>
<?php require_once __DIR__ . '/footer.php'; ?>
