<?php $__env->startSection('title', 'Dashboard - SI Apotek'); ?>

<?php $__env->startSection('content'); ?>
<h2 class="my-6 text-2xl font-semibold text-gray-700">
    Beranda
</h2>

<!-- Cards -->
<div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
    <!-- Card 1: Total Obat -->
    <div class="flex items-center p-4 bg-white rounded-lg shadow-sm border border-gray-100">
        <div class="p-3 mr-4 text-emerald-500 bg-emerald-100 rounded-full">
            <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path></svg>
        </div>
        <div>
            <p class="mb-1 text-sm font-medium text-gray-500">Total Macam Obat</p>
            <p class="text-2xl font-bold text-gray-700"><?php echo e($totalMedicines ?? 0); ?></p>
        </div>
    </div>
    
    <!-- Card 2: Stok Menipis -->
    <div class="flex items-center p-4 bg-white rounded-lg shadow-sm border border-gray-100 border-l-4 border-l-red-500">
        <div class="p-3 mr-4 text-red-500 bg-red-100 rounded-full">
            <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg>
        </div>
        <div>
            <p class="mb-1 text-sm font-medium text-gray-500">Obat Stok Minim</p>
            <p class="text-2xl font-bold text-gray-700"><?php echo e($lowStockCount ?? 0); ?></p>
        </div>
    </div>

    <!-- Card 3: Mendekati Expired -->
    <div class="flex items-center p-4 bg-white rounded-lg shadow-sm border border-gray-100 border-l-4 border-l-orange-500">
        <div class="p-3 mr-4 text-orange-500 bg-orange-100 rounded-full">
            <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
        </div>
        <div>
            <p class="mb-1 text-sm font-medium text-gray-500">Obat Mendekati ED</p>
            <p class="text-2xl font-bold text-gray-700"><?php echo e($expiringCount ?? 0); ?></p>
        </div>
    </div>
</div>

<!-- Warning System: Stok Menipis -->
<h3 class="mb-4 text-lg font-semibold text-gray-700 flex items-center gap-2">
    <svg class="w-5 h-5 text-red-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg>
    Peringatan Stok Menipis
</h3>
<div class="w-full mb-8 overflow-hidden rounded-lg shadow-sm border border-gray-200">
    <div class="w-full overflow-x-auto">
        <table class="w-full whitespace-no-wrap">
            <thead>
                <tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b bg-gray-50">
                    <th class="px-4 py-3">Nama Obat</th>
                    <th class="px-4 py-3">Kategori</th>
                    <th class="px-4 py-3">Stok Saat Ini</th>
                    <th class="px-4 py-3">Batas Minimum</th>
                </tr>
            </thead>
            <tbody class="bg-white divide-y">
                <?php $__empty_1 = true; $__currentLoopData = $lowStockMedicines ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $med): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr class="text-gray-700 hover:bg-gray-50">
                    <td class="px-4 py-3">
                        <div class="font-semibold text-sm"><?php echo e($med->name); ?></div>
                        <div class="text-xs text-gray-500"><?php echo e($med->code ?? '-'); ?></div>
                    </td>
                    <td class="px-4 py-3 text-sm"><?php echo e($med->category->name ?? '-'); ?></td>
                    <td class="px-4 py-3 text-sm">
                        <span class="px-2 py-1 font-semibold leading-tight text-red-700 bg-red-100 rounded-full">
                            <?php echo e($med->current_stock); ?> <?php echo e($med->unit->name ?? ''); ?>

                        </span>
                    </td>
                    <td class="px-4 py-3 text-sm font-semibold"><?php echo e($med->min_stock); ?></td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="4" class="px-4 py-8 text-sm text-center text-gray-500">
                        <svg class="w-12 h-12 mx-auto text-emerald-300 mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
                        Semua stok obat dalam kondisi aman.
                    </td>
                </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>

<!-- Warning System: Expired Date -->
<h3 class="mb-4 text-lg font-semibold text-gray-700 flex items-center gap-2 mt-8">
    <svg class="w-5 h-5 text-orange-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
    Peringatan Kedaluwarsa (ED < 90 Hari)
</h3>
<div class="w-full mb-8 overflow-hidden rounded-lg shadow-sm border border-gray-200">
    <div class="w-full overflow-x-auto">
        <table class="w-full whitespace-no-wrap">
            <thead>
                <tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b bg-gray-50">
                    <th class="px-4 py-3">Nama Obat</th>
                    <th class="px-4 py-3">Kategori</th>
                    <th class="px-4 py-3 text-center">Batch</th>
                    <th class="px-4 py-3 text-center">Expired Date</th>
                    <th class="px-4 py-3 text-center">Status</th>
                </tr>
            </thead>
            <tbody class="bg-white divide-y">
                <?php $__empty_1 = true; $__currentLoopData = $expiringBatches ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $batch): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <?php
                    $daysRemaining = \Carbon\Carbon::now()->diffInDays(\Carbon\Carbon::parse($batch->expired_date), false);
                ?>
                <tr class="text-gray-700 hover:bg-gray-50">
                    <td class="px-4 py-3">
                        <div class="font-semibold text-sm"><?php echo e($batch->medicine->name ?? 'Obat Terhapus'); ?></div>
                        <div class="text-xs text-gray-500"><?php echo e($batch->medicine->code ?? '-'); ?></div>
                    </td>
                    <td class="px-4 py-3 text-sm"><?php echo e($batch->medicine->category->name ?? '-'); ?></td>
                    <td class="px-4 py-3 text-sm text-center"><?php echo e($batch->batch_number ?? '-'); ?></td>
                    <td class="px-4 py-3 text-sm text-center font-semibold text-orange-600">
                        <?php echo e(\Carbon\Carbon::parse($batch->expired_date)->format('d/m/Y')); ?>

                    </td>
                    <td class="px-4 py-3 text-sm text-center">
                        <?php if($daysRemaining < 0): ?>
                            <span class="px-2 py-1 font-semibold leading-tight text-red-700 bg-red-100 rounded-full text-xs">Kedaluwarsa</span>
                        <?php else: ?>
                            <span class="px-2 py-1 font-semibold leading-tight text-orange-700 bg-orange-100 rounded-full text-xs">Sisa <?php echo e(intval($daysRemaining)); ?> Hari</span>
                        <?php endif; ?>
                    </td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="5" class="px-4 py-8 text-sm text-center text-gray-500">
                        <svg class="w-12 h-12 mx-auto text-emerald-300 mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
                        Tidak ada obat yang mendekati tanggal kedaluwarsa.
                    </td>
                </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\PROJECT\xampp\htdocs\apoteks\resources\views/dashboard.blade.php ENDPATH**/ ?>