$ddpurple: #632ca6;

body {
    .sidenav {
        .sticky {
            top: 98px;
        }
    }
}

.api {
    .sidenav-api {
        .sticky {
            top: 103px !important;

            @include media-breakpoint-up(xl) {
                top: 98px !important;
            }
        }
    }
}

.side {
    &:before,
    &:after {
        content: '';
        position: absolute;
        margin-left: -2000px;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        background: #f8f8f8;
        z-index: -1;
        height: 100%;
    }
    &:after {
        height: 50px;
    }
}

.sidenav {
    background: #f8f8f8;
    width: 100%;
    position: relative;
    z-index: 2;
    padding-right: 15px;
    padding-bottom: 50px;

    i[class*='icon-'] {
        display: inline-block;
        width: 20px;
        margin-top: 4px;
    }

    // Exception for main sidenav since APM's title wraps to a second line
    .en &:not(.navbar-sidenav .sidenav) .icon-apm,
    .en &:not(.navbar-sidenav .sidenav) .icon-cog,
    // Exceptions for FR site
    .fr &:not(.navbar-sidenav .sidenav) .icon-security,
    .fr &:not(.navbar-sidenav .sidenav) .icon-synthetics,
    .fr &:not(.navbar-sidenav .sidenav) .icon-dev-code {
        @include media-breakpoint-only(lg) {
            align-self: flex-start;
            margin-top: 8px;
        }
    }

    .sticky {
        .col {
            padding-right: 0;
        }
    }

    & > .row {
        &:before,
        &:after {
            content: '';
            position: absolute;
            margin-left: -2000px;
            left: 0;
            top: 0;
            right: -15px;
            bottom: 0;
            background: #f8f8f8;
            z-index: -1;
        }
        &:after {
            height: 50px;
        }
    }

    .h4 {
        padding: 0 0 10px 10px;
        color: $ddpurple;
        font-size: 24px;
        font-weight: 200;
        margin-top: 14px;

        &:lang(ja) {
            font-size: 20px;
            font-weight: 200;
            line-height: 37px;
        }
    }

    .h5 {
        color: #4a4a4a;
    }

    .sidenav-search {
        margin-left: 7px;
        padding-right: 10px;
        //margin-right: 30px;
        .input-group-addon {
            background: none;
            border: none;
            padding: 6px 0 0 3px;
            border-radius: 0;
            position: absolute;
            left: 0;
        }
        .form-control:focus {
            border-color: $ddpurple;
            padding-left: 5px;
            & ~ .input-group-addon {
                display: none;
            }
        }
        input {
            border-top: none;
            border-left: none;
            border-right: none;
            background: transparent;
            border-radius: 0;
            font-size: 18px;
            padding-bottom: 3px;
            padding-left: 30px;
            transition: all 0.1s ease-in;
        }
    }

    .sidenav-nav {
        margin-left: 7px;
        overflow-x: hidden;
        overflow-y: auto;
        ul {
            margin-top: 0px;
            padding-bottom: 3px;
        }
        & > ul {
            margin-top: 5px;
        }

        .nav-top-level {
            & > a div {
                margin-left: 10px;
            }
        }

        ul li > ul {
            display: none;
        }
        ul li.open > ul {
            display: block;
        }
        > ul > li.open {
            > a {
                // Style the first a tag nested in an open list element.
                color: $ddpurple;
                border: 1px solid transparent;
                margin-bottom: 1px;
            }
            .hover {
                display: inline-block;
            }
            .static {
                display: none;
            }
        }
        ul li.open > ul,
        ul li.active > ul {
            li {
                padding-left: 27px;
                a {
                    padding: 0;
                    padding-bottom: 0px;
                    margin-top: 0px;
                }
            }
        }
        // First level should get underline no other li nested
        > ul {
            > li.open > a > div > span {
                border-bottom: 1px solid $ddpurple;
                padding-bottom: 2px;
                margin-bottom: 1px;
            }
            li {
                a {
                    color: #000;
                    font-size: 18px;
                    font-weight: 600;
                    padding: 3px 0 0 2px;
                    margin-right: 10px;
                    display: flex;
                    border: 1px solid transparent;
                    &:hover {
                        background: transparent;
                        color: $ddpurple;
                        border-radius: 0px;
                        border: 1px solid transparent;
                    }
                    &.active span,
                    &.active a {
                        background: transparent;
                        border-radius: 0px;
                        color: $ddpurple;
                    }
                    .hover {
                        display: none;
                    }

                    span,
                    img {
                        vertical-align: top;
                    }
                    img {
                        margin-top: 4px;
                        &:lang(ja) {
                            margin-top: 0px;
                        }
                        @include media-breakpoint-up(xxl) {
                            image-rendering: -webkit-optimize-contrast;
                        }
                    }

                    &:lang(ja) {
                        font-style: normal;
                        font-weight: bold;
                        font-size: 15px;
                        line-height: 24px;
                    }
                }

                // 2nd level
                ul li {
                    a {
                        margin-left: 5px;
                        font-weight: 200;
                        line-height: 24px;
                        &:lang(ja) {
                            font-style: normal;
                            font-weight: 300;
                            font-size: 14px;
                            line-height: 22px;
                        }
                    }

                    // 3rd level
                    ul li a {
                        margin-left: 5px;
                        font-size: 15px;
                        line-height: 22px;
                        &:lang(ja) {
                            font-size: 11px;
                            line-height: 22px;
                        }
                    }
                }
            }
        }
    }
}

.sidenav-api, .sidenav-partners {
    .sidenav-nav {
        overflow-x: hidden;
        overflow-y: scroll;
        &::-webkit-scrollbar {
            appearance: none;
            width: 7px;
        }
        &::-webkit-scrollbar-thumb {
            border-radius: 4px;
            background-color: rgba(0, 0, 0, 0.5);
            box-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
        }

        scrollbar-width: thin;

        margin: 0;
        ul li.active {
            > a {
                background: transparent;
                color: $ddpurple;
                border-bottom: 1px solid transparent;
            }
            ul {
                display: block;
                li {
                    padding-left: 0;
                    &.active {
                        a {
                            background: transparent;
                            color: $ddpurple;
                            border-bottom: 1px solid transparent;
                        }
                    }
                }
            }
        }
        ul li > ul {
            list-style-type: none;
            padding-left: 20px;
            li a {
                font-size: 16px;
                margin-top: 0px;
                padding: 0px;
            }
        }
    }
    ul li a {
        line-height: 24px;
        font-size: 18px;
        font-weight: 600;
        color: #000;
        padding: 6px 0 0 2px;
        display: block;
    }
    ul:first-of-type {
        margin-left: 3px;
    }

    .toc_scrolled {
        background: transparent !important;
        color: $ddpurple !important;
        border: 1px solid transparent !important;
        span {
            border-bottom: 1px solid $ddpurple;
        }
    }
    // open adjacent ul to open link
    .toc_open ~ ul {
        display: block !important;
    }
}

//@include media-breakpoint-up(xs) { ... }
@media (min-width: 576px) {
    .sidenav {
        ul {
            li {
                a {
                    &:hover,
                    &.active {
                        color: $ddpurple;
                        & .hover {
                            display: inline-block;
                        }
                        & .static {
                            display: none;
                        }
                    }
                    .hover {
                        display: none;
                    }
                }
            }
        }
    }
}

@media (max-width: 1199px) {
    .sidenav {
        ul {
            li {
                a {
                    font-size: 17px;
                }
            }
        }
    }
}

.fr .sidenav {
    .h4 {
        font-size: 22px;
    }
}

@media (max-width: 1199px) {
    .fr {
        .sidenav {
            .h4 {
                font-size: 18px;
                padding-top: 15px;
            }
        }
    }
}

.ja .sidenav {
    i[class*='icon-'] {
        margin-top: 0;
    }

    &:not(.navbar-sidenav .sidenav) [data-path='ja/security_monitoring'] .icon-security {
        align-self: flex-start;
        margin-top: 4px;
    }

    @include media-breakpoint-only(lg) {
        &:not(.navbar-sidenav .sidenav) .icon-mobile,
        &:not(.navbar-sidenav .sidenav) .icon-host-map,
        &:not(.navbar-sidenav .sidenav) .icon-apm,
        &:not(.navbar-sidenav .sidenav) .icon-rum,
        &:not(.navbar-sidenav .sidenav) .icon-network,
        &:not(.navbar-sidenav .sidenav) [data-path='ja/security_monitoring'] .icon-security {
            align-self: flex-start;
            margin-top: 4px;
        }
    }
}
