<div class="row justify-content-center">
    <div class="col-lg-7">
        <div class="card shadow-sm">
            <div class="card-header bg-white d-flex justify-content-between align-items-center">
                <h5 class="mb-0"><i class="bi bi-plus-circle text-success"></i> Enregistrer un Cash Advance</h5>
                <a href="<?= site_url('statements'); ?>" class="btn btn-sm btn-outline-secondary">
                    <i class="bi bi-arrow-left"></i> Retour
                </a>
            </div>
            <div class="card-body">

                <?php if ( ! empty($error)): ?>
                    <div class="alert alert-danger"><?= $error; ?></div>
                <?php endif; ?>

                <div class="alert alert-info py-2">
                    <i class="bi bi-info-circle"></i>
                    Un <strong>cash advance</strong> est un versement de la compagnie maritime vers le compte bancaire de Wassim Service.
                    Cette opération va :
                    <ol class="mb-0 mt-1">
                        <li>Enregistrer un <strong>crédit</strong> dans le compte partenaire</li>
                        <li>Créditer le <strong><?= htmlspecialchars($bank->name); ?></strong> (solde actuel : <?= number_format($bank->current_balance, 0, ',', ' '); ?> KMF)</li>
                    </ol>
                </div>

                <?= form_open('statements/cash_advance'); ?>

                <div class="row">
                    <!-- Référence -->
                    <div class="col-md-4 mb-3">
                        <label class="form-label">Référence</label>
                        <input type="text" class="form-control" value="<?= $reference; ?>" disabled>
                        <div class="form-text">Générée automatiquement.</div>
                    </div>

                    <!-- Date -->
                    <div class="col-md-4 mb-3">
                        <label class="form-label">Date du versement <span class="text-danger">*</span></label>
                        <input type="date" name="date" class="form-control" required
                               value="<?= set_value('date', date('Y-m-d')); ?>">
                    </div>

                    <!-- Montant -->
                    <div class="col-md-4 mb-3">
                        <label class="form-label">Montant <span class="text-danger">*</span></label>
                        <div class="input-group">
                            <input type="number" name="amount" class="form-control" 
                                   step="1" min="1" required
                                   value="<?= set_value('amount'); ?>"
                                   placeholder="49000000">
                            <span class="input-group-text">KMF</span>
                        </div>
                    </div>

                    <!-- Description -->
                    <div class="col-12 mb-3">
                        <label class="form-label">Description <span class="text-danger">*</span></label>
                        <input type="text" name="description" class="form-control" required
                               value="<?= set_value('description', 'Cash advance compagnie maritime'); ?>"
                               placeholder="Cash advance compagnie maritime">
                    </div>
                </div>

                <hr>
                <div class="d-flex gap-2">
                    <button type="submit" class="btn btn-success"
                            onclick="return confirm('Confirmer l\'enregistrement de ce cash advance ?');">
                        <i class="bi bi-check-lg"></i> Enregistrer le cash advance
                    </button>
                    <a href="<?= site_url('statements'); ?>" class="btn btn-outline-secondary">Annuler</a>
                </div>

                <?= form_close(); ?>
            </div>
        </div>
    </div>
</div>
