<?php 
$this->load->view('layouts/header');
$this->load->helper('layout');
$is_edit = !empty($wallet);
?>

    <!-- App Header -->
    <div class="appHeader bg-primary text-light">
        <div class="left">
            <a href="<?php echo base_url('admin/crypto-wallets'); ?>" class="headerButton">
                <ion-icon name="chevron-back-outline"></ion-icon>
            </a>
        </div>
        <div class="pageTitle"><?php echo $is_edit ? 'Edit Wallet' : 'Add Wallet'; ?></div>
        <div class="right"></div>
    </div>

    <!-- App Capsule -->
    <div id="appCapsule">
        <div class="section mt-2">
            <form method="post" action="">
                <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
                <div class="card">
                    <div class="card-body">
                        <div class="form-group basic">
                            <label class="label">Name</label>
                            <input type="text" class="form-control" name="name" required
                                value="<?php echo $is_edit ? htmlspecialchars($wallet->name) : ''; ?>"
                                placeholder="e.g. Bitcoin">
                        </div>
                        <div class="form-group basic">
                            <label class="label">Symbol</label>
                            <input type="text" class="form-control" name="symbol" required
                                value="<?php echo $is_edit ? htmlspecialchars($wallet->symbol) : ''; ?>"
                                placeholder="e.g. BTC">
                        </div>
                        <div class="form-group basic">
                            <label class="label">Network (optional)</label>
                            <input type="text" class="form-control" name="network"
                                value="<?php echo $is_edit ? htmlspecialchars($wallet->network ?? '') : ''; ?>"
                                placeholder="e.g. ERC-20, Mainnet">
                        </div>
                        <div class="form-group basic">
                            <label class="label">Deposit instructions (optional)</label>
                            <textarea class="form-control" name="instructions" rows="4" placeholder="Instructions shown to users when depositing..."><?php echo $is_edit ? htmlspecialchars($wallet->instructions ?? '') : ''; ?></textarea>
                        </div>
                        <div class="form-group basic">
                            <label class="label">Display order</label>
                            <input type="number" class="form-control" name="display_order" value="<?php echo $is_edit ? (int)$wallet->display_order : '0'; ?>">
                        </div>
                        <div class="form-group basic">
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" name="is_active" value="1" id="isActive" <?php echo ($is_edit && $wallet->is_active) || !$is_edit ? 'checked' : ''; ?>>
                                <label class="form-check-label" for="isActive">Active</label>
                            </div>
                        </div>
                        <label class="form-check-label mb-2" for="isActive">Active (show on deposit page)</label>

                        <button type="submit" class="btn btn-primary btn-block btn-lg"><?php echo $is_edit ? 'Update' : 'Add'; ?> Wallet</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <?php $this->load->view('admin/partials/sidebar'); ?>

<?php $this->load->view('layouts/footer'); ?>
