:root {
    --trees-background-color: 240, 248, 255;

    --switcher-container-size: 20%;
    --_3d-container-size: 30%;
    --buttons-container-size: 30%;
    --messages-container-size: 20%;

    user-select: none;
}

.icon::before {
  display: inline-block;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
}

@font-face {
    font-family: 'titillium-light';
    src: url('../fonts/TitilliumWeb-Light.ttf');
}

@font-face {
    font-family: 'titillium-regular';
    src: url('../fonts/TitilliumWeb-Regular.ttf');
}

@font-face {
    font-family: 'titillium-bold';
    src: url('../fonts/TitilliumWeb-SemiBold.ttf');
}

body,
html {
    height: 99%;
    font-family: 'titillium-regular', 'Siemens Sans', 'Segoe UI';
    background-color: darkslategray;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    text-align: center;
    font-family: 'titillium-bold';
}

.treesContainer,
.actionsContainer {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 49%;
    justify-content: space-between;
}

.actionsContainer {
    flex: 1;
}

.treesContainer {
    gap: 8px;
}

.tree {
    background-color: rgb(var(--trees-background-color));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.tree p {
    padding: 1rem .5rem;
    margin: 0;
    user-select: none;
}

.tree p:nth-child(2n+1) {
    background-color: lightcyan;
}

.tree p:nth-child(2n+2) {
    background-color: lightblue;
}

.tree p.currentPageButtonPressed {
    background-color: lightseagreen !important;
}

.tree p.currentMeccanicoButtonPressed {
    background-color: #4fadda;
}

.tree p.currentPageButtonPressed.currentMeccanicoButtonPressed {
    /* box-shadow: inset 0 0 2rem #4fadda; */
    /* outline: 5px solid #4fadda;
    outline-offset: -5px; */
    background: linear-gradient(135deg, lightseagreen 0%, lightseagreen 50%, #4fadda 50%, #4fadda 100%);
}

.treesContainer .tree {
    flex: 1;
}

.tree .titlediv {
    width: 100%;
    position: sticky;
    top: 0;
    background: linear-gradient(rgba(var(--trees-background-color), 1), rgba(var(--trees-background-color), 1) 80%, rgba(var(--trees-background-color), 0.5) 90%, rgba(var(--trees-background-color), 0) 100%);
    display: flex;
    justify-content: flex-end;
    height: 3rem;
    align-items: flex-start;
}

.tree .titlediv h3 {
    margin: auto;
}
.tree .titlediv button {
    border: none;
    background-color: rgba(0,0,0,0);
    color: black;
    padding: 12px 16px;
    font-size: 16px;
    cursor: pointer;
}

.tree.collapsed {
    width: 6ch !important;
    flex: none !important;
}

.tree.collapsed>*:not(.titlediv) {
    display: none;
}

.tree.collapsed .collapseButton {
    display: none;
}

.tree:not(.collapsed) .expandButton {
    display: none;
}

.tree.collapsed .titlediv {
    flex-direction: column-reverse;
}

.tree.collapsed h3 {
    writing-mode: vertical-lr;
    text-orientation: upright;
}

.treesContainer:not(:has(.tree:not(.collapsed))) {
    height: 3rem;
}

.treesContainer:not(:has(.tree:not(.collapsed))) .tree.collapsed {
    flex:1 !important;
}

.treesContainer:not(:has(.tree:not(.collapsed))) .tree.collapsed .titlediv {
    flex-direction: row;
}

.treesContainer:not(:has(.tree:not(.collapsed))) .tree.collapsed h3 {
    flex:1 !important;
    writing-mode: horizontal-tb;
}


.mainContainer {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
    gap: 8px;
}

.switcherContainer {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
    width: var(--switcher-container-size);
    height: 100%;
    background-color: darkolivegreen;
}

.switcherContainer button {
    padding: 2rem;
}

.switcherContainer button.current {
    background-color: #efadda;
}

._3dContainer .lil-gui {
    /* position: absolute; */
    top: 8px;
    right: 8px;
    z-index: 10;
    pointer-events: auto;
}

._3dContainer {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    width: var(--_3d-container-size);
    height: 100%;
    background-color: cadetblue;
}

._3dContainer canvas {
    display: block;
    width: 100%;
    height: 100%;
}



.buttonsContainer {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
    width: var(--buttons-container-size);
    height: 100%;
    background-color: bisque;
    overflow-y: auto;
}

.messagesContainer {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
    width: var(--messages-container-size);
    height: 100%;
    background-color: burlywood;
}

.messagesContainer p {
    text-align: center;
    margin: 0;
}

.messagesContainer span img {
    max-height: 2rem;
}

.messagesContainer span {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.messagesContainer span.hidden {
    display: none;
}

img {
    max-height: 75%;
    max-width: 90%;
    user-select: none;
    pointer-events: none;
}

.debugText {
    display: none;
}

#vistaMacchina.hidden,
#vistaLavorazione.hidden {
    display: none;
}

#alberoMeccanico>div.hidden {
    display: none;
}

#alberoImpiantistico .hidden {
    display: none;
}

.tree:has(#sprotty-diagram) {
    position: relative;
}

.tree:has(#sprotty-diagram) .titlediv {
    background: transparent;
    position: absolute;
}

.tree:has(#sprotty-diagram) .titlediv h3,
.treesContainer:has(.tree:not(.collapsed)) .tree:not(.collapsed):has(#sprotty-diagram) .titlediv button {
    border: 5px rgba(var(--trees-background-color), 0.9) solid;
    background-color: rgba(var(--trees-background-color), 0.9);
    padding: 5px;
}


#tabellare div {
    display: flex;
    flex-direction: row;
}

#tabellare div.hidden {
    display: none;
}

#tabellare div:has(:first-child.destro):not(:has(div)) {
    flex-direction: row-reverse;
}

#tabellare div:has(div) {
    flex-direction: column;
    width: 90%;
    height: 95%;
    justify-content: flex-start;
    gap: 16px;
}

#tabellare div .sinistro {
    margin-right: auto;
}

#tabellare div .destro {
    margin-left: auto;
}


#sprotty-diagram {
    height: 100%;
    overflow: hidden;
}

svg.hidden {
    display: none;
}

.interactableContainer {
    display: flex;
    flex-direction: row;
    width: 50%;
    height: 56px;
    gap: 16px;
}

.interactableContainer.destro {
    justify-content: flex-end;
}

div:has(>.interactableContainer) {
    display: flex;
    flex-direction: row !important;
    height: 56px !important;
    width: 100% !important;
}

div:has(>.interactableContainer):has(:first-child.destro) {
    flex-direction: row-reverse !important;
}

@media only screen and (max-width: 600px) and (min-height: 600px) {

    .treesContainer,
    .actionsContainer {
        flex-direction: column-reverse;
        width: 49%;
        height: 100%;
    }

    .actionsContainer {
        width: 50%;
    }

    .mainContainer {
        flex-direction: row;
    }

    .tree {
        width: 100% !important;
    }

    .tree.collapsed {
        width: auto !important;
        height: 6ch;
    }

    .tree.collapsed .titlediv {
        flex-direction: row;
    }

    .tree.collapsed h3 {
        writing-mode: horizontal-tb;
    }
    
    .treesContainer:not(:has(.tree:not(.collapsed))) {
        width: 3rem;
        height: auto;
    }

    .treesContainer:not(:has(.tree:not(.collapsed))) .tree.collapsed {
        flex:1 !important;
    }

    .treesContainer:not(:has(.tree:not(.collapsed))) .tree.collapsed .titlediv {
        flex-direction: column-reverse;
        height: auto;
    }

    .treesContainer:not(:has(.tree:not(.collapsed))) .tree.collapsed h3 {
        flex:1 !important;
        writing-mode: vertical-lr;
    }

    .switcherContainer {
        height: var(--switcher-container-size);
        width: 100%;
    }

    ._3dContainer {
        height: var(--_3d-container-size);
        width: 100%;
    }

    .buttonsContainer {
        height: var(--buttons-container-size);
        width: 100%;
    }

    .messagesContainer {
        height: var(--messages-container-size);
        width: 100%;
    }
}