//
// _sidenav.scss
//

.sidenav-menu {
    z-index: 1005;
    position: fixed;
    bottom: 0;
    top: 0;
    width: $sidenav-width;
    background: $sidenav-bg;
    box-shadow: var(--#{$prefix}box-shadow);
    border-inline-end: $card-border-width solid $sidenav-border-color;
    transition: width 0.25s ease-in-out;

    [data-simplebar] {
        height: calc(100% - $topbar-height);
    }
}

// Side-nav
.side-nav {
    padding-inline-start: 0;
    list-style-type: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-bottom: 50px;
    font-family: $font-family-secondary;

    .side-nav-item {
        .side-nav-link {
            display: flex;
            align-items: center;
            gap: $sidenav-item-gap;
            position: relative;
            white-space: nowrap;
            color: $sidenav-item-color;
            transition: color 0.25s ease-in-out;
            line-height: calc($sidenav-item-font-size * 1.25);
            font-size: $sidenav-item-font-size;
            font-weight: $sidenav-item-font-weight;
            padding: $sidenav-item-padding-y $sidenav-item-padding-x;
            border-radius: 5px;

            &:hover,
            &:focus,
            &:active {
                color: $sidenav-item-hover-color;
            }

            .menu-icon {
                font-size: $sidenav-item-icon-size;
                line-height: $sidenav-item-icon-size;

                i {
                    font-size: $sidenav-item-icon-size;
                    line-height: $sidenav-item-icon-size;
                }

                svg {
                    height: $sidenav-item-icon-size;
                    width: $sidenav-item-icon-size;
                }
            }

            .menu-text {
                text-overflow: ellipsis;
                overflow: hidden;
            }

            .badge {
                margin-inline-start: auto;
            }

            &.disabled {
                pointer-events: none;
                cursor: default;
                opacity: 0.5;
            }

            &.special-menu {
                background-color: var(--#{$prefix}primary) !important;
                color: $white !important;
            }
        }
    }

    > .side-nav-item {
        padding: 0 10px;
    }

    // Multi Level Menu
    .sub-menu {
        list-style-type: none;
        display: flex;
        flex-direction: column;
        gap: $sidenav-sub-item-gap;
        padding-inline-start: 0;

        .side-nav-item {
            .side-nav-link {
                font-size: $sidenav-sub-item-font-size;
                padding-block: $sidenav-sub-item-padding-y;
                padding-inline: $sidenav-item-padding-x;
                padding-inline-start: calc($sidenav-item-icon-size + $sidenav-item-padding-x + $sidenav-item-gap);
                font-weight: $sidenav-sub-item-font-weight;
            }
        }

        .sub-menu {
            padding-inline-start: 15px;
        }
    }

    .side-nav-title {
        letter-spacing: 0.1em;
        pointer-events: none;
        cursor: default;
        white-space: nowrap;
        text-transform: uppercase;
        color: $sidenav-item-color;
        font-weight: $font-weight-bold;
        font-size: calc($sidenav-item-font-size * 0.7);
        padding: $sidenav-item-padding-y calc($sidenav-item-padding-x + 10px);
    }

    // Active Menu
    > .side-nav-item.active {
        > a {
            color: $sidenav-item-active-color !important;
            background-color: $sidenav-item-active-bg;

            .menu-arrow {
                transform: rotate(-180deg);
            }
        }

        .side-nav-item.active {
            > a {
                color: $sidenav-item-hover-color;
                font-weight: $sidenav-item-font-weight;

                .menu-arrow {
                    transform: rotate(-180deg);
                }
            }
        }
    }
}

.menu-arrow {
    margin-inline-start: auto;
    transition: transform 0.1s ease-in-out;
    color: var(--#{$prefix}light);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='%239ba6b7'  xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 16a1 1 0 0 1-.64-.23l-6-5a1 1 0 1 1 1.28-1.54L12 13.71l5.36-4.32a1 1 0 0 1 1.41.15a1 1 0 0 1-.14 1.46l-6 4.83A1 1 0 0 1 12 16'/%3E%3C/svg%3E");
    height: 16px;
    width: 16px;
}

[aria-expanded='true'] {
    .menu-arrow {
        transform: rotate(-180deg);
    }
}

// sidenav user
.sidenav-user {
    padding: 15px;
    display: none;
    color: $sidenav-item-color;
    background-size: cover !important;
    margin: 0 10px;
    border-radius: 5px;

    .sidenav-user-name {
        white-space: nowrap;
        display: block;
        color: $sidenav-item-active-color;
    }
}

html[data-sidenav-user='true'] {
    .sidenav-user {
        display: block;
    }
}

// Enlarge Menu (Condensed md size left sidebar )
html[data-sidenav-size='condensed'] {
    .app-topbar {
        z-index: 1005;
        margin-inline-start: $sidenav-width-sm;
    }

    .content-page {
        margin-inline-start: $sidenav-width-sm;
        min-height: 1900px;
    }

    .sidenav-menu {
        position: absolute;
        width: $sidenav-width-sm;

        .simplebar-mask,
        .simplebar-content-wrapper {
            overflow: visible !important;
        }

        .simplebar-scrollbar {
            display: none !important;
        }

        .simplebar-offset {
            bottom: 0 !important;
        }

        .logo {
            z-index: 1;
            background: $sidenav-bg;
            text-align: center;
            padding: 0;

            span.logo-lg {
                display: none;
            }

            span.logo-sm {
                display: block;
            }
        }

        .side-nav {
            gap: 0;

            > .side-nav-item {
                padding: 0px;
            }

            .side-nav-item {
                position: relative;

                .side-nav-link {
                    transition: none;
                    border-radius: 0;
                    padding: calc($sidenav-item-padding-y * 1.75) $sidenav-item-padding-x;

                    .menu-text,
                    .menu-arrow,
                    .badge {
                        display: none;
                    }

                    .menu-icon {
                        display: flex;
                        justify-content: center;
                        font-size: calc($sidenav-item-icon-size * 1.25);
                        line-height: calc($sidenav-item-icon-size * 1.25);
                        min-width: calc($sidenav-width-sm - $sidenav-item-padding-x - $sidenav-item-padding-x);

                        i {
                            font-size: calc($sidenav-item-icon-size * 1.25);
                            line-height: calc($sidenav-item-icon-size * 1.25);
                        }

                        svg {
                            height: calc($sidenav-item-icon-size * 1.25);
                            width: calc($sidenav-item-icon-size * 1.25);
                        }
                    }
                }

                .collapse,
                .collapsing {
                    display: none;
                    height: inherit !important;
                    transition: none !important;

                    .sub-menu {
                        display: none;
                        padding: 5px 0;
                        margin-top: 0;
                        position: absolute;
                        inset-inline-start: $sidenav-width-sm;
                        box-shadow: var(--#{$prefix}box-shadow);
                        border: $card-border-width solid $sidenav-border-color;
                        border-top: 0;
                        background: $sidenav-bg;
                        border-radius: 0 0 4px 4px;

                        .sub-menu {
                            border-radius: 4px;
                        }
                    }
                }

                &:hover {
                    .side-nav-link {
                        position: relative;

                        .menu-text,
                        .badge {
                            display: flex;
                            // visibility: visible;
                        }

                        .side-nav-link::before {
                            display: none;
                        }
                    }

                    > .collapse,
                    > .collapsing {
                        display: block !important;
                        transition: none !important;

                        > .sub-menu {
                            display: block;
                            inset-inline-start: $sidenav-width-sm;
                            width: calc($sidenav-width - calc($sidenav-width-sm * 0.65));

                            .side-nav-item:hover {
                                > .collapse,
                                > .collapsing {
                                    > .sub-menu {
                                        top: 0;
                                        inset-inline-start: calc($sidenav-width - calc($sidenav-width-sm * 0.65));
                                        width: calc($sidenav-width - calc($sidenav-width-sm * 0.65));
                                    }
                                }
                            }

                            .menu-arrow {
                                transform: rotate(-90deg);
                                display: flex;
                            }
                        }
                    }
                }

                .sub-menu {
                    .side-nav-item {
                        .side-nav-link {
                            transition: $transition-base;
                            padding: calc($sidenav-sub-item-padding-y * 1.5) calc($sidenav-sub-item-padding-x * 1.5);
                            white-space: inherit;
                        }
                    }
                }
            }

            > .side-nav-item:hover {
                > .side-nav-link {
                    color: $sidenav-item-active-color;
                    background: $sidenav-bg;
                    box-shadow: var(--#{$prefix}box-shadow);
                    width: calc($sidenav-width + calc($sidenav-width-sm * 0.35));
                    border-radius: 4px;

                    &[data-bs-toggle='collapse'] {
                        border-end-end-radius: 0;
                    }
                }
            }
        }
    }

    .side-nav-link::before,
    .sidenav-user,
    .side-nav-title {
        display: none;
    }
}

//  Compact Menu
html[data-sidenav-size='compact'] {
    .sidenav-menu {
        width: $sidenav-width-md;

        .sidenav-user {
            .sidenav-user-set-icon {
                display: none;
            }
        }
    }

    .content-page,
    .app-topbar {
        margin-inline-start: $sidenav-width-md;
    }

    .menu-arrow {
        display: none;
    }
}

// Hover View Menu
html[data-sidenav-size='on-hover'] {
    .content-page,
    .app-topbar {
        margin-inline-start: $sidenav-width-sm;
    }

    .sidenav-toggle-button {
        display: none;
    }

    .sidenav-menu:not(:hover) {
        width: $sidenav-width-sm;

        .simplebar-scrollbar:before {
            background: transparent;
        }

        .logo {
            .logo-sm {
                display: block;
            }

            .logo-lg {
                display: none;
            }
        }

        .side-nav-item {
            .side-nav-link {
                justify-content: center;

                .menu-text,
                .menu-arrow,
                .badge {
                    display: none;
                }
            }
        }

        .side-nav-title {
            display: none;
        }

        .button-on-hover,
        .sidenav-user,
        .menu-text {
            display: none;
        }

        .sub-menu {
            height: 0;
            opacity: 0;
        }

        .menu-icon {
            font-size: calc($sidenav-item-icon-size * 1.15);
            line-height: calc($sidenav-item-icon-size * 1.15);

            i {
                font-size: calc($sidenav-item-icon-size * 1.15);
                line-height: calc($sidenav-item-icon-size * 1.15);
            }

            svg {
                height: calc($sidenav-item-icon-size * 1.15);
                width: calc($sidenav-item-icon-size * 1.15);
            }
        }
    }

    .sidenav-menu {
        .simplebar-horizontal .simplebar-scrollbar:before {
            background: transparent;
        }

        .logo {
            text-align: start;
        }

        &:hover {
            z-index: 1045;
            box-shadow: var(--#{$prefix}box-shadow-lg) !important;
        }

        .button-on-hover {
            display: block;
        }
    }
}

// Sidebar sm hover Toggle Menu Button (sm hover active button)
.button-on-hover {
    cursor: pointer;
    display: none;
    inset-inline-end: 10px;
    top: 0;
    position: absolute;
    font-size: 18px;
    line-height: $topbar-height;
    background: transparent;
    border: none;
    z-index: 1;
    color: $sidenav-item-color;
    padding-block: 0;

    &:hover,
    &:focus,
    &:active {
        color: $sidenav-item-hover-color;
    }

    .btn-on-hover-icon {
        height: 1em;
        width: 1em;
        border-radius: 50%;
        border: 2px solid currentColor;
        display: inline-block;
        position: relative;
        vertical-align: middle;
    }
}

html[data-sidenav-size='on-hover-active'] {
    .sidenav-toggle-button {
        display: none;
    }

    .sidenav-menu {
        .logo {
            text-align: start;
        }

        .button-on-hover {
            display: block;

            .btn-on-hover-icon {
                &::before {
                    height: 0.325em;
                    width: 0.325em;
                    background-color: currentColor;
                    border-radius: 50%;
                    position: absolute;
                    content: "";
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                }
            }
        }
    }
}

// Fullscreen Close Button
.button-close-offcanvas {
    display: none;
    z-index: 1;
    position: absolute;
    background: transparent;
    border: none;
    top: 0;
    inset-inline-end: calc($sidenav-width-sm * 0.5 - $logo-sm-height * 0.7);
    cursor: pointer;
    color: $sidenav-item-color;
    line-height: $topbar-height;
    font-size: $sidenav-item-icon-size;

    &:hover,
    &:focus,
    &:active {
        color: $sidenav-item-hover-color;
    }
}

// Offcanvas Menu
html[data-sidenav-size='offcanvas'] {
    .logo-topbar {
        display: inline-block;

        @include media-breakpoint-up(xl) {
            min-width: 200px;
        }
    }

    .content-page,
    .app-topbar {
        margin-inline-start: 0;
    }

    .button-close-offcanvas {
        display: block;
    }

    .sidenav-menu {
        margin-inline-start: calc($sidenav-width * -1);
        opacity: 0;
        transition: all 0.25s ease-in-out;

        .logo {
            text-align: start;
        }
    }

    &.sidebar-enable {
        .sidenav-menu {
            opacity: 1;
            z-index: 1055;
            margin-inline-start: 0;
        }
    }
}
