html {

    &[data-theme-color-auto="on"] {
        .compact_nav_icon[data-helper="toggleColorMode"] {
            display: none !important;
        }
    }

    &:not([data-controls-subtitle="on"]) {
        .compact_nav_icon::after {
            display: none !important;
        }
    }

    &[data-kiosk-mode="on"] {

        .mdw-GridContainer {
            grid-template-columns: 0 auto;
            grid-template-rows: 0 auto;
        }

        .mdw-ConsolePageHead {
            display: none;
        }

        .mdw-ConsoleNavigation {
            display: none !important;
        }

        .mdw-Main {
            height: 100dvh;
            width: 100dvw;
            border-top: none;
            /*
                        &:has(.saveRowParent) {
                            height: calc(100vh - 4rem);
                        }
              */
        }

        .saveRowParent {
            left: 0;
            width: 100vw;
        }
    }

    &[data-auto-table-layout="off"] {
        .cactiTable {
            overflow-x: unset !important;
        }
    }
}

.mdw-GridContainer {
    display: grid;
    grid-template-areas: "sidebar  header    header   header    header"
                         "sidebar  dockLeft  dockTop  dockRight actionbar"
                         "sidebar  dockLeft  main     dockRight actionbar";
    grid-template-columns: 4rem minmax(0, min-content) 1fr minmax(0, min-content) minmax(0, min-content);
    grid-template-rows: 3.5rem minmax(0rem, auto) clamp( calc( 100dvh - 8rem), calc( 100dvh - 3.5rem), 100dvh);
}

.mdw-GridContainer-Overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: rgba( 0, 0, 0, 0.4);
}

.mdw-ConsolePageHead {
    display: flex;
    align-items: center;
    flex-direction: row;
    flex-wrap: nowrap;
    background-image: linear-gradient(90deg, var(--background-navigation-top-darkblue) 35%, var(--background-navigation-top-lightblue));
    grid-area: header;
    padding: 0 0 0 18px;

    * {
        float: left;
        padding-bottom: 0;
        color: snow !important;
    }

    > div {
        height: 100%;
        display: flex;
        align-items: center;
        background: transparent;
        font-size: var(--fs-big);
        font-weight: var(--fw-medium);

        .compact_nav_icon {
            font-size: var(--fs-regular);
            width: 2.5rem;
            height: 2.8rem;
            margin: 2px 4px;
            border: 2px solid transparent;
            border-radius: 4px;

            &:last-of-type {
                margin-left: 12px;
            }

            &[data-tooltip]:not([data-tooltip=""]) {
                &::before {
                    font-family: unset;
                    width: fit-content;
                    position: absolute;
                    left: unset !important;
                    top: 3.8rem;
                    transition: 0s;
                    right: 2.5rem;
                }
            }
        }
    }
}

.navBreadCrumb {
    display: flex;
    overflow: hidden;
    flex-wrap: nowrap;

    & div {
        display: flex;
        padding: 0;
        cursor: pointer;
        text-align: center;
        align-items: center;

        & a, span {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;

        }

        & a:hover,
          span:hover {
            text-decoration: underline;
            color: var(--text-color-highlight-a);
        }

        &:not(:last-child)::after {
            margin: 0 0.5rem;
            content: "\f105";
            font-family: "Font Awesome 5 Free";
            font-weight: 600;
            display: block;
        }

    }

    & a {

        &:visited,
        & mark {
            color: var(--text-color-normal);
        }

        &:hover,
        & mark:hover,
        &:focus {
            text-decoration: underline;
            color: var(--text-color-highlight-a);
        }
    }
}

.navSearch {
    flex: 1;
}

.navFilter {
    &::after {
        content: "";
        height: 70%;
        border-left: 1px solid var(--border-color);
        margin: 0.2rem;
    }

    .compact_nav_icon.selected {
        color: var(--text-color-normal);
        background-color: rgba(0,0,0,0.2);
        &::after {
            height: 25px;
            width: 25px;
            background-color: #bbb;
            border-radius: 50%;
            display: inline-block;
        }
        &:hover {
            color: var(--text-color-white);
            background-color: rgba(0,0,0,0.3);
        }
    }
}

.navControl {
    font-size: var(--fs-regular);
}

/* Console Navigation Area */
.mdw-ConsoleNavigation {
    z-index: 1000;
    display: flex;
    float: left;
    overflow-y: visible !important;
    flex-direction: column;
    justify-content: flex-start;
    width: 100%;
    background: var(--background-navigation);
    grid-area: sidebar;
    padding-bottom: 2px;
    box-shadow: -2px 10px 5px 2px var(--box-shadow-color);

    .compact_nav_icon_menu {
        &:last-child {
            display: flex;
            align-items: stretch;
            flex: 1;
            flex-direction: column;
            justify-content: flex-end;
        }
        &:has(.navBackdrop){
            height: 3.5rem;
            margin-bottom: 1.5rem;
            background: var(--background-navigation-top-blue);
        }
    }

    .compact_nav_icon {
        font-size: var(--fs-semilarge);
        height: 3.5rem;
        margin: 2px 3px;
        border-radius: 4px;
        border: 2px solid transparent;

        &:has(.navBackdrop){
            height: 4.8rem;
        }


        & .navBackdrop {
            width: 100%;
            height: 5rem;
            background: transparent url("./../../images/cacti_logo.svg") no-repeat scroll 50% 50% / 2rem auto;
            position: relative;
            z-index: auto;
            html[data-controls-subtitle="on"] & {
                flex: 1;
                background: transparent url("./../../images/cacti_logo.svg") no-repeat scroll 50% 14% / min(1.5rem) auto;
            }
        }

        &[data-subtitle]:not([data-subtitle=""])::after {
            display: block;
            content: attr(data-subtitle);
            font-size: var(--fs-small);
            margin-top: 2px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 100%;
        }

        & > span {
            display: none;
        }
    }
}

.mdw-active::before {
    background-color: var(--background-active);
    border-radius: 4px;
    content: " ";
    display: block;
    height: 100%;
    position: absolute;
    width: 0.25rem;
    left: -1px;
}

.mdw-ActionBar {
    display: none;
    grid-area: actionbar;
    z-index: 1000;
    float: left;
    overflow-y: visible !important;
    flex-direction: column;
    justify-content: flex-start;
    width: auto;
    background: var(--background-navigation);
    align-items: center;
    box-shadow: 3px 6px 5px 2px var(--box-shadow-color);

    &:has( div[class^="mdw-Action"]:not(:empty) ) {     /* only show ActionBar with content */
        display: flex;
    }

    .compact_nav_icon {
        font-size: var(--fs-big);
        width: 2.5rem;
        height: 2.5rem;
        margin: 4px 3px;
        border-radius: 4px;
        border: 2px solid transparent;

        &[data-subtitle]:not([data-subtitle=""])::after {
            display: block;
            content: attr(data-subtitle);
            font-size: var(--fs-small);
            margin-top: 2px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 100%;
        }

        & > span {
            display: none;
        }
    }

    .mdw-ActionBarTop {
        display: none;
        &:has( div:not([class*="hide"])) {    /* only visible if at least one child is not marked as hidden */
            display: block;
        }
        &:not(:empty):has( + .mdw-ActionBarMiddle:not(:empty))::after {         /* separator */
                display: block;
                content: " ";
                width: 70%;
                border-bottom: 1px solid var(--border-color);
                margin: calc(0.4rem - 1px) auto 0 auto;
        }
    }

    .mdw-ActionBarMiddle {
        &:not(:empty) {
            margin: 0.4rem auto;
            width: 3rem;
        }
    }
}

* {
    /* CSS driven tooltip */
    &[data-tooltip]:not([data-tooltip=""]) {
        &::before {
            font-family: var(--font-sans), serif;
            font-weight: var(--fw-normal);
            z-index: 1500;
            font-size: var(--fs-regular);
            position: absolute;
            left: 10px;
            width: fit-content;
            height: fit-content;
            padding: 0.5rem 1rem;
            content: attr(data-tooltip);
            transition: 0.05s;
            transform: translate(0, 0) scale(0);
            transform-origin: center;
            text-align: center;
            white-space: nowrap;
            opacity: 0;
            color: var(--text-color-normal);
            border: 1px solid var(--border-color);
            border-radius: 5px;
            background: var(--background-navigation-top);
            box-shadow: var(--box-shadow-color) 0 10px 20px;
        }
    }

    &[data-tooltip]:not([data-tooltip=""]):not(.selected):hover {
        &:before {
            opacity: 1;
            animation: scaleDelay ease 0.1s;
            animation-delay: 0.75s;
            animation-iteration-count: 1;
            animation-fill-mode: forwards;
        }
    }
}


.mdw-ConsoleNavigationBox {
    visibility: hidden;             /* although visibility is boolean only, this is important to avoid that the menu
                                       items are focusable while the navigation box is outside the viewport. */
    position: absolute;
    z-index: 900;
    top: 3.5rem;
    left: 4rem;
    display: flex;
    flex-direction: column;
    width: 55rem;
    min-width: 19rem;
    max-width: calc(100dvw - 5rem);
    height: calc(100dvh - 3.5rem);
    transition: visibility 0.5s linear, transform 0.5s ease-in-out;
    transform: translateX(-125%);
    border-top: 1px solid var(--border-color-light);
    border-right: 1px solid var(--background-navigation);
    border-bottom: 1px solid var(--background-navigation);
    border-radius: 2px;
    background-color: var(--background-menu);

    &[data-align="right"] {
        right: 3rem;
        left: unset;
        transform: translateX(+125%);
        border: unset;
        border-top: 1px solid var(--border-color-light);
        border-bottom: 1px solid var(--background-navigation);
        border-left: 1px solid var(--border-color);
        box-shadow: 0 10px 5px 0 var(--box-shadow-color);

        .navBox-header {
            padding: 0 10px;
        }

        .navBox-header-title {
            text-align: left;
        }


        .navBox-content {
            overflow-y: auto;
            padding: 0;
            flex: 1;
            scrollbar-gutter: stable;
        }


    }

    &.visible {
        visibility: visible;
        transform: translate(0);

        & input {
            display: block;
        }
    }

    &[data-width="1"]    { width: 19.0rem; }
    &[data-width="1.5"]  { width: 28.5rem; }
    &[data-width="2"]    { width: 36.0rem; }
    &[data-width="3"]    { width: 53.0rem; }
    &[data-width="4"]    { width: 70.0rem; }
    &[data-width="5"]    { width: 87.0rem; }
    &[data-width="auto"] { width: auto;   }

    &[data-height="half"] {
        top: unset;
        bottom: 0;
        height: auto;
        max-height: 100dvh;
    }

    &[data-height="half"] .navBox-header {
        text-align: right;
    }

    &:has(.navBox-search:not(.hide)) {
       & > .navBox-content {
            height: calc( 100% - 7rem );
        }
    }

    & input {
        /*display: none;*/
    }

    & ul.nav,
    & ul#nav {
        display: flex;
        gap: 1rem;
        align-content: flex-start;
        flex-flow: row wrap;
        writing-mode: vertical-lr;
        flex-direction: row;
        justify-content: flex-start;
        height: 100%;

        &::after{
            content: "";
            flex: auto;
            flex-basis: 16rem;
        }

        .mdw-ConsoleNavigationBox:not([data-width="auto"]) & {
            writing-mode: unset;
        }
    }

    & .filterColumn:has(div.filterFieldName) {
        display: none;
    }

    & .filterRow {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;

        .filterColumnButton {
            order: 0;
        }
        .filterColumn {
            order: 1;
            width: 100%;
        }
        .filterColumn:not(:has(div.filterFieldName)) {
            margin: 0.25rem 0;
        }
    }

    & .filterColumn {
        line-height: 1.5rem;
    }

    & .filterColumnButton {
        button {
            font-family: "Font Awesome 6 Free", serif;
            font-weight: 600;
        }
        button span.button-text {
            display:none;
        }
        button[id=go]::after    { content: "\f0b0"; }
        button[id=clear]::after { content: "\e17b"; }
        button[id=save]::after  { content: "\f005"; font-weight: 400; }
    }
}

#nav li a,
.nav li a {
    padding: unset;
}


.navBox-header {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    height: 3rem;
    text-align: center;
    background: var(--background-navigation);
    padding: 2px 0.5rem 3px 0.75rem;
}

.navBox-header-title {
    flex-grow: 1;
    > span {
        margin-right: 2rem;
    }
}


.navBox-header-button {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 4px;
    min-width: 2.5rem;
    width: 2.5rem;
    height: 2.5rem;
    &[aria-pressed="true"] {
        /*background: var(--background-active-section);*/
        box-shadow: 0 .33em 2em rgba(25,85,138,.67) inset,
                    1px 1px 0 rgba(255,255,255,.25) inset,
                    -1px -1px 0 rgba(255,255,255,.25) inset;
        &:has(~ .navBox-header-search) {
            ~ .navBox-header-search {
                flex-grow: 5;
                visibility: visible;
            }
            ~ .navBox-header-search > input {
                display: block !important;
                width: 100%;
                min-width: 8.5rem;
            }
            ~ .navBox-header-title  { display: none; }
            ~ .navBox-header-filler { flex-grow: 1;  }
        }
    }

    &:hover {
        color: white;
        background-color: hsla(208, 69%, 40%, 0.5);
    }
}

.navBox-header-filler {
    flex-grow: 0;
}

.navBox-header-button.show[data-action="dropdown"] > .navBox-header-dropdown-content {
    display: block !important;
}

/* Dropdown Content (Hidden by Default) */
.navBox-header-dropdown-content {
    font-family: "Segoe UI", "Segoe UI Web Regular", "Segoe UI Symbol", "Helvetica Neue", "BBAlpha Sans", "S60 Sans", Arial, sans-serif;
    position: absolute;
    z-index: 1;
    top: 2rem;
    right: 0;
    display: none;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--background);
    box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);

    &.show {
        display: block;
    }

    & a {
        display: block;
        padding: 0.5rem 1rem;
        text-decoration: none;

        &:hover {

        }
    }
}

.navBox-header-search {
    display: flex;
    visibility: hidden;
    width: 0;
    align-items: stretch;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    background: var(--background-navigation);
    transition: flex 0.3s ease-in-out, visibility 0.25s ease-in-out;
    padding: 0 1rem;
    flex-shrink: 0;

    & input {
        height: 2rem;
        display: block;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: var(--fs-regular);
        color: var(--text-color-normal);
        background-color: var(--background-navigation-top) !important;
        border: 1px solid var(--border-color-highlight);
        padding: 0 0.5rem 0 1rem;
        max-width: 50rem;
    }
}

.navBox-content {
    overflow: auto;
    padding: 1rem 0 0 1rem;
    height: calc( 100% - 3.5rem );
    border-top: 1px solid var(--background-navigation-top);
    background-color: var(--background-menu);

    &:has(.mdw_tree) {
        padding: 1rem 1rem 0 1rem;
    }

    & .mdw_tree {
        height: 100%;
    }
}

.mdw-SideBarContainer {
    .menu_glyph {
        font-size: var(--fs-big);
        font-weight: var(--fw-semibold);
        width: 1.5rem;
        color: var(--background-progress);
    }

    .menu_parent {
        font-size: var(--fs-big);
        display: flex !important;
        flex-direction: row;
        flex-shrink: 1;
        margin-bottom: 0.3rem;
        cursor: default;
        pointer-events: none;

        &:not(.selected) {
            #color: #3d3d3d;
        }
    }

    .menuitem {
        position: relative;
        overflow: hidden;
        width: 16rem;
        writing-mode: initial;

        & span {
            font-weight: var(--fw-medium);
            color: var(--text-color-high-contrast);
        }

        &:hover span {
            display: inline-block !important;
            animation: dropdown-anim .15s ease-in-out .1s forwards;
        }

        & ul {
            display: block !important;
            border-left: none !important;
        }

        &:hover ul {
            display: inline-block !important;
        }

        &.double {
            width: 34rem;

            & div:first-child {
                width: calc(16rem - 4px);
            }

            & div:nth-child(2) {
                &:has(output) {
                    display: flex;
                    align-items: center;
                    width: 17rem;
                    max-width: 17rem;
                    justify-content: space-between;
                }
            }

            & input[type="range"] {
                padding: 0;
                display: block;
                float: left;
                cursor: pointer;
            }

            & output {
                width: 6rem;
                text-align: right;
            }
        }
    }
}

@media screen and (max-height: 450px) {
    .mdw-GridContainer {
        grid-template-areas: "sidebar main";
        grid-template-columns: 4rem calc(100dvw - 4rem);
        grid-template-rows: 100dvh;
    }

    [class^="mdw-ConsoleNavigationBox"] {
        top: 0;
        /*width: calc(100vw - 4rem) !important;*/
        max-width: calc(100dvw - 4rem) !important;
        max-height: 100dvh;
        border-top: none;
        &[data-height="full"] {
            height: 100dvh;
        }
        & ul.nav,
        & ul#nav {
            flex-direction: row;
            height: 100%;
            padding-top: 1rem;
        }
    }
}

@media screen and (max-width: 768px) {

    .mdw-GridContainer {
        grid-template-areas:    "header"
                                 "main"
                                 "footer";
        grid-template-columns: 100dvw;
        grid-template-rows: 4rem calc(100dvh - 8rem) 4rem;
    }

    .mdw-ConsolePageHead {
        grid-area: header;
        background: var(--background-navigation);
        border-bottom: 1px solid var(--text-color-black);
        .navBreadCrumb > div {
            &:not(:first-child):not(:last-child) {
                display: none;
            }
        }
        .navControl {
            display: none;
        }
    }

    .mdw-ConsoleNavigation {
        grid-area: footer;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        border-right: none;
        border-top: 1px solid var(--text-color-black);

        & .compact_nav_icon {
            & .navBackdrop {
                html[data-controls-subtitle="on"] & {
                    height: 15px;
                    background: transparent url("./../../images/cacti_logo.svg") no-repeat scroll 50% 50% / 10px auto;
                }
            }
        }
    }

    .mdw-Main {
        border-bottom: 1px solid var(--border-color-light);
    }

    .compact_nav_icon_menu {
        display: flex;
        align-items: center;
        padding-top: 4px;

        &:first-of-type {
            margin-left: 1rem;
            border-radius: 4px 4px 0 0 !important;
        }

        &:last-child {
            flex-direction: row-reverse !important;
            justify-content: unset !important;
            margin-right: 1rem;
        }

        .compact_nav_icon {
            display: inline-flex;
            justify-content: center;
            align-content: center;
            flex-wrap: wrap;
            width: 3.25rem;
            cursor: pointer;
            font-size: var(--fs-semilarge);
            border-radius: 4px 4px 0 0;

            &[data-helper="logout"] {
                display: none;
            }
        }
    }

    .mdw-active::before {
        width: 100%;
        height: 0.25rem;
        left: unset;
        bottom: 0;
    }


    [class^="mdw-ConsoleNavigationBox"] {
        left: unset;
        top: unset;
        bottom: 4rem !important;
        width: 100dvw !important;
        max-width: 100dvw;
        height: calc(100dvh - 4rem) !important;
        transform: translateY(+125%);
        padding-bottom: 2rem;
        border-top: 1px solid var(--text-color-black);

        & ul.nav, & ul#nav {
            writing-mode: unset;
        }

        & .navBox-header {
            border-top: 1px solid var(--border-color-semilight);
        }

        & .navBox-header-dropdown {
            visibility: hidden;
            width: 1rem;
        }
    }

    .saveRowParent {
        bottom: 4rem;
        left: 0;
        width: 100dvw;
        height: 4rem;
    }

    .cactiGraphContentArea, .cactiConsoleContentArea {
        & #main {
           /* padding: 0 0.5rem 1rem 0.5rem; */
        }
    }

    html {
        &[data-kiosk-mode="on"] {
            .mdw-GridContainer {
                grid-template-areas: "main";
                grid-template-rows: 100dvh;
                grid-template-columns: auto;
            }

            .saveRowParent {
                bottom: 0;
            }
        }

        &[data-auto-table-layout="on"] {
            .cactiTable:has(th) {
                th:nth-of-type(n+3):nth-last-of-type(n+2):not(.nohide),
                td:nth-of-type(n+3):nth-last-of-type(n+2):not(.nohide) {
                    display: none !important;
                }
            }
        }
    }
}
@media screen and (max-width: 768px) {
    &[data-auto-table-layout="on"] {
        .cactiTable:has(th) {
            th:nth-of-type(n+2):nth-last-of-type(n+2):not(.nohide),
            td:nth-of-type(n+2):nth-last-of-type(n+2):not(.nohide) {
                display: none !important;
            }
        }
    }
}
@media screen and (min-width: 769px) and (max-width: 1023px) {
    &[data-auto-table-layout="on"] {
        .cactiTable:has(th) {
            th:nth-of-type(n+3):nth-last-of-type(n+4):not(.nohide),
            td:nth-of-type(n+3):nth-last-of-type(n+4):not(.nohide) {
                display: none !important;
            }
        }
    }
}
@media screen and (min-width: 1024px) and (max-width: 1280px) {
    &[data-auto-table-layout="on"] {
        .cactiTable:has(th) {
            th:nth-of-type(n+4):nth-last-of-type(n+5):not(.nohide),
            td:nth-of-type(n+4):nth-last-of-type(n+5):not(.nohide) {
                display: none !important;
            }
        }
    }
}