@extends('layouts.admin')

@section('title', 'Services')

@section('content')
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h5 class="page-title mb-0">Services</h5>
        <a href="{{ route('admin.services.create') }}" class="btn btn-primary"><i class="bi bi-plus-lg me-1"></i> Add Service</a>
    </div>

    <div class="card">
        <div class="card-body p-0">
            <table class="table table-hover align-middle mb-0">
                <thead>
                    <tr><th>#</th><th>Image</th><th>Title</th><th>Slug</th><th>Features</th><th>Status</th><th class="text-end">Actions</th></tr>
                </thead>
                <tbody>
                    @forelse($services as $service)
                        <tr>
                            <td>{{ $loop->iteration }}</td>
                            <td>
                                @if($service->image)
                                    <img src="{{ \App\Services\FileUploadService::url($service->image) }}" class="list-image" alt="">
                                @else
                                    <span class="badge bg-secondary"><i class="bi bi-grid"></i></span>
                                @endif
                            </td>
                            <td class="fw-semibold">{{ $service->title }}</td>
                            <td><code>{{ $service->slug }}</code></td>
                            <td><span class="badge bg-light text-dark">{{ $service->features_count }}</span></td>
                            <td>@if($service->status)<span class="badge bg-success">Active</span>@else<span class="badge bg-secondary">Inactive</span>@endif</td>
                            <td class="text-end">
                                <a href="{{ route('admin.services.edit', $service) }}" class="btn btn-sm btn-outline-primary">Edit</a>
                                <form action="{{ route('admin.services.destroy', $service) }}" method="POST" class="d-inline" data-confirm="Delete this service?">
                                    @csrf @method('DELETE')
                                    <button type="submit" class="btn btn-sm btn-outline-danger">Delete</button>
                                </form>
                            </td>
                        </tr>
                    @empty
                        <tr><td colspan="7" class="text-center text-muted py-4">No services yet.</td></tr>
                    @endforelse
                </tbody>
            </table>
        </div>
    </div>
    <div class="mt-3">{{ $services->links() }}</div>
@endsection
