<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=documents" 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($doc['title']) ?></h1><p class="text-sm text-gray-500">Uploaded <?= timeAgo($doc['created_at']) ?></p></div></div>
        <div class="flex gap-2">
            <?php if ($doc['file_path']): ?><a href="?page=documents&action=download&id=<?= $doc['id'] ?>" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 text-sm font-medium">Download</a><?php endif; ?>
            <form method="POST" action="?page=documents&action=delete&id=<?= $doc['id'] ?>" onsubmit="return confirm('Delete?')"><?= CSRF::field() ?><button class="px-4 py-2 border border-red-300 text-red-600 rounded-lg hover:bg-red-50 text-sm font-medium">Delete</button></form>
        </div>
    </div>
    <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
        <dl class="space-y-4 text-sm">
            <div class="flex justify-between"><dt class="text-gray-500">Filename</dt><dd class="font-medium"><?= htmlspecialchars($doc['filename'] ?? '-') ?></dd></div>
            <div class="flex justify-between"><dt class="text-gray-500">Category</dt><dd><span class="inline-flex px-2 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-700"><?= ucfirst($doc['category'] ?? 'other') ?></span></dd></div>
            <div class="flex justify-between"><dt class="text-gray-500">File Size</dt><dd class="font-medium"><?= $doc['file_size'] ? round($doc['file_size']/1024).'KB' : '-' ?></dd></div>
            <div class="flex justify-between"><dt class="text-gray-500">Type</dt><dd class="font-medium"><?= htmlspecialchars($doc['mime_type'] ?? '-') ?></dd></div>
            <div class="flex justify-between"><dt class="text-gray-500">Uploaded By</dt><dd class="font-medium"><?= htmlspecialchars(($doc['uploader_first'] ?? '').' '.($doc['uploader_last'] ?? '')) ?></dd></div>
            <?php if ($doc['expiry_date']): ?><div class="flex justify-between"><dt class="text-gray-500">Expiry Date</dt><dd class="font-medium <?= strtotime($doc['expiry_date']) < time() ? 'text-red-600' : '' ?>"><?= formatDate($doc['expiry_date']) ?></dd></div><?php endif; ?>
            <?php if ($doc['documentable_type']): ?><div class="flex justify-between"><dt class="text-gray-500">Attached To</dt><dd class="font-medium"><?= ucfirst($doc['documentable_type']) ?> #<?= $doc['documentable_id'] ?></dd></div><?php endif; ?>
            <?php if ($doc['description']): ?><div class="pt-4 border-t border-gray-100"><dt class="text-gray-500 mb-1">Description</dt><dd class="text-gray-700"><?= htmlspecialchars($doc['description']) ?></dd></div><?php endif; ?>
        </dl>
    </div>
</div>
