{% extends "base.html" %}
{% from "components/ui.html" import page_header %}

{% block content %}
{% set breadcrumbs = [
    {'text': 'Inventory', 'url': url_for('inventory.list_stock_items')},
    {'text': 'Adjustments', 'url': url_for('inventory.list_adjustments')},
    {'text': 'New Adjustment'}
] %}

{{ page_header(
    icon_class='fas fa-edit',
    title_text='New Stock Adjustment',
    subtitle_text='Record stock adjustment or correction',
    breadcrumbs=breadcrumbs
) }}

<div class="bg-card-light dark:bg-card-dark p-6 rounded-xl border border-border-light dark:border-border-dark shadow-sm max-w-2xl mx-auto">
    <form method="POST" action="{{ url_for('inventory.new_adjustment') }}">
        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
        <div class="space-y-6">
            <div>
                <label for="stock_item_id" class="form-label">{{ _('Stock Item') }} *</label>
                <select name="stock_item_id" id="stock_item_id" class="form-input" required>
                    <option value="">{{ _('Select Item') }}</option>
                    {% for item in stock_items %}
                    <option value="{{ item.id }}">{{ item.sku }} - {{ item.name }}</option>
                    {% endfor %}
                </select>
            </div>
            <div>
                <label for="warehouse_id" class="form-label">{{ _('Warehouse') }} *</label>
                <select name="warehouse_id" id="warehouse_id" class="form-input" required>
                    <option value="">{{ _('Select Warehouse') }}</option>
                    {% for warehouse in warehouses %}
                    <option value="{{ warehouse.id }}">{{ warehouse.code }} - {{ warehouse.name }}</option>
                    {% endfor %}
                </select>
            </div>
            <div>
                <label for="quantity" class="form-label">{{ _('Adjustment Quantity') }} *</label>
                <input type="number" name="quantity" id="quantity" step="0.01" class="form-input" required>
                <p class="mt-1 text-sm text-gray-500">{{ _('Use positive values to increase stock, negative values to decrease') }}</p>
            </div>
            <div>
                <label for="reason" class="form-label">{{ _('Reason') }} *</label>
                <input type="text" name="reason" id="reason" class="form-input" required placeholder="{{ _('e.g., Physical count correction, Damage, Found items') }}">
            </div>
            <div>
                <label for="notes" class="form-label">{{ _('Notes') }}</label>
                <textarea name="notes" id="notes" rows="3" class="form-input" placeholder="{{ _('Additional details about this adjustment') }}"></textarea>
            </div>
        </div>
        <div class="mt-6 flex flex-col sm:flex-row justify-end gap-3">
            <a href="{{ url_for('inventory.list_adjustments') }}" class="px-4 py-2 bg-gray-200 dark:bg-gray-700 rounded-lg hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors text-center">
                {{ _('Cancel') }}
            </a>
            <button type="submit" class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors">
                {{ _('Record Adjustment') }}
            </button>
        </div>
    </form>
</div>
{% endblock %}

