<?php
/**
 * Admin shell for Noesia Smart Waiter.
 *
 * Bridge template: shell logic is prepared by a helper/service while the file
 * remains the compatibility-layer renderer for the current admin UI.
 *
 * True lazy render version:
 * - shell renders nav/topbar/menu visibility manager immediately
 * - only the active section HTML is rendered on first paint
 * - inactive sections keep placeholder panels and load over AJAX on demand
 *
 * @package Noesia_Smart_Waiter
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

$noesia_swa_settings_shell_service = null;

if ( function_exists( 'noesia_swa' ) ) {
    $noesia_swa_plugin = noesia_swa();

    if ( is_object( $noesia_swa_plugin ) && isset( $noesia_swa_plugin->settings_shell_data ) ) {
        $noesia_swa_settings_shell_service = $noesia_swa_plugin->settings_shell_data;
    }
}

if ( ! $noesia_swa_settings_shell_service instanceof Noesia_SWA_Settings_Shell_Data && class_exists( 'Noesia_SWA_Settings_Shell_Data' ) ) {
    $noesia_swa_settings_shell_service = new Noesia_SWA_Settings_Shell_Data();
}

$noesia_swa_settings_shell_context = ( $noesia_swa_settings_shell_service instanceof Noesia_SWA_Settings_Shell_Data )
    ? $noesia_swa_settings_shell_service->get_context( __DIR__ )
    : array();

( static function ( $noesia_swa_settings_shell_context ) {
    $options = isset( $noesia_swa_settings_shell_context['options'] ) && is_array( $noesia_swa_settings_shell_context['options'] )
        ? $noesia_swa_settings_shell_context['options']
        : array();

    $site_admin_url = isset( $noesia_swa_settings_shell_context['site_admin_url'] )
        ? (string) $noesia_swa_settings_shell_context['site_admin_url']
        : admin_url();

    $settings_form_action = admin_url( 'options.php' );
    $settings_page_url    = menu_page_url( 'noesia_swa_settings', false );

    if ( ! is_string( $settings_page_url ) || '' === $settings_page_url ) {
        $settings_page_url = admin_url( 'admin.php?page=noesia_swa_settings' );
    }

    $active_section = isset( $noesia_swa_settings_shell_context['active_section'] )
        ? sanitize_key( (string) $noesia_swa_settings_shell_context['active_section'] )
        : 'dashboard';

    $active_requests_count = isset( $noesia_swa_settings_shell_context['active_requests_count'] )
        ? max( 0, (int) $noesia_swa_settings_shell_context['active_requests_count'] )
        : 0;

    $active_reminders_count = isset( $noesia_swa_settings_shell_context['active_reminders_count'] )
        ? max( 0, (int) $noesia_swa_settings_shell_context['active_reminders_count'] )
        : 0;

    $active_appointments_count = isset( $noesia_swa_settings_shell_context['active_appointments_count'] )
        ? max( 0, (int) $noesia_swa_settings_shell_context['active_appointments_count'] )
        : 0;

    $active_badge_type = isset( $noesia_swa_settings_shell_context['active_badge_type'] )
        ? sanitize_key( (string) $noesia_swa_settings_shell_context['active_badge_type'] )
        : '';

    $active_badge_visible = ! empty( $noesia_swa_settings_shell_context['active_badge_visible'] );

    $active_badge_count = isset( $noesia_swa_settings_shell_context['active_badge_count'] )
        ? max( 0, (int) $noesia_swa_settings_shell_context['active_badge_count'] )
        : 0;

    $active_badge_label = isset( $noesia_swa_settings_shell_context['active_badge_label'] )
        ? (string) $noesia_swa_settings_shell_context['active_badge_label']
        : __( 'Live status', 'noesia-smart-waiter' );

    $active_badge_text = isset( $noesia_swa_settings_shell_context['active_badge_text'] )
        ? (string) $noesia_swa_settings_shell_context['active_badge_text']
        : '';

    $active_badge_target = isset( $noesia_swa_settings_shell_context['active_badge_target'] )
        ? sanitize_key( (string) $noesia_swa_settings_shell_context['active_badge_target'] )
        : '';

    $bookmark_menu = isset( $noesia_swa_settings_shell_context['bookmark_menu'] ) && is_array( $noesia_swa_settings_shell_context['bookmark_menu'] )
        ? $noesia_swa_settings_shell_context['bookmark_menu']
        : array();

    $topbar_nav_actions = isset( $noesia_swa_settings_shell_context['topbar_nav_actions'] ) && is_array( $noesia_swa_settings_shell_context['topbar_nav_actions'] )
        ? $noesia_swa_settings_shell_context['topbar_nav_actions']
        : array();

    $nav_items = isset( $noesia_swa_settings_shell_context['nav_items'] ) && is_array( $noesia_swa_settings_shell_context['nav_items'] )
        ? $noesia_swa_settings_shell_context['nav_items']
        : array();

    $nav_card_states = isset( $noesia_swa_settings_shell_context['nav_card_states'] ) && is_array( $noesia_swa_settings_shell_context['nav_card_states'] )
        ? $noesia_swa_settings_shell_context['nav_card_states']
        : array();

    $admin_sections_registry = isset( $noesia_swa_settings_shell_context['admin_sections_registry'] )
        ? $noesia_swa_settings_shell_context['admin_sections_registry']
        : null;

    $menu_hidden_sections = array();

    if ( isset( $options['menu_hidden_sections'] ) ) {
        $hidden_raw     = (string) $options['menu_hidden_sections'];
        $hidden_decoded = json_decode( $hidden_raw, true );

        if ( is_array( $hidden_decoded ) ) {
            $menu_hidden_sections = array_values(
                array_unique(
                    array_filter(
                        array_map( 'sanitize_key', $hidden_decoded )
                    )
                )
            );
        }
    }

    $render_registry_unavailable = static function () {
        echo '<div class="noesia-swa-card noesia-swa-card--span2">';
        echo '<h3>' . esc_html__( 'Admin sections registry unavailable', 'noesia-smart-waiter' ) . '</h3>';
        echo '<p class="noesia-swa-muted">' . esc_html__( 'This screen now requires the registry-driven shell.', 'noesia-smart-waiter' ) . '</p>';
        echo '</div>';
    };

    $registered_sections   = array();
    $current_section_title = ucfirst( str_replace( '-', ' ', (string) $active_section ) );

$get_requested_section_from_query = static function () {
	// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only display-state query parameter; validated against registered admin sections before use.
	if ( ! isset( $_GET['section'] ) ) {
		return '';
	}

	// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only display-state query parameter; validated against registered admin sections before use.
	return sanitize_key( wp_unslash( (string) $_GET['section'] ) );
};

$requested_section = $get_requested_section_from_query();

  if ( $admin_sections_registry instanceof Noesia_SWA_Admin_Sections ) {
	if ( '' !== $requested_section ) {
		$active_section = $admin_sections_registry->resolve_active_section( $requested_section );
	} else {
		$active_section = $admin_sections_registry->resolve_active_section( $active_section );
	}

        $registered_sections = $admin_sections_registry->get_sections();

        if ( empty( $nav_items ) ) {
            foreach ( $admin_sections_registry->get_nav_items() as $nav_key => $nav_item ) {
                $nav_key = sanitize_key( (string) $nav_key );

                if ( '' === $nav_key ) {
                    continue;
                }

                $nav_items[ $nav_key ] = array(
                    'icon'         => isset( $nav_item['icon'] ) ? (string) $nav_item['icon'] : 'dashicons-admin-generic',
                    'title'        => isset( $nav_item['nav_label'] ) ? (string) $nav_item['nav_label'] : ( isset( $nav_item['label'] ) ? (string) $nav_item['label'] : ucfirst( str_replace( '-', ' ', $nav_key ) ) ),
                    'sub'          => isset( $nav_item['nav_sub'] ) ? (string) $nav_item['nav_sub'] : '',
                    'hero'         => ! empty( $nav_item['hero'] ),
                    'tier'         => isset( $nav_item['tier'] ) ? (string) $nav_item['tier'] : 'free',
                    'owner'        => isset( $nav_item['owner'] ) ? (string) $nav_item['owner'] : 'core',
                    'icon_type'    => isset( $nav_item['icon_type'] ) ? (string) $nav_item['icon_type'] : '',
                    'icon_svg_key' => isset( $nav_item['icon_svg_key'] ) ? (string) $nav_item['icon_svg_key'] : '',
                    'icon_color'   => isset( $nav_item['icon_color'] ) ? (string) $nav_item['icon_color'] : '',
                );
            }
        }

        $active_section_meta = $admin_sections_registry->get_section( $active_section );

        if ( is_array( $active_section_meta ) && ! empty( $active_section_meta['label'] ) ) {
            $current_section_title = (string) $active_section_meta['label'];
        }
  } elseif ( '' !== $requested_section ) {
	$active_section = $requested_section;
}

    $normalized_nav_items = array();

    foreach ( $nav_items as $nav_key => $nav_item ) {
        if ( ! is_array( $nav_item ) ) {
            continue;
        }

        $nav_key = sanitize_key( (string) $nav_key );

        if ( '' === $nav_key ) {
            continue;
        }

        $fallback_section = isset( $registered_sections[ $nav_key ] ) && is_array( $registered_sections[ $nav_key ] )
            ? $registered_sections[ $nav_key ]
            : array();

        $normalized_nav_items[ $nav_key ] = array(
            'icon'         => isset( $nav_item['icon'] ) && '' !== (string) $nav_item['icon']
                ? (string) $nav_item['icon']
                : ( isset( $fallback_section['icon'] ) ? (string) $fallback_section['icon'] : 'dashicons-admin-generic' ),
            'title'        => isset( $nav_item['title'] ) && '' !== (string) $nav_item['title']
                ? (string) $nav_item['title']
                : ( isset( $fallback_section['nav_label'] ) && '' !== (string) $fallback_section['nav_label']
                    ? (string) $fallback_section['nav_label']
                    : ( isset( $fallback_section['label'] ) ? (string) $fallback_section['label'] : ucfirst( str_replace( '-', ' ', $nav_key ) ) ) ),
            'sub'          => isset( $nav_item['sub'] ) ? (string) $nav_item['sub'] : ( isset( $fallback_section['nav_sub'] ) ? (string) $fallback_section['nav_sub'] : '' ),
            'hero'         => ! empty( $nav_item['hero'] ) || ! empty( $fallback_section['hero'] ),
            'tier'         => isset( $nav_item['tier'] ) ? (string) $nav_item['tier'] : ( isset( $fallback_section['tier'] ) ? (string) $fallback_section['tier'] : 'free' ),
            'owner'        => isset( $nav_item['owner'] ) ? (string) $nav_item['owner'] : ( isset( $fallback_section['owner'] ) ? (string) $fallback_section['owner'] : 'core' ),
            'icon_type'    => isset( $nav_item['icon_type'] ) ? (string) $nav_item['icon_type'] : ( isset( $fallback_section['icon_type'] ) ? (string) $fallback_section['icon_type'] : '' ),
            'icon_svg_key' => isset( $nav_item['icon_svg_key'] ) ? (string) $nav_item['icon_svg_key'] : ( isset( $fallback_section['icon_svg_key'] ) ? (string) $fallback_section['icon_svg_key'] : '' ),
            'icon_color'   => isset( $nav_item['icon_color'] ) ? (string) $nav_item['icon_color'] : ( isset( $fallback_section['icon_color'] ) ? (string) $fallback_section['icon_color'] : '' ),
        );
    }

    $nav_items = $normalized_nav_items;

    $visible_nav_items = array();
    $hidden_nav_items  = array();

    foreach ( $nav_items as $nav_key => $nav_item ) {
        if ( in_array( sanitize_key( (string) $nav_key ), $menu_hidden_sections, true ) ) {
            $hidden_nav_items[ $nav_key ] = $nav_item;
        } else {
            $visible_nav_items[ $nav_key ] = $nav_item;
        }
    }
    ?>
    <div id="noesia-swa-wrapper" class="noesia-swa-admin-wrap noesia-swa-theme-default" data-noesia-swa-section="<?php echo esc_attr( $active_section ); ?>" data-noesia-swa-nav-style="hub" data-noesia-swa-settings-form-action="<?php echo esc_url( $settings_form_action ); ?>" data-noesia-swa-settings-page-url="<?php echo esc_url( $settings_page_url ); ?>" data-noesia-swa-active-count="<?php echo esc_attr( (string) $active_badge_count ); ?>" data-noesia-swa-active-requests-count="<?php echo esc_attr( (string) $active_requests_count ); ?>" data-noesia-swa-active-reminders-count="<?php echo esc_attr( (string) $active_reminders_count ); ?>" data-noesia-swa-active-appointments-count="<?php echo esc_attr( (string) $active_appointments_count ); ?>" data-noesia-swa-active-badge-type="<?php echo esc_attr( $active_badge_type ); ?>" data-noesia-swa-active-badge-target="<?php echo esc_attr( $active_badge_target ); ?>">
        <aside
            class="noesia-swa-sidebar"
            aria-label="<?php esc_attr_e( 'Noesia Smart Waiter navigation', 'noesia-smart-waiter' ); ?>"
        >
            <div class="noesia-swa-sidebar-head">
    <button
    type="button"
    class="noesia-swa-sidebar-collapse"
    data-noesia-swa-action="toggleSidebar"
    aria-label="<?php esc_attr_e( 'Collapse menu', 'noesia-smart-waiter' ); ?>"
>
    <span class="dashicons dashicons-menu-alt2" aria-hidden="true"></span>
</button>

 <div class="noesia-swa-brand-block">
    <h1 class="noesia-swa-brand-title"><?php esc_html_e( 'Noesia', 'noesia-smart-waiter' ); ?></h1>
    <?php /* <div class="noesia-swa-brand-subtitle"><?php esc_html_e( 'Smart Waiter', 'noesia-smart-waiter' ); ?></div> */ ?>
</div>
</div>

<div class="noesia-swa-theme-dots" aria-label="<?php esc_attr_e( 'Theme selector', 'noesia-smart-waiter' ); ?>">
    <button type="button" class="noesia-swa-theme-dot is-active" data-noesia-swa-theme="default" aria-label="<?php esc_attr_e( 'Default theme', 'noesia-smart-waiter' ); ?>"></button>
    <button type="button" class="noesia-swa-theme-dot" data-noesia-swa-theme="graphite" aria-label="<?php esc_attr_e( 'Graphite theme', 'noesia-smart-waiter' ); ?>"></button>
    <button type="button" class="noesia-swa-theme-dot" data-noesia-swa-theme="dark" aria-label="<?php esc_attr_e( 'Dark theme', 'noesia-smart-waiter' ); ?>"></button>
    <button type="button" class="noesia-swa-theme-dot" data-noesia-swa-theme="black" aria-label="<?php esc_attr_e( 'Black theme', 'noesia-smart-waiter' ); ?>"></button>
    <button type="button" class="noesia-swa-theme-dot" data-noesia-swa-theme="ciel" aria-label="<?php esc_attr_e( 'Ciel theme', 'noesia-smart-waiter' ); ?>"></button>
    <button type="button" class="noesia-swa-theme-dot" data-noesia-swa-theme="minimal" aria-label="<?php esc_attr_e( 'Minimal theme', 'noesia-smart-waiter' ); ?>"></button>
</div>

            <div class="noesia-swa-nav-style-switcher" aria-label="<?php esc_attr_e( 'Navigation style', 'noesia-smart-waiter' ); ?>">
                <button
                    type="button"
                    class="noesia-swa-nav-style-btn noesia-swa-nav-style-btn--icon"
                    data-noesia-swa-action="toggleNavReorder"
                    aria-label="<?php esc_attr_e( 'Rearrange menu', 'noesia-smart-waiter' ); ?>"
                    aria-pressed="false"
                    title="<?php esc_attr_e( 'Rearrange menu', 'noesia-smart-waiter' ); ?>"
                >
                    <span class="dashicons dashicons-move" aria-hidden="true"></span>
                </button>

                <button
                    type="button"
                    class="noesia-swa-nav-style-btn noesia-swa-nav-style-btn--icon"
                    data-noesia-swa-action="saveNavReorder"
                    aria-label="<?php esc_attr_e( 'Save menu order', 'noesia-smart-waiter' ); ?>"
                    title="<?php esc_attr_e( 'Save menu order', 'noesia-smart-waiter' ); ?>"
                >
                    <span class="dashicons dashicons-saved" aria-hidden="true"></span>
                </button>

                <button
                    type="button"
                    class="noesia-swa-nav-style-btn is-active"
                    data-noesia-swa-nav-style-switch="hub"
                >
                    <?php esc_html_e( 'HUB', 'noesia-smart-waiter' ); ?>
                </button>

                <button
                    type="button"
                    class="noesia-swa-nav-style-btn noesia-swa-nav-style-btn--icon"
                    data-noesia-swa-nav-style-switch="titan"
                    aria-label="<?php esc_attr_e( 'Switch to Titan style', 'noesia-smart-waiter' ); ?>"
                    title="<?php esc_attr_e( 'Switch to Titan style', 'noesia-smart-waiter' ); ?>"
                >
                    <span class="dashicons dashicons-screenoptions" aria-hidden="true"></span>
                </button>
            </div>

            <div id="noesia-swa-gemini-visible-catalog" hidden>
                <?php foreach ( $visible_nav_items as $nav_key => $nav_item ) : ?>
                    <button
                        type="button"
                        data-noesia-swa-gemini-catalog-item="<?php echo esc_attr( $nav_key ); ?>"
                        data-noesia-swa-nav-target="<?php echo esc_attr( $nav_key ); ?>"
                        data-noesia-swa-nav-title="<?php echo esc_attr( $nav_item['title'] ); ?>"
                        data-noesia-swa-nav-sub="<?php echo esc_attr( isset( $nav_item['sub'] ) ? (string) $nav_item['sub'] : '' ); ?>"
                        data-noesia-swa-nav-icon="<?php echo esc_attr( $nav_item['icon'] ); ?>"
                    ></button>
                <?php endforeach; ?>
            </div>

            <div id="noesia-swa-gemini-root-template" hidden>
                <?php foreach ( $visible_nav_items as $nav_key => $nav_item ) : ?>
                    <?php $gemini_icon_class = isset( $nav_item['icon'] ) ? (string) $nav_item['icon'] : ''; ?>
                    <button
                        type="button"
                        class="noesia-swa-gemini-link<?php echo '' === $gemini_icon_class ? ' noesia-swa-gemini-link--text-only' : ''; ?>"
                        data-noesia-swa-gemini-item="<?php echo esc_attr( $nav_key ); ?>"
                        data-noesia-swa-nav-target="<?php echo esc_attr( $nav_key ); ?>"
                        data-noesia-swa-nav-icon="<?php echo esc_attr( $gemini_icon_class ); ?>"
                        data-noesia-swa-gemini-title="<?php echo esc_attr( $nav_item['title'] ); ?>"
                        data-noesia-swa-gemini-icon="<?php echo esc_attr( $gemini_icon_class ); ?>"
                        draggable="true"
                        title="<?php echo esc_attr( $nav_item['title'] ); ?>"
                    >
                        <?php if ( '' !== $gemini_icon_class ) : ?>
                            <span class="noesia-swa-gemini-link-icon" aria-hidden="true">
                                <span class="dashicons <?php echo esc_attr( $gemini_icon_class ); ?>" aria-hidden="true"></span>
                            </span>
                        <?php endif; ?>
                        <span class="noesia-swa-gemini-link-label">
                            <?php echo esc_html( $nav_item['title'] ); ?>
                        </span>
                    </button>
                <?php endforeach; ?>
            </div>

            <nav class="noesia-swa-nav" aria-label="<?php esc_attr_e( 'Main sections', 'noesia-smart-waiter' ); ?>">
                <div class="noesia-swa-nav-grid">
                    <?php foreach ( $visible_nav_items as $nav_key => $nav_item ) : ?>
                        <?php
                        $nav_card_classes      = array( 'noesia-swa-nav-card' );
                        $nav_card_state        = isset( $nav_card_states[ $nav_key ] ) && is_array( $nav_card_states[ $nav_key ] ) ? $nav_card_states[ $nav_key ] : array();
                        $nav_state_class       = isset( $nav_card_state['state'] ) ? sanitize_html_class( (string) $nav_card_state['state'] ) : 'is-clear';
                        $nav_state_color       = isset( $nav_card_state['color'] ) ? sanitize_hex_color( (string) $nav_card_state['color'] ) : '';
                        $nav_icon_type         = isset( $nav_item['icon_type'] ) ? sanitize_key( (string) $nav_item['icon_type'] ) : '';
                        $nav_icon_svg_key      = isset( $nav_item['icon_svg_key'] ) ? sanitize_key( (string) $nav_item['icon_svg_key'] ) : '';
                        $nav_icon_color        = isset( $nav_item['icon_color'] ) ? ( sanitize_hex_color( (string) $nav_item['icon_color'] ) ?: '' ) : '';
                        $use_custom_pulse_icon = ( 'svg' === $nav_icon_type && 'pulse' === $nav_icon_svg_key );

                        if ( $nav_key === $active_section ) {
                            $nav_card_classes[] = 'is-active';
                        }

                        if ( $use_custom_pulse_icon ) {
                            $nav_card_classes[] = 'noesia-swa-nav-card--global-pulse';
                            $nav_card_classes[] = $nav_state_class ? $nav_state_class : 'is-clear';
                        }
                        ?>
                        <button
                            type="button"
                            class="<?php echo esc_attr( implode( ' ', $nav_card_classes ) ); ?>"
                            data-noesia-swa-nav-target="<?php echo esc_attr( $nav_key ); ?>"
                        >
                            <span class="noesia-swa-nav-emoji<?php echo $use_custom_pulse_icon ? ' noesia-swa-nav-emoji--global-pulse ' . esc_attr( $nav_state_class ? $nav_state_class : 'is-clear' ) : ''; ?>">
                                <?php if ( $use_custom_pulse_icon ) : ?>
                                    <?php $resolved_global_pulse_color = $nav_state_color ? $nav_state_color : ( $nav_icon_color ? $nav_icon_color : '#8e93a8' ); ?>
                                    <svg class="noesia-swa-nav-ecg-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false">
                                        <path d="M2 12h4l2.1-4.2 3.1 8.1 2.6-5.6H22" stroke="<?php echo esc_attr( $resolved_global_pulse_color ); ?>" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round"></path>
                                        <circle cx="20.5" cy="12" r="1.25" fill="<?php echo esc_attr( $resolved_global_pulse_color ); ?>"></circle>
                                    </svg>
                                <?php else : ?>
                                    <span class="dashicons <?php echo esc_attr( $nav_item['icon'] ); ?>" aria-hidden="true"></span>
                                <?php endif; ?>
                            </span>

                            <span class="noesia-swa-nav-title"><?php echo esc_html( $nav_item['title'] ); ?></span>

                            <?php if ( ! empty( $nav_item['sub'] ) ) : ?>
                                <span class="noesia-swa-nav-sub"><?php echo esc_html( $nav_item['sub'] ); ?></span>
                            <?php endif; ?>
                        </button>
                    <?php endforeach; ?>
                </div>
            </nav>

      <div class="noesia-swa-sidebar-visibility">
    <button
        type="button"
        class="noesia-swa-menu-visibility-trigger"
        data-noesia-swa-action="openMenuVisibilityManager"
        aria-label="<?php esc_attr_e( 'Enable or disable boxes from menu', 'noesia-smart-waiter' ); ?>"
        title="<?php esc_attr_e( 'Enable or disable boxes from menu', 'noesia-smart-waiter' ); ?>"
    >
        <span class="noesia-swa-menu-visibility-trigger-icon" aria-hidden="true">
            <svg viewBox="0 0 20 20" focusable="false" aria-hidden="true">
                <rect x="3" y="3" width="5" height="5" rx="1.2"></rect>
                <rect x="12" y="3" width="5" height="5" rx="1.2"></rect>
                <rect x="3" y="12" width="5" height="5" rx="1.2"></rect>
                <rect x="12" y="12" width="5" height="5" rx="1.2"></rect>
            </svg>
        </span>
    </button>
</div>
           <div class="noesia-swa-sidebar-footer">
    <span class="noesia-swa-intel-kicker"><?php esc_html_e( 'Noesia Intelligence', 'noesia-smart-waiter' ); ?></span>
    <strong class="noesia-swa-intel-title"><?php esc_html_e( 'Matrix OS · Titan Edition', 'noesia-smart-waiter' ); ?></strong>
    <span class="noesia-swa-intel-version"><?php echo esc_html( 'v' . NOESIA_SWA_VERSION ); ?></span>
</div>
        </aside>

        <main class="noesia-swa-main">
            <header class="noesia-swa-topbar">
                <div class="noesia-swa-topbar-left">
                    <div class="noesia-swa-section-title-wrap">
                        <span class="noesia-swa-section-label"><?php esc_html_e( 'Section:', 'noesia-smart-waiter' ); ?></span>
                        <span id="noesia-swa-current-section"><?php echo esc_html( $current_section_title ); ?></span>
                    </div>

                    <span id="noesia-swa-active-requests-pill" class="noesia-swa-active-pill <?php echo ( $active_badge_visible && $active_badge_count > 0 ) ? 'has-active' : ''; ?>" data-noesia-swa-active-badge="topbar" data-noesia-swa-active-badge-label="<?php echo esc_attr( $active_badge_label ); ?>"<?php echo $active_badge_visible ? '' : ' hidden'; ?>>
                        <?php echo esc_html( $active_badge_text ); ?>
                    </span>

                    <details id="noesia-swa-bookmarks-dropdown" class="noesia-swa-bookmarks">
                        <summary class="noesia-swa-icon-btn" aria-label="<?php esc_attr_e( 'Bookmarks', 'noesia-smart-waiter' ); ?>">
                            <span class="dashicons dashicons-book-alt" aria-hidden="true"></span>
                        </summary>

                        <div class="noesia-swa-bookmarks-dropdown">
                            <?php if ( ! empty( $bookmark_menu ) ) : ?>
                                <div class="noesia-swa-bookmarks-grid">
                                    <?php foreach ( $bookmark_menu as $bookmark ) : ?>
                                        <a
                                            class="noesia-swa-bookmark-link"
                                            href="<?php echo esc_url( $bookmark['url'] ); ?>"
                                            target="_blank"
                                            rel="noopener noreferrer"
                                        >
                                            <?php echo esc_html( $bookmark['name'] ); ?>
                                        </a>
                                    <?php endforeach; ?>
                                </div>
                            <?php else : ?>
                                <div class="noesia-swa-bookmarks-empty"><?php esc_html_e( 'No bookmarks saved yet.', 'noesia-smart-waiter' ); ?></div>
                            <?php endif; ?>
                        </div>
                    </details>

                    <?php foreach ( $topbar_nav_actions as $topbar_action ) : ?>
                        <?php
                        $topbar_action_type       = isset( $topbar_action['type'] ) ? sanitize_key( (string) $topbar_action['type'] ) : 'nav';
                        $topbar_action_target     = isset( $topbar_action['target'] ) ? sanitize_key( (string) $topbar_action['target'] ) : '';
                        $topbar_action_icon       = isset( $topbar_action['icon'] ) ? sanitize_html_class( (string) $topbar_action['icon'] ) : 'dashicons-admin-generic';
                        $topbar_action_label      = isset( $topbar_action['label'] ) ? sanitize_text_field( (string) $topbar_action['label'] ) : ucfirst( str_replace( '-', ' ', (string) $topbar_action_target ) );
                        $topbar_action_badge      = isset( $topbar_action['badge_count'] ) ? max( 0, absint( $topbar_action['badge_count'] ) ) : 0;
                        $topbar_action_badge_hide = ! empty( $topbar_action['badge_hidden'] );

                        if ( '' === $topbar_action_target ) {
                            continue;
                        }
                        ?>
                        <button
                            type="button"
                            class="noesia-swa-icon-btn"
                            <?php if ( 'nav' === $topbar_action_type ) : ?>
                                data-noesia-swa-nav-target="<?php echo esc_attr( $topbar_action_target ); ?>"
                            <?php else : ?>
                                data-noesia-swa-action-target="<?php echo esc_attr( $topbar_action_target ); ?>"
                            <?php endif; ?>
                            aria-label="<?php echo esc_attr( $topbar_action_label ); ?>"
                            title="<?php echo esc_attr( $topbar_action_label ); ?>"
                        >
                            <span class="dashicons <?php echo esc_attr( $topbar_action_icon ); ?>" aria-hidden="true"></span>
                            <?php if ( $topbar_action_badge > 0 && ! $topbar_action_badge_hide ) : ?>
                                <span class="noesia-swa-reminders-badge">
                                    <?php echo esc_html( $topbar_action_badge > 99 ? '99+' : (string) $topbar_action_badge ); ?>
                                </span>
                            <?php endif; ?>
                        </button>
                    <?php endforeach; ?>
                </div>

                <div class="noesia-swa-topbar-right">
                    <?php do_action( 'noesia_swa_header_before_actions', $active_section ); ?>

                    <button
                        type="button"
                        class="button noesia-swa-topbar-shell-toggle"
                        data-noesia-swa-action="toggleShellImmersive"
                        aria-label="<?php esc_attr_e( 'Hide header and menu', 'noesia-smart-waiter' ); ?>"
                        title="<?php esc_attr_e( 'Hide header and menu', 'noesia-smart-waiter' ); ?>"
                    >
                        <span class="dashicons dashicons-editor-expand" aria-hidden="true"></span>
                    </button>

                    <button
                        type="button"
                        class="button noesia-swa-topbar-browser-fullscreen-toggle"
                        data-noesia-swa-action="toggleBrowserFullscreen"
                        aria-label="<?php esc_attr_e( 'Toggle browser fullscreen', 'noesia-smart-waiter' ); ?>"
                        aria-pressed="false"
                        title="<?php esc_attr_e( 'Toggle browser fullscreen', 'noesia-smart-waiter' ); ?>"
                    >
                        <span class="dashicons dashicons-fullscreen-alt" aria-hidden="true"></span>
                    </button>

                    <button
                        type="button"
                        class="button noesia-swa-topbar-dock-toggle"
                        data-noesia-swa-action="toggleQuickDock"
                        aria-label="<?php esc_attr_e( 'Toggle quick dock', 'noesia-smart-waiter' ); ?>"
                        aria-pressed="false"
                        title="<?php esc_attr_e( 'Toggle quick dock', 'noesia-smart-waiter' ); ?>"
                    >
                        <span class="dashicons dashicons-screenoptions" aria-hidden="true"></span>
                    </button>
<button
    type="button"
    class="button noesia-swa-topbar-wizard-toggle"
    data-noesia-swa-open-wizard="1"
    aria-label="<?php esc_attr_e( 'Open setup wizard', 'noesia-smart-waiter' ); ?>"
    title="<?php esc_attr_e( 'Open setup wizard', 'noesia-smart-waiter' ); ?>"
>
    <span class="dashicons dashicons-superhero-alt" aria-hidden="true"></span>
</button>
                    <a
                        class="button noesia-swa-topbar-wp-link"
                        href="<?php echo esc_url( $site_admin_url ); ?>"
                        target="_blank"
                        rel="noopener noreferrer"
                        aria-label="<?php esc_attr_e( 'Open WordPress Admin', 'noesia-smart-waiter' ); ?>"
                    >
                        <span class="dashicons dashicons-wordpress" aria-hidden="true"></span>
                    </a>

                    <?php do_action( 'noesia_swa_header_after_actions', $active_section ); ?>
                </div>
            </header>

            <?php settings_errors(); ?>

            <form id="noesia-swa-settings-form" method="post" action="<?php echo esc_url( $settings_form_action ); ?>" class="noesia-swa-form-shell" data-noesia-swa-settings-form="1">
                <?php settings_fields( 'noesia_swa_options_group' ); ?>
                <input type="hidden" name="noesia_swa_options[menu_hidden_sections]" id="noesia-swa-menu-hidden-sections" value="<?php echo esc_attr( wp_json_encode( $menu_hidden_sections ) ); ?>" />
                <input type="hidden" name="noesia_swa_shell[current_section]" id="noesia-swa-shell-current-section" value="<?php echo esc_attr( $active_section ); ?>" />

                <div class="noesia-swa-content">
                    <div class="noesia-swa-sections">
                        <?php if ( ! empty( $registered_sections ) ) : ?>
                            <?php foreach ( $registered_sections as $section_id => $section_meta ) : ?>
                                <?php
                                $section_id    = sanitize_key( (string) $section_id );
                                $section_label = isset( $section_meta['label'] ) ? (string) $section_meta['label'] : ucfirst( str_replace( '-', ' ', $section_id ) );
                                $is_active     = ( $section_id === $active_section );
                                ?>
                                <section
                                    class="noesia-swa-section noesia-swa-section-panel"
                                    data-noesia-swa-section-panel="<?php echo esc_attr( $section_id ); ?>"
                                    data-noesia-swa-section-loaded="<?php echo $is_active ? '1' : '0'; ?>"
                                    data-noesia-swa-section-title="<?php echo esc_attr( $section_label ); ?>"
                                    <?php echo $is_active ? '' : 'hidden'; ?>
                                >
                                    <?php if ( $is_active ) : ?>
                                        <?php
                                        if ( $admin_sections_registry instanceof Noesia_SWA_Admin_Sections ) {
                                            $admin_sections_registry->render_section( $section_id );
                                        } else {
                                            $render_registry_unavailable();
                                        }
                                        ?>
                                    <?php else : ?>
                                        <div class="noesia-swa-card noesia-swa-card--span2 noesia-swa-section-placeholder" data-noesia-swa-section-placeholder="1" aria-hidden="true">
                                            <h3><?php echo esc_html( $section_label ); ?></h3>
                                            <p class="noesia-swa-muted"><?php esc_html_e( 'This section will load when you open it.', 'noesia-smart-waiter' ); ?></p>
                                        </div>
                                    <?php endif; ?>
                                </section>
                            <?php endforeach; ?>
                        <?php else : ?>
                            <section class="noesia-swa-section noesia-swa-section-panel" data-noesia-swa-section-panel="registry-unavailable" data-noesia-swa-section-loaded="1" data-noesia-swa-section-title="<?php esc_attr_e( 'Admin sections registry unavailable', 'noesia-smart-waiter' ); ?>">
                                <?php $render_registry_unavailable(); ?>
                            </section>
                        <?php endif; ?>
                    </div>
                </div>

                <div id="noesia-swa-dock-shortcuts-card-template" hidden>
                    <div class="noesia-swa-card noesia-swa-card--span2 noesia-swa-dock-shortcuts-card" data-noesia-swa-dock-shortcuts-card="1">
                        <div class="noesia-swa-card-header noesia-swa-dock-shortcuts-card-header">
                            <div>
                                <div class="noesia-swa-kicker"><?php esc_html_e( 'DOCK URL SHORTCUTS', 'noesia-smart-waiter' ); ?></div>
                                <h3><?php esc_html_e( 'Quick Dock URL Shortcuts', 'noesia-smart-waiter' ); ?></h3>
                                <p class="noesia-swa-muted"><?php esc_html_e( 'Add shortcuts after the dock separator. Choose a preset with a ready link or enter your own website URL or supported deep link.', 'noesia-smart-waiter' ); ?></p>
                            </div>
                            <div class="noesia-swa-inline-actions">
                                <button type="button" class="button" data-noesia-swa-action="resetDockShortcuts"><?php esc_html_e( 'Reset', 'noesia-smart-waiter' ); ?></button>
                                <button type="button" class="button button-primary" data-noesia-swa-action="openDockShortcutModal"><?php esc_html_e( 'Add URL Shortcut', 'noesia-smart-waiter' ); ?></button>
                            </div>
                        </div>
                        <div class="noesia-swa-dock-shortcuts-helper-row">
                            <span class="noesia-swa-dock-shortcuts-helper-badge"><?php esc_html_e( 'Quick tips', 'noesia-smart-waiter' ); ?></span>
                            <span class="noesia-swa-dock-shortcuts-helper-text"><?php esc_html_e( 'Core Noesia apps stay on the left. Your shortcuts render after the separator. Use normal website links such as https://mail.google.com for browser shortcuts. Use supported deep links such as viber://chatex only when your app or operating system already handles that target.', 'noesia-smart-waiter' ); ?></span>
                        </div>
                        <div class="noesia-swa-dock-shortcuts-info-box">
                            <strong><?php esc_html_e( 'How to use the Target field', 'noesia-smart-waiter' ); ?></strong>
                            <p class="noesia-swa-muted"><?php esc_html_e( 'Use a full website URL or a supported deep link. Do not use local app file paths. Ready examples:', 'noesia-smart-waiter' ); ?></p>
                            <div class="noesia-swa-dock-shortcuts-example-grid">
                                <span class="noesia-swa-dock-shortcuts-example-pill"><strong><?php esc_html_e( 'Chrome / Browser', 'noesia-smart-waiter' ); ?></strong><code>https://www.google.com/</code></span>
                                <span class="noesia-swa-dock-shortcuts-example-pill"><strong><?php esc_html_e( 'Gmail', 'noesia-smart-waiter' ); ?></strong><code>https://mail.google.com/</code></span>
                                <span class="noesia-swa-dock-shortcuts-example-pill"><strong><?php esc_html_e( 'Viber', 'noesia-smart-waiter' ); ?></strong><code>viber://chatex</code></span>
                                <span class="noesia-swa-dock-shortcuts-example-pill"><strong><?php esc_html_e( 'Messenger', 'noesia-smart-waiter' ); ?></strong><code>https://www.messenger.com/</code></span>
                                <span class="noesia-swa-dock-shortcuts-example-pill"><strong><?php esc_html_e( 'Canva', 'noesia-smart-waiter' ); ?></strong><code>https://www.canva.com/</code></span>
                                <span class="noesia-swa-dock-shortcuts-example-pill"><strong><?php esc_html_e( 'Photoshop Web', 'noesia-smart-waiter' ); ?></strong><code>https://www.adobe.com/products/photoshop.html</code></span>
                            </div>
                        </div>
                        <p class="noesia-swa-dock-shortcuts-helper-text">
                            <?php esc_html_e( 'Examples: Chrome should use a website URL such as https://www.google.com. Viber can use a deep link such as viber://chatex.', 'noesia-smart-waiter' ); ?>
                        </p>

                        <div class="noesia-swa-dock-shortcuts-empty" data-noesia-swa-dock-shortcuts-empty="1" hidden>
                            <p class="noesia-swa-muted"><?php esc_html_e( 'No custom URL shortcuts yet. Add your first shortcut to extend the dock.', 'noesia-smart-waiter' ); ?></p>
                        </div>
                        <div class="noesia-swa-dock-shortcuts-list" data-noesia-swa-dock-shortcuts-list="1"></div>
                    </div>
                </div>

                <div class="noesia-swa-dock-shortcuts-modal" data-noesia-swa-dock-shortcuts-modal="1" hidden aria-hidden="true">
                    <div class="noesia-swa-dock-shortcuts-modal-backdrop" data-noesia-swa-action="closeDockShortcutModal"></div>
                    <div class="noesia-swa-dock-shortcuts-modal-dialog" role="dialog" aria-modal="true" aria-labelledby="noesia-swa-dock-shortcuts-modal-title">
                        <div class="noesia-swa-dock-shortcuts-modal-header">
                            <div>
                                <div class="noesia-swa-kicker"><?php esc_html_e( 'DOCK URL SHORTCUT', 'noesia-smart-waiter' ); ?></div>
                                <h3 id="noesia-swa-dock-shortcuts-modal-title"><?php esc_html_e( 'Add shortcut', 'noesia-smart-waiter' ); ?></h3>
                            </div>
                            <button type="button" class="button noesia-swa-dock-shortcuts-close" data-noesia-swa-action="closeDockShortcutModal" aria-label="<?php esc_attr_e( 'Close', 'noesia-smart-waiter' ); ?>">
                                <span class="dashicons dashicons-no-alt" aria-hidden="true"></span>
                            </button>
                        </div>
                        <div class="noesia-swa-dock-shortcuts-modal-body">
                            <input type="hidden" id="noesia-swa-dock-shortcut-edit-index" value="" />
                            <div class="noesia-swa-form-grid">
                                <div class="noesia-swa-form-row noesia-swa-dock-shortcuts-form-row">
                                    <div class="noesia-swa-form-group">
                                        <label for="noesia-swa-dock-shortcut-preset"><?php esc_html_e( 'Default preset', 'noesia-smart-waiter' ); ?></label>
                                        <select id="noesia-swa-dock-shortcut-preset">
                                            <option value="custom-url"><?php esc_html_e( 'Custom URL', 'noesia-smart-waiter' ); ?></option>
                                            <option value="chrome"><?php esc_html_e( 'Chrome', 'noesia-smart-waiter' ); ?></option>
                                            <option value="whatsapp"><?php esc_html_e( 'WhatsApp', 'noesia-smart-waiter' ); ?></option>
                                            <option value="gmail"><?php esc_html_e( 'Gmail', 'noesia-smart-waiter' ); ?></option>
                                            <option value="google-drive"><?php esc_html_e( 'Google Drive', 'noesia-smart-waiter' ); ?></option>
                                            <option value="youtube"><?php esc_html_e( 'YouTube', 'noesia-smart-waiter' ); ?></option>
                                            <option value="facebook"><?php esc_html_e( 'Facebook', 'noesia-smart-waiter' ); ?></option>
                                            <option value="instagram"><?php esc_html_e( 'Instagram', 'noesia-smart-waiter' ); ?></option>
                                            <option value="tiktok"><?php esc_html_e( 'TikTok', 'noesia-smart-waiter' ); ?></option>
                                            <option value="github"><?php esc_html_e( 'GitHub', 'noesia-smart-waiter' ); ?></option>
                                            <option value="stack-overflow"><?php esc_html_e( 'Stack Overflow', 'noesia-smart-waiter' ); ?></option>
                                            <option value="viber-chatex"><?php esc_html_e( 'Viber ChatX', 'noesia-smart-waiter' ); ?></option>
                                            <option value="messenger"><?php esc_html_e( 'Messenger', 'noesia-smart-waiter' ); ?></option>
                                            <option value="canva"><?php esc_html_e( 'Canva', 'noesia-smart-waiter' ); ?></option>
                                            <option value="photoshop-web"><?php esc_html_e( 'Photoshop Web', 'noesia-smart-waiter' ); ?></option>
                                        </select>
                                    </div>
                                    <div class="noesia-swa-form-group">
                                        <label for="noesia-swa-dock-shortcut-title"><?php esc_html_e( 'Shortcut title', 'noesia-smart-waiter' ); ?></label>
                                        <input type="text" id="noesia-swa-dock-shortcut-title" maxlength="40" />
                                    </div>
                                </div>
                                <div class="noesia-swa-form-group">
                                    <label for="noesia-swa-dock-shortcut-url"><?php esc_html_e( 'Target URL', 'noesia-smart-waiter' ); ?></label>
                                    <input type="text" id="noesia-swa-dock-shortcut-url" placeholder="https://example.com or viber://chatex" />
                                    <p class="noesia-swa-muted"><?php esc_html_e( 'Use a full website URL or a supported deep link. Presets auto-fill this field, and all shortcuts open in a new tab.', 'noesia-smart-waiter' ); ?></p>
                                </div>
                                <div class="noesia-swa-form-group">
                                    <label><?php esc_html_e( 'Icon source', 'noesia-smart-waiter' ); ?></label>
                                    <div class="noesia-swa-dock-shortcuts-icon-mode-switch" role="group" aria-label="<?php esc_attr_e( 'Icon source', 'noesia-smart-waiter' ); ?>">
                                        <button type="button" class="button is-active" data-noesia-swa-dock-shortcut-icon-mode="builtin"><?php esc_html_e( 'Built-in library', 'noesia-smart-waiter' ); ?></button>
                                        <button type="button" class="button" data-noesia-swa-dock-shortcut-icon-mode="upload"><?php esc_html_e( 'Upload icon', 'noesia-smart-waiter' ); ?></button>
                                    </div>
                                </div>
                                <div class="noesia-swa-dock-shortcuts-icon-library" data-noesia-swa-dock-shortcuts-icon-panel="builtin"></div>
                                <div class="noesia-swa-dock-shortcuts-upload-panel" data-noesia-swa-dock-shortcuts-icon-panel="upload" hidden>
                                    <div class="noesia-swa-dock-shortcuts-upload-preview" data-noesia-swa-dock-shortcuts-upload-preview="1"></div>
                                    <input type="file" id="noesia-swa-dock-shortcut-icon-file" accept="image/png,image/webp,image/jpeg,image/svg+xml" />
                                    <div class="noesia-swa-inline-actions">
                                        <button type="button" class="button" data-noesia-swa-action="clearDockShortcutIconUpload"><?php esc_html_e( 'Remove uploaded icon', 'noesia-smart-waiter' ); ?></button>
                                    </div>
                                    <input type="hidden" id="noesia-swa-dock-shortcut-icon-url" value="" />
                                    <p class="noesia-swa-muted"><?php esc_html_e( 'PNG, JPG, WebP or SVG under 512 KB works best. Upload only if you do not want to use the built-in icon library.', 'noesia-smart-waiter' ); ?></p>
                                </div>
                                <div class="noesia-swa-form-group noesia-swa-dock-shortcuts-enabled-row">
                                    <label class="noesia-swa-dock-shortcuts-toggle-row">
                                        <input type="checkbox" id="noesia-swa-dock-shortcut-enabled" checked />
                                        <span><?php esc_html_e( 'Enable this shortcut in the dock', 'noesia-smart-waiter' ); ?></span>
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="noesia-swa-dock-shortcuts-modal-footer">
                            <button type="button" class="button" data-noesia-swa-action="testDockShortcutDraft"><?php esc_html_e( 'Test', 'noesia-smart-waiter' ); ?></button>
                            <button type="button" class="button" data-noesia-swa-action="closeDockShortcutModal"><?php esc_html_e( 'Cancel', 'noesia-smart-waiter' ); ?></button>
                            <button type="button" class="button button-primary" data-noesia-swa-action="saveDockShortcutDraft"><?php esc_html_e( 'Save shortcut', 'noesia-smart-waiter' ); ?></button>
                        </div>
                    </div>
                </div>

                <div id="noesia-swa-menu-visibility-manager" class="noesia-swa-menu-visibility-manager" data-noesia-swa-ui="classic" hidden aria-hidden="true">
                    <div class="noesia-swa-menu-visibility-backdrop" data-noesia-swa-action="closeMenuVisibilityManager"></div>
                    <div class="noesia-swa-menu-visibility-dialog" role="dialog" aria-modal="true" aria-labelledby="noesia-swa-menu-visibility-title">
                        <div class="noesia-swa-card-header noesia-swa-menu-visibility-header">
                            <div class="noesia-swa-menu-visibility-head-copy">
                                <div class="noesia-swa-kicker"><?php esc_html_e( 'MENU BOX MANAGER', 'noesia-smart-waiter' ); ?></div>
                                <h3 id="noesia-swa-menu-visibility-title"><?php esc_html_e( 'Enable or disable boxes from menu', 'noesia-smart-waiter' ); ?></h3>
                                <p class="noesia-swa-muted"><?php esc_html_e( 'Move boxes between the visible and hidden areas, then save your menu layout.', 'noesia-smart-waiter' ); ?></p>
                            </div>
                            <div class="noesia-swa-menu-visibility-header-tools">
                                <div class="noesia-swa-menu-visibility-layout-switch" role="group" aria-label="<?php esc_attr_e( 'Menu Box Manager layout', 'noesia-smart-waiter' ); ?>">
                                    <button type="button" class="noesia-swa-menu-visibility-layout-btn is-active" data-noesia-swa-menu-ui="classic" aria-pressed="true"><?php esc_html_e( 'Classic', 'noesia-smart-waiter' ); ?></button>
                                    <button type="button" class="noesia-swa-menu-visibility-layout-btn" data-noesia-swa-menu-ui="finder" aria-pressed="false"><?php esc_html_e( 'Finder', 'noesia-smart-waiter' ); ?></button>
                                </div>
                            </div>
                        </div>

                        <div class="noesia-swa-menu-visibility-columns">
                            <section class="noesia-swa-menu-visibility-column">
                                <div class="noesia-swa-menu-visibility-column-title"><?php esc_html_e( 'Visible in menu', 'noesia-smart-waiter' ); ?></div>
                                <div id="noesia-swa-menu-visible-list" class="noesia-swa-menu-visibility-list" data-noesia-swa-menu-list="visible">
                                    <?php foreach ( $visible_nav_items as $nav_key => $nav_item ) : ?>
                                        <button type="button" class="noesia-swa-nav-card noesia-swa-menu-visibility-card" data-noesia-swa-menu-card="<?php echo esc_attr( $nav_key ); ?>" data-noesia-swa-menu-state="visible" data-noesia-swa-nav-target="<?php echo esc_attr( $nav_key ); ?>" data-noesia-swa-nav-title="<?php echo esc_attr( $nav_item['title'] ); ?>" data-noesia-swa-nav-sub="<?php echo esc_attr( isset( $nav_item['sub'] ) ? (string) $nav_item['sub'] : '' ); ?>" data-noesia-swa-nav-icon="<?php echo esc_attr( $nav_item['icon'] ); ?>">
                                            <span class="noesia-swa-menu-visibility-badge is-remove" aria-hidden="true">−</span>
                                            <span class="noesia-swa-nav-emoji"><span class="dashicons <?php echo esc_attr( $nav_item['icon'] ); ?>" aria-hidden="true"></span></span>
                                            <span class="noesia-swa-nav-title"><?php echo esc_html( $nav_item['title'] ); ?></span>
                                            <?php if ( ! empty( $nav_item['sub'] ) ) : ?><span class="noesia-swa-nav-sub"><?php echo esc_html( $nav_item['sub'] ); ?></span><?php endif; ?>
                                        </button>
                                    <?php endforeach; ?>
                                </div>
                            </section>

                            <section class="noesia-swa-menu-visibility-column">
                                <div class="noesia-swa-menu-visibility-column-title"><?php esc_html_e( 'Hidden from menu', 'noesia-smart-waiter' ); ?></div>
                                <div id="noesia-swa-menu-hidden-list" class="noesia-swa-menu-visibility-list" data-noesia-swa-menu-list="hidden">
                                    <?php foreach ( $hidden_nav_items as $nav_key => $nav_item ) : ?>
                                        <button type="button" class="noesia-swa-nav-card noesia-swa-menu-visibility-card" data-noesia-swa-menu-card="<?php echo esc_attr( $nav_key ); ?>" data-noesia-swa-menu-state="hidden" data-noesia-swa-nav-target="<?php echo esc_attr( $nav_key ); ?>" data-noesia-swa-nav-title="<?php echo esc_attr( $nav_item['title'] ); ?>" data-noesia-swa-nav-sub="<?php echo esc_attr( isset( $nav_item['sub'] ) ? (string) $nav_item['sub'] : '' ); ?>" data-noesia-swa-nav-icon="<?php echo esc_attr( $nav_item['icon'] ); ?>">
                                            <span class="noesia-swa-menu-visibility-badge is-add" aria-hidden="true">+</span>
                                            <span class="noesia-swa-nav-emoji"><span class="dashicons <?php echo esc_attr( $nav_item['icon'] ); ?>" aria-hidden="true"></span></span>
                                            <span class="noesia-swa-nav-title"><?php echo esc_html( $nav_item['title'] ); ?></span>
                                            <?php if ( ! empty( $nav_item['sub'] ) ) : ?><span class="noesia-swa-nav-sub"><?php echo esc_html( $nav_item['sub'] ); ?></span><?php endif; ?>
                                        </button>
                                    <?php endforeach; ?>
                                </div>
                            </section>
                        </div>

                        <div class="noesia-swa-menu-visibility-actions">
                            <button type="button" class="button" data-noesia-swa-action="closeMenuVisibilityManager"><?php esc_html_e( 'Cancel', 'noesia-smart-waiter' ); ?></button>
                            <button type="button" class="button button-primary" data-noesia-swa-action="saveMenuVisibilityManager"><?php esc_html_e( 'Save', 'noesia-smart-waiter' ); ?></button>
                        </div>
                    </div>
                </div>
            </form>
        </main>

        <div class="noesia-swa-quick-dock" data-noesia-swa-quick-dock="1" hidden aria-hidden="true">
            <div class="noesia-swa-quick-dock-shell">
                <div class="noesia-swa-quick-dock-bar" data-noesia-swa-quick-dock-bar="1" data-noesia-swa-quick-dock-size="compact">
                    <div class="noesia-swa-quick-dock-controls" aria-label="<?php esc_attr_e( 'Quick dock size controls', 'noesia-smart-waiter' ); ?>">
                        <button
                            type="button"
                            class="noesia-swa-quick-dock-control"
                            data-noesia-swa-action="quickDockShrink"
                            aria-label="<?php esc_attr_e( 'Show fewer apps', 'noesia-smart-waiter' ); ?>"
                            title="<?php esc_attr_e( 'Show fewer apps', 'noesia-smart-waiter' ); ?>"
                        >
                            <span class="dashicons dashicons-minus" aria-hidden="true"></span>
                        </button>
                        <button
                            type="button"
                            class="noesia-swa-quick-dock-control"
                            data-noesia-swa-action="quickDockExpand"
                            aria-label="<?php esc_attr_e( 'Show more apps', 'noesia-smart-waiter' ); ?>"
                            title="<?php esc_attr_e( 'Show more apps', 'noesia-smart-waiter' ); ?>"
                        >
                            <span class="dashicons dashicons-plus-alt2" aria-hidden="true"></span>
                        </button>
                        <button
                            type="button"
                            class="noesia-swa-quick-dock-control noesia-swa-quick-dock-control--palette"
                            data-noesia-swa-action="quickDockColorize"
                            data-noesia-swa-quick-dock-color-stage="mono"
                            aria-label="<?php esc_attr_e( 'Cycle dock icon color styles', 'noesia-smart-waiter' ); ?>"
                            title="<?php esc_attr_e( 'Cycle dock icon color styles', 'noesia-smart-waiter' ); ?>"
                        >
                            <span class="dashicons dashicons-art" aria-hidden="true"></span>
                        </button>
                        <button
                            type="button"
                            class="noesia-swa-quick-dock-control noesia-swa-quick-dock-control--autohide"
                            data-noesia-swa-action="toggleQuickDockAutohide"
                            aria-label="<?php esc_attr_e( 'Toggle dock auto-hide', 'noesia-smart-waiter' ); ?>"
                            title="<?php esc_attr_e( 'Toggle dock auto-hide', 'noesia-smart-waiter' ); ?>"
                            aria-pressed="false"
                        >
                            <span class="dashicons dashicons-arrow-down-alt2" aria-hidden="true"></span>
                        </button>
                    </div>

                    <div class="noesia-swa-quick-dock-viewport" data-noesia-swa-quick-dock-viewport="1">
                        <div class="noesia-swa-quick-dock-track" data-noesia-swa-quick-dock-track="1" role="toolbar" aria-label="<?php esc_attr_e( 'Quick dock apps', 'noesia-smart-waiter' ); ?>">
                            <?php foreach ( $visible_nav_items as $nav_key => $nav_item ) : ?>
                                <button
                                    type="button"
                                    class="noesia-swa-quick-dock-item<?php echo $nav_key === $active_section ? ' is-active' : ''; ?>"
                                    data-noesia-swa-quick-dock-group="core"
                                    data-noesia-swa-quick-dock-visual="1"
                                    data-noesia-swa-quick-dock-item="<?php echo esc_attr( $nav_key ); ?>"
                                    data-noesia-swa-nav-target="<?php echo esc_attr( $nav_key ); ?>"
                                    data-noesia-swa-nav-title="<?php echo esc_attr( $nav_item['title'] ); ?>"
                                    draggable="true"
                                    aria-label="<?php echo esc_attr( $nav_item['title'] ); ?>"
                                    title="<?php echo esc_attr( $nav_item['title'] ); ?>"
                                >
                                    <span class="noesia-swa-quick-dock-item-bg" aria-hidden="true"></span>
                                    <span class="noesia-swa-quick-dock-icon" aria-hidden="true">
                                        <span class="dashicons <?php echo esc_attr( $nav_item['icon'] ); ?>" aria-hidden="true"></span>
                                    </span>
                                </button>
                            <?php endforeach; ?>
                            <span class="noesia-swa-quick-dock-separator" data-noesia-swa-quick-dock-separator="1" hidden aria-hidden="true"></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="noesia-swa-quick-dock-float-tooltip" data-noesia-swa-quick-dock-tooltip-float="1" hidden aria-hidden="true"></div>
        </div>

        <button
            type="button"
            class="noesia-swa-shell-restore"
            data-noesia-swa-action="restoreShellImmersive"
            aria-label="<?php esc_attr_e( 'Restore header and menu', 'noesia-smart-waiter' ); ?>"
            title="<?php esc_attr_e( 'Restore header and menu', 'noesia-smart-waiter' ); ?>"
            hidden
        >
            <span class="dashicons dashicons-editor-contract" aria-hidden="true"></span>
        </button>

    </div>
    <?php
} )( $noesia_swa_settings_shell_context );
