<?php
$stores = isset($stores) ? $stores : array();
?>

<div class="container-fluid py-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h4 class="fw-bold mb-1"><i class="fa-solid fa-graduation-cap text-primary me-2"></i>Training Store Assignment</h4>
            <p class="text-muted mb-0">Enroll branch teams and supervisors in mandatory training programs.</p>
        </div>
    </div>

    <div class="card border-0 shadow-sm rounded-4">
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0">
                    <thead class="table-light">
                        <tr>
                            <th class="ps-4">Store Branch</th>
                            <th>Mandatory Modules Assigned</th>
                            <th>Staff Completion Rate</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($stores as $sId => $s): ?>
                            <tr>
                                <td class="ps-4">
                                    <div class="fw-bold text-dark"><?php echo htmlspecialchars(isset($s['name']) ? $s['name'] : $sId); ?></div>
                                    <div class="small text-muted"><?php echo htmlspecialchars(isset($s['city']) ? $s['city'] : 'Islamabad'); ?></div>
                                </td>
                                <td>
                                    <span class="badge bg-primary bg-opacity-10 text-primary me-1">Kitchen Walkthrough SOP</span>
                                    <span class="badge bg-warning bg-opacity-10 text-warning">Toppings Prep Protocol</span>
                                </td>
                                <td>
                                    <div class="d-flex align-items-center gap-2" style="max-width: 160px;">
                                        <div class="progress flex-grow-1" style="height: 6px;">
                                            <div class="progress-bar bg-success" style="width: 100%"></div>
                                        </div>
                                        <span class="small fw-bold text-success">100%</span>
                                    </div>
                                </td>
                                <td>
                                    <button class="btn btn-sm btn-outline-primary" onclick="alert('Store training modules updated!');">Assign Modules</button>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
