@import "scss/_sphinx_basic";
@import "scss/_variables";
@import "scss/bootstrap_overridden";
@import "scss/bootstrap_scss/bootstrap";
@import "scss/_mixins";
@import "scss/_typography";
@import "scss/_iconfont";

div[aria-label="related navigation"] {
    display: none;
}

body {
    a:not(:hover), a.o_logo {
        text-decoration: none !important;
    }

    dd {
        margin-left: 1rem;
    }

    // This fixes the scroll position on all elements, including refs
    :target {
        &:before {
            @include o-scroll-padding()
        }
    }

    abbr[title="Pull Request"] {
        @include o-easter-egg();
    }
}

.hidden {
    visibility: hidden !important;
    display: none !important;
    opacity: 0 !important;
}
//------------------------------------------------------------------------------
// Header with logo, searchbar and switchers
//------------------------------------------------------------------------------

header.o_main_header {
    width: 100%;
    height: $o-header-mobile-height;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: $o-header-white;
    z-index: 10;
    padding: 0 $padding-s;
    @include media-breakpoint-up(lg) {
        height: $o-header-height;
        padding: 0 $padding-m;
    }
    @include media-breakpoint-up(xl) {
        padding: 0 $padding-l 0 $padding-m;
    }

    .o_logo_wrapper {
        > .o_logo {
            img {
                margin-bottom: -2px;
                vertical-align: baseline;
            }

            span {
                @include font-size($font-size-base);
                color: $o-violet;
                @include o-easter-egg($img:'img/ducky.svg');
            }
        }
        @include media-breakpoint-up(xl) {
            width: calc(#{$o-side-nav-width} - #{$padding-l});
        }
        @include media-breakpoint-up(lg) {
            margin-right: $margin-l;
        }
    }

    .o_logo img {
        @include media-breakpoint-up(lg) {
            height: 30px
        }
    }

    .o_search_wrapper {
        display: flex;
        position: relative;
        opacity: 1;
        @include transition(opacity .3s);
        @include media-breakpoint-down(lg) {
            display: block;
            position: absolute;
            width: calc(100% - (#{$padding-s} * 2));
            top: calc(100% + #{$padding-s});
        }
        @include media-breakpoint-up(lg) {
            flex-grow: 1;
            max-width: 500px;
        }

        .o_search {
            position: relative;
            width: 100%;


            .btn {
                @include o-position-absolute($top: 50%, $right: 1rem);
                @include o-transform (translateY(-50%)) ;
                padding: 0;
                font-size: 1.2rem;
                color: $gray;
            }
        }
    }

    &.o_header_scrolled {
        .o_search_wrapper {
            @include media-breakpoint-down(lg) {
                opacity: 0;
            }
        }
    }

    .highlight-link {
        @include o-position-absolute($bottom: -1.5rem, $right: 1rem);
        margin-bottom: 0;
        a {
            @include font-size(12px);
        }
    }

    .navbar-toggler {
        &[aria-expanded="true"] {
            .icon-bar {
                &:nth-of-type(1) {
                    @include o-transform(rotate(45deg));;
                    @include o-transform-origin(10%, 10%)
                }

                &:nth-of-type(2) {
                    opacity: 0;
                    filter: alpha(opacity=0);
                }

                &:nth-of-type(3) {
                    @include o-transform(rotate(-45deg));
                    @include o-transform-origin(10%, 90%)
                }
            }
        }

        .icon-bar {
            display: block;
            width: 22px;
            height: 2px;
            background-color: $gray-dark;
            @include o-transition(all, .2s);

            &+ .icon-bar {
                margin-top: 4px;
            }

            &:nth-of-type(1) {
                @include o-transform(rotate(0));
            }

            &:nth-of-type(2) {
                opacity: 1;
                filter: alpha(opacity=100);
            }

            &:nth-of-type(3) {
                @include o-transform(rotate(0));
            }
        }

        &:focus {
            box-shadow: none;
            outline:none;
        }
    }
}

//------------------------------------------------------------------------------
// Left side nav toctree
//------------------------------------------------------------------------------

.o_side_nav {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    position: fixed;
    top: -100%;
    left:0;
    @include o-transition(all, .3s);
    padding-top: 4rem;
    padding-left: $padding-s;
    background-color: lighten($o-violet-dark, 70%) ;
    z-index: 10;
    @include font-size($font-size-secondary);
    color: $o-violet-dark;
    font-weight: $fw_regular;
    @include media-breakpoint-up(lg) {
        width: calc(#{$o-side-nav-width} - 1rem);
        height: calc(100vh - #{$o-header-height});
        top: $o-header-height;
        padding-top: $padding-m;
        padding-left: $padding-m;
    }
    @include media-breakpoint-up(xl) {
        width: $o-side-nav-width;
    }

    &.show {
        top: $o-header-mobile-height;
    }

    .toctree-l1 {
        padding-top: $padding-xs;
        padding-bottom: $padding-xs;

        > .o_toc_entry_wrapper a {
            color: $o-violet-dark;
            font-weight: 600;
        }
    }

    ul {
        .o_deepest_active_toc_entry {
            background-color: $gray-lighter;
            border-left: 3px solid $gray-lighter;
            margin-left: -3px;
        }

        li {
            &.o_active_toc_entry {
                &:not(.toctree-l1) > .o_toc_entry_wrapper i[class^="i-"]:not(.collapsed), > a , > .o_toc_entry_wrapper a, > .o_toc_entry_wrapper i {
                    color: $o-violet-dark;
                }
            }

            a {
                &.current {
                    color: $o-violet-dark;
                }
            }
        }

        > .toctree-l1 {
            &[class*="o_menu_"] > .o_toc_entry_wrapper > i:before {
                @include o-inline-icon($i-doc-apps, 0 5px 0 0);
                color: $o-violet-dark;
            }

            &.o_menu_applications > .o_toc_entry_wrapper > i:before{
                content:'#{$i-doc-apps}';
            }

            &.o_menu_administration > .o_toc_entry_wrapper > i:before{
                content:'#{$i-doc-admin}';
            }

            &.o_menu_developer > .o_toc_entry_wrapper > i:before{
                content:'#{$i-doc-dev}';
            }

            &.o_menu_services > .o_toc_entry_wrapper > i:before{
                content:'#{$i-doc-services}';
            }

            &.o_menu_contributing > .o_toc_entry_wrapper > i:before{
                content:'#{$i-doc-contribute}';
            }

        }
    }
    scrollbar-width: thin;
    scrollbar-color: $o-violet-darker transparent;

    &::-webkit-scrollbar {
        width: 5px;
    }

    &::-webkit-scrollbar-track {
        background: $white;
    }

    &::-webkit-scrollbar-thumb {
        background-color: $o-violet-darker ;
        border-radius: 0;
    }
}

.o_side_nav, .o_page_toc_nav {
    ul { // all uls in toc
        list-style: none;
        padding-left: $padding-s;

        li {
            > a.reference {
                padding-left: .875rem;
            }

            a {
                display: inline-block;
                padding: .4rem 0;
                color: $gray-darker;
                font-weight: $fw_regular;
            }

            &:not(.toctree-l1) {
                .o_toc_entry_wrapper {
                    &:not(.o_page_toc_title) {
                        display: flex;
                        align-items: baseline;
                    }

                    > i[class^="i-"] {
                        display: inline-block;
                        margin-right: .125rem;
                        @include o-transition(rotate, .3s);
                        font-size: .75rem;
                        &[aria-expanded="true"] {
                            @include o-transform(rotate(90deg));
                        }
                    }
                }
            }

            &.o_active_toc_entry {
                &:not(.toctree-l1) > .o_toc_entry_wrapper {
                    i[class^="i-"]:not(.collapsed) {
                        @include o-transform(rotate(90deg));
                    }
                }
                > a , > .o_toc_entry_wrapper a, > .o_toc_entry_wrapper i {
                    font-weight: $fw_bold;
                }
            }
        }
    }

    > ul { //is first ul in toc
        padding-left: 0;
    }
}
//------------------------------------------------------------------------------
// On this page local toctree
//------------------------------------------------------------------------------

    aside.o_page_toc {
        display: none;
        @include font-size($font-size-secondary);
        @include media-breakpoint-up(xl) {
            display: block;
            position: -webkit-sticky;
            position: sticky;
            top: $o-header-height;
            right: 0;
            width: $o-on-page-width;
            height: 100%;
            max-height: calc(100vh - #{$o-header-height});
            padding: $padding-l $padding-s $padding-l 0;
            overflow-y: auto;
        }

        h3 {
            text-transform: uppercase;
            font-weight: $fw_bold;
            color: $gray-darker;
            padding-left: $padding-xs;
            margin-bottom: $padding-xs;
        }

        a {
            font-weight: $fw_regular;
            color: $gray-darker;
        }

        .o_page_toc_title {
            display:none;

            + ul {
                padding-left: 0;
            }
        }
    }

//------------------------------------------------------------------------------
// Main page content
//------------------------------------------------------------------------------

#wrap {
    margin-top: $o-header-mobile-height;
    @include media-breakpoint-up(lg) {
        display: flex;
        justify-content: space-between;
        margin-top: $o-header-height;
    }

    code {
        display: inline-block;
        color: inherit;
        background: $doc_code-bg;
        padding: 0 .3rem;
        margin: 0 0.1rem;
        line-height: 1.3;
        border: 1px solid $gray-light;
        overflow-wrap: anywhere;
    }

    iframe {
        max-width: 100%;
    }

    main {
        position: relative;
        padding-top: 5rem;
        padding-bottom: $padding-l;
        @include media-breakpoint-up(lg) {
            left: calc(#{$o-side-nav-width} - #{$padding-s});
            max-width: calc(100vw - #{$o-side-nav-width});
            padding: $padding-l;
            margin: 0;
        }
        @include media-breakpoint-up(xl) {
            left: $o-side-nav-width;
            max-width: calc(100vw - #{$o-side-nav-width} - #{$o-on-page-width});
        }

        &.o_index, &.o_fullwidth_page, &.o_has_code_column {
            @include media-breakpoint-up(xl) {
                max-width: calc(100vw - #{$o-side-nav-width});
            }
        }

        // Homepage

        &.o_index {
            .o_content_fw_banner {
                margin: 0 -0.75rem $margin-m;
                padding: $padding-m $padding-s;
                align-items: center;
                @include o-gradient();
                @include media-breakpoint-up(lg) {
                    margin: -#{$margin-m} -#{$margin-m} $margin-m;
                    padding: $padding-m $padding-m;
                }
                @include media-breakpoint-up(xl) {
                    margin: -#{$margin-l} -#{$margin-l} $margin-l;
                    padding: $padding-l $padding-l;
                }
            }
            .row:first-of-type h2.border-top {
                @include media-breakpoint-up(lg) {
                    border-top: 0 solid transparent !important;
                }
            }

            h5 {
                font-size: 12px;
            }

            ul {
                > li {
                    position: relative;
                    padding-bottom: $padding-xs;
                    display: flex;
                    align-items: center;

                    &:before {
                        @include o-inline-icon($i-article, 0 .2rem 0 0);
                        color: $gray-light;
                    }
                }
            }

            .o_changelog {
                .row:last-of-type > .border-bottom {
                    border: none !important;
                }
            }
        }

        // First level legal page and pages with toctrees (i.e.: User Docs, Install & Maintain, Developer, Contributing)
        &.o_fullwidth_page {
                div.toctree-wrapper > ul {
                    display: flex;
                    flex-wrap: wrap;
                    > li {
                        @include media-breakpoint-down(lg) {
                            width: 100%;
                        }
                        @include media-breakpoint-up(lg) {
                            width: 33%;
                            &:not(:nth-of-type(3n)){
                                padding-right: $padding-m;
                            }
                        }

                    }
                }
            }

        // pages with column for code on the right
        &.o_has_code_column {
            article.doc-body {
                > * {
                  max-width: 100%;
                }

                .content-switcher {
                    .nav-tabs .nav-link.active {
                        background-color: #f8f8f8;
                        border-color: #dee2e6 #dee2e6 #f8f8f8;
                        font-weight: $fw_semibold;
                    }

                    .tab-content {
                        background: $doc_code-bg;
                        border: 1px $gray-300 solid;
                        border-top: 0;

                        div[class^="highlight"] {
                            border: 0;
                            margin: 0;
                        }
                    }
                }

                @include media-breakpoint-up(xl) {
                    width: 100%;
                    padding-right: 0;

                    &:before {
                        @include o-code-col();
                    }

                    .o_git_link {
                        right: calc(#{$o-codecol-width} + $padding-l);
                    }

                    section {
                        > * {
                            width: $o-halfpage-width;
                            float: left;
                            clear: left;
                        }

                        > h1 {
                            max-width: calc(#{$o-halfpage-width} - 120px);
                        }

                        > h1, > h2, > h3, > h4, > h5, > h6 {
                            float: none;
                            clear: none;
                        }

                        .doc-aside {
                            width: $o-codecol-width;
                            float: none;
                            clear: none;
                            margin-left: 57%;
                            padding: $padding-s;

                            blockquote {
                                font-weight: $fw_semibold;
                                font-style: italic;
                            }

                            pre {
                                font-size: 12px;
                            }
                        }
                    }
                }
            }

            + aside.o_page_toc{
                display: none;
            }
        }

        &.o_hide_toc {
            .toctree-wrapper {
                display: none;
            }
        }

        .toctree-wrapper {
            > ul, .toctree-l1 > ul {
                padding-left: 0;
                list-style: none;
            }

            .toctree-l1 > a {
                display: block;
                @include font-size($h2-font-size);
                margin-top: $padding-m;
                padding-bottom: $padding-xs;
                border-bottom: 1px solid $gray-light;
                margin-bottom: $margin-s;
                font-size: 1.2rem;
                font-weight: 600;
            }

            .toctree-l1 {
                margin-bottom: 2rem;
            }

            .toctree-l2 > a[href="#"] {
                margin-top: 0.7rem;
                display: inline-block;
            }

            a[href="#"] {
                pointer-events: none;
                cursor: default;
                color: $gray-darker;
                font-weight: $fw_semibold;
            }
        }

        article.doc-body {
            position: relative;

            .o_git_link {
                @include font-size($font-size-secondary);
                @include o-position-absolute($top: 0px, $right: $margin-s);
                @include media-breakpoint-up(lg) {
                    @include o-position-absolute($top: 10px, $right: $margin-s);
                }
                i {
                    margin-right: .2rem;
                }
            }

            .command {
                font-family: var(--bs-font-monospace);
            }

            .field-list {
                @include font-size($font-size-secondary);
                padding: .5rem;
                border: 1px solid $gray-light;

                ul {
                    list-style: none;
                    padding-left: 0;

                    li {
                        padding-bottom: $padding-xs;
                    }
                }
            }

            // Search items highlighted
            span.highlighted {
                background-color: lighten($warning, 15%);
            }

            section {
                > h1 {
                    color: $o-violet-dark;
                    font-weight: $fw_bold;
                    @include media-breakpoint-up(lg) {
                        max-width: calc(100% - 120px);
                    }
                    + * {
                        margin-top: $margin-s;
                    }
                }

                > h2 {
                    font-family: $font-family-serif;
                    color: $gray-darker;
                    margin-top: $margin-m;
                    margin-bottom: $margin-s;
                    padding-bottom: .3rem;
                    border-bottom: 1px solid $gray-light;
                }

                > h3 {
                    margin-top: $margin-m;
                    font-weight: $fw_bold;
                }

                > h4 {
                    margin-top: $margin-l;
                }

                > h4, > h5, > h6 {
                    font-weight: $fw_semibold;
                }

                img:not([alt="green"]):not([alt="orange"]):not([alt="red"]) {
                    border: 1px solid $gray-lighter;
                    background: $white;
                    padding: .5rem;
                }

                img:not([alt="green"]):not([alt="orange"]):not([alt="red"]), iframe {
                    margin-bottom: 1rem;
                }

                p > img {
                    border: none;
                    padding: 0;
                    margin-bottom: 0;
                }

                .figure {

                    .caption, .caption-text {
                        font-weight: $fw_semibold;
                        color: $gray;
                    }

                    .caption, .caption-text, .legend, .legend p {
                        font-style: italic;
                        margin: 0 auto;
                    }

                    @include media-breakpoint-up(md) {
                        &:not([class^="col"]) .legend {
                            max-width: 60%;
                        }
                    }
                }

                a.headerlink {
                    text-decoration: none;
                    font-size: 0;
                    visibility: hidden !important;

                    &:before {
                        content: "\a0";
                    }

                    &:after {
                        content: '#{$i-link}';
                        font-family: icomoon !important;
                        @include font-size($font-size-base);
                        margin: 0 0 0 .3rem;
                        visibility: hidden;
                        color: $gray-light;
                        opacity: 0;
                        @include o-transition(all, .1s)
                    }
                }

                *:hover > a.headerlink:after {
                    // This makes permalinks only visible on hover.
                        visibility: visible;
                        opacity: 1;
                }

                table.table {
                    @include media-breakpoint-down(lg){
                    display: block;
                    overflow-x: auto;
                        code {
                            overflow-wrap: break-word;
                        }
                    }
                }
            }
        }

        div[class^="highlight"] {
            // This styles the consoles like read-the-doc's consoles
            overflow-x: auto;
            border: 1px solid $gray-light;
            margin: 1px 0 24px 0;

            div[class^="highlight"] {
                padding: 0px;
                border: none;
                margin: 0;
            }
            pre {
                white-space: pre;
                margin: 0;
                padding: 1rem;
                display: block;
                overflow: auto;
            }
        }

        .guilabel, .menuselection {
            font-weight: $fw_semibold;
        }

        .dfn{
            @include font-size($font-size-secondary);
            line-height: 1;
            color: $o-violet;
            font-weight: $fw_semibold;
            &:before {
                content:'?';
                display: inline-block;
                width: 15px;
                height: 15px;
                background-color: $o-violet;
                border: 1px solid $o-violet;
                border-radius: 20px;
                text-align: center;
                color: $white;
                font-weight: $fw_extrabold;
                font-style: normal;
                margin: 0 .2rem;
            }
        }

        .pq-patch em {
            display: block;
            border-radius: 4px 4px 0 0;
            background: $gray-lighter;
            padding: .2rem 1rem;
            @include font-size($font-size-secondary);
            font-weight: 600;
        }

        .container .container:not([class^="col"]) {
            padding: 0;
            margin: 0;
        }

        ul, ol {
            text-align: left;
        }

        ol {
            ol {
                list-style: lower-alpha;
                > li:before {
                    content: none;
                }
            }
        }

//------------------------------------------------------------------------------
// Alerts
//------------------------------------------------------------------------------
// alert-info
// alert-warning
// alert-danger
// alert-go_to
// alert-exercise
// alert-success // removed : never used in doc
        .alert {
            position: relative;
            display: block;
            border-radius: 0;
            border-width: 0 0 0 3px;
            @include font-size($font-size-secondary);

            code {
                background-color: $white !important;
            }

            > p , > ul {
                margin-bottom: .5rem;
            }
            > *:last-child {
                margin-bottom: 0;
            }

            > h3, > .alert-title {
                line-height: 1em;
                margin: 0 0 10px 0;
                @include font-size($font-size-base);
                font-weight: $fw_bold;

                &:before {
                    @include o-inline-icon($i-info, 0 .2rem 0 0, baseline, $font-size-base, inherit);
                    @include media-breakpoint-down(md) {
                        display:none;
                    }
                }
            }

            &.alert-info, &[class^="admonition"] {
                border-color: tint-color($brand-info, 30%);
                background-color: tint-color($brand-info, 85%);
                color: shade-color($brand-info, 35%);

                > .alert-title, > h3 {
                    color: $brand-info;
                    &:before {
                        content: '#{$i-info}';
                    }
                }
            }

            &.alert-note {
                border-color: shade-color($info, 30%);
                background-color: $gray-lightest;
                color: shade-color($info, 55%);

                > .alert-title, > h3 {
                    color: shade-color($info, 45%);
                    &:before {
                        content: '#{$i-note}';
                    }
                }
            }

            &.alert-tip, &.tip {
                border-color: shade-color($color-alpha, 10%);
                background-color: $gray-lightest;
                color: shade-color($color-alpha, 55%);

                > .alert-title, > h3 {
                    color: shade-color($color-alpha, 40%);
                    &:before {
                        content: '#{$i-lightbulb}';
                        @include font-size(1.2rem);
                    }
                }
            }

            &.alert-warning, &.warning {
                border-color: $brand-warning;

                > .alert-title, > h3 {
                    color: shade-color($brand-warning, 10%);
                    &:before {
                        content: '#{$i-warning}';
                    }
                }
            }

            &.alert-danger {
                border-color: $danger;

                > .alert-title, > h3 {
                    color: darken($brand-danger,20%);
                    &:before {
                        content: '#{$i-danger}';
                    }
                }
            }

            &.alert-exercise {
                border-color: tint-color($doc_exercise, 30%);
                background-color: tint-color($doc_exercise, 90%);
                color: shade-color($doc_exercise, 35%);

                > .alert-title, > h3 {
                    color: shade-color($doc_exercise, 35%);
                }

                > .alert-title:before, > h3:before {
                    content: '#{$i-exercise}';
                }
            }

            &.alert-go_to {
                border-color: $o-violet;
                background-color: $gray-lightest;
                @include media-breakpoint-up(lg){
                    display: inline-block;
                    width: calc(50% - 1rem);
                }

                a {
                    color: $o-violet-dark;
                }

                > .alert-title, > h3 {
                    color: $o-violet-dark;
                }

                > .alert-title:before, > h3:before {
                    content: '#{$i-arrow-right}';
                }
            }
        }
    }
}
//------------------------------------------------------------------------------
// Footer
//------------------------------------------------------------------------------
footer {
    .o_get_help {
        padding-top: $padding-l;
        padding-bottom: $padding-l;
        background: $gray-lighter;
        @include media-breakpoint-up(lg) {
            padding-left: calc(#{$o-side-nav-width} + #{$padding-l})
        }

        h5 {
            color: $secondary;
            font-size: 20px;
            font-weight: $fw_bold;
            margin-bottom: 1.5rem;
        }

    }
}