@extends('layouts.app')

@section('title', 'Models')

@section('actions')
<a href="{{ route('settings.models.create') }}" class="btn btn-primary">
    <i class="fas fa-plus-circle"></i> Add New Model
</a>
@endsection

@section('content')
<div class="container-fluid">
    <div class="card">
        <div class="card-header">
            <h5 class="mb-0"><i class="fas fa-cube me-2"></i>Model List</h5>
        </div>
        <div class="card-body">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Name</th>
                        <th>Code</th>
                        <th>Brand</th>
                        <th>Category</th>
                        <th>Status</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($models as $model)
                    <tr>
                        <td>{{ $model->id }}</td>
                        <td>{{ $model->name }}</td>
                        <td><code>{{ $model->code }}</code></td>
                        <td>{{ $model->brand->name ?? 'N/A' }}</td>
                        <td>{{ $model->category->name ?? 'N/A' }}</td>
                        <td>{!! $model->status_badge !!}</td>
                        <td>
                            <a href="{{ route('settings.models.edit', $model) }}" class="btn btn-sm btn-info">
                                <i class="fas fa-edit"></i>
                            </a>
                            <form action="{{ route('settings.models.destroy', $model) }}" method="POST" class="d-inline">
                                @csrf
                                @method('DELETE')
                                <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure?')">
                                    <i class="fas fa-trash"></i>
                                </button>
                            </form>
                        </td>
                    </tr>
                    @empty
                    <tr>
                        <td colspan="7" class="text-center">No models found.</td>
                    </tr>
                    @endforelse
                </tbody>
            </table>
            
            <div class="mt-3">
                {{ $models->links() }}
            </div>
        </div>
    </div>
</div>
@endsection