@extends('layouts.app')

@section('content')
<div class="page-wrapper">
    {{-- Print Button --}}
    <div class="mb-6 text-right no-print">
        <button onclick="window.print()" class="btn btn-primary gap-2">
            <x-heroicon-o-printer class="w-5 h-5" /> {{ __('Imprimir / Guardar PDF') }}
        </button>
        <a href="{{ route('reports.project.excel', ['project' => $project->id] + $filters->toArray()) }}" 
           class="btn btn-success gap-2 ml-2">
            <x-heroicon-o-document-arrow-down class="w-5 h-5" /> {{ __('Descargar Excel') }}
        </a>
        <a href="{{ route('projects.map', $project) }}" class="btn btn-ghost btn-sm ml-2">
            <x-heroicon-o-arrow-left class="w-4 h-4 mr-1" /> {{ __('Volver') }}
        </a>
    </div>

    {{-- Header --}}
    @include('reports.partials._header', ['project' => $project, 'filters' => $filters])

    {{-- Summary KPIs --}}
    @include('reports.partials._summary', ['summary' => $summary])

    {{-- Progress Curve Chart --}}
    @if(isset($progress_curve) && !empty($progress_curve['labels']))
        @include('reports.partials._progress-curve', ['curveData' => $progress_curve])
    @endif

    {{-- Deviations --}}
    @if(isset($deviations))
        @include('reports.partials._deviations', ['deviations' => $deviations])
    @endif

    {{-- Phases --}}
    @if(isset($phases) && !empty($phases))
        @include('reports.partials._phases', ['phases' => $phases])
    @endif

    {{-- Features --}}
    @if(isset($features) && !empty($features))
        @include('reports.partials._features', ['features' => $features])
    @endif

    {{-- Inspections --}}
    @if(isset($inspections) && !empty($inspections))
        @include('reports.partials._inspections', ['inspections' => $inspections])
    @endif

    {{-- Issues --}}
    @if(isset($issues) && !empty($issues))
        @include('reports.partials._issues', ['issues' => $issues])
    @endif

    {{-- Tasks --}}
    @if(isset($tasks) && !empty($tasks))
        @include('reports.partials._tasks', ['tasks' => $tasks])
    @endif

    {{-- Media --}}
    @if(isset($media) && !empty($media) && $filters['include_photos'])
        @include('reports.partials._media', ['media' => $media])
    @endif

    {{-- Footer --}}
    <div class="report-footer no-print">
        <div class="flex justify-between items-center">
            <span>ConstProgress &mdash; Sistema de Gestión de Obras</span>
            <span>{{ now()->format('d/m/Y H:i') }}</span>
        </div>
    </div>
</div>
@endsection