:root {
    /* Enable transition of height 0 to auto. See
       https://stackoverflow.com/a/3512194 */
    interpolate-size: allow-keywords;
}


/* Override water.css */
body {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    /* Sticky top and middle elements to close the space between them on
       scrolling. */
    .top-sticky {
	position: sticky;
	z-index: 2;
	top: 0;
	/* --background-body from water.css */
	background-color: var(--background-body);
	flex-grow: 0;
	flex-shrink: 1;
	flex-basis: auto;
    }
    .mid-sticky {
	position: sticky;
	z-index: 1;
	top: 180px;
	/* --background-body from water.css */
	background-color: var(--background-body);
	flex-grow: 1;
	flex-shrink: 1;
	flex-basis: auto;
    }
}
table {
    input {
	border: 1px solid #c2c2c2;
	width: 100%;
	box-sizing: border-box;
    }
    textarea {
	border: 1px solid #c2c2c2;
	width: 100%;
    }
    select {
	border: 1px solid #c2c2c2;
	width: 100%;
    }
    &.flexible {
	table-layout: auto;
	td {
	    max-width: 500px;
	}
    }
}
textarea {
    white-space: pre-line;
}


/*  */
form.table-controls {
    display: flex;
    justify-content: end;
    input {
	width: 98px;
	height: 41px;
    }
}


/* Many to many fields in tables */
td > ul {
    margin: 0;
    padding-left: 20px;
}


/* Many to many form field search */
.option-scrollable {
    overflow: auto;
    resize: vertical;
    height: 160px;
}
.option-filter-selected .option-not-selected, .option-filtered {
    display: none;
}


/* Navigation bar */
.top-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
    background-color: #092642;
    & > div:first-child {
	display: flex;
	align-items: center;
	& img {
	    display: block;
	    width: 54px;
	    margin: 5px;
	    margin-left: 13px;
	}
	& .title {
	    margin-left: 10px;
	    color: #f2f2f2;
	    font-family: Arial;
	    font-weight: bold;
	    font-size: 18pt;
	}
	& .user {
	    margin-left: auto;
	    margin-right: 6px;
	    color: #f2f2f2;
	}
    }
    & > div:last-child {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	align-items: stretch;
	grid-auto-flow: column;
	grid-auto-rows: minmax(40px, auto);
	& a {
	    display: flex;
	    align-items: center;
	    justify-content: center;
	    padding-left: 15px;
	    padding-right: 15px;
	    padding-top: 10px;
	    padding-bottom: 10px;
	    color: #f2f2f2;
	    text-decoration: none;
	    font-size: 17px;
	    transition:
		background-color 0.1s,
		color 0.1s;
	}
	& a:hover {
	    background-color: #ddd;
	    color: black;
	}
	& a.active {
	    background-color: #0080A8;
	    color: white;
	}
	& form {
	    margin-left: auto;
	    & input {
		display: flex;
		align-items: center;
		justify-content: center;
		border: none;
		border-radius: 0;
		margin: 0;
		background-color: transparent;
		color: #f2f2f2;
		text-decoration: none;
		font-size: 17px;
		transition:
		    background-color 0.2s,
		    color 0.2s;
	    }
	    & input:hover {
		background-color: #ddd;
		color: black;
	    }
	}
    }
}


/* Login and Sign Up forms. */
.registration {
    display: flex;
    flex-direction: column;
    align-items: center;
    & form {
	display: flex;
	flex-direction: column;
	align-items: center;
	& a {
	    align-self: end;
	}
	& label {
	    margin-top: 10px;
	}
	& input {
	    width: 320px;
	}
	& input[type="submit"] {
	    min-width: 160px;
	    margin-top: 20px;
	}
    }
    p {
	align-self: start;
    }
    .hidden {
	display: none;
    }
}


/* Treeview list */
.tree-grid {
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: 3fr 1fr 2fr;
    align-items: center;
    gap: 6px;
}
.tree {
    margin-bottom: 20px;
}
.tree-node {
    &.tree-hidden {
	display: none;
    }
    &.tree-filtered {
	display: none;
    }
    .related-element {
	/* For systems shown in PBS. */
	color: black;
	font-style: italic;
    }
    .filtered-element {
	/* For ancestors in the list that do not meet filter criteria. */
	color: black;
    }
    .tree-branch {
	margin-left: calc(var(--depth) * 20px);
	cursor: pointer;
    }
    .tree-branch::before {
	display: inline-block;
	color: black;
	content: "\0025B6";
	font-family: sans-serif;
	rotate: 90deg;
	transition: rotate 0.2s;
    }
    .tree-branch:hover::before {
	color: #0080A8;
    }
    &.tree-closed .tree-branch::before {
	rotate: 0deg;
	transition: rotate 0.2s;
    }
    .tree-leaf {
	margin-left: calc(var(--depth) * 20px + 4px);
    }
    .tree-leaf::before {
	display: inline-block;
	/* margin-right: 6px; */
	color: black;
	content: "\0025CF";
	font-family: sans-serif;
    }
}


/* Collapse and Expand Buttons */
.tree-controls {
    display: flex;
    flex-direction: row;
    justify-content: end;
    align-items: stretch;
    margin-top: 20px;
    margin-bottom: 20px;
    label {
	flex-grow: 1;
    }
}
.list-search-controls {
    display: flex;
    justify-content: end;
    align-items: end;
    .list-search-fields {
	flex-grow: 1;
	display: flex;
	flex-wrap: wrap;
	justify-content: end;
	align-items: start;
	div {
	    flex-grow: 1;
	    display: flex;
	    flex-direction: column;
	    input {
		flex-grow: 1;
	    }
	}
    }
}
.list-filter-controls {
    display: flex;
    justify-content: end;
    align-items: center;
    margin-top: 20px;
    input {
	flex-grow: 1;
    }
}


/* Buttons to add/remove items from the list. */
.list-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    margin-top: 20px;
}


.controls {
    display: flex;
    flex-direction: row;
    margin-top: 20px;
    gap: 5px;
    .distant {
	margin-left: auto;
    }
}

.attention {
    color: #fff;
    background-color: #ba2121;
    &:hover {
	background-color: #a41515;
    }
}

.commit {
    color: #fff;
    background-color: #2121ba;
    &:hover {
	background-color: #1515a4;
    }
}


/* Loader animation */

.loader {
    color: #092642;
}

.loader,
.loader div {
    box-sizing: border-box;
}
.loader {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
}
.loader div {
    position: absolute;
    top: 33.33333px;
    width: 13.33333px;
    height: 13.33333px;
    border-radius: 50%;
    background: currentcolor;
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}
.loader div:nth-child(1) {
    left: 8px;
    animation: loader1 0.6s infinite;
}
.loader div:nth-child(2) {
    left: 8px;
    animation: loader2 0.6s infinite;
}
.loader div:nth-child(3) {
    left: 32px;
    animation: loader2 0.6s infinite;
}
.loader div:nth-child(4) {
    left: 56px;
    animation: loader3 0.6s infinite;
}
@keyframes loader1 {
    0% {
	transform: scale(0);
    }
    100% {
	transform: scale(1);
    }
}
@keyframes loader3 {
    0% {
	transform: scale(1);
    }
    100% {
	transform: scale(0);
    }
}
@keyframes loader2 {
    0% {
	transform: translate(0, 0);
    }
    100% {
	transform: translate(24px, 0);
    }
}


/* Form errors */

.errorlist {
    color: #c62828;
}
