<!-- views/pinjaman/data_pinjaman.php -->
<style>
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --teal-900: #0d3d38;
  --teal-800: #0b5a52;
  --teal-700: #0b7a6e;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --teal-400: #2dd4bf;
  --teal-100: #ccfbf1;
  --teal-50:  #f0fdfa;
  --green-500: #10b981;
  --green-600: #059669;
  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-50:  #fffbeb;
  --amber-100: #fef3c7;
  --red-400:  #f87171;
  --red-500:  #ef4444;
  --blue-500: #3b82f6;
  --blue-50:  #eff6ff;
  --slate-50: #f8fafc;
  --slate-100:#f1f5f9;
  --slate-200:#e2e8f0;
  --slate-300:#cbd5e1;
  --slate-400:#94a3b8;
  --slate-500:#64748b;
  --slate-700:#334155;
  --slate-900:#0f172a;
  --card-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 20px rgba(0,0,0,.06);
}

.dp-wrapper {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  color: var(--slate-900);
  padding-bottom: 32px;
}

/* ── Page Header ── */
.dp-page-header {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 12px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.dp-page-header h4 {
  font-size: 1.3rem; font-weight: 800;
  color: var(--slate-900); margin: 0 0 6px;
  display: flex; align-items: center; gap: 10px;
}
.dp-page-header h4 .head-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--teal-700), var(--teal-500));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.05rem;
  box-shadow: 0 4px 12px rgba(13,148,136,.3);
  flex-shrink: 0;
}
.dp-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--slate-400); flex-wrap: wrap;
}
.dp-breadcrumb a { color: var(--teal-600); text-decoration: none; font-weight: 600; }
.dp-breadcrumb a:hover { text-decoration: underline; }
.dp-breadcrumb .sep { color: var(--slate-300); }
.dp-breadcrumb .current { color: var(--slate-500); font-weight: 600; }

/* ── Flash ── */
.dp-flash {
  display: flex; align-items: flex-start; gap: 11px;
  border-radius: 10px; padding: 13px 16px;
  margin-bottom: 18px; font-size: .85rem;
  animation: fadeUp .3s ease both;
}
.dp-flash.success { background: #d1fae5; border: 1px solid #6ee7b7; color: #065f46; }
.dp-flash.error   { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.dp-flash i { font-size: 1rem; margin-top: 1px; flex-shrink: 0; }
.dp-flash .flash-close {
  margin-left: auto; background: none; border: none;
  cursor: pointer; opacity: .6; font-size: .9rem;
  color: inherit; padding: 0; line-height: 1; flex-shrink: 0;
}
.dp-flash .flash-close:hover { opacity: 1; }

/* ── Summary Cards ── */
.dp-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 20px;
}
.dp-summary-card {
  border-radius: 14px; padding: 20px 18px;
  position: relative; overflow: hidden; color: #fff;
  transition: transform .2s, box-shadow .2s;
  animation: fadeUp .35s ease both;
}
.dp-summary-card:nth-child(1) { animation-delay: .05s; }
.dp-summary-card:nth-child(2) { animation-delay: .10s; }
.dp-summary-card:nth-child(3) { animation-delay: .15s; }
.dp-summary-card:nth-child(4) { animation-delay: .20s; }
.dp-summary-card:hover { transform: translateY(-3px); }
.dp-summary-card::before {
  content: ''; position: absolute; top: -28px; right: -28px;
  width: 110px; height: 110px; border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.dp-summary-card::after {
  content: ''; position: absolute; bottom: -40px; right: 35px;
  width: 150px; height: 150px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.dp-summary-card .sc-label {
  font-size: .72rem; font-weight: 600; opacity: .85;
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 8px; position: relative; z-index: 1;
}
.dp-summary-card .sc-value {
  font-size: 1.25rem; font-weight: 800; line-height: 1.2;
  position: relative; z-index: 1;
}
.dp-summary-card .sc-value small { font-size: .58em; font-weight: 600; opacity: .8; }
.dp-summary-card .sc-icon {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px;
  background: rgba(255,255,255,.16); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; z-index: 1;
}
.sc-teal   { background: linear-gradient(135deg, var(--teal-800), var(--teal-600), var(--teal-400)); box-shadow: 0 8px 24px rgba(13,148,136,.28); }
.sc-green  { background: linear-gradient(135deg, #059669, #10b981, #34d399); box-shadow: 0 8px 24px rgba(16,185,129,.28); }
.sc-amber  { background: linear-gradient(135deg, #b45309, #d97706, #f59e0b); box-shadow: 0 8px 24px rgba(245,158,11,.28); }
.sc-blue   { background: linear-gradient(135deg, #1d4ed8, #3b82f6, #60a5fa); box-shadow: 0 8px 24px rgba(59,130,246,.28); }

/* ── Main Card ── */
.dp-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--slate-200);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  animation: fadeUp .4s .22s ease both;
}
.dp-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(90deg, var(--teal-50), #fff);
  border-bottom: 1px solid rgba(13,148,136,.1);
  gap: 12px; flex-wrap: wrap;
}
.dp-card-head h5 {
  margin: 0; font-size: .98rem; font-weight: 800; color: var(--slate-900);
  display: flex; align-items: center; gap: 8px;
}
.dp-card-head h5 i { color: var(--teal-600); }
.dp-count-pill {
  background: var(--teal-50); color: var(--teal-700);
  border: 1px solid rgba(13,148,136,.2);
  padding: 3px 10px; border-radius: 20px;
  font-size: .74rem; font-weight: 700;
}

/* ── Table ── */
.dp-table-wrap { overflow-x: auto; }
.dp-table {
  width: 100%; border-collapse: collapse;
  font-size: .83rem;
}
.dp-table thead th {
  padding: 11px 14px;
  background: var(--slate-50);
  border-bottom: 2px solid var(--slate-200);
  font-weight: 700; font-size: .74rem;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--slate-500); white-space: nowrap;
}
.dp-table tbody tr { border-bottom: 1px solid #f8fafc; transition: background .12s; }
.dp-table tbody tr:last-child { border-bottom: none; }
.dp-table tbody tr:hover { background: var(--teal-50); }
.dp-table tbody td { padding: 12px 14px; vertical-align: middle; }

/* badges */
.badge-kode {
  font-family: monospace; font-size: .78rem; font-weight: 700;
  background: var(--teal-50); color: var(--teal-700);
  padding: 3px 8px; border-radius: 5px;
  border: 1px solid rgba(13,148,136,.15);
}
.badge-belum-cairkan {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--amber-100); color: #92400e;
  border: 1px solid var(--amber-400);
  font-size: .68rem; font-weight: 700;
  padding: 2px 6px; border-radius: 4px; margin-top: 4px;
}
.badge-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px;
  font-size: .73rem; font-weight: 700; white-space: nowrap;
}
.badge-status.aktif {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: var(--blue-500); border: 1px solid rgba(59,130,246,.2);
}
.badge-status.lunas {
  background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7;
}

/* progress bar */
.tenor-progress { min-width: 100px; }
.tenor-text { font-size: .78rem; color: var(--slate-500); margin-bottom: 4px; white-space: nowrap; }
.progress-track {
  height: 5px; background: var(--slate-100); border-radius: 10px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 10px;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-400));
  transition: width .4s ease;
}
.progress-fill.done { background: linear-gradient(90deg, var(--green-500), #34d399); }

/* nominal colors */
.nom-total { color: var(--red-500); font-weight: 700; font-size: .82rem; }
.nom-sisa-ada { color: var(--amber-600); font-weight: 800; }
.nom-sisa-lunas { color: var(--green-500); font-weight: 700; }
.nom-disetujui { color: var(--teal-700); font-weight: 700; }

/* action buttons */
.btn-detail-sm {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--teal-50); color: var(--teal-700);
  border: 1px solid rgba(13,148,136,.25); border-radius: 6px;
  padding: 5px 11px; font-size: .76rem; font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
  text-decoration: none; transition: all .15s;
}
.btn-detail-sm:hover { background: var(--teal-600); color: #fff; border-color: var(--teal-600); }
.btn-cairkan-sm {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, var(--green-500), var(--green-600));
  color: #fff; border: none; border-radius: 6px;
  padding: 5px 11px; font-size: .76rem; font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
  text-decoration: none; cursor: pointer;
  box-shadow: 0 2px 8px rgba(16,185,129,.22);
  transition: all .15s;
}
.btn-cairkan-sm:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,185,129,.32); color: #fff; }

/* ── Mobile Cards ── */
.dp-mobile { display: none; padding: 12px 14px; }
.dp-m-card {
  border: 1px solid var(--slate-200); border-radius: 12px;
  padding: 13px 14px; margin-bottom: 10px;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.05);
  position: relative; overflow: hidden;
}
.dp-m-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  border-radius: 3px 0 0 3px;
}
.dp-m-card.aktif::before { background: var(--blue-500); }
.dp-m-card.lunas::before { background: var(--green-500); }
.dp-m-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.dp-m-kode { font-family: monospace; font-size: .82rem; font-weight: 700; color: var(--teal-700); }
.dp-m-body { margin-bottom: 10px; }
.dp-m-nama { font-size: .88rem; font-weight: 700; margin-bottom: 2px; }
.dp-m-row {
  display: flex; justify-content: space-between;
  font-size: .78rem; margin-bottom: 4px;
  align-items: center;
}
.dp-m-row .r-label { color: var(--slate-400); }
.dp-m-row .r-val   { font-weight: 700; }
.dp-m-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.dp-m-actions { display: flex; gap: 6px; }
.dp-m-progress { margin-top: 8px; }

/* ── Empty ── */
.dp-empty {
  padding: 60px 24px; text-align: center; color: var(--slate-400);
}
.dp-empty .ei {
  width: 68px; height: 68px; border-radius: 18px;
  background: var(--teal-50); color: var(--teal-400);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; margin: 0 auto 14px;
}
.dp-empty h5 { color: var(--slate-600); font-weight: 700; margin-bottom: 6px; font-size: .95rem; }
.dp-empty p  { font-size: .82rem; margin: 0; }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* ══════════ RESPONSIVE ══════════ */
@media (max-width: 991px) {
  .dp-summary-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}
@media (max-width: 767px) {
  .dp-table-wrap { display: none; }
  .dp-mobile { display: block; }
  .dp-summary-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .dp-summary-card .sc-value { font-size: 1rem; }
  .dp-summary-card .sc-icon { width: 38px; height: 38px; font-size: 1rem; right: 12px; }
  .dp-page-header h4 .page-title { display: none; }
}
@media (max-width: 500px) {
  .dp-summary-grid { grid-template-columns: 1fr 1fr; }
}
</style>

<div class="dp-wrapper container-fluid">

  <!-- ── Page Header ── -->
  <div class="dp-page-header">
    <div>
      <h4>
        <div class="head-icon"><i class="bi bi-wallet2"></i></div>
        <span class="page-title"><?php echo $title; ?></span>
      </h4>
      <div class="dp-breadcrumb">
        <a href="<?php echo base_url('dashboard'); ?>"><i class="bi bi-grid-1x2-fill me-1"></i>Dashboard</a>
        <span class="sep">›</span>
        <a href="<?php echo base_url('pinjaman'); ?>">Pinjaman</a>
        <span class="sep">›</span>
        <span class="current">Data Pinjaman</span>
      </div>
    </div>
  </div>

  <!-- ── Flash Messages ── -->
  <?php if($this->session->flashdata('success')): ?>
  <div class="dp-flash success">
    <i class="bi bi-check-circle-fill"></i>
    <span><?php echo $this->session->flashdata('success'); ?></span>
    <button class="flash-close" onclick="this.closest('.dp-flash').remove()"><i class="bi bi-x"></i></button>
  </div>
  <?php endif; ?>
  <?php if($this->session->flashdata('error')): ?>
  <div class="dp-flash error">
    <i class="bi bi-exclamation-triangle-fill"></i>
    <span><?php echo $this->session->flashdata('error'); ?></span>
    <button class="flash-close" onclick="this.closest('.dp-flash').remove()"><i class="bi bi-x"></i></button>
  </div>
  <?php endif; ?>

  <!-- ── Summary Cards ── -->
  <?php if(!empty($pinjaman)):
    $total_nominal = 0; $total_dibayar = 0; $total_sisa = 0;
    foreach($pinjaman as $p) {
      $total_nominal += $p->total_pinjaman;
      $total_dibayar += ($p->total_pinjaman - $p->sisa_pinjaman);
      $total_sisa    += $p->sisa_pinjaman;
    }
  ?>
  <div class="dp-summary-grid">
    <div class="dp-summary-card sc-teal">
      <div class="sc-label"><i class="bi bi-cash-stack me-1"></i>Total Pinjaman</div>
      <div class="sc-value"><small>Rp </small><?php echo number_format($total_nominal, 0, ',', '.'); ?></div>
      <div class="sc-icon"><i class="bi bi-cash-stack"></i></div>
    </div>
    <div class="dp-summary-card sc-green">
      <div class="sc-label"><i class="bi bi-graph-up me-1"></i>Sudah Dibayar</div>
      <div class="sc-value"><small>Rp </small><?php echo number_format($total_dibayar, 0, ',', '.'); ?></div>
      <div class="sc-icon"><i class="bi bi-graph-up-arrow"></i></div>
    </div>
    <div class="dp-summary-card sc-amber">
      <div class="sc-label"><i class="bi bi-hourglass-split me-1"></i>Sisa Pinjaman</div>
      <div class="sc-value"><small>Rp </small><?php echo number_format($total_sisa, 0, ',', '.'); ?></div>
      <div class="sc-icon"><i class="bi bi-hourglass-split"></i></div>
    </div>
    <div class="dp-summary-card sc-blue">
      <div class="sc-label"><i class="bi bi-file-earmark-check me-1"></i>Jumlah Pinjaman</div>
      <div class="sc-value"><?php echo count($pinjaman); ?> <small>pinjaman</small></div>
      <div class="sc-icon"><i class="bi bi-file-earmark-check-fill"></i></div>
    </div>
  </div>
  <?php endif; ?>

  <!-- ── Main Card ── -->
  <div class="dp-card">
    <div class="dp-card-head">
      <h5><i class="bi bi-wallet2"></i> Daftar Pinjaman Aktif</h5>
      <?php if(!empty($pinjaman)): ?>
      <span class="dp-count-pill"><?php echo count($pinjaman); ?> pinjaman</span>
      <?php endif; ?>
    </div>

    <?php if(empty($pinjaman)): ?>
    <div class="dp-empty">
      <div class="ei"><i class="bi bi-inbox"></i></div>
      <h5>Belum Ada Data Pinjaman</h5>
      <p>Belum ada pinjaman aktif yang dapat ditampilkan.</p>
    </div>

    <?php else: ?>

    <!-- DESKTOP TABLE -->
    <div class="dp-table-wrap">
      <table class="dp-table" id="tablePinjaman">
        <thead>
          <tr>
            <th width="46px">No</th>
            <th>Kode Pinjaman</th>
            <?php if(is_admin()): ?>
            <th>Nama Warga</th>
            <th>No. HP</th>
            <?php endif; ?>
            <th class="text-end">Nominal Disetujui</th>
            <th class="text-end">Total Pinjaman</th>
            <th class="text-end">Sisa</th>
            <th>Tenor</th>
            <th>Status</th>
            <th class="text-center" width="130px">Aksi</th>
          </tr>
        </thead>
        <tbody>
          <?php $no = 1; foreach($pinjaman as $p):
            $pct = $p->tenor > 0 ? round((($p->tenor - $p->sisa_tenor) / $p->tenor) * 100) : 0;
          ?>
          <tr>
            <td style="color:var(--slate-400);font-size:.78rem;"><?php echo $no++; ?></td>
            <td>
              <span class="badge-kode"><?php echo htmlspecialchars($p->kode_pinjaman); ?></span>
              <?php if($p->sudah_diterima == 'tidak'): ?>
              <div><span class="badge-belum-cairkan"><i class="bi bi-clock"></i> Belum Dicairkan</span></div>
              <?php endif; ?>
            </td>
            <?php if(is_admin()): ?>
            <td style="font-weight:600;"><?php echo htmlspecialchars($p->nama_lengkap); ?></td>
            <td style="font-size:.8rem;color:var(--slate-500);"><?php echo $p->no_hp; ?></td>
            <?php endif; ?>
            <td class="text-end nom-disetujui">Rp <?php echo number_format($p->nominal_disetujui, 0, ',', '.'); ?></td>
            <td class="text-end nom-total">Rp <?php echo number_format($p->total_pinjaman, 0, ',', '.'); ?></td>
            <td class="text-end <?php echo $p->sisa_pinjaman > 0 ? 'nom-sisa-ada' : 'nom-sisa-lunas'; ?>">
              Rp <?php echo number_format($p->sisa_pinjaman, 0, ',', '.'); ?>
            </td>
            <td>
              <div class="tenor-progress">
                <div class="tenor-text"><?php echo $p->sisa_tenor; ?> / <?php echo $p->tenor; ?> bln</div>
                <div class="progress-track">
                  <div class="progress-fill <?php echo $pct >= 100 ? 'done' : ''; ?>" style="width:<?php echo $pct; ?>%"></div>
                </div>
              </div>
            </td>
            <td>
              <?php if($p->status_pinjaman == 'aktif'): ?>
                <span class="badge-status aktif"><i class="bi bi-activity"></i>Aktif</span>
              <?php else: ?>
                <span class="badge-status lunas"><i class="bi bi-check-circle-fill"></i>Lunas</span>
              <?php endif; ?>
            </td>
            <td class="text-center">
              <a href="<?php echo base_url('pinjaman/detail/'.$p->id); ?>" class="btn-detail-sm">
                <i class="bi bi-eye"></i> Detail
              </a>
              <?php if(is_admin() && $p->sudah_diterima == 'tidak'): ?>
              <a href="<?php echo base_url('pinjaman/pencairan/'.$p->id); ?>"
                 class="btn-cairkan-sm ms-1"
                 data-confirm="Konfirmasi pencairan pinjaman untuk <strong><?php echo htmlspecialchars($p->nama_lengkap ?? ''); ?></strong> sebesar <strong>Rp <?php echo number_format($p->nominal_disetujui, 0, ',', '.'); ?></strong>?" 
                 data-title="Konfirmasi Pencairan" data-type="success">
                <i class="bi bi-cash"></i> Cairkan
              </a>
              <?php endif; ?>
            </td>
          </tr>
          <?php endforeach; ?>
        </tbody>
      </table>
    </div>

    <!-- MOBILE CARDS -->
    <div class="dp-mobile">
      <?php foreach($pinjaman as $p):
        $pct = $p->tenor > 0 ? round((($p->tenor - $p->sisa_tenor) / $p->tenor) * 100) : 0;
      ?>
      <div class="dp-m-card <?php echo $p->status_pinjaman; ?>">
        <div class="dp-m-top">
          <span class="dp-m-kode"><?php echo htmlspecialchars($p->kode_pinjaman); ?></span>
          <?php if($p->status_pinjaman == 'aktif'): ?>
            <span class="badge-status aktif"><i class="bi bi-activity"></i>Aktif</span>
          <?php else: ?>
            <span class="badge-status lunas"><i class="bi bi-check-circle-fill"></i>Lunas</span>
          <?php endif; ?>
        </div>

        <?php if(is_admin()): ?>
        <div class="dp-m-nama"><?php echo htmlspecialchars($p->nama_lengkap); ?></div>
        <?php endif; ?>

        <?php if($p->sudah_diterima == 'tidak'): ?>
        <div style="margin-bottom:8px;"><span class="badge-belum-cairkan"><i class="bi bi-clock"></i> Belum Dicairkan</span></div>
        <?php endif; ?>

        <div class="dp-m-body">
          <div class="dp-m-row">
            <span class="r-label">Nominal Disetujui</span>
            <span class="r-val nom-disetujui">Rp <?php echo number_format($p->nominal_disetujui, 0, ',', '.'); ?></span>
          </div>
          <div class="dp-m-row">
            <span class="r-label">Total Pinjaman</span>
            <span class="r-val nom-total">Rp <?php echo number_format($p->total_pinjaman, 0, ',', '.'); ?></span>
          </div>
          <div class="dp-m-row">
            <span class="r-label">Sisa</span>
            <span class="r-val <?php echo $p->sisa_pinjaman > 0 ? 'nom-sisa-ada' : 'nom-sisa-lunas'; ?>">
              Rp <?php echo number_format($p->sisa_pinjaman, 0, ',', '.'); ?>
            </span>
          </div>
          <div class="dp-m-progress">
            <div class="tenor-text"><?php echo $p->sisa_tenor; ?> / <?php echo $p->tenor; ?> bulan tersisa</div>
            <div class="progress-track">
              <div class="progress-fill <?php echo $pct >= 100 ? 'done' : ''; ?>" style="width:<?php echo $pct; ?>%"></div>
            </div>
          </div>
        </div>

        <div class="dp-m-footer">
          <?php if(is_admin()): ?>
          <span style="font-size:.75rem;color:var(--slate-400);"><i class="bi bi-telephone me-1"></i><?php echo $p->no_hp; ?></span>
          <?php else: ?>
          <span></span>
          <?php endif; ?>
          <div class="dp-m-actions">
            <a href="<?php echo base_url('pinjaman/detail/'.$p->id); ?>" class="btn-detail-sm">
              <i class="bi bi-eye"></i> Detail
            </a>
            <?php if(is_admin() && $p->sudah_diterima == 'tidak'): ?>
            <a href="<?php echo base_url('pinjaman/pencairan/'.$p->id); ?>"
               class="btn-cairkan-sm"
               data-confirm="Konfirmasi pencairan pinjaman sebesar Rp <?php echo number_format($p->nominal_disetujui, 0, ',', '.'); ?>?" 
               data-title="Cairkan Pinjaman" data-type="success">
              <i class="bi bi-cash"></i> Cairkan
            </a>
            <?php endif; ?>
          </div>
        </div>
      </div>
      <?php endforeach; ?>
    </div>

    <?php endif; ?>
  </div><!-- /.dp-card -->

</div><!-- /.dp-wrapper -->

<script>
$(document).ready(function() {
  $('#tablePinjaman').DataTable({
    language: { url: '//cdn.datatables.net/plug-ins/1.13.7/i18n/id.json' },
    order: [[1, 'desc']],
    pageLength: 25,
    responsive: true,
    columnDefs: [{ orderable: false, targets: -1 }]
  });

  // Auto-close flash
  setTimeout(() => {
    document.querySelectorAll('.dp-flash').forEach(el => {
      el.style.transition = 'opacity .4s';
      el.style.opacity = '0';
      setTimeout(() => el.remove(), 400);
    });
  }, 4000);
});
</script>