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

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

    <!-- App Capsule -->
    <div id="appCapsule">
        <div class="section mt-2">
            <?php foreach ($accounts as $account): ?>
            <div class="card mb-2">
                <a href="<?php echo base_url('accounts/view/' . $account->id); ?>">
                    <div class="card-body">
                        <div class="d-flex justify-content-between align-items-start">
                            <div>
                                <span class="badge badge-<?php echo $account->account_type == 'savings' ? 'primary' : 'secondary'; ?> mb-1">
                                    <?php echo ucfirst($account->account_type); ?>
                                </span>
                                <?php if ($account->is_primary): ?>
                                <span class="badge badge-success mb-1">Primary</span>
                                <?php endif; ?>
                                <h3 class="mb-1"><?php echo $account->account_number; ?></h3>
                                <p class="text-muted mb-0"><?php echo htmlspecialchars($account->account_name); ?></p>
                            </div>
                            <div class="text-end">
                                <h2 class="mb-0"><?php echo format_money($account->available_balance ?? 0, $account->currency); ?></h2>
                                <span class="badge badge-<?php echo $account->status == 'active' ? 'success' : ($account->status == 'frozen' ? 'danger' : 'warning'); ?>">
                                    <?php echo ucfirst($account->status); ?>
                                </span>
                            </div>
                        </div>
                    </div>
                </a>
            </div>
            <?php endforeach; ?>
        </div>

        <!-- Account Info -->
        <div class="section mt-3 mb-3">
            <div class="card">
                <div class="card-body">
                    <h4>Account Information</h4>
                    <p class="text-muted mb-0">Your accounts are protected with bank-grade security. Contact support if you need to open a new account type.</p>
                </div>
            </div>
        </div>
    </div>

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

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