-- ============================================================
-- NICC Admin Menu - Migracion 0011
-- Agregar Proteccion Grupo Manager (solo visible para manager)
-- ============================================================

INSERT OR IGNORE INTO admin_menu_items (
    category_id,
    code,
    plugin_name,
    name,
    description,
    icon,
    url,
    sort_order,
    is_active,
    is_dangerous,
    requires_confirmation
)
SELECT
    (SELECT id FROM admin_menu_categories WHERE code = 'tools' LIMIT 1),
    'managerprotect',
    'managerprotect',
    'Proteccion Manager',
    'Configurar contrasena SIE para creacion de usuarios',
    'shield',
    '?do=admin&page=managerprotect',
    55,
    1,
    0,
    0
WHERE NOT EXISTS (SELECT 1 FROM admin_menu_items WHERE code = 'managerprotect');

-- Manager: acceso total
INSERT OR REPLACE INTO admin_menu_permissions (item_id, role, can_view, can_execute)
SELECT id, 'manager', 1, 1 FROM admin_menu_items WHERE code = 'managerprotect';

-- Admin: oculto
INSERT OR REPLACE INTO admin_menu_permissions (item_id, role, can_view, can_execute)
SELECT id, 'admin', 0, 0 FROM admin_menu_items WHERE code = 'managerprotect';

-- Superuser: oculto
INSERT OR REPLACE INTO admin_menu_permissions (item_id, role, can_view, can_execute)
SELECT id, 'superuser', 0, 0 FROM admin_menu_items WHERE code = 'managerprotect';

-- Fin de migracion
SELECT 1;
