<?php
$page_title = 'Franchise Operating System';
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-store" style="color:#ef4444; margin-right:10px;"></i>Franchise Operating System</h2>
        <p style="color:#64748b; font-size:0.95rem; margin-top:5px;">Franchise onboarding, compliance, royalties, and performance tracking.</p>
    </div>
    <button style="background:linear-gradient(135deg,#ef4444,#dc2626); 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> Onboard Franchise</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 #ef4444;">
        <div style="color:#64748b; font-size:0.8rem; font-weight:600; margin-bottom:8px;">TOTAL FRANCHISES</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">48</div>
        <div style="color:#ef4444; font-size:0.8rem; margin-top:5px;"><i class="fas fa-map-marker-alt"></i> Across 12 States</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;">FRANCHISE REVENUE</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">₹18.4 Cr</div>
        <div style="color:#10b981; font-size:0.8rem; margin-top:5px;"><i class="fas fa-arrow-up"></i> +15% 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;">ROYALTIES COLLECTED</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">₹1.84 Cr</div>
        <div style="color:#f59e0b; font-size:0.8rem; margin-top:5px;"><i class="fas fa-coins"></i> 10% Royalty Rate</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;">COMPLIANCE SCORE</div>
        <div style="font-size:1.6rem; font-weight:700; color:#0f172a;">92%</div>
        <div style="color:#3b82f6; font-size:0.8rem; margin-top:5px;"><i class="fas fa-check-double"></i> Brand Audit</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-chart-line" style="color:#ef4444; margin-right:8px;"></i>Franchise Performance</h3>
        <?php
        $franchises = [
            ['Balimeen Delhi NCR', '₹3.2 Cr', '96%', '#10b981', 'A+'],
            ['Balimeen Mumbai', '₹2.8 Cr', '94%', '#10b981', 'A+'],
            ['Balimeen Bengaluru', '₹2.1 Cr', '91%', '#3b82f6', 'A'],
            ['Balimeen Chennai', '₹1.9 Cr', '88%', '#3b82f6', 'A'],
            ['Balimeen Hyderabad', '₹1.5 Cr', '82%', '#f59e0b', 'B+'],
        ];
        foreach ($franchises as $f): ?>
        <div style="border:1px solid #e2e8f0; border-radius:8px; padding:12px 15px; margin-bottom:10px; display:flex; justify-content:space-between; align-items:center;">
            <div>
                <div style="font-weight:600; font-size:0.9rem; color:#0f172a;"><?= $f[0] ?></div>
                <div style="font-size:0.75rem; color:#94a3b8;">Revenue: <?= $f[1] ?> · Compliance: <?= $f[2] ?></div>
            </div>
            <span style="background:<?= $f[3] ?>15; color:<?= $f[3] ?>; padding:4px 12px; border-radius:8px; font-size:0.8rem; font-weight:bold;"><?= $f[4] ?></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-tasks" style="color:#f59e0b; margin-right:8px;"></i>Franchise Operations</h3>
            <div style="border-left:3px solid #10b981; padding-left:12px; margin-bottom:15px;">
                <div style="font-weight:600; font-size:0.9rem;">Onboarding Pipeline</div>
                <div style="font-size:0.8rem; color:#64748b;">5 new franchises in progress</div>
            </div>
            <div style="border-left:3px solid #3b82f6; padding-left:12px; margin-bottom:15px;">
                <div style="font-weight:600; font-size:0.9rem;">Contract Renewals</div>
                <div style="font-size:0.8rem; color:#64748b;">8 contracts due next quarter</div>
            </div>
            <div style="border-left:3px solid #f59e0b; padding-left:12px; margin-bottom:15px;">
                <div style="font-weight:600; font-size:0.9rem;">Brand Compliance Audit</div>
                <div style="font-size:0.8rem; color:#64748b;">Q2 audit scheduled for 12 outlets</div>
            </div>
            <div style="border-left:3px solid #ec4899; padding-left:12px;">
                <div style="font-weight:600; font-size:0.9rem;">Local Marketing Kit</div>
                <div style="font-size:0.8rem; color:#64748b;">New Q2 creative assets deployed</div>
            </div>
        </div>

        <div style="background:linear-gradient(135deg,#ef4444,#dc2626); color:#fff; padding:20px; border-radius:12px;">
            <h3 style="margin:0 0 8px; font-size:1.1rem;"><i class="fas fa-graduation-cap"></i> Franchise Learning Portal</h3>
            <p style="margin:0 0 10px; font-size:0.85rem; opacity:0.85;">82% franchise staff certified this quarter.</p>
            <div style="background:rgba(255,255,255,0.2); height:8px; border-radius:4px; overflow:hidden;">
                <div style="width:82%; height:100%; background:#fff; border-radius:4px;"></div>
            </div>
        </div>
    </div>
</div>

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