<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AETERNA - Админ-панель</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: Arial, sans-serif; background: #f5f5f5; }
        .admin-header { background: #453227; color: white; padding: 20px; display: flex; justify-content: space-between; align-items: center; }
        .admin-header h1 { font-size: 20px; }
        .admin-tabs { background: white; padding: 10px; border-bottom: 2px solid #453227; display: flex; gap: 10px; flex-wrap: wrap; }
        .admin-tab { padding: 10px 20px; border-radius: 5px; text-decoration: none; color: #333; transition: all 0.3s; }
        .admin-tab:hover, .admin-tab.active { background: #453227; color: white; }
        .admin-content { padding: 20px; }
        .form-container { background: white; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); max-width: 800px; margin: 0 auto; }
        .form-group { margin-bottom: 15px; }
        .form-group label { display: block; margin-bottom: 5px; font-weight: bold; }
        .form-control { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; }
        .btn { padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; text-decoration: none; display: inline-block; transition: all 0.3s; }
        .btn-primary { background: #453227; color: white; }
        .btn-success { background: #28a745; color: white; }
        .btn-danger { background: #dc3545; color: white; }
        .btn-warning { background: #ffc107; color: #333; }
        .btn-sm { padding: 5px 10px; font-size: 12px; }
        .btn:hover { opacity: 0.9; }
        .alert { padding: 15px; border-radius: 4px; margin-bottom: 20px; }
        .alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
        .alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
        table { width: 100%; border-collapse: collapse; background: white; }
        th, td { padding: 10px; border: 1px solid #ddd; text-align: left; }
        th { background: #f8f9fa; }
        .action-buttons { display: flex; gap: 5px; }
        .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin: 20px 0; }
        .stat-card { background: white; padding: 20px; border-radius: 5px; text-align: center; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
        .stat-card h3 { font-size: 32px; color: #453227; margin-bottom: 5px; }
        .stat-card p { color: #666; }
    </style>
</head>
<body>
    <div class="admin-header">
        <h1><i class="fas fa-user-shield"></i> Админ-панель AETERNA</h1>
        <div>
            <span><?= htmlspecialchars($user['email'] ?? 'Администратор') ?></span>
            <a href="/catalog" class="btn btn-primary" style="margin-left: 10px;">В каталог</a>
            <a href="/logout" class="btn btn-danger" style="margin-left: 10px;">Выйти</a>
        </div>
    </div>

    <div class="admin-tabs">
        <a href="/admin" class="admin-tab <?= ($action ?? '') === 'dashboard' ? 'active' : '' ?>">
            <i class="fas fa-tachometer-alt"></i> Дашборд
        </a>
        <a href="/admin/products" class="admin-tab <?= str_contains($_SERVER['REQUEST_URI'] ?? '', '/products') ? 'active' : '' ?>">
            <i class="fas fa-box"></i> Товары
        </a>
        <a href="/admin/categories" class="admin-tab <?= str_contains($_SERVER['REQUEST_URI'] ?? '', '/categories') ? 'active' : '' ?>">
            <i class="fas fa-tags"></i> Категории
        </a>
        <a href="/admin/orders" class="admin-tab <?= str_contains($_SERVER['REQUEST_URI'] ?? '', '/orders') ? 'active' : '' ?>">
            <i class="fas fa-shopping-cart"></i> Заказы
        </a>
        <a href="/admin/users" class="admin-tab <?= str_contains($_SERVER['REQUEST_URI'] ?? '', '/users') ? 'active' : '' ?>">
            <i class="fas fa-users"></i> Пользователи
        </a>
    </div>

    <div class="admin-content">
        <?= $content ?>
    </div>
</body>
</html>
