@extends('layouts.app')
@section('title', 'Lab Test Catalogue')
@section('content')
<section class="content-header"><h1><i class="fas fa-book-medical"></i> Lab Test Catalogue</h1></section>
<section class="content">
    @includeIf('clinicLab::partials._tabs', ['active' => 'catalog'])
    <p><a href="{{ route('clinic-lab.catalog.create') }}" class="btn btn-primary btn-sm"><i class="fas fa-plus"></i> New test / panel</a></p>
    @component('components.widget', ['class' => 'box-primary', 'title' => 'Tests & panels'])
        <table class="table table-sm">
            <thead><tr>
                <th>Code</th><th>Name</th><th>Category</th><th>Specimen</th><th>Analytes</th>
                <th>Panel</th><th>Billed as</th><th>Active</th><th></th>
            </tr></thead>
            <tbody>
            @forelse($tests as $t)
                <tr>
                    <td><code>{{ $t->code }}</code></td>
                    <td>{{ $t->name }}</td>
                    <td>{{ ucfirst($t->category) }}</td>
                    <td>{{ ucfirst($t->specimen_type) }}@if($t->fasting_required) <span class="label label-warning">fasting</span>@endif</td>
                    <td>{{ $t->analytes_count }}</td>
                    <td>@if($t->is_panel)<i class="fas fa-check text-success"></i>@endif</td>
                    <td>@if($t->product_id)<span class="text-muted">#{{ $t->product_id }}</span>@else <span class="text-muted">—</span>@endif</td>
                    <td>@if($t->is_active)<span class="label label-success">Active</span>@else<span class="label label-default">Inactive</span>@endif</td>
                    <td>
                        <a href="{{ route('clinic-lab.catalog.edit', $t->id) }}" class="btn btn-xs btn-default"><i class="fas fa-edit"></i></a>
                        <form method="POST" action="{{ route('clinic-lab.catalog.destroy', $t->id) }}" style="display:inline;" onsubmit="return confirm('Remove this test?');">
                            @csrf @method('DELETE')
                            <button class="btn btn-xs btn-danger"><i class="fas fa-trash"></i></button>
                        </form>
                    </td>
                </tr>
            @empty
                <tr><td colspan="9" class="text-muted">No tests yet. Add your common panels to enable specimen requirements and critical-value validation.</td></tr>
            @endforelse
            </tbody>
        </table>
    @endcomponent
</section>
@endsection
