@page "/admin/inventory/suppliers"
@layout AdminLayout
@inherits AdminBase

@*
    EN: Supplier Management — supplier list, add supplier, order history, ratings.
    VI: Quản lý nhà cung cấp — danh sách NCC, thêm NCC, lịch sử đặt, đánh giá.
    Design: pencil-design/src/pages/tPOS/admin/supplier-management.pen
*@

<PageTitle>Nhà cung cấp — GoodGo Admin</PageTitle>

@* ═══ TOP BAR ═══ *@
<div class="admin-topbar">
    <div class="admin-topbar__left">
        <h1 class="admin-topbar__title">Nhà cung cấp</h1>
        <p class="admin-topbar__subtitle">@_suppliers.Length nhà cung cấp • Quản lý & đánh giá</p>
    </div>
    <div class="admin-topbar__right">
        <div class="admin-search" style="width:220px;">
            <i data-lucide="search"></i>
            <input type="text" placeholder="Tìm NCC..." @bind="SearchQuery" />
        </div>
        <button class="admin-btn-primary">
            <i data-lucide="plus"></i>
            <span>Thêm NCC</span>
        </button>
    </div>
</div>

@* ═══ CONTENT ═══ *@
<div class="admin-content" style="display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:20px;">
    @foreach (var sup in _suppliers)
    {
        <div class="admin-staff-card">
            <div class="admin-staff-card__header">
                <div style="display:flex;align-items:center;gap:12px;">
                    <div class="admin-user-avatar" style="background-color:@sup.Color;">@sup.Initials</div>
                    <div>
                        <div style="font-size:14px;font-weight:600;">@sup.Name</div>
                        <div style="font-size:11px;color:var(--admin-text-tertiary);">@sup.Category</div>
                    </div>
                </div>
                <div class="admin-status-badge @(sup.Active ? "admin-status-badge--online" : "admin-status-badge--offline")" style="font-size:10px;padding:2px 8px;">
                    <span class="admin-status-badge__dot"></span>
                    @(sup.Active ? "Hoạt động" : "Ngưng")
                </div>
            </div>

            @* Contact info *@
            <div style="display:flex;flex-direction:column;gap:6px;">
                <div style="display:flex;align-items:center;gap:8px;">
                    <i data-lucide="phone" style="width:14px;height:14px;color:var(--admin-text-tertiary);"></i>
                    <span style="font-size:12px;color:var(--admin-text-secondary);">@sup.Phone</span>
                </div>
                <div style="display:flex;align-items:center;gap:8px;">
                    <i data-lucide="mail" style="width:14px;height:14px;color:var(--admin-text-tertiary);"></i>
                    <span style="font-size:12px;color:var(--admin-text-secondary);">@sup.Email</span>
                </div>
            </div>

            @* Stats *@
            <div style="display:flex;gap:12px;">
                <div class="admin-store-stat" style="flex:1;">
                    <div class="admin-store-stat__value">@sup.TotalOrders</div>
                    <div class="admin-store-stat__label">Đơn hàng</div>
                </div>
                <div class="admin-store-stat" style="flex:1;">
                    <div class="admin-store-stat__value">@sup.TotalValue</div>
                    <div class="admin-store-stat__label">Tổng tiền</div>
                </div>
                <div class="admin-store-stat" style="flex:1;">
                    <div class="admin-store-stat__value" style="color:@(sup.Rating >= 4 ? "#22C55E" : "#F59E0B");">@sup.Rating ★</div>
                    <div class="admin-store-stat__label">Đánh giá</div>
                </div>
            </div>
        </div>
    }
</div>

@code {
    private record SupplierItem(string Name, string Initials, string Color, string Category, string Phone, string Email, string TotalOrders, string TotalValue, double Rating, bool Active);
    private readonly SupplierItem[] _suppliers = new[]
    {
        new SupplierItem("Cà phê Trung Nguyên", "TN", "#FF5C00", "Nguyên liệu cà phê", "028 3820 1234", "order@trungnguyen.vn", "24", "86.5M", 4.8, true),
        new SupplierItem("Vinamilk", "VM", "#3B82F6", "Sữa & Dairy", "028 5413 0000", "b2b@vinamilk.vn", "18", "42.3M", 4.5, true),
        new SupplierItem("Metro Cash & Carry", "MC", "#22C55E", "Tổng hợp", "028 3742 0888", "supply@metro.vn", "32", "128.6M", 4.2, true),
        new SupplierItem("Đại Tân Phát", "ĐT", "#8B5CF6", "Bao bì & Dụng cụ", "028 3850 4567", "sales@daitanphat.vn", "15", "28.4M", 4.0, true),
        new SupplierItem("TH True Milk", "TH", "#EC4899", "Sữa & Dairy", "028 3930 1122", "order@thtruemilk.vn", "12", "18.8M", 4.6, true),
        new SupplierItem("Saigon Food", "SF", "#F59E0B", "Thực phẩm đông lạnh", "028 3820 5678", "info@saigonfood.vn", "8", "15.2M", 3.8, false),
    };
}
