@extends('back-end.master.app')

@section('title', 'Poets Report')

@section('body')
<main class="app-content">
    <div class="card">
        <div class="card-header d-flex justify-content-between">
            <h4>Poets Report</h4>
            <a href="{{ route('poets.index') }}" class="btn btn-secondary btn-sm">Back to List</a>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-4">
                    <div class="info-box bg-info">
                        <span class="info-box-icon"><i class="fa fa-users"></i></span>
                        <div class="info-box-content">
                            <span class="info-box-text">Total Poets</span>
                            <span class="info-box-number">{{ $totalPoets }}</span>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="info-box bg-success">
                        <span class="info-box-icon"><i class="fa fa-book"></i></span>
                        <div class="info-box-content">
                            <span class="info-box-text">Poets with Poetries</span>
                            <span class="info-box-number">{{ $poetsWithPoetries }}</span>
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="info-box bg-warning">
                        <span class="info-box-icon"><i class="fa fa-exclamation-triangle"></i></span>
                        <div class="info-box-content">
                            <span class="info-box-text">Poets without Poetries</span>
                            <span class="info-box-number">{{ $poetsWithoutPoetries }}</span>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row mt-4">
                <div class="col-md-6">
                    <div class="card">
                        <div class="card-header">
                            <h5>Poets by Century</h5>
                        </div>
                        <div class="card-body">
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>Century</th>
                                        <th>Number of Poets</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($byCentury as $item)
                                    <tr>
                                        <td>{{ $item->centry->title_ps ?? 'Unknown' }}</td>
                                        <td>{{ $item->total }}</td>
                                    </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="card">
                        <div class="card-header">
                            <h5>Top 10 Poets by Poetry Count</h5>
                        </div>
                        <div class="card-body">
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>Poet</th>
                                        <th>Number of Poetries</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($topPoets as $poet)
                                    <tr>
                                        <td>{{ $poet->name }}</td>
                                        <td>{{ $poet->poetries_count }}</td>
                                    </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
@endsection

@section('pageJs')
<script>
    $(".app-menu").removeClass("active");
    $("#nav_poetsi").addClass("active");
    $("#poetsi").addClass("is-expanded");
    $("#poets_history").addClass("active");
</script>
@endsection
