<?php 
$this->load->view('layouts/header');
$this->load->helper('layout');
?>

    <!-- App Header -->
    <div class="appHeader">
        <div class="left">
            <a href="<?php echo base_url('cards'); ?>" class="headerButton">
                <ion-icon name="chevron-back-outline"></ion-icon>
            </a>
        </div>
        <div class="pageTitle">Create Virtual Card</div>
        <div class="right"></div>
    </div>

    <!-- App Capsule -->
    <div id="appCapsule">
        
        <!-- Info -->
        <div class="section mt-2">
            <div class="card bg-primary text-white">
                <div class="card-body">
                    <div class="d-flex align-items-center">
                        <div class="icon-box bg-light text-primary me-3">
                            <ion-icon name="card-outline"></ion-icon>
                        </div>
                        <div>
                            <h4 class="mb-1 text-white">Virtual Visa Card</h4>
                            <p class="mb-0 opacity-75">Create a virtual card for online payments</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Features -->
        <div class="section mt-3">
            <div class="section-title">Card Features</div>
            <div class="card">
                <ul class="listview flush transparent image-listview">
                    <li>
                        <div class="item">
                            <div class="icon-box bg-success">
                                <ion-icon name="checkmark-outline"></ion-icon>
                            </div>
                            <div class="in">
                                <div>Instant Issuance</div>
                                <span class="text-muted">Get your card immediately</span>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item">
                            <div class="icon-box bg-success">
                                <ion-icon name="checkmark-outline"></ion-icon>
                            </div>
                            <div class="in">
                                <div>Global Acceptance</div>
                                <span class="text-muted">Use anywhere Visa is accepted</span>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item">
                            <div class="icon-box bg-success">
                                <ion-icon name="checkmark-outline"></ion-icon>
                            </div>
                            <div class="in">
                                <div>Secure Transactions</div>
                                <span class="text-muted">3D Secure enabled</span>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item">
                            <div class="icon-box bg-success">
                                <ion-icon name="checkmark-outline"></ion-icon>
                            </div>
                            <div class="in">
                                <div>Easy Controls</div>
                                <span class="text-muted">Freeze, set limits anytime</span>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
        </div>

        <!-- Create Form -->
        <div class="section mt-3 mb-3">
            <div class="section-title">Create Your Card</div>
            <div class="card">
                <div class="card-body">
                    <?php echo form_open('cards/create'); ?>
                        
                        <div class="form-group basic">
                            <div class="input-wrapper">
                                <label class="label">Funding Account</label>
                                <select class="form-control" name="account_id" required>
                                    <option value="">Select Account</option>
                                    <?php foreach ($accounts as $acc): ?>
                                    <option value="<?php echo $acc->id; ?>">
                                        <?php echo $acc->account_number; ?> - <?php echo format_money($acc->available_balance ?? 0, $acc->currency); ?>
                                    </option>
                                    <?php endforeach; ?>
                                </select>
                            </div>
                            <div class="input-info">Card will be linked to this account</div>
                        </div>
                        
                        <div class="form-group basic">
                            <div class="input-wrapper">
                                <label class="label">Card Currency</label>
                                <select class="form-control" name="currency">
                                    <option value="USD">USD - US Dollar</option>
                                    <option value="EUR">EUR - Euro</option>
                                    <option value="GBP">GBP - British Pound</option>
                                    <option value="USD">USD - Nigerian Naira</option>
                                </select>
                            </div>
                            <div class="input-info">Currency for card transactions</div>
                        </div>
                        
                        <?php if ($user->user_type !== 'admin'): ?>
                        <div class="form-group basic">
                            <div class="input-wrapper">
                                <label class="label">Transaction PIN</label>
                                <input type="password" class="form-control" name="pin" maxlength="4" placeholder="Enter your 4-digit PIN" required>
                            </div>
                            <div class="input-info">Enter your transaction PIN to confirm</div>
                        </div>
                        <?php endif; ?>

                        <div class="mt-3">
                            <div class="alert alert-outline-warning mb-2">
                                <ion-icon name="information-circle-outline"></ion-icon>
                                <span>Card creation fee: <strong>$2.00</strong></span>
                            </div>
                        </div>
                        
                        <div class="form-group basic mt-3">
                            <button type="submit" class="btn btn-primary btn-block btn-lg">
                                <ion-icon name="card-outline"></ion-icon> Create Virtual Card
                            </button>
                        </div>
                    <?php echo form_close(); ?>
                </div>
            </div>
        </div>
    </div>

    <!-- App Bottom Menu -->
    <?php echo get_bottom_menu('cards'); ?>

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