@extends('admin.admin_master')

@section('admin')
<br/><br/>
<div class="container mx-auto p-4 mt-5">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2 class="text-2xl font-bold mb-0">Folder & File Statistics</h2>
        <a href="{{ route('reports.folder-file-stats.pdf', request()->query()) }}" class="btn btn-danger btn-sm text-white">
            <span style="font-size:1.2em;vertical-align:middle;">&#128462;</span> Download PDF
        </a>
    </div>

    <div class="mb-5">
        <h5 class="mt-4 mb-4">All Folders</h5>
        <form method="GET" class="row g-2 mb-3">
            <div class="col-md-4">
                <input type="text" name="folder_name" class="form-control" placeholder="Search by Folder Name" value="{{ request('folder_name') }}">
            </div>
            <div class="col-md-4">
                <input type="text" name="user_name" class="form-control" placeholder="Search by User Name" value="{{ request('user_name') }}">
            </div>
            <div class="col-md-2">
                <button type="submit" class="btn btn-primary w-100">Search</button>
            </div>
            <div class="col-md-2">
                <a href="{{ route('reports.folder-file-stats') }}" class="btn btn-secondary w-100 text-white">Reset</a>
            </div>
        </form>
        <div class="table-responsive">
            <table class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th>Folder ID</th>
                        <th>Name</th>
                        <th>Path</th>
                        <th>Parent ID</th>
                        <th>Created By</th>
                        <th>Created At</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($folders as $folder)
                        <tr>
                            <td>{{ $folder->id }}</td>
                            <td>{{ $folder->name }}</td>
                            <td>{{ $folder->path }}</td>
                            <td>{{ $folder->parent ? $folder->parent->name : '-' }}</td>
                            <td>
                                @if($folder->creator)
                                    {{ trim($folder->creator->first_name . ' ' . $folder->creator->last_name) }}
                                @else
                                    -
                                @endif
                            </td>
                            <td>{{ $folder->created_at ? $folder->created_at->format('Y-m-d H:i') : '-' }}</td>
                        </tr>
                    @empty
                        <tr><td colspan="6" class="text-center">No folders found</td></tr>
                    @endforelse
                </tbody>
            </table>
        </div>
    </div>

    <!-- Folder stats table removed as requested -->
</div>
@endsection
