@extends('admin.layouts.app')

@section('title', __('admin/reports.title'))

@section('content')
@can('view reports')
<div class="container-fluid px-4">
    <x-admin.page-header :title="__('admin/reports.title')" icon="fas fa-chart-bar" />

    <!-- Rapor Kategorileri -->
    @foreach($reports as $category => $categoryReports)
    <div class="row mb-4">
        <div class="col-12">
            <h5 class="text-muted mb-3">
                <i class="fas fa-folder me-2"></i>{{ $category }}
            </h5>
        </div>

        @foreach($categoryReports as $report)
        <div class="col-xl-4 col-md-6 mb-3">
            <x-admin.card class="report-card h-100">
                <div class="d-flex justify-content-between align-items-start mb-3">
                    <div class="flex-grow-1">
                        <h5 class="card-title mb-1">{{ $report->getName() }}</h5>
                        <p class="text-muted small mb-0">{{ $report->getDescription() }}</p>
                    </div>
                    <div class="ms-3">
                        <span class="badge bg-primary rounded-pill">
                            <i class="{{ $report->getIcon() }}"></i>
                        </span>
                    </div>
                </div>

                <div class="d-flex justify-content-between align-items-center">
                    <div class="small text-muted">
                        @if($report->hasChart())
                        <span class="badge bg-success me-1">
                            <i class="fas fa-chart-bar me-1"></i>{{ __('admin/reports.chart') }}
                        </span>
                        @endif
                        <span class="badge bg-info">
                            <i class="fas fa-table me-1"></i>{{ __('admin/reports.table') }}
                        </span>
                    </div>

                    <div class="btn-group" role="group">
                        <a href="{{ route('admin.reports.detail', ['module' => $report->getRouteName()]) }}"
                           class="btn btn-sm btn-outline-primary">
                            <i class="fas fa-play me-1"></i>{{ __('admin/reports.run') }}
                        </a>
                    </div>
                </div>
            </x-admin.card>
        </div>
        @endforeach
    </div>
    @endforeach

    <!-- Rapor Yoksa -->
    @if(empty($reports))
    <div class="row">
        <div class="col-12">
            <x-admin.card>
                <div class="text-center">
                    <i class="fas fa-chart-bar fa-3x text-muted mb-3"></i>
                    <h5>{{ __('admin/reports.no_reports') }}</h5>
                    <p class="text-muted">{{ __('admin/reports.add_reports_instruction') }}</p>
                </div>
            </x-admin.card>
        </div>
    </div>
    @endif
</div>
@else
<div class="container-fluid px-4">
    <div class="row">
        <div class="col-12">
            <div class="alert alert-danger">
                <h4>{{ __('admin/common.access_denied') }}</h4>
                <p>{{ __('admin/common.no_page_permission') }}</p>
            </div>
        </div>
    </div>
</div>
@endcan
@endsection
