@extends('layouts.app')

@section('title', 'Stock Adjustment')

@section('content')
    <div class="mb-4">
        <h4 class="mb-0">Inventory Adjustment</h4>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb mb-0">
                <li class="breadcrumb-item"><a href="{{ url('/') }}">Dashboard</a></li>
                <li class="breadcrumb-item"><a href="{{ route('inventory.index') }}">Inventory</a></li>
                <li class="breadcrumb-item active">Adjustment</li>
            </ol>
        </nav>
    </div>

    <div class="row justify-content-center">
        <div class="col-lg-8">
            <div class="card border-0 shadow-sm">
                <div class="card-body p-4">
                    <form action="{{ route('inventory.store-adjustment') }}" method="POST">
                        @csrf

                        <div class="row g-4">
                            <div class="col-md-12">
                                <label class="form-label fw-bold small text-muted text-uppercase">Product / Item <span
                                        class="text-danger">*</span></label>
                                <select name="product_id" class="form-select form-select-lg" required>
                                    <option value="">Identify product...</option>
                                    @foreach($products as $product)
                                        <option value="{{ $product->id }}">{{ $product->name }} ({{ $product->sku }})</option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="col-md-6">
                                <label class="form-label fw-bold small text-muted text-uppercase">Target Warehouse <span
                                        class="text-danger">*</span></label>
                                <select name="warehouse_id" class="form-select" required>
                                    @foreach($warehouses as $wh)
                                        <option value="{{ $wh->id }}">{{ $wh->name }}</option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="col-md-6">
                                <label class="form-label fw-bold small text-muted text-uppercase">Movement Type <span
                                        class="text-danger">*</span></label>
                                <select name="type" class="form-select" required>
                                    <option value="in">Stock In (Receipt)</option>
                                    <option value="out">Stock Out (Shipment/Loss)</option>
                                    <option value="adjustment">Direct Adjustment</option>
                                </select>
                            </div>

                            <div class="col-md-12">
                                <label class="form-label fw-bold small text-muted text-uppercase">Quantity <span
                                        class="text-danger">*</span></label>
                                <div class="input-group input-group-lg">
                                    <input type="number" step="0.0001" name="quantity" class="form-control" required
                                        placeholder="0.00">
                                    <span class="input-group-text bg-white">Units</span>
                                </div>
                                <small class="text-muted">Enter positive numbers. Type will determine the sign.</small>
                            </div>

                            <div class="col-md-12">
                                <label class="form-label fw-bold small text-muted text-uppercase">Adjustment Reason /
                                    Notes</label>
                                <textarea name="notes" class="form-control" rows="3"
                                    placeholder="Explain why this adjustment is being made..."></textarea>
                            </div>
                        </div>

                        <div class="mt-5 pt-3 border-top d-flex justify-content-end gap-2">
                            <a href="{{ route('inventory.index') }}" class="btn btn-light px-4">Cancel</a>
                            <button type="submit" class="btn btn-primary px-5 shadow-sm">Process Movement</button>
                        </div>
                    </form>
                </div>
            </div>

            <div class="alert alert-info mt-4 border-0 shadow-sm d-flex gap-3">
                <i class="bi bi-qr-code-scan fs-3"></i>
                <div>
                    <h6 class="fw-bold mb-1">Barcode Support Alert</h6>
                    <p class="small mb-0 opacity-75">In the next iteration, clicking the scanner icon will enable
                        camera-based QR/Barcode identification for faster processing.</p>
                </div>
            </div>
        </div>
    </div>
@endsection