.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(10px);
    background-color: rgba(var(--bs-secondary-rgb), 0.50);
    z-index: 998;
    display: none;  /* Must start as hidden! */
}

.reveal-sidebar-btn {
    z-index: 998;
    display: none;
    position: fixed;
    bottom: 1rem;
    right: 1rem;

    @include media-breakpoint-down(lg) { display: block; }

}

.server-rate-limit { display: none; }

.sidebar {

    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 300px;
    color: var(--bs-body-color);
    background-color: var(--bs-secondary-bg-subtle);
    transition: transform 0.3s ease-in-out;
    z-index: 999;

    // Hide the sidebar 
    @include media-breakpoint-down(lg) {
        transform: translateX(-100%);
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
    }

    // Show the sidebar on smaller screens
    &.visible {
        @include media-breakpoint-down(lg) { transform: translateX(0); }
        @include media-breakpoint-down(sm) { width: 100vw; }
    }

    .sidebar-divider { margin: 1rem; }

    .sidebar-header {

        display: flex;
        align-items: center;
        padding: 1rem 1rem 0 1rem;
        text-decoration: none;
        color: inherit;

        .sidebar-header-link {

            display: flex;
            align-items: center;
            text-decoration: none;
            color: inherit;

            .sidebar-logo {
    
                width: 45px;
                margin-right: 0.5rem;
    
            }
    
            .sidebar-title {
    
                font-size: 2rem;
                font-weight: bold;
    
            }

        }

        // Hide on larger screens, show on smaller screens
        .btn-close {

            display: none;

            @include media-breakpoint-down(lg) { display: block; }

        }

    }

    .sidebar-content {

        padding: 0 1rem ;
        margin-bottom: auto;
        list-style: none;

        .sidebar-placeholder {

            display: flex;
            align-items: center;
            width: 100%;
            padding: 0.5rem;
            border: none;

            .sidebar-placeholder-image {

                flex-shrink: 0;
                width: 50px;
                height: 50px;
                margin-right: 0.75rem;
                border-radius: $border-radius-sm;

            }

            .sidebar-placeholder-data {

                display: flex;
                flex-direction: column;
                overflow: hidden;
                width: 100%;

                >.placeholder { border-radius: $border-radius-sm; }

            }

        }

        .sidebar-item {

            position: relative;
            display: flex;
            align-items: center;
            width: 100%;
            padding: 0.5rem;
            border: none;
            border-radius: $border-radius-sm;
            background-color: inherit;

            // Highlight effect
            &:not(:disabled):hover,
            &:not(:disabled):focus,
            &.active {

                background-color: var(--bs-body-bg);

                &.spot {

                    border-radius: 0 $border-radius-sm $border-radius-sm 0;

                }

            }

            // 'Spot' is an alert indicator, that appears as a coloured dot against a sidebar item 
            &.spot {

                &::before {

                    content: "";
                    transition: 0.1s ease;
                    transform: translate(-100%, -50%);
                    position: absolute;
                    left: -1px;
                    top: 50%;
                    width: 0.5rem;
                    height: 0.5rem;
                    border-radius: 50%;
                    background-color: var(--bs-body-bg);

                }

                &:not(:disabled):hover::before,
                &:not(:disabled):focus::before,
                &.active::before {

                    transition: 0.15s ease;
                    width: 0.25rem;
                    height: 100%;
                    border-radius: 0.25rem 0 0 0.25rem;  

                }

                // Spot Colours
                &.spot-primary::before { background-color: var(--bs-primary); }
                &.spot-secondary::before { background-color: var(--bs-secondary); }
                &.spot-success::before { background-color: var(--bs-success); }
                &.spot-danger::before { background-color: var(--bs-danger); }
                &.spot-warning::before { background-color: var(--bs-warning); }
                &.spot-info::before { background-color: var(--bs-info); }

            }

            .sidebar-item-image {

                display: flex;
                justify-content: center;
                align-items: center;
                flex-shrink: 0;
                width: 50px;
                height: 50px;
                border-radius: $border-radius-sm;
                margin-right: 0.75rem;

            }

            // Includes the server name and id
            .sidebar-item-data {

                display: flex;
                flex-direction: column;
                width: 100%;
                overflow: hidden;

                &>span {

                    text-align: start;
                    display: block;
                    width: 100%;
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;

                }

            }

        }

    }

    .sidebar-footer {

        display: flex;
        padding: 0 1rem 1rem 1rem;
        
    }

    .sidebar-btn {

        display: flex;
        align-items: center;
        width: auto;
        padding: 0.5rem;
        border: none;
        border-radius: $border-radius-sm;
        color: var(--bs-body-color);
        background-color: inherit;

        &:hover, &:focus, &.active, &:has(>.show) { background-color: var(--bs-body-bg); }

        &.sidebar-mini-btn {

            justify-content: center;
            padding-left: 1rem;
            padding-right: 1rem;

        }

        &.dropdown { padding: 0; }

        >.sidebar-menu-btn {

            text-align: start;
            padding: 0.5rem;
            border: 0;
            width: 100%;
            height: 100%;
            color: inherit;
            background-color: inherit;
            border-radius: $border-radius-sm;

        }

    }

    .sidebar-avatar {

        border-radius: 50%;
        margin-right: 0.5rem;
        width: 32px;
        height: 32px;

    }

    .theme-menu {

        flex-direction: row;

        &.show {
            display: flex;
            inset: auto auto 0 auto !important;
            // transform: translateX(-50%) !important;
        }

        .theme-btn {

            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 1.25rem;
            border: 0;
            width: 50px;
            height: 50px;
            color: var(--bs-body-color);
            background-color: inherit;
            border-radius: $border-radius-sm;

            &:hover, &:focus { background-color: var(--bs-body-bg); }

            &.active {

                color: var(--bs-white);
                background-color: var(--bs-primary);

            }

        }

    }

    .dropdown-menu {

        border: none;
        padding: 0.25rem;
        box-shadow: var(--bs-box-shadow);
        border-radius: var(--bs-border-radius-sm);
        background-color: var(--bs-tertiary-bg);

        .dropdown-item {

            border-radius: var(--bs-border-radius-sm);

            &:hover, &:focus { background-color: var(--bs-body-bg); }

        }

    }

}
