@model LittleShop.DTOs.CreateProductDto

@{
    ViewData["Title"] = "Create Product";
    var categories = ViewData["Categories"] as IEnumerable<LittleShop.DTOs.CategoryDto>;
}

<div class="row mb-4">
    <div class="col">
        <h1><i class="fas fa-plus"></i> Create Product</h1>
    </div>
</div>

<div class="row">
    <div class="col-md-8">
        <div class="card">
            <div class="card-body">
                <form method="post" asp-area="Admin" asp-controller="Products" asp-action="Create">
                    @Html.AntiForgeryToken()
                    @if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count > 0)
                    {
                        <div class="alert alert-danger" role="alert">
                            @foreach (var error in ViewData.ModelState[""].Errors)
                            {
                                <div>@error.ErrorMessage</div>
                            }
                        </div>
                    }
                    
                    <div class="mb-3">
                        <label for="Name" class="form-label">Product Name</label>
                        <input name="Name" id="Name" class="form-control" required />
                    </div>
                    
                    <div class="mb-3">
                        <label for="Description" class="form-label">Description</label>
                        <textarea name="Description" id="Description" class="form-control" rows="4" required></textarea>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="Price" class="form-label">Price (£)</label>
                                <input name="Price" id="Price" type="number" step="0.01" class="form-control" required />
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="CategoryId" class="form-label">Category</label>
                                <select name="CategoryId" id="CategoryId" class="form-select" required>
                                    <option value="">Select a category</option>
                                    @if (categories != null)
                                    {
                                        @foreach (var category in categories)
                                        {
                                            <option value="@category.Id">@category.Name</option>
                                        }
                                    }
                                </select>
                            </div>
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="Weight" class="form-label">Weight/Volume</label>
                                <input name="Weight" id="Weight" type="number" step="0.01" class="form-control" required />
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="WeightUnit" class="form-label">Unit</label>
                                <select name="WeightUnit" id="WeightUnit" class="form-select">
                                    <option value="0">Unit</option>
                                    <option value="1">Micrograms</option>
                                    <option value="2">Grams</option>
                                    <option value="3">Ounces</option>
                                    <option value="4">Pounds</option>
                                    <option value="5">Millilitres</option>
                                    <option value="6">Litres</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    
                    <div class="d-flex justify-content-between">
                        <a href="@Url.Action("Index")" class="btn btn-secondary">
                            <i class="fas fa-arrow-left"></i> Back to Products
                        </a>
                        <button type="submit" class="btn btn-primary">
                            <i class="fas fa-save"></i> Create Product
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    
    <div class="col-md-4">
        <div class="card">
            <div class="card-header">
                <h5><i class="fas fa-info-circle"></i> Product Information</h5>
            </div>
            <div class="card-body">
                <ul class="list-unstyled">
                    <li><strong>Name:</strong> Unique product identifier</li>
                    <li><strong>Description:</strong> Supports Unicode and emojis</li>
                    <li><strong>Price:</strong> Base price in GBP</li>
                    <li><strong>Weight/Volume:</strong> Used for shipping calculations</li>
                    <li><strong>Category:</strong> Product organization</li>
                </ul>
                <small class="text-muted">You can add photos after creating the product.</small>
            </div>
        </div>
    </div>
</div>