<!DOCTYPE html>
<html lang="en">
@include('index.head')
<body>
@include('index.navigation')
<main>
    <section class="public-page-hero">
        <div class="container">
            <span class="kicker">Resources</span>
            <h1 class="page-title">NGBVD Resources</h1>
            <p class="section-intro">Official resources, documents and reference materials published for public access.</p>
        </div>
    </section>
    <section class="section">
        <div class="container">
            <div class="public-card" style="overflow-x:auto;">
                <table class="table" width="100%">
                    <thead><tr><th>No.</th><th>Resource Name</th><th>Category</th><th>Resource Content</th></tr></thead>
                    <tbody>
                    <?php $key = 1; ?>
                    @foreach($resources as $resource)
                        <tr>
                            <td>{{ $key }}</td>
                            <td>{{ $resource->name }}</td>
                            <td>{{ $resource->category }}</td>
                            <td>
                                @if (in_array(strtolower(pathinfo($resource->name, PATHINFO_EXTENSION)), ['jpg', 'jpeg', 'png', 'gif']))
                                    <img src="{{ url('resource/downloadfile/' . encrypt($resource->id)) }}" alt="{{ $resource->name }}" style="max-width: 180px; max-height: 140px; border-radius:12px;">
                                @else
                                    <a class="btn btn-outline" href="{{ url('resource/downloadfile/' . encrypt($resource->id)) }}" target="_blank">Open Resource</a>
                                @endif
                            </td>
                        </tr>
                        <?php $key++; ?>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </section>
</main>
@include('index.footer')
</body>
</html>