<?php
// This file is included by the AdminController, which will handle the layout
// No need to set $pageTitle here as it's already set in the controller
?>

<div class="admin-card">
    <div class="flex justify-between items-center mb-6">
        <h2 class="text-xl font-semibold">Menus</h2>
        <a href="/admin/menus/add" class="btn-primary">
            <i class="fas fa-plus mr-2"></i>Add New Menu
        </a>
    </div>
    
    <?php if (empty($menus)): ?>
    <div class="bg-dark p-6 rounded-lg text-center">
        <i class="fas fa-bars text-4xl text-gray-500 mb-4"></i>
        <h3 class="text-lg font-medium mb-2">No Menus Yet</h3>
        <p class="text-gray-400 mb-4">Create menus to organize your site navigation.</p>
        <a href="/admin/menus/add" class="btn-primary">
            <i class="fas fa-plus mr-2"></i>Create Your First Menu
        </a>
    </div>
    <?php else: ?>
    <div class="overflow-x-auto">
        <table class="w-full">
            <thead>
                <tr>
                    <th class="text-left py-3 px-4 border-b border-gray-800">Name</th>
                    <th class="text-left py-3 px-4 border-b border-gray-800">Location</th>
                    <th class="text-left py-3 px-4 border-b border-gray-800">Created</th>
                    <th class="text-right py-3 px-4 border-b border-gray-800">Actions</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($menus as $menu): ?>
                <tr class="hover:bg-dark">
                    <td class="py-3 px-4 border-b border-gray-800">
                        <div class="font-medium"><?= htmlspecialchars($menu['name']) ?></div>
                    </td>
                    <td class="py-3 px-4 border-b border-gray-800">
                        <?php if (!empty($menu['location'])): ?>
                            <span class="inline-block bg-primary bg-opacity-20 text-primary px-2 py-1 rounded text-xs">
                                <?= htmlspecialchars(ucfirst($menu['location'])) ?>
                            </span>
                        <?php else: ?>
                            <span class="text-gray-500">Not assigned</span>
                        <?php endif; ?>
                    </td>
                    <td class="py-3 px-4 border-b border-gray-800 text-gray-400">
                        <?= date('M j, Y', strtotime($menu['created_at'])) ?>
                    </td>
                    <td class="py-3 px-4 border-b border-gray-800 text-right">
                        <div class="flex justify-end space-x-2">
                            <a href="/admin/menus/edit?id=<?= $menu['id'] ?>" class="btn-icon" title="Edit">
                                <i class="fas fa-edit"></i>
                            </a>
                            <form method="POST" action="/admin/menus/delete" class="inline" onsubmit="return confirm('Are you sure you want to delete this menu?');">
                                <input type="hidden" name="id" value="<?= $menu['id'] ?>">
                                <button type="submit" class="btn-icon text-red-500" title="Delete">
                                    <i class="fas fa-trash-alt"></i>
                                </button>
                            </form>
                        </div>
                    </td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
    <?php endif; ?>
</div> 