:root {
	--radius: 16px;
	--boxShadow1: rgba(0, 0, 0, 0.18) 0 2px 1px -1px, rgba(0, 0, 0, 0.12) 0 1px 1px 0, rgba(0, 0, 0, 0.1) 0 1px 3px 0px;
}

@media (prefers-color-scheme: light) {
	:root {
		--color4xxBackground: #ffedd1;
		--colorAccent: #0b61ec;
		--colorBackground: #fff;
		--colorComboBoxHeaderBackground: #fff;
		--colorComboBoxBackground: #eee;
		--colorHeaderBackground: #efefef;
		--colorSecondaryButtonBackground: #fcfcfc;
		--colorSecondaryActionBorder: #ddd;
		--colorSecondaryAction: #666;
		--colorDisabledMockSelector: #444;
		--colorHover: rgba(119, 193, 255, 0.5);
		--colorLabel: #555;
		--colorLightRed: #ffe4ee;
		--colorRed: #da0f00;
		--colorText: #000;
		--colorPink: #ed206a;
		--colorPurple: #9b71e8;
		--colorGreen: #388e3c;
	}
}
@media (prefers-color-scheme: dark) {
	:root {
		--color4xxBackground: #68554a;
		--colorAccent: #2495ff;
		--colorBackground: #181818;
		--colorHeaderBackground: #111;
		--colorComboBoxBackground: #2a2a2a;
		--colorSecondaryButtonBackground: #2a2a2a;
		--colorSecondaryActionBorder: #333;
		--colorSecondaryAction: #aaa;
		--colorComboBoxHeaderBackground: #222;
		--colorDisabledMockSelector: #b9b9b9;
		--colorHover: rgba(0, 63, 115, 0.5);
		--colorLabel: #aaa;
		--colorLightRed: #ffe4ee;
		--colorRed: #f41606;
		--colorText: #fff;
		--colorPink: #f92672;
		--colorPurple: #ae81ff;
		--colorGreen: #a6e22e;
	}
}

html,
body {
	overflow: hidden;
	height: 100%;
	padding: 0;
	margin: 0;
	background: var(--colorHeaderBackground);
	font-size: 12px;
}
body {
	display: grid;
	grid-template-rows: auto 1fr;
	background: var(--colorBackground);
	color: var(--colorText);
	font-family: system-ui, sans-serif;
}

* {
	box-sizing: border-box;
	padding: 0;
	border: 0;
	margin: 0;
	font-family: inherit;
	font-size: 100%;
	outline: 0;
	scrollbar-width: thin;
}

a:focus-visible,
input:focus-visible,
select:focus-visible,
button:focus-visible {
	outline-offset: -1px;
	outline: 2px solid var(--colorAccent);
}

a,
select,
button,
input[type=checkbox] {
	cursor: pointer;
}

a:active,
select:active,
button:active,
input[type=checkbox]:active {
	cursor: grabbing;
}

a {
	text-decoration: none;
}

select {
	border: 1px solid transparent;
	font-size: 100%;
	color: var(--colorText);
	border-radius: var(--radius);
	appearance: none;
	background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23888888'><path d='M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z'/></svg>") no-repeat;
	background-size: 16px;
	background-position: calc(100% - 3px) center;

	&:enabled {
		border-color: var(--colorSecondaryActionBorder);
		background-color: var(--colorSecondaryButtonBackground);
		&:hover {
			border-color: var(--colorHover);
			background-color: var(--colorHover);
		}
	}
	&:disabled {
		cursor: not-allowed;
		opacity: 0.5;
	}
}

header {
	display: flex;
	width: 100vw;
	padding: 16px;
	border-bottom: 1px solid var(--colorSecondaryActionBorder);
	background: var(--colorHeaderBackground);

	> object {
		align-self: end;
		margin-right: 22px;
		margin-bottom: 5px;
	}

	> div {
		display: flex;
		width: 100%;
		flex-wrap: wrap;
		align-items: flex-end;
		gap: 16px 8px;
	}

	@media (max-width: 760px) {
		> img {
			width: 100px;
			align-self: center;
		}

		> div {
			width: 400px;
			.MenuTrigger {
				margin-left: unset;
			}
		}
	}
	@media (max-width: 424px) {
		> img {
			display: none;
		}
	}

	.Field {
		width: 116px;

		span {
			display: flex;
			align-items: center;
			margin-left: 8px;
			color: var(--colorLabel);
			font-size: 11px;
			gap: 4px;
		}

		input[type=url],
		input[type=number],
		select {
			width: 100%;
			height: 28px;
			padding: 4px 8px;
			border: 1px solid var(--colorSecondaryActionBorder);
			margin-top: 2px;
			color: var(--colorText);
			font-size: 11px;
			background-color: var(--colorComboBoxHeaderBackground);
			border-radius: var(--radius);
		}

		select:enabled:hover {
			border-color: var(--colorSecondaryActionBorder);
			background: var(--colorHover);
		}

		&.GlobalDelayField {
			width: 76px;

			input[type=number] {
				padding-right: 6px;
			}

			svg {
				width: 12px;
				height: 12px;
				border: 1px solid var(--colorLabel);
				stroke-width: 3px;
				border-radius: 50%;
			}
		}

		&.CookieSelector {
			width: 100px;
		}

		&.FallbackBackend {
			position: relative;
			width: 160px;

			.SaveProxiedCheckbox {
				position: absolute;
				top: 0;
				right: 0;
				display: flex;
				width: auto;
				min-width: unset;
				align-items: center;
				font-size: 11px;
				gap: 4px;

				input + .checkboxBody {
					margin: 0;
					margin-right: 4px;
				}
				input:enabled + .checkboxBody {
					cursor: pointer;
				}
				input:disabled + .checkboxBody {
					opacity: 0.8;
				}
			}
		}
	}

	.BulkSelector {
		background-image: none;
		text-align-last: center;
	}

	.ResetButton {
		padding: 6px 12px;
		border: 1px solid var(--colorRed);
		margin-right: 8px;
		margin-left: 4px;
		background: transparent;
		border-radius: 50px;
		color: var(--colorRed);
		@media (prefers-color-scheme: dark) {
			color: var(--colorLightRed);
		}

		&:hover {
			background: var(--colorRed);
			color: white;
		}
	}

	.MenuTrigger {
		width: 24px;
		height: 24px;
		flex-shrink: 0;
		align-self: end;
		margin-bottom: 2px;
		margin-left: auto;
		fill: var(--colorSecondaryAction);
		background: transparent;
		border-radius: 50%;

		&:hover {
			fill: var(--colorAccent);
		}
	}
}

.SettingsMenu {
	position: absolute;
	top: 62px;
	right: 10px;
	left: auto;
	border: 1px solid var(--colorSecondaryActionBorder);
	color: var(--colorText);
	border-radius: var(--radius);
	box-shadow: var(--boxShadow1);
	background: var(--colorHeaderBackground);

	> div {
		display: inline-flex;
		flex-direction: column;
		padding: 20px;
		cursor: auto;
		gap: 12px;
		text-align: left;

		a {
			color: var(--colorAccent);
		}

		.GroupByMethod {
			display: flex;
			align-items: center;
			gap: 6px;
			cursor: pointer;
		}
	}
}


main {
	display: flex;
	min-width: 0;
	min-height: 0;

	@media (max-width: 760px) {
		flex-direction: column;

		.Resizer {
			display: none;
		}

		.leftSide {
			min-width: 100%;
			min-height: 50%;
			max-height: 50%;
			border: 0;
		}
	}

	.leftSide {
		width: 50%; /* resizable in js */
		padding: 16px;
		border-right: 1px solid var(--colorSecondaryActionBorder);
		user-select: none;
		overflow-y: auto;
		box-shadow: var(--boxShadow1);
	}

	.rightSide {
		position: relative;
		min-width: 100px;
		min-height: 0;
		flex: 1;

		.Resizer {
			position: absolute;
			top: 0;
			left: 0;
			width: 8px;
			height: 100%;
			border-left: 3px solid transparent;
			cursor: col-resize;

			&:active {
				border-color: var(--colorSecondaryActionBorder);
			}
		}
	}
}

.Table {
	.TableHeading {
		padding-bottom: 4px;
		padding-left: 4px;
		border-top: 24px solid transparent;
		margin-left: 74px;
		font-weight: bold;
		text-align: left;

		&:first-of-type {
			border-top: 0
		}

		&.canProxy {
			margin-left: 110px;
		}
		&.nonGroupedByMethod {
			margin-left: 122px;

			&.canProxy {
				margin-left: 160px;
			}
		}
	}

	.TableRow {
		display: flex;
		align-items: center;

		&.animIn {
			opacity: 0;
			transform: scaleY(0);
			animation: _kfRowIn 180ms ease-in-out forwards;
		}
	}
}

@keyframes _kfRowIn {
	to {
		opacity: 1;
		transform: scaleY(1);
	}
}

.Method {
	overflow: hidden;
	min-width: 38px;
	padding: 4px 0;
	margin-right: 8px;
	color: var(--colorSecondaryAction);
	font-size: 11px;
	text-align: center;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.PreviewLink {
	position: relative;
	left: -8px;
	display: inline-block;
	width: 100%;
	min-width: 140px;
	padding: 6px 8px;
	margin-left: 4px;
	border-radius: var(--radius);
	color: var(--colorAccent);
	word-break: break-word;


	&:hover {
		background: var(--colorHover);
	}
	&.chosen {
		color: white;
		background: var(--colorAccent);
	}
	.dittoDir {
		opacity: 0.9;
		filter: saturate(0.1);
	}
}


.MockSelector {
	height: 24px;
	padding-right: 20px;
	padding-left: 8px;
	text-overflow: ellipsis;
	font-size: 12px;

	&.nonDefault {
		font-weight: bold;
		font-size: 0.92rem;
	}
	&.status4xx {
		background: var(--color4xxBackground);
	}
	&:disabled {
		padding-right: 4px;
		border-color: transparent;
		appearance: none;
		background: transparent;
		cursor: default;
		color: var(--colorDisabledMockSelector);
		opacity: 0.8;
	}
}

.DelayToggler,
.ProxyToggler {
	display: flex;

	> input {
		/* For click drag target */
		position: absolute;
		width: 22px;
		height: 22px;
		opacity: 0;

		&:focus-visible {
			outline: 0;
			& + svg {
				outline: 2px solid var(--colorAccent)
			}
		}
	}

	> svg {
		fill: none;
		stroke: var(--colorSecondaryAction);
	}
}

.DelayToggler {
	> input {
		&:checked + svg {
			border-color: var(--colorAccent);
			fill: var(--colorAccent);
			background: var(--colorAccent);
			stroke: var(--colorBackground);
		}

		&:enabled:hover:not(:checked) + svg {
			border-color: var(--colorHover);
			background: var(--colorHover);
			stroke: var(--colorText);
		}
	}

	> svg {
		width: 22px;
		height: 22px;
		border: 1px solid var(--colorSecondaryActionBorder);
		stroke-width: 2.5px;
		border-radius: 50%;
	}

	&.canProxy {
		margin-left: 36px;
	}
}

.ProxyToggler {
	border: 1px solid var(--colorSecondaryActionBorder);
	margin-right: 8px;
	border-radius: var(--radius);

	&:has(input:checked),
	&:has(input:disabled) {
		background: transparent;
		box-shadow: none;
	}

	> input {
		&:checked + svg {
			fill: var(--colorAccent);
			stroke: var(--colorAccent);

			path:last-of-type { /* inner cloud curve */
				stroke: var(--colorBackground);
			}
			transform: scale(1.1);
		}

		&:enabled:hover:not(:checked) + svg {
			fill: var(--colorHover);
			stroke: var(--colorText);
		}

		&:disabled + svg {
			stroke-opacity: 0.4;
			cursor: not-allowed;
			box-shadow: none;
			fill: transparent;

			path:last-of-type {
				stroke-opacity: 0;
				stroke: transparent;
			}
		}
	}

	> svg {
		width: 26px;
		padding: 1px 4px;
		stroke-width: 2px;
		border-radius: var(--radius);
	}
}

.InternalServerErrorToggler,
.NotFoundToggler {
	display: flex;
	margin-right: 10px;
	margin-left: 8px;
	cursor: pointer;

	> input {
		appearance: none;

		&:focus-visible {
			outline: 0;
			& + .checkboxBody {
				outline: 2px solid var(--colorAccent)
			}
		}

		&:disabled + .checkboxBody {
			cursor: not-allowed;
			opacity: 0.7;
		}
		&:checked + .checkboxBody {
			border-color: var(--colorRed);
			color: white;
			background: var(--colorRed);
		}
		&:not(:checked):enabled:hover + .checkboxBody {
			border-color: var(--colorRed);
			color: var(--colorRed);
		}
		&:enabled:active + .checkboxBody {
			cursor: grabbing;
		}
	}

	> .checkboxBody {
		padding: 4px;
		border: 1px solid var(--colorSecondaryActionBorder);
		font-size: 10px;
		font-weight: bold;
		color: var(--colorSecondaryAction);
		border-radius: var(--radius);
	}
}


.PayloadViewer {
	display: flex;
	height: 100%;
	flex-direction: column;
	padding-top: 16px;

	> h2 {
		padding-bottom: 4px;
		padding-left: 16px;
	}

	> pre {
		overflow: auto;
		height: 100%;
		padding: 16px;
		padding-top: 12px;
		font-family: monospace;

		> code {
			white-space: pre;
			tab-size: 2;
			color: var(--colorSecondaryAction);
		}
	}
}

.syntaxPunc {
	color: var(--colorSecondaryAction);
}
.syntaxKey,
.syntaxTag {
	color: var(--colorPink);
}
.syntaxVal,
.syntaxAttr {
	color: var(--colorPurple);
}
.syntaxStr,
.syntaxAttrVal {
	color: var(--colorGreen);
}


.ProgressBar {
	position: relative;
	top: -4px;
	width: 100%;
	height: 2px;
	background: var(--colorComboBoxHeaderBackground);

	> div {
		position: absolute;
		top: 0;
		left: 0;
		width: 0;
		height: 100%;
		background: var(--colorAccent);
		animation-name: _kfProgress;
		animation-timing-function: linear;
		animation-iteration-count: infinite;
		animation-direction: alternate;
		/* duration in JavaScript */
	}
}
@keyframes _kfProgress {
	to {
		width: 100%;
	}
}


.ErrorToast {
	position: fixed;
	z-index: 9999;
	bottom: 12px;
	left: 12px;
	padding: 12px 16px;
	cursor: pointer;
	background: var(--colorRed);
	color: white;
	border-radius: var(--radius);
	box-shadow: var(--boxShadow1);
	opacity: 0;
	transform: translateY(20px);
	animation: _kfToastIn 240ms forwards;

	&:hover::after {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		text-align: center;
		content: '×';
		font-size: 28px;
		line-height: 34px;
		border-radius: var(--radius);
		background: rgba(0, 0, 0, 0.5);
	}
}

@keyframes _kfToastIn {
	to {
		opacity: 1;
		transform: translateY(0);
	}
}
