@extends('layouts.app')

@section('title', 'Create Prescription Item')

@section('content')
<div class="max-w-2xl mx-auto px-4 sm:px-6 lg:px-8">
    <div class="mb-6 flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
        <h1 class="text-3xl font-bold text-gray-800">Create Prescription Item</h1>
        <a href="{{ route('admin.prescription-items.index', ['type' => $type]) }}" class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded">
            <i class="fas fa-arrow-left mr-2"></i>Back to List
        </a>
    </div>

    <form method="POST" action="{{ route('admin.prescription-items.store') }}" class="bg-white rounded-lg shadow p-6">
        @csrf

        <div class="mb-4">
            <label class="block text-gray-700 text-sm font-bold mb-2">Type</label>
            <select name="type" required class="w-full px-3 py-2 border rounded">
                <option value="quantity" {{ $type === 'quantity' ? 'selected' : '' }}>Quantity</option>
                <option value="frequency" {{ $type === 'frequency' ? 'selected' : '' }}>Frequency</option>
                <option value="instruction" {{ $type === 'instruction' ? 'selected' : '' }}>Instruction</option>
                <option value="duration" {{ $type === 'duration' ? 'selected' : '' }}>Duration</option>
            </select>
        </div>

        <div class="mb-4">
            <label class="block text-gray-700 text-sm font-bold mb-2">Name *</label>
            <input type="text" name="name" required class="w-full px-3 py-2 border rounded" placeholder="Enter item name">
        </div>

        <div class="mb-4">
            <label class="block text-gray-700 text-sm font-bold mb-2">Sort Order</label>
            <input type="number" name="sort_order" min="0" value="0" class="w-full px-3 py-2 border rounded">
            <p class="text-sm text-gray-600 mt-1">Lower numbers appear first in dropdown lists</p>
        </div>

        <div class="mb-4">
            <label class="flex items-center">
                <input type="checkbox" name="is_active" value="1" checked class="mr-2">
                <span class="text-gray-700 text-sm font-bold">Active</span>
            </label>
        </div>

        <div class="flex justify-end">
            <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded">
                Create Item
            </button>
        </div>
    </form>
</div>
@endsection

