@extends('layouts.dashboard')
@section('title', 'Packages')
@section('page-title', 'Blog Packages')
@section('content')
<div class="content-card">
    <div class="content-card-header">
        <h3>All Packages</h3>
        <a href="{{ route('admin.packages.create') }}" class="btn btn-primary btn-sm">+ New Package</a>
    </div>
    <div class="table-responsive">
    <table class="table">
        <thead><tr><th>Name</th><th>Blogs</th><th>Price</th><th>Featured</th><th>Status</th><th>Actions</th></tr></thead>
        <tbody>
        @forelse($packages as $p)
            <tr>
                <td><strong>{{ $p->name }}</strong></td>
                <td>{{ $p->blogs_count }}</td>
                <td>${{ number_format($p->price, 2) }}</td>
                <td>{{ $p->is_featured ? '★' : '—' }}</td>
                <td>{!! $p->is_active ? '<span class="badge bg-success">Active</span>' : '<span class="badge bg-secondary">Inactive</span>' !!}</td>
                <td>
                    <a href="{{ route('admin.packages.edit', $p) }}" class="btn btn-sm btn-outline-primary">Edit</a>
                    <form action="{{ route('admin.packages.destroy', $p) }}" method="POST" class="d-inline" onsubmit="return confirm('Delete this package?')">
                        @csrf @method('DELETE')
                        <button class="btn btn-sm btn-outline-danger">Del</button>
                    </form>
                </td>
            </tr>
        @empty
            <tr><td colspan="6" class="text-center text-muted py-3">No packages defined yet.</td></tr>
        @endforelse
        </tbody>
    </table>
    </div>
    {{ $packages->links() }}
</div>
@endsection
