<!doctype html>
<html lang="id">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
  <title>Detail Permintaan Peminjaman - <?php echo e(config('app.name', 'Laravel')); ?></title>
  <link rel="icon" type="image/svg+xml" href="<?php echo e(asset('favicon.svg')); ?>">

  <script src="https://cdn.tailwindcss.com"></script>
  <script src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
  <script src="https://unpkg.com/lucide@latest"></script>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">

  <style>
    :root {
      --bg: #eef4ff;
      --panel: rgba(255, 255, 255, 0.92);
      --text: #172554;
      --muted: #64748b;
      --line: #dbe6f7;
      --primary: #4f46e5;
      --secondary: #2563eb;
      --cyan: #38bdf8;
      --green: #16a34a;
      --amber: #f59e0b;
      --red: #ef4444;
      --shadow-soft: 0 28px 55px rgba(59, 84, 145, 0.12);
      --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      font-family: var(--font-main);
      color: var(--text);
      background:
        radial-gradient(circle at top left, rgba(79, 70, 229, 0.10), transparent 22%),
        radial-gradient(circle at top right, rgba(56, 189, 248, 0.10), transparent 24%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
      -webkit-font-smoothing: antialiased;
    }

    .app { display: flex; min-height: 100vh; }

    .content {
      flex: 1;
      width: 100%;
      padding: 28px;
    }

    .shell {
      max-width: 1420px;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      gap: 20px;
    }

    .surface {
      background: var(--panel);
      border: 1px solid rgba(255, 255, 255, 0.82);
      box-shadow: var(--shadow-soft);
      backdrop-filter: blur(16px);
    }

    .hero {
      position: relative;
      overflow: hidden;
      border-radius: 32px;
      padding: 28px;
      background:
        radial-gradient(circle at 82% 14%, rgba(79, 70, 229, 0.14), transparent 25%),
        radial-gradient(circle at 14% 18%, rgba(56, 189, 248, 0.12), transparent 24%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(243, 247, 255, 0.96) 100%);
    }

    .hero::after {
      content: "";
      position: absolute;
      right: -90px;
      bottom: -120px;
      width: 320px;
      height: 320px;
      border-radius: 999px;
      background: rgba(79, 70, 229, 0.08);
    }

    .hero-inner {
      position: relative;
      z-index: 1;
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 24px;
      align-items: start;
    }

    .pill {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 8px 14px;
      border-radius: 999px;
      background: linear-gradient(135deg, rgba(79, 70, 229, 0.10), rgba(37, 99, 235, 0.08));
      color: var(--primary);
      font-size: 11px;
      font-weight: 900;
      letter-spacing: 0.16em;
      text-transform: uppercase;
      border: 1px solid rgba(99, 102, 241, 0.12);
    }

    .hero-title {
      margin: 16px 0 10px;
      font-size: clamp(34px, 4vw, 56px);
      line-height: 0.94;
      letter-spacing: -0.06em;
      font-weight: 900;
      color: #172554;
    }

    .hero-text {
      margin: 0;
      max-width: 720px;
      color: var(--muted);
      font-size: 14px;
      line-height: 1.8;
    }

    .hero-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      justify-content: flex-end;
    }

    .btn-primary,
    .btn-soft,
    .btn-danger,
    .btn-green,
    .btn-amber {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      min-height: 46px;
      padding: 0 18px;
      border: 0;
      border-radius: 18px;
      cursor: pointer;
      text-decoration: none;
      font-size: 14px;
      font-weight: 900;
      transition: all 0.2s ease;
    }

    .btn-primary {
      color: #fff;
      background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
      box-shadow: 0 18px 28px rgba(79, 70, 229, 0.24);
    }

    .btn-soft {
      color: var(--text);
      background: rgba(255, 255, 255, 0.84);
      border: 1px solid var(--line);
    }

    .btn-green {
      color: #fff;
      background: linear-gradient(135deg, #22c55e, #16a34a);
      box-shadow: 0 16px 26px rgba(34, 197, 94, 0.22);
    }

    .btn-danger {
      color: #fff;
      background: linear-gradient(135deg, #f43f5e, #dc2626);
      box-shadow: 0 16px 26px rgba(244, 63, 94, 0.20);
    }

    .btn-amber {
      color: #fff;
      background: linear-gradient(135deg, #f59e0b, #d97706);
      box-shadow: 0 16px 26px rgba(245, 158, 11, 0.22);
    }

    .btn-primary:hover,
    .btn-soft:hover,
    .btn-danger:hover,
    .btn-green:hover,
    .btn-amber:hover {
      transform: translateY(-1px);
    }

    .summary-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 16px;
    }

    .summary-card {
      position: relative;
      min-height: 126px;
      overflow: hidden;
      border-radius: 24px;
      padding: 22px;
      background: rgba(255, 255, 255, 0.88);
      border: 1px solid rgba(214, 226, 247, 0.98);
      box-shadow: 0 18px 32px rgba(148, 163, 184, 0.12);
    }

    .summary-card::after {
      content: "";
      position: absolute;
      top: 0;
      right: 0;
      width: 66px;
      height: 66px;
      border-bottom-left-radius: 32px;
      opacity: 0.76;
    }

    .summary-card.primary::after { background: #ede9fe; }
    .summary-card.blue::after { background: #dbeafe; }
    .summary-card.amber::after { background: #fff4df; }
    .summary-card.green::after { background: #dcfce7; }

    .summary-icon {
      position: absolute;
      top: 22px;
      right: 22px;
      z-index: 1;
    }

    .summary-label {
      color: var(--muted);
      font-size: 11px;
      font-weight: 900;
      letter-spacing: 0.14em;
      text-transform: uppercase;
    }

    .summary-value {
      margin-top: 14px;
      font-size: 26px;
      font-weight: 900;
      line-height: 1.05;
      color: #172554;
    }

    .layout-grid {
      display: grid;
      grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
      gap: 20px;
      align-items: start;
    }

    .panel {
      overflow: hidden;
      border-radius: 30px;
    }

    .panel-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      padding: 22px 24px 0;
    }

    .panel-eyebrow {
      color: var(--muted);
      font-size: 11px;
      font-weight: 900;
      letter-spacing: 0.14em;
      text-transform: uppercase;
    }

    .panel-title {
      margin: 6px 0 0;
      color: #172554;
      font-size: 22px;
      font-weight: 900;
      letter-spacing: -0.04em;
    }

    .status-badge {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 10px 14px;
      border-radius: 999px;
      font-size: 12px;
      font-weight: 900;
      white-space: nowrap;
    }

    .status-pending,
    .status-revision_requested {
      background: #fff7ed;
      color: #c2410c;
      border: 1px solid #fed7aa;
    }

    .status-approved,
    .status-final_approved,
    .status-returned {
      background: #ecfdf5;
      color: #15803d;
      border: 1px solid #bbf7d0;
    }

    .status-rejected {
      background: #fef2f2;
      color: #dc2626;
      border: 1px solid #fecaca;
    }

    .status-staff_approved,
    .status-sekretariat_approved,
    .status-kepala_approved {
      background: #eff6ff;
      color: #2563eb;
      border: 1px solid #bfdbfe;
    }

    .status-default {
      background: #f8fafc;
      color: #475569;
      border: 1px solid #e2e8f0;
    }

    .product-preview {
      margin: 20px 24px 0;
      height: 320px;
      border-radius: 28px;
      border: 1px solid rgba(214, 226, 247, 0.98);
      background:
        radial-gradient(circle at top left, rgba(79, 70, 229, 0.10), transparent 26%),
        radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.14), transparent 28%),
        linear-gradient(135deg, #f8fbff, #eef6ff);
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
    }

    .product-preview img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      padding: 18px;
    }

    .empty-image {
      display: grid;
      place-items: center;
      gap: 10px;
      color: #8ba0bd;
      text-align: center;
      font-weight: 800;
    }

    .info-list {
      padding: 22px 24px 24px;
      display: grid;
      gap: 12px;
    }

    .info-row {
      display: grid;
      grid-template-columns: 150px minmax(0, 1fr);
      gap: 14px;
      padding: 14px;
      border-radius: 18px;
      background: rgba(248, 251, 255, 0.82);
      border: 1px solid rgba(219, 230, 247, 0.85);
    }

    .info-label {
      color: var(--muted);
      font-size: 11px;
      font-weight: 900;
      letter-spacing: 0.12em;
      text-transform: uppercase;
    }

    .info-value {
      color: #172554;
      font-size: 14px;
      font-weight: 800;
      line-height: 1.55;
      word-break: break-word;
    }

    .note-box {
      margin: 0 24px 24px;
      padding: 18px;
      border-radius: 22px;
      background: linear-gradient(135deg, rgba(239, 246, 255, 0.92), rgba(255, 255, 255, 0.92));
      border: 1px solid rgba(191, 219, 254, 0.9);
      color: #334155;
    }

    .timeline {
      padding: 22px 24px 24px;
    }

    .timeline-list {
      position: relative;
      display: grid;
      gap: 16px;
      margin-top: 18px;
    }

    .timeline-item {
      position: relative;
      display: grid;
      grid-template-columns: 44px minmax(0, 1fr);
      gap: 14px;
    }

    .timeline-dot {
      width: 44px;
      height: 44px;
      border-radius: 16px;
      display: grid;
      place-items: center;
      color: #fff;
      background: linear-gradient(135deg, #4f46e5, #2563eb);
      box-shadow: 0 14px 24px rgba(79, 70, 229, 0.22);
    }

    .timeline-dot.green { background: linear-gradient(135deg, #22c55e, #16a34a); }
    .timeline-dot.red { background: linear-gradient(135deg, #fb7185, #dc2626); }
    .timeline-dot.amber { background: linear-gradient(135deg, #f59e0b, #d97706); }

    .timeline-card {
      padding: 16px;
      border-radius: 22px;
      background: rgba(248, 251, 255, 0.82);
      border: 1px solid rgba(219, 230, 247, 0.9);
    }

    .timeline-title {
      margin: 0;
      color: #172554;
      font-size: 14px;
      font-weight: 900;
    }

    .timeline-meta {
      margin-top: 4px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }

    .timeline-comment {
      margin-top: 10px;
      padding: 12px;
      border-radius: 16px;
      background: rgba(255, 255, 255, 0.78);
      color: #475569;
      font-size: 13px;
      line-height: 1.6;
      border: 1px solid rgba(226, 232, 240, 0.9);
    }

    .empty-state {
      margin-top: 18px;
      padding: 28px;
      border-radius: 24px;
      text-align: center;
      color: var(--muted);
      background: rgba(248, 251, 255, 0.82);
      border: 1px dashed #cbd5e1;
      font-weight: 800;
    }

    .action-panel {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 12px;
      padding: 20px 24px 24px;
      border-top: 1px solid rgba(219, 230, 247, 0.9);
    }

    @media (max-width: 1180px) {
      .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .layout-grid { grid-template-columns: 1fr; }
    }

    @media (max-width: 1024px) {
      .app { display: block; }
      .content { padding: 88px 20px 22px; }
    }

    @media (max-width: 760px) {
      .hero,
      .panel { border-radius: 24px; }
      .hero-inner { grid-template-columns: 1fr; }
      .hero-actions { justify-content: stretch; }
      .hero-actions a,
      .action-panel button,
      .action-panel a,
      .action-panel form { width: 100%; }
      .summary-grid { grid-template-columns: 1fr; }
      .product-preview { height: 250px; margin-inline: 16px; border-radius: 22px; }
      .panel-head,
      .info-list,
      .timeline,
      .action-panel { padding-inline: 16px; }
      .info-row { grid-template-columns: 1fr; gap: 6px; }
    }
  </style>
</head>

<body>
  <?php
    $status = strtolower($borrowRequest->status ?? 'pending');
    $statusLabel = ucwords(str_replace('_', ' ', $status));
    $statusClass = in_array($status, ['pending', 'revision_requested', 'approved', 'final_approved', 'returned', 'rejected', 'staff_approved', 'sekretariat_approved', 'kepala_approved'], true)
      ? 'status-' . $status
      : 'status-default';
    $item = $borrowRequest->item;
    $itemImage = $item->image ?? null;
    $borrowDate = optional($borrowRequest->tanggal_pinjam)->format('d M Y, H:i');
    $returnPlan = $borrowRequest->tanggal_kembali ? $borrowRequest->tanggal_kembali->format('d M Y, H:i') : null;
    $actualReturn = $borrowRequest->actual_return_date ? \Carbon\Carbon::parse($borrowRequest->actual_return_date)->format('d M Y, H:i') : null;
  ?>

  <div class="app">
    <?php echo $__env->make('partials.sidebar', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <main class="content">
      <div class="shell">
        <section class="hero surface">
          <div class="hero-inner">
            <div>
              <span class="pill">
                <i data-lucide="clipboard-list" class="w-4 h-4"></i>
                Detail Peminjaman
              </span>
              <h1 class="hero-title"><?php echo e($item->nama ?? 'Permintaan Barang'); ?></h1>
              <p class="hero-text">
                Ringkasan lengkap permintaan peminjaman barang, mulai dari data peminjam, jadwal, status, sampai jejak persetujuannya.
              </p>
            </div>

            <div class="hero-actions">
              <a href="<?php echo e(route('borrow.index')); ?>" class="btn-soft">
                <i data-lucide="arrow-left" class="w-4 h-4"></i>
                Kembali
              </a>
              <a href="<?php echo e(route('borrow.select')); ?>" class="btn-primary">
                <i data-lucide="plus" class="w-4 h-4"></i>
                Buat Baru
              </a>
            </div>
          </div>
        </section>

        <section class="summary-grid">
          <div class="summary-card primary">
            <i data-lucide="package" class="summary-icon w-6 h-6 text-indigo-600"></i>
            <div class="summary-label">Jumlah Barang</div>
            <div class="summary-value"><?php echo e($borrowRequest->jumlah ?? 0); ?> Unit</div>
          </div>

          <div class="summary-card blue">
            <i data-lucide="user-round" class="summary-icon w-6 h-6 text-blue-600"></i>
            <div class="summary-label">Peminjam</div>
            <div class="summary-value"><?php echo e(optional($borrowRequest->user)->name ?? '-'); ?></div>
          </div>

          <div class="summary-card amber">
            <i data-lucide="calendar-clock" class="summary-icon w-6 h-6 text-amber-500"></i>
            <div class="summary-label">Tanggal Pinjam</div>
            <div class="summary-value"><?php echo e($borrowDate ?? '-'); ?></div>
          </div>

          <div class="summary-card green">
            <i data-lucide="badge-check" class="summary-icon w-6 h-6 text-green-600"></i>
            <div class="summary-label">Status</div>
            <div class="summary-value"><?php echo e($statusLabel); ?></div>
          </div>
        </section>

        <section class="layout-grid">
          <article class="panel surface">
            <div class="panel-head">
              <div>
                <div class="panel-eyebrow">Barang Dipinjam</div>
                <h2 class="panel-title">Preview Barang</h2>
              </div>
              <span class="status-badge <?php echo e($statusClass); ?>">
                <i data-lucide="sparkles" class="w-4 h-4"></i>
                <?php echo e($statusLabel); ?>

              </span>
            </div>

            <div class="product-preview">
              <?php if($itemImage && Storage::disk('public')->exists($itemImage)): ?>
                <img src="<?php echo e(asset('storage/' . $itemImage)); ?>" alt="<?php echo e($item->nama ?? 'Foto barang'); ?>">
              <?php else: ?>
                <div class="empty-image">
                  <i data-lucide="image" class="w-12 h-12"></i>
                  <div>Belum ada foto barang.</div>
                </div>
              <?php endif; ?>
            </div>

            <div class="info-list">
              <div class="info-row">
                <div class="info-label">Nama Barang</div>
                <div class="info-value"><?php echo e($item->nama ?? '-'); ?></div>
              </div>
              <div class="info-row">
                <div class="info-label">Divisi Pemilik</div>
                <div class="info-value"><?php echo e(optional($item->divisi)->nama ?? '-'); ?></div>
              </div>
              <div class="info-row">
                <div class="info-label">Deskripsi</div>
                <div class="info-value"><?php echo e($item->deskripsi ?? 'Tidak ada deskripsi barang.'); ?></div>
              </div>
            </div>
          </article>

          <div class="grid gap-5">
            <article class="panel surface">
              <div class="panel-head">
                <div>
                  <div class="panel-eyebrow">Informasi Utama</div>
                  <h2 class="panel-title">Detail Permintaan</h2>
                </div>
              </div>

              <div class="info-list">
                <div class="info-row">
                  <div class="info-label">Peminjam</div>
                  <div class="info-value"><?php echo e(optional($borrowRequest->user)->name ?? '-'); ?></div>
                </div>
                <div class="info-row">
                  <div class="info-label">Tanggal Pinjam</div>
                  <div class="info-value"><?php echo e($borrowDate ?? '-'); ?></div>
                </div>
                <div class="info-row">
                  <div class="info-label">Rencana Kembali</div>
                  <div class="info-value"><?php echo e($returnPlan ?? '-'); ?></div>
                </div>
                <?php if($actualReturn): ?>
                  <div class="info-row">
                    <div class="info-label">Dikembalikan</div>
                    <div class="info-value text-green-700"><?php echo e($actualReturn); ?></div>
                  </div>
                <?php endif; ?>
                <div class="info-row">
                  <div class="info-label">Jumlah</div>
                  <div class="info-value"><?php echo e($borrowRequest->jumlah ?? '-'); ?> Unit</div>
                </div>
                <div class="info-row">
                  <div class="info-label">Status Saat Ini</div>
                  <div class="info-value">
                    <span class="status-badge <?php echo e($statusClass); ?>"><?php echo e($statusLabel); ?></span>
                  </div>
                </div>
              </div>

              <?php if($borrowRequest->comment): ?>
                <div class="note-box">
                  <div class="flex items-center gap-2 font-black text-blue-950 mb-2">
                    <i data-lucide="message-square-text" class="w-4 h-4"></i>
                    Catatan Peminjaman
                  </div>
                  <div class="text-sm leading-7"><?php echo e($borrowRequest->comment); ?></div>
                </div>
              <?php endif; ?>

              <?php if(
                (auth()->user()->role === 'staff_bidang' && $borrowRequest->status === 'pending') ||
                (auth()->user()->role === 'user' && $borrowRequest->status === 'revision_requested')
              ): ?>
                <div class="action-panel">
                  <?php if(auth()->user()->role === 'staff_bidang' && $borrowRequest->status === 'pending'): ?>
                    <form action="<?php echo e(route('borrow.approve', $borrowRequest->id)); ?>" method="POST">
                      <?php echo csrf_field(); ?>
                      <?php echo method_field('PATCH'); ?>
                      <button type="submit" class="btn-green">
                        <i data-lucide="check" class="w-4 h-4"></i>
                        Setujui
                      </button>
                    </form>

                    <form action="<?php echo e(route('borrow.reject', $borrowRequest->id)); ?>" method="POST">
                      <?php echo csrf_field(); ?>
                      <?php echo method_field('PATCH'); ?>
                      <button type="submit" class="btn-danger">
                        <i data-lucide="x" class="w-4 h-4"></i>
                        Tolak
                      </button>
                    </form>

                    <?php if(Route::has('borrow.revision')): ?>
                      <form action="<?php echo e(route('borrow.revision', $borrowRequest->id)); ?>" method="POST">
                        <?php echo csrf_field(); ?>
                        <?php echo method_field('PATCH'); ?>
                        <button type="submit" class="btn-amber">
                          <i data-lucide="pencil" class="w-4 h-4"></i>
                          Minta Revisi
                        </button>
                      </form>
                    <?php endif; ?>
                  <?php endif; ?>

                  <?php if(auth()->user()->role === 'user' && $borrowRequest->status === 'revision_requested'): ?>
                    <a href="<?php echo e(route('borrow.edit', $borrowRequest->id)); ?>" class="btn-amber">
                      <i data-lucide="pencil" class="w-4 h-4"></i>
                      Revisi Permintaan
                    </a>
                  <?php endif; ?>
                </div>
              <?php endif; ?>
            </article>

            <article class="panel surface">
              <div class="timeline">
                <div class="panel-eyebrow">Jejak Aktivitas</div>
                <h2 class="panel-title">Riwayat Persetujuan</h2>

                <?php if($borrowRequest->histories && $borrowRequest->histories->count()): ?>
                  <div class="timeline-list">
                    <?php $__currentLoopData = $borrowRequest->histories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $history): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <?php
                        $action = strtolower($history->action ?? '');
                        $dotClass = match (true) {
                          str_contains($action, 'reject') => 'red',
                          str_contains($action, 'revision') => 'amber',
                          str_contains($action, 'approve'), str_contains($action, 'return') => 'green',
                          default => '',
                        };
                      ?>
                      <div class="timeline-item">
                        <div class="timeline-dot <?php echo e($dotClass); ?>">
                          <i data-lucide="<?php echo e($dotClass === 'red' ? 'x' : ($dotClass === 'amber' ? 'pencil' : 'check')); ?>" class="w-5 h-5"></i>
                        </div>
                        <div class="timeline-card">
                          <p class="timeline-title"><?php echo e(ucwords(str_replace('_', ' ', $history->action))); ?></p>
                          <div class="timeline-meta">
                            <?php echo e($history->user->name ?? 'System'); ?> · <?php echo e($history->role ?? '-'); ?> · <?php echo e(optional($history->created_at)->format('d M Y, H:i')); ?>

                          </div>
                          <?php if($history->comment): ?>
                            <div class="timeline-comment"><?php echo e($history->comment); ?></div>
                          <?php endif; ?>
                        </div>
                      </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                  </div>
                <?php else: ?>
                  <div class="empty-state">
                    <i data-lucide="history" class="w-8 h-8 mx-auto mb-3"></i>
                    Belum ada riwayat aktivitas.
                  </div>
                <?php endif; ?>
              </div>
            </article>
          </div>
        </section>
      </div>
    </main>
  </div>

  <script>
    if (window.lucide) {
      window.lucide.createIcons();
    }
  </script>
</body>

</html>
<?php /**PATH /Users/Afifudin/Downloads/Magang/SIpian_2026-05-06/resources/views/borrow/show.blade.php ENDPATH**/ ?>