﻿@model IEnumerable<WarehouseAppSHIPS.Models.Barang>

@{
    ViewData["Title"] = "Master Inventory";
}

<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">

<style>
    body {
        font-family: 'Plus Jakarta Sans', sans-serif !important;
        background-color: #f8f9fa;
    }
    .erp-card {
        background-color: #fff;
        padding: 24px;
        border-radius: 16px;
        border: 1px solid #e5e7eb;
        box-shadow: 0 4px 20px rgba(0,0,0,0.04);
        margin-bottom: 20px;
    }
    .status-aman { color: #10B981; font-weight: bold; background: #D1FAE5; padding: 5px 10px; border-radius: 6px;}
    .status-menipis { color: #F59E0B; font-weight: bold; background: #FEF3C7; padding: 5px 10px; border-radius: 6px;}
    .status-kosong { color: #EF4444; font-weight: bold; background: #FEE2E2; padding: 5px 10px; border-radius: 6px;}
</style>

<div class="container mt-4">
    <div class="erp-card">
        <h4 style="font-weight: 800; color: #0052CC; margin-bottom: 20px;">🗄️ Database Material SHIPS</h4>

        <form asp-controller="Barang" asp-action="Index" method="get" class="mb-4">
            <div class="input-group">
                <input type="text" name="searchString" class="form-control" placeholder="🔍 Cari Nama Barang atau Kode Aset..." />
                <button type="submit" class="btn btn-primary" style="background-color: #0052CC; border: none; font-weight: 600;">Cari Data</button>
            </div>
        </form>

        <div class="table-responsive">
            <table class="table table-hover align-middle">
                <thead style="background-color: #f1f5f9; border-bottom: 2px solid #e2e8f0;">
                    <tr>
                        <th>Kode Aset</th>
                        <th>Nama Material Lengkap</th>
                        <th>Kategori</th>
                        <th class="text-center">Stok Gudang</th>
                        <th class="text-center">Status</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model)
                    {
                        // Logika Penentuan Status Peringatan
                        string statusText = item.Stok == 0 ? "🔴 Kosong" : (item.Stok <= item.MinStok ? "🟠 Menipis" : "🟢 Aman");
                        string statusClass = item.Stok == 0 ? "status-kosong" : (item.Stok <= item.MinStok ? "status-menipis" : "status-aman");

                        <tr>
                            <td style="font-weight: 600; color: #475569;">@item.KodeAsset</td>
                            <td style="font-weight: 700;">@item.NamaBarang</td>
                            <td><span class="badge bg-secondary">@item.Kategori</span></td>
                            <td class="text-center"><h4 style="margin: 0; font-weight: 800;">@item.Stok</h4></td>
                            <td class="text-center"><span class="@statusClass">@statusText</span></td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>