@extends('layouts.pmar.theme')
@section("title", env("APP_NAME") . " :: " . $ppp->projeto)

@section('content')
<style>
    .bg-primary { background: linear-gradient(135deg, #0d6efd, #084298); }
    .landing-header {
        color: white;
        padding: 3rem 0 2.5rem 0;
        margin-bottom: 2rem;
        border-radius: 0 0 50px 50px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.15);
        position: relative;
        overflow: hidden;
    }
    .landing-header.bg-primary::before {
        content: '';
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 0;
        background: url('https://www.angra.rj.gov.br/uploads/2023/01/20230113110543.jpg') center/cover;
        opacity: 0.08;
        mix-blend-mode: overlay;
    }
    .detail-card {
        border: none;
        border-radius: 15px;
        background: white;
        box-shadow: 0 5px 20px rgba(0,0,0,0.05);
        margin-bottom: 2rem;
        overflow: hidden;
    }
    .detail-card-header {
        background: #f8f9fa;
        padding: 1.5rem;
        border-bottom: 1px solid #eee;
    }
    .detail-card-body {
        padding: 2rem;
    }
    .info-group {
        margin-bottom: 1.5rem;
    }
    .info-label {
        font-size: 0.8rem;
        color: #6c757d;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 0.25rem;
    }
    .info-value {
        font-size: 1.1rem;
        font-weight: 600;
        color: #212529;
    }
    .status-timeline {
        position: relative;
        padding-left: 30px;
        margin-top: 2rem;
    }
    .status-item {
        position: relative;
        padding-bottom: 2rem;
    }
    .status-item::before {
        content: '';
        position: absolute;
        left: -34px;
        top: 5px;
        width: 15px;
        height: 15px;
        border-radius: 50%;
        background: #0055a5;
        border: 3px solid #e9ecef;
    }
    .status-item::after {
        content: '';
        position: absolute;
        left: -28px;
        top: 25px;
        width: 3px;
        height: 100%;
        background: #e9ecef;
    }
    .status-item:last-child::after {
        display: none;
    }
    .btn-back {
        background: rgba(255,255,255,0.1);
        color: white;
        border: 1px solid rgba(255,255,255,0.3);
        border-radius: 25px;
        padding: 8px 20px;
        transition: all 0.3s;
    }
    .btn-back:hover {
        background: rgba(255,255,255,0.2);
        color: white;
    }
</style>

<div class="landing-header bg-primary text-center position-relative">
    <div class="container position-relative">
        <div class="d-flex justify-content-between align-items-start flex-wrap gap-3 mb-3">
            <div class="d-flex align-items-center gap-3">
                <div class="bg-white text-primary rounded-circle p-3 shadow-sm">
                    <i class="fa-solid fa-handshake fa-2x"></i>
                </div>
                <div class="text-start">
                    <h1 class="h3 mb-1 text-white fw-bold">{{ $ppp->projeto }}</h1>
                    <p class="lead mb-0 text-white opacity-75">
                        <i class="fa-solid fa-building me-2"></i>{{ $ppp->show_secretaria_responsavel ? ($ppp->secretaria_responsavel ?? '–') : '' }}
                    </p>
                </div>
            </div>
            <div class="d-flex align-items-center gap-2 ms-auto">
                <a href="{{ route('pppseconvenios') }}" class="btn btn-outline-light btn-sm rounded-pill">
                    <i class="fa-solid fa-arrow-left me-2"></i> {{ __('Início') }}
                </a>
                <a href="{{ route('ppps.public.list') }}" class="btn btn-outline-light btn-sm rounded-pill">
                    <i class="fa-solid fa-list me-2"></i> {{ __('Voltar à lista') }}
                </a>
                @if($ppp->show_andamento ?? true)
                <span class="badge badge-status-andamento px-3 py-2 rounded-pill">
                    {{ $ppp->andamento ?? __('Em Análise') }}
                </span>
                @endif
            </div>
        </div>
    </div>
</div>

<div class="container mb-5">
    <div class="row">
        <div class="col-lg-8">
            <div class="detail-card">
                <div class="detail-card-header">
                    <h4 class="mb-0 fw-bold text-primary"><i class="fa-regular fa-file-lines me-2"></i>{{ __('Informações do Projeto') }}</h4>
                </div>
                <div class="detail-card-body">
                    <div class="row">
                        @if($ppp->show_empresa)
                        <div class="col-md-6 info-group">
                            <div class="info-label">{{ __('Empresa Responsável') }}</div>
                            <div class="info-value">{{ $ppp->empresa ?? '–' }}</div>
                        </div>
                        @endif
                        @if($ppp->show_criterio_julgamento)
                        <div class="col-md-6 info-group">
                            <div class="info-label">{{ __('Critério de Julgamento') }}</div>
                            <div class="info-value">{{ $ppp->criterio_julgamento ?? '–' }}</div>
                        </div>
                        @endif
                        @if($ppp->show_prazo_concessao)
                        <div class="col-md-6 info-group">
                            <div class="info-label">{{ __('Prazo de Concessão') }}</div>
                            <div class="info-value">{{ $ppp->prazo_concessao ?? '–' }}</div>
                        </div>
                        @endif
                        @if($ppp->show_prazo_implantacao)
                        <div class="col-md-6 info-group">
                            <div class="info-label">{{ __('Prazo de Implantação') }}</div>
                            <div class="info-value">{{ $ppp->prazo_implantacao ?? '–' }}</div>
                        </div>
                        @endif
                    </div>
                    @if($ppp->show_observacoes && $ppp->observacoes)
                    <div class="mt-4">
                        <div class="info-label">{{ __('Observações') }}</div>
                        <p class="text-muted">{{ $ppp->observacoes }}</p>
                    </div>
                    @endif
                    @if($ppp->show_obrigacao && $ppp->obrigacao)
                    <div class="mt-4">
                        <div class="info-label">{{ __('Obrigações') }}</div>
                        <p class="text-muted">{{ $ppp->obrigacao }}</p>
                    </div>
                    @endif
                    @if(!empty($ppp->normativas))
                    <div class="mt-4">
                        <div class="info-label">{{ __('Normativas') }}</div>
                        <p class="text-muted">{{ $ppp->normativas }}</p>
                    </div>
                    @endif
                </div>
            </div>

            <div class="detail-card">
                <div class="detail-card-header">
                    <h4 class="mb-0 fw-bold text-primary">
                        <i class="fa-solid fa-clock-rotate-left me-2"></i>{{ __('Histórico de Tramitações') }}
                    </h4>
                </div>
                <div class="detail-card-body">
                    @if($ppp->historicos && $ppp->historicos->count() > 0)
                        <div class="status-timeline">
                            @foreach($ppp->historicos as $historico)
                                <div class="status-item">
                                    <div class="d-flex justify-content-between align-items-center mb-1">
                                        <div class="fw-semibold text-primary">
                                            {{ $historico->orgao ?? __('Órgão não informado') }}
                                        </div>
                                        <small class="text-muted">
                                            <i class="fa-regular fa-calendar-days me-1"></i>
                                            {{ $historico->data ? \Carbon\Carbon::parse($historico->data)->format('d/m/Y') : optional($historico->created_at)->format('d/m/Y H:i') }}
                                        </small>
                                    </div>
                                    @if($historico->observacao)
                                        <div class="border rounded-3 p-2 bg-light small text-muted">
                                            {{ $historico->observacao }}
                                        </div>
                                    @endif
                                </div>
                            @endforeach
                        </div>
                    @else
                        <p class="text-muted mb-0">{{ __('Nenhum histórico de tramitação cadastrado.') }}</p>
                    @endif
                </div>
            </div>
        </div>
        <div class="col-lg-4">
            <div class="detail-card">
                <div class="detail-card-header bg-primary text-white">
                    <h5 class="mb-0 fw-bold"><i class="fa-solid fa-coins me-2"></i>{{ __('Dados Financeiros') }}</h5>
                </div>
                <div class="detail-card-body">
                    @if($ppp->show_valor_estimado_contrato)
                    <div class="info-group border-bottom pb-2">
                        <div class="info-label">{{ __('Valor Estimado do Contrato') }}</div>
                        <div class="info-value text-success">{{ $ppp->valor_estimado_contrato ?? '–' }}</div>
                    </div>
                    @endif
                    @if($ppp->show_investimento_total)
                    <div class="info-group border-bottom pb-2">
                        <div class="info-label">{{ __('Investimento Total') }}</div>
                        <div class="info-value text-primary">{{ $ppp->investimento_total ?? '–' }}</div>
                    </div>
                    @endif
                    @if($ppp->show_aporte_municipio)
                    <div class="info-group border-bottom pb-2">
                        <div class="info-label">{{ __('Aporte do Município') }}</div>
                        <div class="info-value">{{ $ppp->aporte_municipio ?? '–' }}</div>
                    </div>
                    @endif
                    @if($ppp->show_contraprestacao_mensal)
                    <div class="info-group border-bottom pb-2">
                        <div class="info-label">{{ __('Contraprestação Mensal') }}</div>
                        <div class="info-value">{{ $ppp->contraprestacao_mensal ?? '–' }}</div>
                    </div>
                    @endif
                    @if($ppp->show_outorga_fixa)
                    <div class="info-group border-bottom pb-2">
                        <div class="info-label">{{ __('Outorga Fixa') }}</div>
                        <div class="info-value">{{ $ppp->outorga_fixa ?? '–' }}</div>
                    </div>
                    @endif
                    @if($ppp->show_outorga_variavel)
                    <div class="info-group">
                        <div class="info-label">{{ __('Outorga Variável') }}</div>
                        <div class="info-value">{{ $ppp->outorga_variavel ?? '–' }}</div>
                    </div>
                    @endif
                </div>
            </div>
            <div class="detail-card">
                <div class="detail-card-header">
                    <h5 class="mb-0 fw-bold text-secondary"><i class="fa-solid fa-chart-line me-2"></i>{{ __('Indicadores') }}</h5>
                </div>
                <div class="detail-card-body">
                    <div class="row">
                        @if($ppp->show_tir ?? true)
                        <div class="col-6 info-group text-center">
                            <div class="info-label">{{ __('TIR') }}</div>
                            <div class="display-6 fw-bold text-dark">{{ $ppp->tir ?? '–' }}</div>
                        </div>
                        @endif
                        @if(isset($ppp->reajuste))
                        <div class="col-6 info-group text-center">
                            <div class="info-label">{{ __('Reajuste') }}</div>
                            <div class="h5 fw-bold text-muted mt-2">{{ $ppp->reajuste ?? '–' }}</div>
                        </div>
                        @endif
                    </div>
                    <div class="row mt-3">
                        @if($ppp->show_capex ?? true)
                        <div class="col-6 info-group">
                            <div class="info-label">{{ __('CAPEX') }}</div>
                            <div class="info-value small">{{ $ppp->capex ?? '–' }}</div>
                        </div>
                        @endif
                        @if($ppp->show_opex ?? true)
                        <div class="col-6 info-group">
                            <div class="info-label">{{ __('OPEX') }}</div>
                            <div class="info-value small">{{ $ppp->opex ?? '–' }}</div>
                        </div>
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
