<!DOCTYPE html>
<html lang="pt-BR">

<head>
    <meta charset="UTF-8">
    <title>{{ __('Ficha de Comprovação de Cadastro') }} - {{ $empresa->nomeFantasia ?? $empresa->razaoSocial }}</title>
    <style>
        @page {
            margin: 18mm 15mm 28mm 15mm;
        }

        body {
            font-family: Arial, sans-serif;
            font-size: 10pt;
            color: #000;
            margin: 0;
            padding: 0;
        }

        .pdf-header table {
            width: 100%;
            border-collapse: collapse;
        }

        .pdf-header td {
            border: none;
            vertical-align: middle;
        }

        .pdf-header img {
            width: 75px;
            height: auto;
        }

        h1 {
            font-size: 14pt;
            margin: 0;
            color: #1245A8;
            text-transform: uppercase;
        }

        h2 {
            font-size: 11pt;
            margin: 2px 0 0;
            color: #333;
            font-weight: normal;
        }

        h3 {
            font-size: 11pt;
            margin: 14px 0 6px;
            padding: 4px 8px;
            background: #f2f2f2;
            border-left: 4px solid #1245A8;
            text-transform: uppercase;
            page-break-after: avoid;
        }

        .doc-title {
            margin-top: 10px;
            font-size: 12pt;
            font-weight: bold;
            text-align: center;
            text-transform: uppercase;
            border-bottom: 1px solid #bbb;
            padding-bottom: 6px;
        }

        .info-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 8px;
        }

        .info-table td {
            padding: 4px 6px;
            vertical-align: top;
            border: none;
        }

        .info-label {
            font-weight: bold;
            width: 32%;
            color: #333;
        }

        .info-value {
            width: 68%;
        }

        .person-block {
            width: 100%;
            margin-bottom: 10px;
            page-break-inside: avoid;
        }

        .person-block table {
            width: 100%;
            border-collapse: collapse;
        }

        .person-photo {
            width: 90px;
            vertical-align: top;
            padding-right: 10px;
        }

        .person-photo img {
            width: 85px;
            height: 105px;
            object-fit: cover;
            border: 1px solid #ccc;
        }

        .embarcacoes-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 6px;
            font-size: 9pt;
        }

        .embarcacoes-table th,
        .embarcacoes-table td {
            border: 1px solid #bbb;
            padding: 5px;
            text-align: left;
        }

        .embarcacoes-table th {
            background: #f2f2f2;
            font-weight: bold;
        }

        .embarcacoes-table tr {
            page-break-inside: avoid;
        }

        .status-badge {
            display: inline-block;
            padding: 2px 8px;
            border: 1px solid #999;
            border-radius: 3px;
            font-size: 9pt;
            font-weight: bold;
        }

        .content {
            margin-bottom: 50px;
        }

        .footer-wrapper {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            font-size: 9pt;
            padding: 5px 0;
            border-top: 1px solid #ccc;
        }

        .footer-wrapper table {
            width: 100%;
        }

        .footer-wrapper td {
            border: none;
            padding: 0 5px;
        }

        .page:after {
            content: counter(page);
        }

        .empty-note {
            font-style: italic;
            color: #666;
            margin: 4px 0 8px;
        }
    </style>
</head>

<body>
    <div class="pdf-header">
        <table>
            <tr>
                <td style="width: 85px;">
                    <img src="{{ public_path('pmar/assets/img/icons/prefeitura-angra-dos-reis.jpg') }}"
                        alt="{{ __('Prefeitura Municipal de Angra dos Reis') }}">
                </td>
                <td>
                    <h1>{{ __('Prefeitura Municipal de Angra dos Reis') }}</h1>
                    <h2>{{ __('Empresas de Turismo — Turismo Náutico') }}</h2>
                </td>
            </tr>
        </table>
        <div class="doc-title">{{ __('Ficha de Comprovação de Cadastro') }}</div>
    </div>

    <div class="content">
        <h3>{{ __('Dados da Empresa') }}</h3>
        <table class="info-table">
            <tr>
                <td class="info-label">{{ __('Razão Social') }}:</td>
                <td class="info-value">{{ $empresa->razaoSocial ?? '-' }}</td>
            </tr>
            <tr>
                <td class="info-label">{{ __('Nome Fantasia') }}:</td>
                <td class="info-value">{{ $empresa->nomeFantasia ?? '-' }}</td>
            </tr>
            <tr>
                <td class="info-label">{{ __('CNPJ') }}:</td>
                <td class="info-value">{{ $empresa->cnpj ?? '-' }}</td>
            </tr>
            <tr>
                <td class="info-label">{{ __('Inscrição Municipal') }}:</td>
                <td class="info-value">{{ $empresa->numeroInscricaoMunicipal ?? '-' }}</td>
            </tr>
            <tr>
                <td class="info-label">{{ __('Cadastur') }}:</td>
                <td class="info-value">{{ $empresaTurismo->cadastur ?? '-' }}</td>
            </tr>
            <tr>
                <td class="info-label">{{ __('Vencimento do CADASTUR') }}:</td>
                <td class="info-value">
                    {{ $empresaTurismo->cadastur_vencimento ? $empresaTurismo->cadastur_vencimento->format('d/m/Y') : '-' }}
                </td>
            </tr>
            <tr>
                <td class="info-label">{{ __('Ano de Abertura') }}:</td>
                <td class="info-value">{{ $empresa->anoAbertura ?? '-' }}</td>
            </tr>
            <tr>
                <td class="info-label">{{ __('Principal Atividade') }}:</td>
                <td class="info-value">{{ $empresa->principalAtividade ?? '-' }}</td>
            </tr>
            <tr>
                <td class="info-label">{{ __('Data de Cadastro') }}:</td>
                <td class="info-value">{{ $empresaTurismo->created_at ? date('d/m/Y H:i', strtotime($empresaTurismo->created_at)) : '-' }}</td>
            </tr>
            <tr>
                <td class="info-label">{{ __('Status') }}:</td>
                <td class="info-value">
                    <span class="status-badge">{{ $empresaTurismo->status ?? '-' }}</span>
                </td>
            </tr>
        </table>

        <h3>{{ __('Contato') }}</h3>
        <table class="info-table">
            <tr>
                <td class="info-label">{{ __('E-mail') }}:</td>
                <td class="info-value">{{ $empresa->email ?? '-' }}</td>
            </tr>
            <tr>
                <td class="info-label">{{ __('Telefone') }}:</td>
                <td class="info-value">{{ $empresa->telefone ?? '-' }}</td>
            </tr>
            <tr>
                <td class="info-label">{{ __('Celular') }}:</td>
                <td class="info-value">{{ $empresa->celular ?? '-' }}</td>
            </tr>
            <tr>
                <td class="info-label">{{ __('Site') }}:</td>
                <td class="info-value">{{ $empresa->site ?? '-' }}</td>
            </tr>
        </table>

        <h3>{{ __('Endereço da Sede') }}</h3>
        @if ($endereco)
            <table class="info-table">
                <tr>
                    <td class="info-label">{{ __('CEP') }}:</td>
                    <td class="info-value">{{ $endereco->cep ?? '-' }}</td>
                </tr>
                <tr>
                    <td class="info-label">{{ __('Logradouro') }}:</td>
                    <td class="info-value">
                        {{ $endereco->logradouro ?? '-' }}{{ $endereco->numero ? ', ' . $endereco->numero : '' }}
                    </td>
                </tr>
                <tr>
                    <td class="info-label">{{ __('Complemento') }}:</td>
                    <td class="info-value">{{ $endereco->complemento ?? '-' }}</td>
                </tr>
                <tr>
                    <td class="info-label">{{ __('Bairro') }}:</td>
                    <td class="info-value">{{ $endereco->bairro ?? '-' }}</td>
                </tr>
                <tr>
                    <td class="info-label">{{ __('Cidade/UF') }}:</td>
                    <td class="info-value">{{ ($endereco->cidade ?? '-') . '/' . ($endereco->uf ?? '-') }}</td>
                </tr>
            </table>
        @else
            <p class="empty-note">{{ __('Endereço não informado.') }}</p>
        @endif

        <h3>{{ __('Responsável Legal') }}</h3>
        @if ($responsavel)
            <div class="person-block">
                <table>
                    <tr>
                        <td class="person-photo">
                            <img src="{{ $fotoResponsavel }}" alt="{{ __('Foto do responsável legal') }}">
                        </td>
                        <td>
                            <table class="info-table">
                                <tr>
                                    <td class="info-label">{{ __('Nome') }}:</td>
                                    <td class="info-value">{{ $responsavel->name ?? '-' }}</td>
                                </tr>
                                <tr>
                                    <td class="info-label">{{ __('CPF') }}:</td>
                                    <td class="info-value">{{ $responsavel->cpf ?? '-' }}</td>
                                </tr>
                                <tr>
                                    <td class="info-label">{{ __('E-mail') }}:</td>
                                    <td class="info-value">{{ $responsavel->email ?? '-' }}</td>
                                </tr>
                                <tr>
                                    <td class="info-label">{{ __('Telefone') }}:</td>
                                    <td class="info-value">{{ $responsavel->phoneNumber ?? '-' }}</td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
        @else
            <p class="empty-note">{{ __('Responsável legal não informado.') }}</p>
        @endif

        <h3>{{ __('Preposto') }}</h3>
        @if ($preposto)
            <div class="person-block">
                <table>
                    <tr>
                        <td class="person-photo">
                            <img src="{{ $fotoPreposto }}" alt="{{ __('Foto do preposto') }}">
                        </td>
                        <td>
                            <table class="info-table">
                                <tr>
                                    <td class="info-label">{{ __('Nome') }}:</td>
                                    <td class="info-value">{{ $preposto->name ?? '-' }}</td>
                                </tr>
                                <tr>
                                    <td class="info-label">{{ __('CPF') }}:</td>
                                    <td class="info-value">{{ $preposto->cpf ?? '-' }}</td>
                                </tr>
                                <tr>
                                    <td class="info-label">{{ __('E-mail') }}:</td>
                                    <td class="info-value">{{ $preposto->email ?? '-' }}</td>
                                </tr>
                                <tr>
                                    <td class="info-label">{{ __('Telefone') }}:</td>
                                    <td class="info-value">{{ $preposto->phoneNumber ?? '-' }}</td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
        @else
            <p class="empty-note">{{ __('Preposto não cadastrado.') }}</p>
        @endif

        <h3>{{ __('Embarcações Ativas') }}</h3>
        @if ($embarcacoes->isNotEmpty())
            <table class="embarcacoes-table">
                <thead>
                    <tr>
                        <th>{{ __('Nome') }}</th>
                        <th>{{ __('Categoria') }}</th>
                        <th>{{ __('Inscrição') }}</th>
                        <th>{{ __('RCI') }}</th>
                        <th>{{ __('TIE') }}</th>
                        <th>{{ __('Capacidade') }}</th>
                        <th>{{ __('Tipo') }}</th>
                        <th>{{ __('Atividade') }}</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($embarcacoes as $embarcacao)
                        <tr>
                            <td>{{ $embarcacao->nome }}</td>
                            <td>
                                @include('components.tables._getEnumValue', [
                                    'EnumClass' => App\Enums\StatusTipoCategoriaEmbarcacoesNavegueLegal::cases(),
                                    'arg' => $embarcacao->categoria,
                                ])
                            </td>
                            <td>{{ $embarcacao->inscricao }}</td>
                            <td>{{ $embarcacao->rci }}</td>
                            <td>{{ $embarcacao->tie ?? '-' }}</td>
                            <td>{{ $embarcacao->capacidade }}</td>
                            <td>
                                @if ($embarcacao->categoria === 'TAXI_BOATS')
                                    @include('components.tables._getEnumValue', [
                                        'EnumClass' => App\Enums\StatusTipoBoatsNavegueLegal::cases(),
                                        'arg' => $embarcacao->tipo,
                                    ])
                                @else
                                    {{ $embarcacao->tipo }}
                                @endif
                            </td>
                            <td>{{ $embarcacao->atividade }}</td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        @else
            <p class="empty-note">{{ __('Nenhuma embarcação ativa cadastrada.') }}</p>
        @endif
    </div>

    <div class="footer-wrapper">
        <table>
            <tr>
                <td style="text-align: left;">{{ __('Gerado em') }}: {{ $geradoEm }}</td>
                <td style="text-align: right;">{{ __('Página') }} <span class="page"></span></td>
            </tr>
        </table>
    </div>
</body>

</html>
