<div class="row justify-content-center"><div class="col-lg-8"><div class="card">
    <div class="card-header"><h5 class="mb-0"><?= $account ? lang('common.edit') : lang('common.create') ?> <?= lang('adv_finance.bank_accounts') ?></h5></div>
    <div class="card-body">
        <form method="POST" action="<?= $account ? '/advanced-finance/bank-accounts/' . $account['id'] : '/advanced-finance/bank-accounts/store' ?>" data-ajax="true">
            <?= csrf_field() ?>
            <div class="row g-3">
                <div class="col-md-4"><label class="form-label">Code <span class="text-danger">*</span></label><input type="text" name="account_code" class="form-control" value="<?= e($account['account_code'] ?? '') ?>" required><div class="invalid-feedback" data-field="account_code"></div></div>
                <div class="col-md-4"><label class="form-label">Bank (EN) <span class="text-danger">*</span></label><input type="text" name="bank_name_en" class="form-control" value="<?= e($account['bank_name_en'] ?? '') ?>" required></div>
                <div class="col-md-4"><label class="form-label">Bank (AR) <span class="text-danger">*</span></label><input type="text" name="bank_name_ar" class="form-control" value="<?= e($account['bank_name_ar'] ?? '') ?>" required></div>
                <div class="col-md-4"><label class="form-label">Account Name <span class="text-danger">*</span></label><input type="text" name="account_name" class="form-control" value="<?= e($account['account_name'] ?? '') ?>" required></div>
                <div class="col-md-4"><label class="form-label">Account # <span class="text-danger">*</span></label><input type="text" name="account_number" class="form-control" value="<?= e($account['account_number'] ?? '') ?>" required></div>
                <div class="col-md-4"><label class="form-label">IBAN</label><input type="text" name="iban" class="form-control" value="<?= e($account['iban'] ?? '') ?>"></div>
                <div class="col-md-4"><label class="form-label">SWIFT</label><input type="text" name="swift_code" class="form-control" value="<?= e($account['swift_code'] ?? '') ?>"></div>
                <div class="col-md-4"><label class="form-label">Branch</label><input type="text" name="branch" class="form-control" value="<?= e($account['branch'] ?? '') ?>"></div>
                <div class="col-md-4"><label class="form-label">Currency <span class="text-danger">*</span></label><select name="currency_id" class="form-select" required><?php foreach($currencies as $c): ?><option value="<?= $c['id'] ?>" <?= selected($c['id'], $account['currency_id'] ?? '') ?>><?= e($c['currency_code']) ?></option><?php endforeach; ?></select></div>
                <div class="col-md-4"><label class="form-label">Type <span class="text-danger">*</span></label><select name="account_type" class="form-select" required><option value="current" <?= selected('current', $account['account_type'] ?? '') ?>>Current</option><option value="savings" <?= selected('savings', $account['account_type'] ?? '') ?>>Savings</option><option value="deposit" <?= selected('deposit', $account['account_type'] ?? '') ?>>Deposit</option></select></div>
                <?php if(!$account): ?><div class="col-md-4"><label class="form-label">Opening Balance <span class="text-danger">*</span></label><input type="number" name="opening_balance" class="form-control" step="0.01" value="0" required></div><?php endif; ?>
                <?php if($account): ?><div class="col-md-4 d-flex align-items-end"><div class="form-check"><input type="checkbox" name="is_active" value="1" class="form-check-input" <?= checked(1, $account['is_active'] ?? 1) ?>><label class="form-check-label">Active</label></div></div><?php endif; ?>
            </div>
            <div class="mt-4 d-flex gap-2"><button type="submit" class="btn btn-primary"><i class="fas fa-save me-1"></i><?= lang('common.save') ?></button><a href="/advanced-finance/bank-accounts" class="btn btn-secondary"><?= lang('common.cancel') ?></a></div>
        </form>
    </div>
</div></div></div>