/*
 *	common definitions
 */

:root {
	/* colors from https://developer.apple.com/design/human-interface-guidelines/foundations/color/ */
	--tintcolor: #ff9500;

	--orangecolor: #ff9500;
	--lighterorangecolor: #ffca81;

	--graycolor: gray;

	--greencolor: #34c759;
	--lightergreen: #8bc79c;
	--evenlightergreen: #c2ffd2;

	--redcolor: #ff3b30;
	--lighterredcolor: #ff908a;

	--bluecolor: #2898ff;
    --lighterbluecolor: #b2daff;

	--purplecolor: #8e44ad;

	--yellowcolor: #ffcc00;
	--transparentyellowcolor: #ffcc0080;

	--disabledgraycolor: #808080;
	--helpgraycolor: #c0c0c0;
	--devicegraycolor: #ababab;

	--brightbackgroundcolor: #34485d;
	--backgroundcolor: #253343;
	--darkbackgroundcolor: #1f2a37;

	--levelplaceholder-color: var(--redcolor);
	--level1-color: var(--greencolor);
	--level2-color: var(--bluecolor);
	--level3-color: var(--tintcolor);
	--level4-color: var(--yellowcolor);
	--formula-height: 32px;
	--formula-narrowing: -6px;
	--dialogbackground-color: var(--bluecolor);

	--standard-font-size: 16pt;
	--headline-font-size: 24pt;

	--button-height: calc(1.8 * var(--standard-font-size));
	--button-radius: 6px;

	/* Plotly constants */
	--standarddiagramheight: 450;
	--highdiagramheight: 640;
	--veryhighdiagramheight: 900;
	--thresholdwidth: 4;
	--linewidth: 3;
	--markerwidth: 12;
}

html {
  -webkit-text-size-adjust: none; /* or 100% */
  text-size-adjust: none;
}

body {
	margin: 0;
	padding: 0; }

body, input, select, dialog, textarea {
	font-family: Arial, Helvetica, Sans-Serif;
	font-size: var(--standard-font-size);
	background-color: var(--backgroundcolor);
	color: #ffffff; }

input:invalid {
	border: 2px dashed red; }

input, textarea {
	border: 1px solid lightgray; }

input[type="date"] {
	background-color: transparent;
	color: white;
	vertical-align: baseline;
	align-items: baseline;
	text-align: center;
	text-decoration: none;
	padding-top: 4pt;
	font-size: var(--standard-font-size); }

button {
	border: none;
	color: white;
	background-color: var(--graycolor);
	padding: 5px 8px;
	vertical-align: baseline;
	text-align: center;
	text-decoration: none;
	display: inline-block;
	border-radius: var(--button-radius);
	height: var(--button-height);
	font-size: var(--standard-font-size); }

button:active {
	background-color: var(--tintcolor);
}

.buttonrowleft {
	display: flex;
	flex-wrap: wrap;
	gap: 0.33em;
	align-items: baseline;
}

.buttonrowright {
	display: flex;
	flex-wrap: nowrap;
	margin-left: auto;
	margin-right: 0;
	gap: 0.33em;
	align-items: baseline;
}

.minibutton {
	background: var(--tintcolor);
	font-weight: bold;
	padding-left: 4px;
	padding-right: 4px;
	padding-top: 0px;
	padding-bottom: 0px;
	border-radius: 6px;
	display: inline-block;
	text-align: center;
	width: 20px;
}

.offline {
	background: var(--redcolor);
	font-weight: bold;
	text-align: center;
	margin-top: 20px;
	margin-bottom: 20px;
}

ol {
	margin-left: 20pt; }

sup {
	line-height: 0; }

h2 {
	font-size: var(--headline-font-size);
	font-weight: bold;

	padding-bottom: 10px; }

.error {
	color: var(--redcolor); }

.disabled {
	color: var(--disabledgraycolor); }

.help {
	color: var(--helpgraycolor);
	font-style: italic; }

td.help {
	color: var(--helpgraycolor);
	font-style: italic; }

.timerange {
	color: var(--helpgraycolor);
	font-size: var(--standard-font-size);
	font-style: italic; }

/*
 *	switch layout
 */

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--tintcolor);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--tintcolor);
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/*
 *	select layouts
 */

select {
 	background: transparent;
 	color: var(--tintcolor);
 	border: none;
 	appearance: none;
 	border-radius: 0px;
 	padding-left: 0px;
}

select:invalid {
	border: 2px dashed red;
}

/*
 *	classes to format tabled uniformly
 */

th {
	font-size: var(--standard-font-size);
	font-weight: bold;
	padding-left: 0px;
	padding-right: 20px;
	padding-top: 0px;
	padding-bottom: 10px;
	text-align: left;
}

td {
	font-size: var(--standard-font-size);
	padding-left: 0px;
	padding-right: 20px;
	padding-top: 0px;
	padding-bottom: 10px;
	text-align: left;
}

table.stats {
	width: 100%;
}

table.stats td:first-child {
	width: 100%;
}

table.stats td:last-child {
	padding-right: 0px;
}

table.settings {
}

table.settings td:first-child {
	width: 300pt;
}

table.details {
}

table.details td:last-child {
	width: 100%;
}

table td, table td * {
    vertical-align: baseline;
}

td sup {
	vertical-align: 0.6em;
	font-size: 0.6em;
}

/*
 *	format links
 */

a:link {
  color: var(--tintcolor);
  text-decoration: none;
}

/* visited link */
a:visited {
  color: var(--tintcolor);
  text-decoration: none;
}

/* mouse over link */
a:hover {
  color: var(--tintcolor);
  text-decoration: none;
}

/* selected link */
a:active {
  color: var(--tintcolor);
  text-decoration: none;
}

/*
 *	waiting icon
 */
.waiting-icon {
	position: absolute;
	right: 0;
	top: 0;
	width: 32px;
	height: 32px;
}

/*
 * 	dialogs
 */

dialog {
  background-color: var(--brightbackgroundcolor);
  border: none;
  border-radius: 20px;
}

.dialogtitle {
	font-size: var(--standard-font-size);
	font-weight: bold;
	color: white;
}

/*
 *	display formulas
 */

.formula {
	display: inline-block;
	height: var(--formula-height);
	vertical-align: middle;
	float:left;
	clear:none;
	margin-top: 2px; /* for multiline display */
	margin-bottom: 2px; /* for multiline display */
}

.levelplaceholder {
	fill: var(--levelplaceholder-color);
}

.level1 {
	fill: var(--level1-color);
}

.textlevel1 {
	background: var(--level1-color);
	color: white;
	line-height: var(--formula-height);
}

.level2 {
	fill: var(--level2-color);
}

.textlevel2 {
	background:var(--level2-color);
	color:white;
	line-height: var(--formula-height);
}

.level3 {
	fill: var(--level3-color);
}

.textlevel3 {
	background: var(--level3-color);
	color:white;
	line-height: var(--formula-height);
}

.level4 {
	fill: var(--level4-color);
}

.textlevel4 {
	background: var(--level4-color);
	color:white;
	line-height: var(--formula-height);
}

.narrowleft {
	margin-left: var(--formula-narrowing);
}

.narrowright {
	margin-right: var(--formula-narrowing);
}

.planSVG {
	width: 100%;
	height: auto;
	background-color: var(--darkbackgroundcolor);
}

/*
 *	Input fields in conditions
 */

.condition {
  background-color: transparent;
  border: 0;
  margin-top: 2px;
}

/*
 *	Popup support - used for help
 */

/* Popup container - can be anything you want */
.popup {
	position: relative;
	display: inline-block;
	cursor: pointer;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

/* The actual popup */
.popup .popuptext {
	visibility: hidden;
  	min-width: 240px;
	background-color: var(--brightbackgroundcolor);
	color: #ffffff;
	text-align: center;
	border-radius: 6px;
	padding: 8px 0;
	position: absolute;
	z-index: 1;
	bottom: 125%;
	left: 50%;
	margin-left: -80px;
}

/* Popup arrow */
.popup .popuptext::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	margin-left: -5px;
	border-width: 5px;
	border-style: solid;
	border-color: #555 transparent transparent transparent;
}

/* Toggle this class - hide and show the popup */

.popup .show {
	visibility: visible;
  	-webkit-animation: fadeIn 1s;
  	animation: fadeIn 1s;
}

/* Add animation (fade in the popup) */
@-webkit-keyframes fadeIn {
	from {opacity: 0;}
	to {opacity: 1;}
}

@keyframes fadeIn {
	from {opacity: 0;}
	to {opacity:1 ;}
}

/* pull to refresh support */

body {
	overscroll-behavior-y: auto;
}

.pull-to-refresh {
	position: fixed;
	top: -50px;
	width: 100%;
	height: 60px;
	display: flex;
	justify-content: center;
	align-items: center;
	transition: top 0.7s ease-in-out;
}

.pull-to-refresh.visible {
	top: 0;
}

/* slider support */

.range-slider {
	-webkit-appearance: none;
	width: 100%;
	height: 15px;
	border-radius: 5px;
	border-color: var(--graycolor);
	background: var(--graycolor);
	outline: none;
	-webkit-transition: .2s;
	transition: opacity .2s;
}

.range-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 25px;
	height: 25px;
	border-radius: 50%;
	background: var(--tintcolor);
	cursor: pointer;
}

.range-slider::-moz-range-thumb {
	width: 25px;
	height: 25px;
	border-radius: 50%;
	background: var(--tintcolor);
	cursor: pointer;
}

/* chat support */

.floating-btn {
	position:fixed;
	bottom: 20px;
	right: 20px;
	z-index: 1;
}

.chat {
	position:fixed;
	bottom: 80px;
	right: 20px;
	z-index: 1;

	width: 50vw;
	height: 60vh;
	background-color: var(--brightbackgroundcolor);
	border: none;
	border-radius: 20px;
	color: white;
	font-size: var(--standard-font-size);
	margin: 0px;
	padding: 20px;

	display: flex;
	flex-flow: column nowrap;
}

.chat p {
	margin: 5px;
}

.chat-header {
	padding: 0px;
	margin: 0px;
	width: 100%;
	height: auto;
	padding-bottom: 20px;

	display: flex;
	flex-flow: column nowrap;
}

.chat-conversation {
	width: 100%;
	flex: 1;
	overflow-y: scroll;
	margin: 0px;
	padding: 0px;

	display: flex;
	flex-flow: column nowrap;
}

.chat-bottom {
	width: 100%;
	height: auto;
	padding-top: 20px;

	display: flex;
	flex-flow: row nowrap;
}

.chat-img {
	width: 48px;
	height: 48px;
}

.msg-avatar {
	margin-top: 0px;
}

.msg-bubble-left {
	padding: 5px;
	margin-top: 10px;
	border-radius: 10px;
	color: white;
	width: 70%;
	font-size: var(--standard-font-size);
	background-color: var(--lightergreen);
}

.msg-bubble-right {
	padding: 5px;
	margin-top: 10px;
	border-radius: 10px;
	color: white;
	width: 70%;
	font-size: var(--standard-font-size);
	background-color: var(--lighterorangecolor);
}

.msg-time {
	background-color: transparent;
	color: var(--helpgraycolor);
}

.msg-left {
	align-self: flex-start;
	float: left;
}

.msg-right {
	align-self: flex-end;
	float: right;
}

.chat-horizontal-group {
	width: 100%;
	align-items: center;
	display: flex;
	flex-flow: row nowrap;
}

/* tool tip support */

.tooltip {
	background-color: var(--brightbackgroundcolor);
	border: none;
	border-radius: 0px; /* should by 10px but Plotly can't round at all; for consistency reasons... */
	color: white;
	font-size: 14pt;
	margin: 0px;
	padding: 5px; /* Plotly uses 0px for hoverLegends, keep this value small although 10px would be better */

	max-width: min(30vw, 320px);
	width: auto;
	white-space: normal;
	word-break: break-word;

	display: none;
	opacity: 0;
	position: fixed;
	z-index: 2000;
}


/*	remote setup remains unavailable until the client runtime check succeeds. */
#remote-setup-link:disabled { opacity: 0.45; cursor: not-allowed; }
