//
// _horizontal.scss
//

html[data-layout='topnav'] {
    .app-topbar {
        margin: 0;
        z-index: 1005;
        box-shadow: none;
        border-bottom: 0;
        
        .logo-topbar {
            display: block;
            float: none;
            margin-inline-end: 30px;
        }

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

        .topbar-menu {
            padding-inline-end: calc(var(--#{$prefix}gutter-x) * 0.5);
            padding-inline-start: calc(var(--#{$prefix}gutter-x) * 0.5);
        }
    }

    .content-page {
        margin-inline-start: 0;
        min-height: calc(100vh - $topbar-height - 43px);
    }

    .topnav {
        width: 100%;
        z-index: 1000;
        position: sticky;
        top: $topbar-height;
        background: $sidenav-bg;
        padding-inline-start: $grid-gutter-width * 0.5;
        padding-inline-end: $grid-gutter-width * 0.5;
        box-shadow: var(--#{$prefix}box-shadow);
        font-family: $font-family-secondary;

        .navbar {
            margin: 0;
            padding: 0;
        }

        .navbar-nav {
            @include media-breakpoint-up(lg) {
                .nav-item {
                    &:first-of-type {
                        .nav-link {
                            padding-inline-start: 0;
                        }
                    }
                }
            }
            .nav-link {
                display: flex;
                align-items: center;
                position: relative;
                line-height: $sidenav-item-font-size;
                font-size: $sidenav-item-font-size;
                font-weight: $sidenav-item-font-weight;
                padding: calc($sidenav-item-padding-y * 1.25) calc($sidenav-item-padding-x * 1.5);

                .menu-icon {
                    margin-inline-end: calc($sidenav-item-icon-size * 0.5);

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

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

                .menu-arrow {
                    margin-inline-start: calc($sidenav-item-icon-size * 0.5);
                }
            }

            .dropdown {
                .dropdown-menu {
                    font-size: $sidenav-sub-item-font-size;

                    .dropdown-item {
                        display: flex;
                        gap: 8px;
                        align-items: center;
                        padding: calc($sidenav-item-padding-y * 0.75) calc($sidenav-item-padding-x * 1.5);

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

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

        .nav-item {
            > a,
            .nav-link {
                color: $sidenav-item-color;

                &:hover {
                    color: $sidenav-item-hover-color;
                }
            }

            &.active {
                > a {
                    color: $sidenav-item-hover-color;
                }
            }
        }
    }

    .page-title-head {
        background-color: transparent;
        border: 0;
        min-height: 60px;
        margin-bottom: 0;
    }
}

@include media-breakpoint-up(lg) {
    .topnav {
        .dropdown {
            .dropdown-menu {
                margin-top: 0;

                .dropdown {
                    .dropdown-menu {
                        position: absolute;
                        top: 0;
                        inset-inline-start: 100%;
                        display: none;
                    }
                }
            }

            &:hover {
                .nav-link {
                    color: $sidenav-item-hover-color !important;
                }

                > .dropdown-menu {
                    display: block;
                }
            }
        }

        .dropdown:hover > .dropdown-menu > .dropdown:hover {
            > .dropdown-item {
                color: $sidenav-item-hover-color !important;
            }
            > .dropdown-menu {
                display: block;
            }
        }

        .dropdown.active > a.dropdown-item {
            color: $dropdown-link-active-color;
            @include gradient-bg($dropdown-link-active-bg);
        }
    }
}

@include media-breakpoint-down(lg) {
    html[data-layout='topnav'] {
        .topnav {
            max-height: 360px;
            overflow-y: auto;

            .navbar-nav {
                .nav-link {
                    padding: calc($sidenav-item-padding-y * 1) calc($sidenav-item-padding-x * 2);
                }
            }

            .dropdown {
                .dropdown-menu {
                    background-color: transparent;
                    border: none;
                    box-shadow: none;
                    padding-inline-start: calc($sidenav-item-padding-x * 3);
                    margin-top: calc($sidenav-item-padding-y * -0.75);

                    .dropdown-menu {
                        margin-top: calc($sidenav-item-padding-y * -0.5);
                        padding-inline-start: calc($sidenav-item-padding-x * 1.5);
                    }
                }

                .dropdown-item {
                    position: relative;
                    background-color: transparent;
                }
            }

            .dropdown {
                .dropdown-item {
                    color: $sidenav-item-color;

                    &.hover {
                        color: $sidenav-item-hover-color;
                    }

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

            .dropdown.active > a.dropdown-item {
                color: $sidenav-item-active-color;
            }
        }

        .topnav-toggle-button {
            display: block;
        }
    }
}

//  Horizontal Menu Toggle Button
.topnav-toggle-button {
    display: none;
    position: relative;
    cursor: pointer;
    float: inline-start;
    padding: 0;
    background-color: transparent;
    border: none;
    color: $topbar-item-color;
    font-size: 22px;
}

@include media-breakpoint-up(xxl) {
    html[data-layout='topnav'] {
        .container-fluid {
            max-width: 85%;
        }
    }
}

.dropdown-menu-columns {
    width: 350px;
    column-count: 2;
    column-gap: 0;

    /* Prevent dropdown items from breaking across columns */
    & > * {
        -webkit-column-break-inside: avoid;
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

@media (min-width: 992px) {
    .dropdown-menu-columns {
        width: 350px;
        column-count: 2;
    }
}
