<?= $this->extend('layout/template') ?>

<?= $this->section('content') ?>
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h1 class="h3 mb-1 text-gray-800 fw-bold">Import Program & Kegiatan</h1>
            <p class="mb-0 text-muted">Gunakan template import agar data masuk rapi</p>
        </div>
        <a href="<?= base_url('program') ?>" class="btn btn-secondary shadow-sm">
            <i class="fas fa-arrow-left fa-sm text-white-50 me-1"></i> Kembali
        </a>
    </div>

    <?php if(session()->getFlashdata('error')): ?>
        <div class="alert alert-danger alert-dismissible fade show shadow-sm border-0 border-start border-danger border-4" role="alert">
            <i class="fas fa-times-circle me-2"></i> <?= session()->getFlashdata('error') ?>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    <?php endif; ?>
    <?php if(session()->getFlashdata('success')): ?>
        <div class="alert alert-success alert-dismissible fade show shadow-sm border-0 border-start border-success border-4" role="alert">
            <i class="fas fa-check-circle me-2"></i> <?= session()->getFlashdata('success') ?>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    <?php endif; ?>

    <div class="card shadow-sm border-0 mb-4 rounded-3">
        <div class="card-body">
            <div class="d-flex flex-wrap gap-2 mb-3">
                <a href="<?= base_url('program/template') ?>" class="btn btn-success shadow-sm">
                    <i class="fas fa-file-excel me-1"></i> Download Template
                </a>
            </div>

            <form action="<?= base_url('program/import') ?>" method="post" enctype="multipart/form-data">
                <div class="mb-3">
                    <label for="file_excel" class="form-label fw-bold text-secondary">File Excel <span class="text-danger">*</span></label>
                    <input type="file" class="form-control" id="file_excel" name="file_excel" accept=".xlsx,.xls,.csv" required>
                    <div class="form-text">Format: xlsx/xls/csv.</div>
                </div>

                <div class="alert alert-info">
                    <div class="fw-bold mb-1">Kolom wajib diisi</div>
                    <div class="small text-muted">OPD, Nama Sub Kegiatan. Kolom lain boleh kosong, tapi disarankan lengkap.</div>
                </div>

                <hr>
                <div class="d-flex justify-content-end">
                    <button type="submit" class="btn btn-primary px-4">
                        <i class="fas fa-upload me-1"></i> Upload & Import
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<?= $this->endSection() ?>
