<div class="space-y-6">
    <!-- Order Info -->
    <div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
        <div class="flex justify-between items-start mb-6">
            <div>
                <h3 class="text-xl font-bold text-gray-900"><?= htmlspecialchars($order['title']) ?></h3>
                <p class="text-sm text-gray-500 mt-1">Recebido em:
                    <?= date('d/m/Y H:i', strtotime($order['received_at'])) ?>
                </p>
            </div>
            <span
                class="px-3 py-1 rounded-full text-sm font-semibold <?= $order['type'] == 'block' ? 'bg-red-100 text-red-800' : 'bg-green-100 text-green-800' ?>">
                <?= $order['type'] == 'block' ? 'Bloqueio' : 'Desbloqueio' ?>
            </span>
        </div>

        <div class="prose max-w-none text-gray-700 bg-gray-50 p-4 rounded-lg border border-gray-200">
            <h4 class="text-sm font-bold text-gray-500 uppercase tracking-wider mb-2">Conteúdo da Ordem</h4>
            <style>
                .prose a {
                    color: #2563eb;
                    text-decoration: underline;
                }

                .prose a:hover {
                    color: #1e40af;
                }
            </style>
            <div class="prose max-w-none text-gray-700">
                <?= \App\Utils\TextFormatter::formatContent($order['content'] ?? '') ?></div>
        </div>
    </div>

    <!-- Domains List -->
    <div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
        <div class="px-6 py-4 border-b border-gray-100 bg-gray-50 flex justify-between items-center">
            <h3 class="text-lg font-semibold text-gray-800">Domínios Afetados (<?= count($domains) ?>)</h3>
        </div>
        <div class="overflow-x-auto">
            <table class="w-full text-left border-collapse">
                <thead>
                    <tr>
                        <th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider bg-gray-50">
                            Domínio</th>
                        <th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider bg-gray-50">Ação
                        </th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-100">
                    <?php if (!empty($domains)): ?>
                        <?php foreach ($domains as $domain): ?>
                            <tr class="hover:bg-gray-50 transition-colors">
                                <td class="px-6 py-4 text-sm font-medium text-gray-900"><?= htmlspecialchars($domain['name']) ?>
                                </td>
                                <td class="px-6 py-4 text-sm">
                                    <span
                                        class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full <?= $domain['action'] == 'block' ? 'bg-red-100 text-red-800' : 'bg-green-100 text-green-800' ?>">
                                        <?= $domain['action'] == 'block' ? 'Bloquear' : 'Desbloquear' ?>
                                    </span>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td colspan="2" class="px-6 py-4 text-center text-gray-500">Nenhum domínio listado nesta ordem.
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>

    <div class="flex justify-end">
        <a href="/client/orders"
            class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-colors">Voltar para
            Lista</a>
    </div>
</div>