<aside class="sidenav navbar navbar-vertical navbar-expand-xs border-0 border-radius-xl my-3 fixed-start ms-3 "
       id="sidenav-main">
    <div class="sidenav-header">
        <i class="fas fa-times p-3 cursor-pointer text-secondary opacity-5 position-absolute end-0 top-0 d-none d-xl-none"
           aria-hidden="true" id="iconSidenav"></i>
        <a class="navbar-brand m-0" href="<?php echo esc_url(wpaisaas_get_page_link('profile')); ?>"
           target="_blank">
            <?php
            global $wp;
            $current_page_url = home_url($wp->request);
            // Get the custom logo URL
            $custom_logo_id = get_theme_mod('custom_logo');
            $custom_logo_url = wp_get_attachment_image_url($custom_logo_id, 'full');

            if (!$custom_logo_url) {
                $site_icon_url = get_site_icon_url();
            }

            // Output the logo or site icon URL
            if ($custom_logo_url) {
                echo '<img src="' . esc_url($custom_logo_url) . '" alt="' . esc_attr(get_bloginfo('name')) . '">';
            } elseif ($site_icon_url) {
                echo '<img src="' . esc_url($site_icon_url) . '" alt="' . esc_attr(get_bloginfo('name')) . '">';
            } else {
                echo '<img src="' . esc_url(get_template_directory_uri() . 'assets/img/logo.svg') . '" alt="' . esc_attr(get_bloginfo('name')) . '">';
            }
            echo '<span class="ms-1 font-weight-bold">' . esc_attr(get_bloginfo('name')) . '</span>';

            ?>
        </a>
    </div>
    <hr class="horizontal dark mt-0">
    <div class="collapse navbar-collapse  w-auto " id="sidenav-collapse-main">
        <ul class="navbar-nav special-nav">
            <?php wpaisaas_display_navigation_based_on_role(); ?>
        </ul>
    </div>

    <div class="sidenav-footer position-absolute left-0 right-0 bottom-0 my-3">
        <ul class="navbar-nav special-nav">
            <?php if (is_user_logged_in()) : ?>
                <li class="nav-item">
                    <?php
                    if (rtrim(wpaisaas_get_page_link('pricing'), '/') !== $current_page_url) {
                    echo '<a class="nav-link d-flex align-items-center text-body font-weight-bold px-0 border-top py-2" href="' . esc_url(wpaisaas_get_page_link('pricing')) . '">';
                        } else {
                        echo '<a class="nav-link d-flex align-items-center text-body font-weight-bold px-0 border-top py-2" href="' . esc_url(wpaisaas_get_page_link('pricing')) . '">';
                            }
                            ?>

                        <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-dark text-center me-2 d-flex align-items-center justify-content-center">
                            <i class="fa fa-dollar"></i>
                        </div>
                        <span class="nav-link-text ms-1"><?php esc_html_e('Subscription', 'wpaisaas'); ?></span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="<?php echo esc_url(wp_logout_url(wp_login_url())); ?>"
                       class="nav-link text-body  d-flex align-items-center  font-weight-bold px-0 border-top py-2">
                        <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-dark text-center me-2 d-flex align-items-center justify-content-center">
                            <i class="fa fa-sign-out me-sm-1"></i>
                        </div>
                        <span class="nav-link-text ms-1"><?php esc_html_e('Logout', 'wpaisaas'); ?></span>
                    </a>
                </li>
            <?php else : ?>
                <li class="nav-item">
                    <a href="<?php echo esc_url(wp_login_url()); ?>"
                       class="nav-link text-body  d-flex align-items-center  font-weight-bold px-0 border-top py-2">
                        <div class="icon icon-shape icon-sm shadow border-radius-md bg-white text-dark text-center me-2 d-flex align-items-center justify-content-center">
                            <i class="fa fa-user me-sm-1"></i>
                        </div>
                        <span class="nav-link-text ms-1"><?php esc_html_e('Sign In', 'wpaisaas'); ?></span>
                    </a>
                </li>
            <?php endif; ?>
        </ul>
    </div>

</aside>
