<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>

<div class="ehx-nav-edit">
    <div class="clear"></div>
    <h4 style="margin-bottom: 0.6em;"><?php esc_html_e('EHx Member Menu Settings', 'ehx-members'); ?></h4>

    <!-- Visibility Settings -->
    <p class="description description-wide ehx-nav-mode">
        <label for="edit-ehxme_menu_visibility-<?php echo esc_attr($item_id); ?>">
            <?php esc_html_e('Who can see this menu link?', 'ehx-members'); ?>
            <br>
            <select id="edit-ehxme_menu_visibility-<?php echo esc_attr($item_id); ?>" name="ehxme_menu_visibility[<?php echo esc_attr($item_id); ?>]" style="width: 100%;">
                <option value="everyone" <?php selected($visibility, 'everyone'); ?>><?php esc_html_e('Everyone', 'ehx-members'); ?></option>
                <option value="logged-in" <?php selected($visibility, 'logged-in'); ?>><?php esc_html_e('Logged-in Users', 'ehx-members'); ?></option>
                <option value="logged-out" <?php selected($visibility, 'logged-out'); ?>><?php esc_html_e('Logged-out Users', 'ehx-members'); ?></option>
            </select>
        </label>
    </p>

    <!-- Role-Based Visibility -->
    <p class="description description-wide ehx-nav-roles">
        <?php esc_html_e('Select the member roles that can see this link', 'ehx-members'); ?>
        <br>
        <span class="ehxme-form-fields-section" style="width:50% !important;">
            <?php foreach (wp_roles()->roles as $role_slug => $role): ?>
                <label for="edit-menu-item-ehx_nav_roles-<?php echo esc_attr($item_id); ?>_<?php echo esc_attr($role_slug); ?>">
                    <input type="checkbox" 
                        id="edit-menu-item-ehx_nav_roles-<?php echo esc_attr($item_id); ?>_<?php echo esc_attr($role_slug); ?>" 
                        name="ehxme_menu_roles[<?php echo esc_attr($item_id); ?>][<?php echo esc_attr($role_slug); ?>]" 
                        value="<?php echo esc_attr($role_slug); ?>" 
                        <?php checked(in_array($role_slug, $roles)); ?>>
                    <span><?php echo esc_html($role['name']); ?></span>
                </label>
            <?php endforeach; ?>
        </span>
    </p>
    <div class="clear"></div>
</div>