<div class="wrap chainpay-admin">
    <h1>Licenses</h1>
    
    <p><a href="<?php echo admin_url('admin.php?page=chainpay-licenses&action=create'); ?>" class="button button-primary">Create New License</a></p>
    
    <div class="chainpay-stats">
        <span>Total: <strong><?php echo esc_html($total); ?></strong></span>
        <span>Active: <strong><?php echo esc_html($active); ?></strong></span>
        <span>Inactive: <strong><?php echo esc_html($inactive); ?></strong></span>
    </div>
    
    <table class="wp-list-table widefat fixed striped">
        <thead>
            <tr>
                <th>License Key</th>
                <th>Email</th>
                <th>Domain</th>
                <th>Status</th>
                <th>Created</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            <?php if (empty($licenses)): ?>
                <tr><td colspan="6">No licenses found.</td></tr>
            <?php else: ?>
                <?php foreach ($licenses as $lic): ?>
                <tr>
                    <td><code><?php echo esc_html($lic->license_key); ?></code></td>
                    <td><?php echo esc_html($lic->user_email); ?></td>
                    <td><?php echo esc_html($lic->user_domain); ?></td>
                    <td><span class="status-<?php echo esc_attr($lic->status); ?>"><?php echo esc_html(ucfirst($lic->status)); ?></span></td>
                    <td><?php echo esc_html($lic->created_at); ?></td>
                    <td>
                        <a href="<?php echo admin_url('admin.php?page=chainpay-licenses&action=view&id=' . $lic->id); ?>">View</a> |
                        <a href="<?php echo admin_url('admin.php?page=chainpay-licenses&action=edit&id=' . $lic->id); ?>">Edit</a> |
                        <a href="#" class="delete-license" data-id="<?php echo esc_attr($lic->id); ?>">Delete</a>
                    </td>
                </tr>
                <?php endforeach; ?>
            <?php endif; ?>
        </tbody>
    </table>
</div>
