<!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" />
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>Permintaan Barang</title>
    <link rel="icon" type="image/svg+xml" href="{{ asset('favicon.svg') }}">

    <script src="https://cdn.tailwindcss.com"></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.9);
            --text: #172554;
            --muted: #64748b;
            --line: #dbe6f7;
            --primary: #4f46e5;
            --secondary: #2563eb;
            --cyan: #38bdf8;
            --shadow-soft: 0 28px 55px rgba(59, 84, 145, 0.10);
            --shadow-card: 0 18px 32px rgba(148, 163, 184, 0.12);
        }

        * {
            box-sizing: border-box;
        }

        body {
            margin: 0;
            font-family: 'Inter', system-ui, -apple-system, sans-serif;
            color: var(--text);
            background:
                radial-gradient(circle at top left, rgba(79, 70, 229, 0.08), transparent 20%),
                radial-gradient(circle at top right, rgba(56, 189, 248, 0.08), transparent 22%),
                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: 1480px;
            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-card {
            border-radius: 32px;
            overflow: hidden;
            padding: 24px;
            background:
                radial-gradient(circle at top right, rgba(99, 102, 241, 0.14), transparent 22%),
                linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(243, 247, 255, 0.96) 100%);
        }

        .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: 800;
            letter-spacing: 0.14em;
            text-transform: uppercase;
            border: 1px solid rgba(99, 102, 241, 0.10);
        }

        .hero-title {
            margin: 16px 0 8px;
            font-size: clamp(30px, 4vw, 44px);
            line-height: 0.98;
            letter-spacing: -0.05em;
            font-weight: 900;
        }

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

        .hero-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            margin-top: 18px;
        }

        .action-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            min-height: 46px;
            padding: 0 18px;
            border-radius: 18px;
            text-decoration: none;
            font-size: 14px;
            font-weight: 800;
            transition: all 0.2s ease;
        }

        .action-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);
        }

        .action-btn.soft {
            color: var(--text);
            background: #fff;
            border: 1px solid var(--line);
        }

        .action-btn:hover {
            transform: translateY(-1px);
        }

        .hero-mini-grid {
            margin-top: 22px;
            display: grid;
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 16px;
        }

        .hero-mini-card {
            position: relative;
            overflow: hidden;
            min-height: 136px;
            padding: 24px 22px;
            border-radius: 24px;
            background: rgba(255, 255, 255, 0.88);
            border: 1px solid rgba(214, 226, 247, 0.98);
            box-shadow: var(--shadow-card);
        }

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

        .hero-mini-card.primary::after {
            background: #ede9fe;
        }

        .hero-mini-card.green::after {
            background: #dcfce7;
        }

        .hero-mini-card.amber::after {
            background: #fff4df;
        }

        .hero-mini-card.red::after {
            background: #ffe7ec;
        }

        .hero-mini-top {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 12px;
        }

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

        .hero-mini-top i {
            position: relative;
            z-index: 1;
        }

        .hero-mini-value {
            margin-top: 12px;
            font-size: 32px;
            font-weight: 900;
            line-height: 1;
        }

        .hero-mini-card.primary .hero-mini-value {
            color: #4f46e5;
        }

        .hero-mini-card.green .hero-mini-value {
            color: #16a34a;
        }

        .hero-mini-card.amber .hero-mini-value {
            color: #f59e0b;
        }

        .hero-mini-card.red .hero-mini-value {
            color: #ef4444;
        }

        .hero-mini-sub {
            margin-top: 12px;
            color: var(--muted);
            font-size: 13px;
            line-height: 1.5;
        }

        .alert {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 16px 18px;
            border-radius: 22px;
            border: 1px solid #bbf7d0;
            background: #f0fdf4;
            color: #15803d;
            font-size: 14px;
            font-weight: 700;
        }

        .inventory-card {
            border-radius: 32px;
            overflow: hidden;
            background:
                radial-gradient(circle at top right, rgba(99, 102, 241, 0.12), transparent 22%),
                linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(243, 247, 255, 0.96) 100%);
        }

        .inventory-head {
            padding: 22px 24px;
            display: flex;
            justify-content: space-between;
            gap: 16px;
            align-items: center;
            border-bottom: 1px solid rgba(219, 230, 247, 0.95);
        }

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

        .inventory-subtitle {
            margin: 6px 0 0;
            color: var(--muted);
            font-size: 13px;
            line-height: 1.6;
        }

        .inventory-head-right {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: flex-end;
        }

        .inventory-chip,
        .inventory-meta {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            min-height: 40px;
            padding: 0 14px;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.88);
            border: 1px solid rgba(214, 226, 247, 0.98);
            color: #233876;
            font-size: 12px;
            font-weight: 800;
            box-shadow: 0 10px 20px rgba(148, 163, 184, 0.10);
        }

        .inventory-chip.pending {
            color: #b45309;
            background: #fffbeb;
            border-color: #fde68a;
        }

        .inventory-chip.approved {
            color: #15803d;
            background: #f0fdf4;
            border-color: #bbf7d0;
        }

        /* -------------------------------------------
           DESAIN BARU CARD STOK BARANG
           ------------------------------------------- */
        .stock-grid {
            padding: 24px;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
            gap: 20px;
        }

        .stock-card {
            position: relative;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            cursor: pointer;
            color: inherit;
            text-decoration: none;
            border-radius: 24px;
            background: #ffffff;
            border: 1px solid #e2e8f0;
            box-shadow: 0 4px 6px -1px rgba(148, 163, 184, 0.1), 0 2px 4px -1px rgba(148, 163, 184, 0.06);
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .stock-card:focus-visible {
            outline: 3px solid rgba(79, 70, 229, 0.35);
            outline-offset: 3px;
        }

        .stock-card:hover {
            transform: translateY(-5px);
            border-color: #a5b4fc;
            box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.1), 0 10px 10px -5px rgba(79, 70, 229, 0.04);
        }

        .stock-card-photo {
            position: relative;
            height: 160px;
            background: #f8fafc;
            overflow: hidden;
        }

        .stock-card-photo img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s ease;
        }

        .stock-card:hover .stock-card-photo img {
            transform: scale(1.08);
        }

        .stock-card-photo::after {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(to top, rgba(15, 23, 42, 0.3) 0%, transparent 40%);
            pointer-events: none;
        }

        .stock-badge-float {
            position: absolute;
            top: 12px;
            right: 12px;
            z-index: 10;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            border-radius: 999px;
            font-size: 11px;
            font-weight: 800;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            backdrop-filter: blur(8px);
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .stock-badge-float.available {
            background: rgba(16, 185, 129, 0.9);
            color: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .stock-badge-float.low {
            background: rgba(245, 158, 11, 0.9);
            color: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .stock-badge-float.empty {
            background: rgba(225, 29, 72, 0.9);
            color: #ffffff;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .stock-card-body {
            padding: 20px;
            flex: 1;
            display: flex;
            flex-direction: column;
        }

        .stock-card-title {
            margin: 0;
            color: #0f172a;
            font-size: 17px;
            font-weight: 900;
            line-height: 1.3;
            display: -webkit-box;
            -webkit-line-clamp: 1;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .stock-card-desc {
            margin: 8px 0 0;
            color: #64748b;
            font-size: 13px;
            line-height: 1.5;
            flex: 1;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .stock-card-footer {
            margin-top: 18px;
            padding-top: 16px;
            border-top: 1px dashed #cbd5e1;
            display: flex;
            align-items: flex-end;
            justify-content: space-between;
        }

        .stock-amount-label {
            display: block;
            font-size: 11px;
            color: #94a3b8;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-bottom: 4px;
        }

        .stock-count {
            display: flex;
            align-items: baseline;
            gap: 4px;
            color: #4f46e5;
        }

        .stock-count strong {
            font-size: 26px;
            line-height: 1;
            font-weight: 900;
            letter-spacing: -0.02em;
        }

        .stock-count span {
            color: #64748b;
            font-size: 13px;
            font-weight: 700;
        }

        .stock-action-icon {
            width: 34px;
            height: 34px;
            border-radius: 12px;
            background: #f1f5f9;
            color: #64748b;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
        }

        .stock-card:hover .stock-action-icon {
            background: #4f46e5;
            color: #ffffff;
            transform: translateX(4px);
        }

        /* -------------------------------------------
           DESAIN BARU CARD DAFTAR PERMINTAAN
           ------------------------------------------- */
        .request-list-grid {
            padding: 24px;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            gap: 20px;
        }

        .request-card-item {
            position: relative;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            border-radius: 26px;
            background: #ffffff;
            border: 1px solid #e2e8f0;
            box-shadow: 0 4px 6px -1px rgba(148, 163, 184, 0.1), 0 2px 4px -1px rgba(148, 163, 184, 0.06);
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .request-card-item:hover {
            transform: translateY(-5px);
            border-color: #a5b4fc;
            box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.1), 0 10px 10px -5px rgba(79, 70, 229, 0.04);
        }

        .request-card-image {
            position: relative;
            height: 180px;
            background: #f8fafc;
            overflow: hidden;
        }

        .request-card-image img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s ease;
        }

        .request-card-item:hover .request-card-image img {
            transform: scale(1.08);
        }

        .request-card-image::after {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(to top, rgba(15, 23, 42, 0.35) 0%, transparent 45%);
            pointer-events: none;
        }

        .request-badge-float {
            position: absolute;
            top: 14px;
            right: 14px;
            z-index: 10;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 14px;
            border-radius: 999px;
            font-size: 11px;
            font-weight: 800;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            backdrop-filter: blur(8px);
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
        }

        .request-badge-float.approved {
            background: rgba(16, 185, 129, 0.9);
            color: #fff;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .request-badge-float.cancelled {
            background: rgba(225, 29, 72, 0.9);
            color: #fff;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .request-badge-float.pending {
            background: rgba(245, 158, 11, 0.9);
            color: #fff;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .request-card-body {
            padding: 20px;
            display: flex;
            flex-direction: column;
            flex: 1;
        }

        .request-card-name {
            margin: 0;
            color: #0f172a;
            font-size: 17px;
            font-weight: 900;
            line-height: 1.3;
        }

        .request-card-purpose {
            margin: 8px 0 0;
            color: #64748b;
            font-size: 13px;
            line-height: 1.55;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            min-height: 40px;
        }

        .request-card-meta {
            margin-top: 14px;
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }

        .quantity-chip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            border-radius: 999px;
            font-size: 12px;
            font-weight: 800;
            color: #1d4ed8;
            background: #eff6ff;
            border: 1px solid #bfdbfe;
        }

        .request-card-info-grid {
            margin-top: 18px;
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 12px;
        }

        .request-card-info {
            border-radius: 14px;
            padding: 12px;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            transition: background 0.2s, border-color 0.2s;
        }

        .request-card-item:hover .request-card-info {
            background: #eff6ff;
            border-color: #dbeafe;
        }

        .request-card-info-label {
            color: #64748b;
            font-size: 10px;
            font-weight: 900;
            letter-spacing: 0.08em;
            text-transform: uppercase;
        }

        .request-card-info-value {
            margin-top: 4px;
            color: #1e293b;
            font-size: 13px;
            font-weight: 800;
            line-height: 1.3;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .request-card-footer {
            margin-top: auto;
            padding-top: 18px;
            border-top: 1px dashed #cbd5e1;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .request-date-text {
            font-size: 12px;
            font-weight: 700;
            color: #64748b;
        }

        .pdf-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 8px 16px;
            border-radius: 12px;
            background: #fee2e2;
            color: #b91c1c;
            font-size: 12px;
            font-weight: 800;
            text-decoration: none;
            transition: all 0.2s ease;
        }

        .pdf-btn:hover {
            background: #fecaca;
            transform: translateY(-2px);
            box-shadow: 0 4px 6px rgba(220, 38, 38, 0.15);
        }

        .no-pdf-text {
            font-size: 12px;
            font-weight: 800;
            color: #94a3b8;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .empty-state {
            min-height: 260px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 12px;
            color: #64748b;
            text-align: center;
            padding: 36px;
        }

        .empty-icon {
            width: 70px;
            height: 70px;
            border-radius: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #4f46e5;
            background: #eef2ff;
            border: 1px solid #dbeafe;
        }

        @media (max-width:1024px) {
            .app {
                display: block;
            }

            .content {
                padding: 20px;
                padding-top: 84px;
            }

            .hero-mini-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }

            .inventory-head {
                flex-direction: column;
                align-items: stretch;
            }

            .inventory-head-right {
                justify-content: flex-start;
            }

            .request-list-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
        }

        @media (max-width:760px) {
            .content {
                padding: 16px;
                padding-top: 84px;
            }

            .hero-card,
            .inventory-card {
                border-radius: 24px;
            }

            .hero-mini-grid {
                grid-template-columns: 1fr;
            }

            .hero-actions {
                flex-direction: column;
            }

            .action-btn {
                width: 100%;
            }

            .stock-grid {
                grid-template-columns: 1fr;
                padding: 16px;
            }

            .request-list-grid {
                grid-template-columns: 1fr;
                padding: 16px;
            }

            .request-card-info-grid {
                grid-template-columns: 1fr;
            }

            .request-card-footer {
                flex-direction: column;
                align-items: stretch;
                gap: 12px;
            }

            .pdf-btn {
                width: 100%;
                justify-content: center;
            }
        }
    </style>
</head>

<body>
    <div class="app">
        @include('partials.sidebar')

        <main class="content">
            <div class="shell">
                @php
                $totalRequests = $requests->total();
                $pageRequests = $requests->getCollection();
                $approvedCount = $pageRequests->where('status', 'approved')->count();
                $pendingCount = $pageRequests->where('status', 'pending')->count();
                $cancelledCount = $pageRequests->where('status', 'cancelled')->count();
                @endphp

                <!-- HERO SECTION -->
                <section class="hero-card surface">
                    <span class="pill">
                        <i data-lucide="clipboard-list" class="w-4 h-4"></i>
                        Permintaan Barang
                    </span>
                    <h1 class="hero-title">Permintaan Barang Operasional</h1>
                    <p class="hero-text">
                        @if(auth()->user()->role === 'sekretariat')
                        Pantau seluruh permintaan barang dari user, termasuk jumlah, surat pengajuan, target realisasi, dan status persetujuan.
                        @else
                        Lihat dan pantau permintaan barang yang Anda ajukan untuk kebutuhan operasional kerja.
                        @endif
                    </p>
                    <div class="hero-actions">
                        <a href="{{ route('item-requests.create') }}" class="action-btn primary">
                            <i data-lucide="plus" class="w-4 h-4"></i>
                            Buat Permintaan
                        </a>
                    </div>

                    <div class="hero-mini-grid">
                        <div class="hero-mini-card primary">
                            <div class="hero-mini-top">
                                <div class="hero-mini-label">Total Permintaan</div>
                                <i data-lucide="files" class="w-5 h-5 text-indigo-600"></i>
                            </div>
                            <div class="hero-mini-value">{{ $totalRequests }}</div>
                            <div class="hero-mini-sub">Semua data sesuai akses Anda.</div>
                        </div>
                        <div class="hero-mini-card green">
                            <div class="hero-mini-top">
                                <div class="hero-mini-label">Disetujui</div>
                                <i data-lucide="badge-check" class="w-5 h-5 text-green-600"></i>
                            </div>
                            <div class="hero-mini-value">{{ $approvedCount }}</div>
                            <div class="hero-mini-sub">Baik dan sesuai quantity.</div>
                        </div>
                        <div class="hero-mini-card amber">
                            <div class="hero-mini-top">
                                <div class="hero-mini-label">Menunggu</div>
                                <i data-lucide="clock-3" class="w-5 h-5 text-amber-500"></i>
                            </div>
                            <div class="hero-mini-value">{{ $pendingCount }}</div>
                            <div class="hero-mini-sub">Belum diproses admin.</div>
                        </div>
                        <div class="hero-mini-card red">
                            <div class="hero-mini-top">
                                <div class="hero-mini-label">Belum Diterima</div>
                                <i data-lucide="x-circle" class="w-5 h-5 text-red-500"></i>
                            </div>
                            <div class="hero-mini-value">{{ $cancelledCount }}</div>
                            <div class="hero-mini-sub">Status cancel atau belum diterima.</div>
                        </div>
                    </div>
                </section>

                @if(session('success'))
                <div class="alert">
                    <i data-lucide="check-circle-2" class="w-5 h-5"></i>
                    <span>{{ session('success') }}</span>
                </div>
                @endif

                <!-- SECTION STOK BARANG -->
                <section class="inventory-card surface">
                    <div class="inventory-head">
                        <div>
                            <h2 class="inventory-title">Daftar Stok Barang</h2>
                            <p class="inventory-subtitle">
                                Cek stok barang yang tersedia sebelum membuat permintaan, supaya jumlah yang diajukan sesuai sisa stok.
                            </p>
                        </div>
                        <div class="inventory-head-right">
                            <div class="inventory-meta">
                                <i data-lucide="package-search" class="w-4 h-4"></i>
                                {{ $stockItems->count() }} Tipe Barang
                            </div>
                        </div>
                    </div>

                    <div class="stock-grid">
                        @forelse($stockItems as $stockItem)
                        @php
                        $stockValue = (float) $stockItem->stock;
                        $minStock = (float) $stockItem->min_stock;
                        $stockLabel = rtrim(rtrim(number_format($stockValue, 2, '.', ''), '0'), '.');
                        $isEmpty = $stockValue <= 0;
                        $isLow = !$isEmpty && $stockValue <= $minStock;
                            @endphp
                            <a href="{{ route('item-requests.items.show', $stockItem) }}" class="stock-card group" aria-label="Lihat detail {{ $stockItem->display_name }}">
                            <div class="stock-card-photo">
                                @if($isEmpty)
                                <div class="stock-badge-float empty">
                                    <i data-lucide="x-octagon" class="w-3 h-3"></i> Habis
                                </div>
                                @elseif($isLow)
                                <div class="stock-badge-float low">
                                    <i data-lucide="alert-triangle" class="w-3 h-3"></i> Menipis
                                </div>
                                @else
                                <div class="stock-badge-float available">
                                    <i data-lucide="check-circle-2" class="w-3 h-3"></i> Tersedia
                                </div>
                                @endif

                                <img
                                    src="{{ $stockItem->image_url ?: 'https://via.placeholder.com/500x320?text=No+Image' }}"
                                    alt="{{ $stockItem->display_name }}"
                                    onerror="this.onerror=null;this.src='https://via.placeholder.com/500x320?text=No+Image';">
                            </div>

                            <div class="stock-card-body">
                                <h3 class="stock-card-title">{{ $stockItem->display_name }}</h3>
                                <p class="stock-card-desc">{{ $stockItem->description ?: 'Barang tersedia untuk diajukan sesuai kebutuhan operasional.' }}</p>

                                <div class="stock-card-footer">
                                    <div>
                                        <span class="stock-amount-label">Sisa Stok</span>
                                        <div class="stock-count">
                                            <strong>{{ $stockLabel }}</strong>
                                            <span>{{ $stockItem->unit }}</span>
                                        </div>
                                    </div>
                                    <div class="stock-action-icon">
                                        <i data-lucide="arrow-right" class="w-4 h-4"></i>
                                    </div>
                                </div>
                            </div>
                            </a>
                            @empty
                            <div class="empty-state col-span-full">
                                <div class="empty-icon">
                                    <i data-lucide="package-x" class="w-8 h-8"></i>
                                </div>
                                <div class="font-black text-slate-800">Belum ada stok barang</div>
                                <div class="text-sm text-slate-500">Stok barang permintaan akan tampil di sini setelah diaktifkan admin.</div>
                            </div>
                            @endforelse
                    </div>
                </section>

                <!-- SECTION DAFTAR PERMINTAAN (YANG DIPERMAK) -->
                <section class="inventory-card surface">
                    <div class="inventory-head">
                        <div>
                            <h2 class="inventory-title">Daftar Permintaan Barang</h2>
                            <p class="inventory-subtitle">
                                @if(auth()->user()->role === 'sekretariat')
                                Menampilkan seluruh permintaan barang yang masuk ke sistem.
                                @else
                                Menampilkan riwayat permintaan barang yang Anda ajukan.
                                @endif
                            </p>
                        </div>
                        <div class="inventory-head-right">
                            <div class="inventory-chip pending">
                                <i data-lucide="clock-3" class="w-4 h-4"></i>
                                {{ $pendingCount }} Menunggu
                            </div>
                            <div class="inventory-chip approved">
                                <i data-lucide="badge-check" class="w-4 h-4"></i>
                                {{ $approvedCount }} Disetujui
                            </div>
                            <div class="inventory-meta">
                                <i data-lucide="files" class="w-4 h-4"></i>
                                {{ $totalRequests }} data
                            </div>
                        </div>
                    </div>

                    <div class="request-list-grid">
                        @forelse($requests as $request)
                        <article class="request-card-item group">
                            <div class="request-card-image">
                                <!-- Floating Badge Status Permintaan -->
                                @if($request->status === 'approved')
                                <div class="request-badge-float approved">
                                    <i data-lucide="check-circle-2" class="w-3 h-3"></i> Baik
                                </div>
                                @elseif($request->status === 'cancelled')
                                <div class="request-badge-float cancelled">
                                    <i data-lucide="x-circle" class="w-3 h-3"></i> Batal
                                </div>
                                @else
                                <div class="request-badge-float pending">
                                    <i data-lucide="clock" class="w-3 h-3"></i> Menunggu
                                </div>
                                @endif

                                <img
                                    src="{{ $request->image_url_snapshot ?: 'https://via.placeholder.com/500x320?text=No+Image' }}"
                                    alt="{{ $request->item_name_snapshot }}"
                                    onerror="this.onerror=null;this.src='https://via.placeholder.com/500x320?text=No+Image';">
                            </div>

                            <div class="request-card-body">
                                <h3 class="request-card-name">{{ $request->item_name_snapshot }}</h3>
                                <p class="request-card-purpose">{{ $request->purpose ?: 'Tidak ada keterangan tambahan dari pemohon.' }}</p>

                                <div class="request-card-meta">
                                    <span class="quantity-chip">
                                        <i data-lucide="hash" class="w-4 h-4"></i>
                                        {{ rtrim(rtrim(number_format($request->quantity, 2, '.', ''), '0'), '.') }} {{ $request->unit_snapshot }}
                                    </span>
                                </div>

                                <div class="request-card-info-grid">
                                    <div class="request-card-info">
                                        <div class="request-card-info-label">Pemohon</div>
                                        <div class="request-card-info-value" title="{{ $request->user->name ?? '-' }}">
                                            {{ $request->user->name ?? '-' }}
                                        </div>
                                    </div>
                                    <div class="request-card-info">
                                        <div class="request-card-info-label">Divisi</div>
                                        <div class="request-card-info-value" title="{{ $request->user->divisi->nama ?? '-' }}">
                                            {{ $request->user->divisi->nama ?? '-' }}
                                        </div>
                                    </div>
                                    <div class="request-card-info">
                                        <div class="request-card-info-label">Tgl Realisasi</div>
                                        <div class="request-card-info-value">
                                            {{ $request->realization_date ? $request->realization_date->format('d M Y') : '-' }}
                                        </div>
                                    </div>
                                    <div class="request-card-info">
                                        <div class="request-card-info-label">File Surat</div>
                                        <div class="request-card-info-value">
                                            {{ $request->letter_file_path ? 'Terlampir' : '-' }}
                                        </div>
                                    </div>
                                </div>

                                <div class="request-card-footer">
                                    <span class="request-date-text">
                                        Diajukan: {{ optional($request->request_date)->format('d M Y') }}
                                    </span>

                                    @if($request->letter_file_path)
                                    <a href="{{ $request->letter_file_path }}" target="_blank" rel="noopener noreferrer" class="pdf-btn">
                                        <i data-lucide="file-text" class="w-4 h-4"></i>
                                        Buka PDF
                                    </a>
                                    @else
                                    <span class="no-pdf-text">
                                        <i data-lucide="file-minus" class="w-4 h-4"></i>
                                        Tanpa PDF
                                    </span>
                                    @endif
                                </div>
                            </div>
                        </article>
                        @empty
                        <div class="empty-state col-span-full">
                            <div class="empty-icon">
                                <i data-lucide="inbox" class="w-8 h-8"></i>
                            </div>
                            <div class="font-black text-slate-800">Belum ada permintaan barang</div>
                            <div class="text-sm text-slate-500">Silakan buat permintaan baru untuk kebutuhan operasional.</div>
                        </div>
                        @endforelse
                    </div>

                    <div class="px-6 py-4 border-t border-slate-200 bg-white/70">
                        {{ $requests->links() }}
                    </div>
                </section>
            </div>
        </main>
    </div>

    <script>
        lucide.createIcons();
    </script>
</body>

</html>
