{{-- admin/pages/resources/index.blade.php --}}
@extends('admin.layouts.app')
@section('title','Resources')
@section('page-title','Resources')
@section('content')
<div class="d-flex justify-content-between align-items-center mb-3">
    <div style="font-size:.82rem;color:#64748b">{{ $resources->count() }} resources</div>
    <a href="{{ route('admin.resources.create') }}" class="btn btn-admin btn-sm px-3"><i class="bi bi-plus-lg me-1"></i>Add Resource</a>
</div>
<div class="card-admin">
    <table class="table table-hover mb-0">
        <thead><tr><th>#</th><th>Title</th><th>Category</th><th>Type</th><th>Status</th><th style="width:100px">Actions</th></tr></thead>
        <tbody>
            @forelse($resources as $res)
            <tr>
                <td class="text-muted">{{ $res->id }}</td>
                <td><div class="fw-600" style="color:#0f172a">{{ $res->title }}</div></td>
                <td><span style="font-size:.78rem;color:#64748b">{{ $res->category->name ?? '—' }}</span></td>
                <td>
                    @php $typeColors = ['pdf'=>'#dbeafe:#1e40af','video'=>'#fef9c3:#854d0e','link'=>'#f0fdf4:#166534','article'=>'#eff6ff:#1d4ed8']; $tc = explode(':', $typeColors[$res->resource_type] ?? '#f1f5f9:#374151'); @endphp
                    <span class="badge" style="background:{{ $tc[0] }};color:{{ $tc[1] }};font-size:.72rem">{{ ucfirst($res->resource_type) }}</span>
                </td>
                <td><span class="badge" style="background:{{ $res->is_active ? '#f0fdf4' : '#fee2e2' }};color:{{ $res->is_active ? '#166534' : '#991b1b' }};font-size:.72rem">{{ $res->is_active ? 'Active' : 'Inactive' }}</span></td>
                <td>
                    <div class="d-flex gap-1">
                        <a href="{{ route('admin.resources.edit', $res->id) }}" class="btn btn-sm" style="background:#eff6ff;color:#1d4ed8;border:none"><i class="bi bi-pencil"></i></a>
                        <form method="POST" action="{{ route('admin.resources.destroy', $res->id) }}" onsubmit="return confirm('Delete?')">@csrf @method('DELETE')
                            <button class="btn btn-sm" style="background:#fee2e2;color:#991b1b;border:none"><i class="bi bi-trash"></i></button>
                        </form>
                    </div>
                </td>
            </tr>
            @empty
            <tr><td colspan="6" class="text-center py-4 text-muted">No resources yet.</td></tr>
            @endforelse
        </tbody>
    </table>
</div>
@endsection
