/* MONITOR */

#monitor {
	width: 100%;
	height: 400px;
	background-color: var(--bg-4);
	z-index: 71;
	position: relative;
	/* Capped at half of .ide-base: in a narrow area (duo mode, simulator opened) the editor stays usable */
	min-width: min(310px, 50%);
	/* Width reference (cqw) of the tooltips of the console */
	container-type: inline-size;
}

#monitor p,
#monitor pre {
	margin-bottom: 0;
}

#monitor:focus-within {
	box-shadow: inset 0 0 0 2px var(--vitta-blue);
}

.monitor-closed {
	min-width: 0px !important; 
}

.monitor-console-only {
	height: 100% !important;
	min-height: 100% !important;
}

/* Monitor tools resize/toggle */

#monitor-tools {
	position: absolute;
	top: -25px;
	right: 0;
	left: 0;
	display: flex;
	margin: 0 auto;
	justify-content: center;
	border: 3px solid var(--bg-4);
	background-color: var(--bg-2);
	border-bottom: 0;
	width: 60px;
	height: 25px !important;
	border-radius: 20px 20px 0 0;
	direction: ltr;
}

.monitor-tools-collapsed-bottom {
	position: absolute !important;
	bottom: 5px !important;
	left: 0;
	right: 0;
}

.monitor-tools-collapsed-right {
	position: absolute !important;
	top: 0;
	bottom: 0;
	right: 2px !important;
}

#monitor-tools:after,
#monitor-tools:before {
	content: '';
	width: 20px;
	height: 10px;
	border: 3px solid var(--bg-4);
	position: absolute;
	bottom: -3px;
	border-top: 0;
	overflow: visible;
}

#monitor-tools:after {
	border-left: 0;
	border-radius: 0 0 45px 0;
	left: -20px;
}

#monitor-tools:before {
	border-right: 0;
	border-radius: 0 0 0 45px;
	right: -20px;
}

/* Text colour of the theme (Bootstrap .btn: dark grey, invisible with the dark theme), icon centered */
#monitor-toggler,
#monitor-resizer {
	color: var(--text-1);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

#monitor-toggler:hover,
#monitor-resizer:hover {
	background-color: var(--vitta-orange);
}

#monitor-resizer {
	cursor: ns-resize;
	touch-action: none; /* dragged with the finger (see resizeMonitorBy) */
	width: 1.5em;
	border-radius: 15px 0 0 0;
	border-right: 2px solid var(--bg-4);
}

#monitor-toggler {
	border-radius: 0 17px 0 0;
	border-left: 1px solid var(--bg-4);
	width: 1.5em;
}

#monitor-content {
	height: 100%;
	width: 100%;
	padding: 10px 10px 0px 10px;
	display: grid;
	grid-column-gap: 0px;
	grid-row-gap: 0px;
}

/* minmax(0, 1fr): a "1fr" column can't be narrower than its content, so the controls bar widened the console over
   the simulator */
.monitor-grid-bottom {
	grid-template-columns: repeat(2, minmax(0, 1fr));
	grid-template-rows: minmax(0, 1fr) auto;
}

.monitor-grid-right {
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto;
}

/* Monitor controller */

/* Container: the labels of the buttons are hidden when the console is narrow (see below) */
#monitor-controls {
	container-type: inline-size;
	position: relative;
	min-height: 45px;
	/* display: flex; */
	margin-bottom: .5rem;
	font-family: var(--main-font);
	grid-area: 2 / 1 / 3 / 3;
	container-type: inline-size;
}

/* Not enough room for the labels (small screen or narrow console): the buttons only show their icon (and keep their tooltip). */
@container (max-width: 700px) {
	#monitor-div-btn .label-button {
		display: none !important;
	}
}

.monitor-controls-right {
	grid-area: 3 / 1 / 4 / 2 !important;
}

/* Narrow console: the buttons (Export, Variables, Files, REPL...) go under the message input instead of overflowing */
#monitor-controls > .d-flex {
	flex-wrap: wrap;
	row-gap: .5rem;
}

#monitor-controls > .d-flex > .w-75 {
	flex: 1 1 200px;
}

#monitor-div-btn {
	flex-wrap: wrap;
	row-gap: .5rem;
	max-width: 100%;
}

/* Narrow console: icons only (their tooltip stays), in a column at the bottom right of the console */
@container (max-width: 650px) {
	#monitor-div-btn {
		position: absolute;
		bottom: calc(100% + 25px);
		inset-inline-end: 15px;
		z-index: 49;
		flex-direction: column;
		row-gap: 0;
	}

	/* Same look as the console/graph/music column (.monitor-view-btn) */
	#monitor-div-btn > * {
		width: 44px;
		min-width: 0;
		height: 38px;
		padding: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 0;
		border-radius: 0 !important;
	}

	/* More specific than "#repl-control:not(.activated)", activated buttons keep their colour */
	#monitor-controls #monitor-div-btn > :not(.activated) {
		background-color: var(--bg-2);
	}

	#monitor-controls #monitor-div-btn > :not(.activated):hover {
		background-color: var(--bg-3);
	}

	#monitor-div-btn > :first-child {
		border-radius: 10px 10px 0 0 !important;
	}

	#monitor-div-btn > :last-child {
		border-radius: 0 0 10px 10px !important;
	}

	#monitor-div-btn > :only-child {
		border-radius: 10px !important;
	}

	#monitor-div-btn .label-button {
		display: none;
	}
}

#repl-variables.activated {
	background-color: var(--vitta-orange-light);
}

/* Monitor view */

.monitor-view-split-bottom {
	grid-area: 1 / 1 / 2 / 3 !important;
}

.monitor-view-split-bottom-debug {
	grid-area: 1 / 1 / 2 / 2 !important;
}

.monitor-view-split-right {
	grid-area: 1 / 1 / 3 / 2 !important;
}

.monitor-view-split-right-debug {
	grid-area: 1 / 1 / 2 / 2 !important;
}

#monitor-view,
#monitor-debugger {
	position: relative;
	width: 100%;
	height: 100%;
	padding-bottom: 10px;
	overflow: hidden;
}

#monitor-view {
	grid-area: 1 / 1 / 2 / 3;
}

/* Variables panel */

#monitor-debugger {
	grid-area: 1 / 2 / 2 / 3;
	padding-left: 10px;
	display: flex;
	flex-direction: column;
	min-height: 0;
	display: none;
}

.monitor-debugger-right {
	grid-area: 2 / 1 / 3 / 2 !important;
	padding-left: 0px !important;
}

.monitor-debugger-wrapper {
	border-radius: 10px;
	background-color: var(--bg-1);
	height: 100%;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

#monitor-variables-panel {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
}

.variables_panel {
	padding: 5px;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

@media (max-width: 610px) {
	.variables_panel {
		padding: 5px;
		box-sizing: border-box;
		flex-direction: column;
		overflow: scroll;
	}
}

#variables_table td,
#variables_table th {
	display: table-cell;
	vertical-align: inherit;
	border: 1px solid var(--text-3);
	text-align: left;
	padding: 4px;
}

#variables_table td {
	padding-top: 2px;
	padding-bottom: 2px;
}

table#variables_table {
	font-size: 14px;
	font-family: var(--main-font);
	border-collapse: collapse;
	border-spacing: 0;
	width: 100%;
}

#variables_table tr:nth-child(even) {
	background-color: var(--bg-2);
}

/* Console */

#monitor-view>#console,
#graph-tab,
#music-tab,
#console-wrapper {
	min-height: 120px;
	flex: 1;
	height: 100%;
	width: 100%;
	background-color: var(--bg-1);
	padding: 10px;
	padding-inline-end: 70px;
	border-radius: 10px;
	font-size: 14px;
	overflow: auto;
	overflow-wrap: break-word;
	outline: none;
}

#console {
	font-family: var(--monospace-font), monospace;
}

#graph-tab,
#music-tab {
	display: none;
}

#traceur {
	display: flex;
	height: 100%;
	width: 100%;
}

#traceur>h2 {
	margin: auto;
}

.ide-console {
	height: 100%;
	max-width: 100% !important;
}

.ide-console a,
.ide-console a:hover,
.ide-console a:focus,
.ide-console a:active {
	text-decoration: underline;
}

#monitor-view-group-btn {
	position: absolute;
	bottom: 15px;
	inset-inline-end: 10px;
	z-index: 49;
	display: flex;
	flex-direction: column;
}

/* Fixed size (not depending on the font): same buttons as the column of #monitor-div-btn in a narrow console */
#monitor-view-group-btn>.monitor-view-btn {
	width: 44px;
	height: 38px;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

#monitor-view-group-btn>.monitor-view-btn:first-child {
	border-radius: 10px 10px 0 0;
}

#monitor-view-group-btn>.monitor-view-btn:not(:first-child):not(:last-child) {
	border-radius: 0;
}

#monitor-view-group-btn>.monitor-view-btn:last-child {
	border-radius: 0 0 10px 10px;
}

.monitor-view-btn {
	float: left;
	display: block;

	--bs-btn-color: var(--text-0);
	--bs-btn-bg: var(--bg-2);
	--bs-btn-border-color: var(--bg-2);

	--bs-btn-hover-color: var(--text-0);
	--bs-btn-hover-bg: var(--bg-3);
	--bs-btn-hover-border-color: var(--bg-3);

	--bs-btn-active-color: var(--text-0);
	--bs-btn-active-bg: var(--bg-3);
	--bs-btn-active-border-color: var(--bg-3);

	--bs-btn-disabled-color: var(--text-0);
	--bs-btn-disabled-bg: var(--bg-2);
	--bs-btn-disabled-border-color: var(--bg-2);
}

.monitor-view-btn.activated {

	--bs-btn-color: var(--bg-0);
	--bs-btn-bg: var(--vitta-green-dark);
	--bs-btn-border-color: var(--vitta-green-dark);

	--bs-btn-hover-color: var(--bg-0);
	--bs-btn-hover-bg: var(--vitta-green-focus-shadow);
	--bs-btn-hover-border-color: var(--vitta-green-focus-shadow);

	--bs-btn-active-color: var(--bg-0);
	--bs-btn-active-bg: var(--vitta-green-focus-shadow);
	--bs-btn-active-border-color: var(--vitta-green-focus-shadow);

	--bs-btn-disabled-color: var(--bg-0);
	--bs-btn-disabled-bg: var(--vitta-green-dark);
	--bs-btn-disabled-border-color: var(--vitta-green-dark);
}



.monitor-btn-music {
	float: left;
	display: block;
}

.monitor-controls-tab {
	width: 100%;
	display: flex;
}

#monitor-controls-graph {
	display: none;
}

/* All tab */

#serial-form {
	display: flex;
	width: 100%;
}

/* Console tab */

.arduino_input {
	max-width: 50%;
	min-width: 100px;
	flex: 1;
	margin-right: 5px;
}

/* Graph tab */

.chart-no-data {
	font-style: italic;
	font-size: 15px;
}

/* Music tab */

/* Music panel (events/music.js): one card per setting */

#music-panel {
	min-height: 100%;
	width: 100%;
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	gap: 10px;
	font-family: var(--main-font);
}

.music-control {
	min-width: 110px;
	padding: 10px 16px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	gap: 6px;
	background-color: var(--bg-2);
	border: 1px solid var(--bg-3);
	border-radius: 10px;
	color: var(--text-1);
}

/* Console on the right (vertical): one card per line, all of the same width */
.monitor-grid-right #music-panel > .music-control {
	flex: 1 1 100%;
}

#music-panel .music-control-label {
	font-size: 13px;
	color: var(--text-0);
}

#music-panel .music-slider {
	height: 90px;
	margin: 4px 0;
	background: var(--bg-4);
	border: none;
	border-radius: 50vh;
}

#music-panel .music-slider .ui-slider-range {
	background: var(--vitta-green);
	border-radius: 50vh;
}

#music-panel .music-slider .ui-slider-handle {
	left: 50%;
	transform: translateX(-50%);
	margin-left: 0;
	background: var(--bg-0);
	border: 2px solid var(--vitta-green);
	cursor: pointer;
}

#music-panel .music-slider .ui-slider-handle:focus-visible {
	box-shadow: 0 0 0 3px var(--vitta-green-focus-shadow);
}

#music-panel .music-slider-value {
	font-size: 13px;
	font-weight: 700;
	color: var(--text-0);
}

#music-panel #music-note {
	min-width: 110px;
	text-align: center;
}

/* Drawing of the wave in the waveform buttons */
#music-panel .music-waveform-button {
	display: inline-flex;
	align-items: center;
	justify-content: flex-start;
	gap: 6px;
	white-space: nowrap;
}

#music-panel .music-waveform-button svg {
	width: 24px;
	height: 12px;
	flex-shrink: 0;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.6;
	stroke-linejoin: round;
}

/* Pill buttons, as in the console bar */
#music-panel .music-control-button {
	width: 100%;
	min-height: 28px;
	margin: 0 !important;
	padding: 4px 14px;
	border: 1px solid var(--bg-4);
	border-radius: 50vh;
	background-color: var(--bg-0);
	color: var(--text-1);
	font-size: 13px;
	font-weight: 600;
}

#music-panel .music-control-button:hover {
	background-color: var(--bg-3);
	color: var(--text-0);
}

#music-panel .music-control-button.active {
	background-color: var(--vitta-green);
	border-color: var(--vitta-green);
	color: var(--bg-0);
}

#music-oscilloscope {
	width: 240px;
	max-width: 100%;
	height: 110px;
	background-color: var(--bg-0);
	border: 1px solid var(--bg-3);
	border-radius: 8px;
}

/* MONITOR DROPDOWN */

.monitor-controls-button {
	height: 100%;
	margin-inline-end: 5px;
	--bs-btn-padding-x: 0.75em;
	--bs-btn-border-radius: 50vh;

	--bs-btn-color: var(--text-1);
	--bs-btn-bg: transparent;
	--bs-btn-border-color: transparent;

	--bs-btn-hover-color: var(--text-1);
	--bs-btn-hover-bg: rgba(var(--text-0-rgb), 0.1);
	--bs-btn-hover-border-color: transparent;

	--bs-btn-active-color: var(--text-1);
	--bs-btn-active-bg: rgba(var(--text-0-rgb), 0.225);
	--bs-btn-active-border-color: transparent;
}

#monitor-controls-dropdown {
	background: var(--bg-4);
	border-radius: 10px 10px 0 0 !important;
	overflow: hidden;
	margin: 0;
	box-shadow: 0 0 3px var(--vitta-shadow-color);
}

#monitor-controls-dropdown .dropdown-item {
	background: var(--bg-4);
}

#serial-input,
#serial-send {
	border: 1px solid var(--bg-4);
}

.console-separator {
	border-left: 1px var(--bg-5) solid;
	margin: -5px 10px -5px 10px;
}

/* bloc tooltip */

#monitor-graph-tooltip.interface-tooltip {
	right: 100%;
	/* Within a narrow console (on the right): its width minus the buttons column */
	width: min(300px, calc(100cqw - 110px));
	bottom: unset;
}

#monitor-graph-tooltip.interface-tooltip::after {
	top: 50%;
	left: 100%;
	border-color: transparent transparent transparent var(--vitta-green);
	margin: 0;
	transform: translateY(-50%);
}

/* repl control */

#repl-control:not(.activated):hover,
#repl-control.activated {
	background-color: var(--vitta-orange-light);
}

#repl-control:not(.activated) {
	background-color: var(--bg-1);
}
/* Phones: the console buttons are in the console settings menu (see placeMonitorButtons), with their label */
#monitor-controls-dropdown > #monitor-div-btn {
	position: static;
	display: grid !important;
	grid-template-columns: 1fr 1fr;
	gap: 6px;
	padding: 0.25rem 0.75rem 0.75rem;
	margin-bottom: 0.25rem;
	border-bottom: 1px solid rgba(128, 128, 128, 0.4);
}

#monitor-controls-dropdown > #monitor-div-btn .ide-btn {
	justify-content: flex-start;
	gap: 0.4em;
	width: 100%;
	min-width: 0;
	height: auto;
	margin: 0;
	padding: 0.4em 0.5em;
	border-radius: 10px !important;
	font-size: 0.9rem;
}

#monitor-controls-dropdown > #monitor-div-btn .label-button {
	display: inline !important;
	margin: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}
