<div class="max-w-3xl mx-auto">
    <div class="flex items-center justify-between mb-6">
        <div class="flex items-center gap-3">
            <a href="?page=workorders" class="text-gray-400 hover:text-gray-600"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/></svg></a>
            <div><h1 class="text-2xl font-bold text-gray-900"><?= htmlspecialchars($order['title']) ?></h1><p class="text-sm text-gray-500">Work Order #<?= $order['id'] ?></p></div>
        </div>
        <div class="flex items-center gap-2"><?= priorityBadge($order['priority']) ?> <?= statusBadge($order['status']) ?>
            <a href="?page=workorders&action=edit&id=<?= $order['id'] ?>" class="ml-2 px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 text-sm font-medium">Edit</a></div>
    </div>

    <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
        <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-5"><p class="text-xs font-medium text-gray-500 uppercase">Cost</p><p class="text-2xl font-bold text-gray-900 mt-1"><?= $order['cost'] ? formatMoney($order['cost']) : '-' ?></p></div>
        <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-5"><p class="text-xs font-medium text-gray-500 uppercase">Scheduled</p><p class="text-lg font-bold text-gray-900 mt-1"><?= $order['scheduled_date'] ? formatDate($order['scheduled_date']) : 'Not scheduled' ?></p></div>
        <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-5"><p class="text-xs font-medium text-gray-500 uppercase">Completed</p><p class="text-lg font-bold text-gray-900 mt-1"><?= $order['completed_date'] ? formatDate($order['completed_date']) : 'Pending' ?></p></div>
    </div>

    <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6 mb-6">
        <dl class="space-y-3 text-sm">
            <div class="flex justify-between"><dt class="text-gray-500">Vendor</dt><dd class="font-medium"><?= $order['vendor_name'] ? '<a href="?page=vendors&action=show&id='.$order['vendor_id'].'" class="text-indigo-600 hover:underline">'.htmlspecialchars($order['vendor_name']).'</a>' : 'Unassigned' ?></dd></div>
            <?php if ($order['vendor_phone']): ?><div class="flex justify-between"><dt class="text-gray-500">Vendor Phone</dt><dd class="font-medium"><?= htmlspecialchars($order['vendor_phone']) ?></dd></div><?php endif; ?>
            <div class="flex justify-between"><dt class="text-gray-500">Property</dt><dd class="font-medium"><?= htmlspecialchars(($order['property_name'] ?? '-') . ($order['unit_number'] ? ' / '.$order['unit_number'] : '')) ?></dd></div>
            <?php if ($order['request_title']): ?><div class="flex justify-between"><dt class="text-gray-500">Linked Request</dt><dd class="font-medium"><a href="?page=maintenance&action=show&id=<?= $order['maintenance_request_id'] ?>" class="text-indigo-600 hover:underline"><?= htmlspecialchars($order['request_title']) ?></a></dd></div><?php endif; ?>
        </dl>
    </div>

    <?php if ($order['description']): ?>
    <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
        <h3 class="text-sm font-semibold text-gray-500 uppercase tracking-wider mb-3">Description</h3>
        <p class="text-sm text-gray-700 whitespace-pre-line"><?= htmlspecialchars($order['description']) ?></p>
    </div>
    <?php endif; ?>
</div>
