@extends('admin.layouts.app')
@section('title', 'Create Product')
@section('content')
<div class="card" style="max-width:800px">
    <div class="card-header">Create Product</div>
    <form action="{{ route('admin.products.store') }}" method="POST" enctype="multipart/form-data">
        @csrf
        <div class="form-group">
            <label>Name</label>
            <input type="text" name="name" class="form-control" value="{{ old('name') }}" required>
        </div>
        <div class="form-row">
            <div class="form-group">
                <label>Slug</label>
                <input type="text" name="slug" class="form-control" value="{{ old('slug') }}" placeholder="Auto">
            </div>
            <div class="form-group">
                <label>SKU</label>
                <input type="text" name="sku" class="form-control" value="{{ old('sku') }}">
            </div>
        </div>
        <div class="form-row">
            <div class="form-group">
                <label>Price ($)</label>
                <input type="number" step="0.01" name="price" class="form-control" value="{{ old('price', 0) }}" required>
            </div>
            <div class="form-group">
                <label>Sale Price ($)</label>
                <input type="number" step="0.01" name="sale_price" class="form-control" value="{{ old('sale_price') }}">
            </div>
        </div>
        <div class="form-row">
            <div class="form-group">
                <label>Stock</label>
                <input type="number" name="stock" class="form-control" value="{{ old('stock', 0) }}" required>
            </div>
            <div class="form-group">
                <label>Category</label>
                <select name="category_id" class="form-control">
                    <option value="">No Category</option>
                    @foreach($categories as $cat)
                        <option value="{{ $cat->id }}">{{ $cat->name }}</option>
                    @endforeach
                </select>
            </div>
        </div>
        <div class="form-group">
            <label>Short Description</label>
            <input type="text" name="short_description" class="form-control" value="{{ old('short_description') }}" maxlength="500">
        </div>
        <div class="form-group">
            <label>Description</label>
            <textarea name="description" class="form-control">{{ old('description') }}</textarea>
        </div>
        <div class="form-row">
            <div class="form-group">
                <label>Main Image</label>
                <input type="file" name="image" class="form-control" accept="image/*">
            </div>
            <div class="form-group" style="display:flex;gap:15px;align-items:center;padding-top:25px">
                <label class="checkbox-label"><input type="checkbox" name="is_featured" value="1"> Featured</label>
                <label class="checkbox-label"><input type="checkbox" name="is_active" value="1" checked> Active</label>
            </div>
        </div>
        <div class="form-row">
            <div class="form-group">
                <label>Meta Title</label>
                <input type="text" name="meta_title" class="form-control" value="{{ old('meta_title') }}">
            </div>
            <div class="form-group">
                <label>Meta Description</label>
                <input type="text" name="meta_description" class="form-control" value="{{ old('meta_description') }}">
            </div>
        </div>
        <button type="submit" class="btn btn-primary">Create Product</button>
    </form>
</div>
@endsection
