/*
 * labete.dev tools: the shared look of the dashboards (logs, Bull queues).
 * Colours, type, the top bar, buttons, status dot, the details drawer and
 * toasts live here so the tools stay one family. Each tool's own stylesheet
 * adds only what is specific to it.
 */
:root {
	color-scheme: light dark;

	--paper: light-dark(#f6f6f3, #15181d);
	--paper-raised: light-dark(#ffffff, #1b1f25);
	--ink: light-dark(#15181d, #eef0f2);
	--soft: light-dark(#5f6771, #99a2ac);
	--rule: light-dark(#d8dad5, #2c313a);
	--wash: light-dark(rgba(21, 24, 29, 0.05), rgba(255, 255, 255, 0.05));
	--select: light-dark(rgba(15, 122, 79, 0.1), rgba(87, 211, 155, 0.12));

	--live: light-dark(#0f7a4f, #57d39b);
	--error: light-dark(#b42318, #f97066);
	--warn: light-dark(#9a5b00, #f5b54a);
	--info: var(--ink);
	--debug: var(--soft);
	--mark: light-dark(#fff1a8, #5c4a00);

	--sans: 'Overpass', 'Helvetica Neue', Arial, sans-serif;
	--mono: 'Fira Code', 'SFMono-Regular', Consolas, monospace;

	--row: 26px;
	--pad: 16px;
	--ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* A theme picked on any labete.dev site (theme.js) overrides the device's */
:root[data-theme='light'] {
	color-scheme: light;
}

:root[data-theme='dark'] {
	color-scheme: dark;
}

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html,
body {
	height: 100%;
}

body {
	background: var(--paper);
	color: var(--ink);
	font-family: var(--sans);
	font-size: 14px;
	line-height: 1.4;
	-webkit-font-smoothing: antialiased;
}

button {
	font: inherit;
	color: inherit;
}

:focus-visible {
	outline: 2px solid var(--live);
	outline-offset: 1px;
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
}

[hidden] {
	display: none !important;
}

/* ───────────── frame ───────────── */

.app {
	display: flex;
	flex-direction: column;
	height: 100vh;
	height: 100dvh;
}

.bar {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 48px;
	padding: 8px var(--pad);
	border-bottom: 1px solid var(--rule);
}

.bar-top {
	gap: 20px;
}

.brand {
	font-weight: 700;
	font-size: 15px;
	letter-spacing: -0.01em;
}

.brand span,
.brand a {
	color: var(--soft);
	font-weight: 500;
}

/* "labete.dev" in the top bar goes back to the portfolio */
.brand a {
	text-decoration: none;
}

.brand a:hover {
	color: var(--ink);
	text-decoration: underline;
}

.bar-actions {
	display: flex;
	gap: 8px;
	margin-left: auto;
}

/* ───────────── controls ───────────── */

.button {
	height: 30px;
	padding: 0 12px;
	border: 1px solid var(--rule);
	border-radius: 6px;
	background: var(--paper-raised);
	cursor: pointer;
	white-space: nowrap;
}

.button:hover:not(:disabled) {
	border-color: var(--soft);
}

.button:disabled {
	opacity: 0.45;
	cursor: default;
}

.button-strong {
	height: 34px;
	padding: 0 16px;
	border-color: var(--ink);
	background: var(--ink);
	color: var(--paper);
	font-weight: 600;
}

.status {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
	color: var(--soft);
}

.status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--soft);
	/* Centring in the line puts the dot at the middle of Overpass's lowercase
	   letters (0.25em above the baseline); the middle of its capitals, where the
	   eye reads "Connected", is 0.35em (cap height 0.7em). */
	transform: translateY(-0.1em);
}

.status-dot.connected {
	background: var(--live);
}

.status-dot.connecting {
	background: var(--warn);
	animation: pulse 1.2s ease-in-out infinite;
}

.status-dot.disconnected {
	background: var(--error);
}

@keyframes pulse {
	50% {
		opacity: 0.35;
	}
}

.empty-title {
	font-size: 20px;
	font-weight: 700;
	letter-spacing: -0.01em;
}

.empty-text {
	max-width: 52ch;
	color: var(--soft);
	line-height: 1.5;
}

/* ───────────── details drawer ───────────── */

.drawer-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(10, 12, 15, 0.32);
	animation: fade 0.2s ease both;
}

.drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(680px, 100vw);
	display: flex;
	flex-direction: column;
	background: var(--paper);
	border-left: 1px solid var(--rule);
	box-shadow: -12px 0 32px rgba(0, 0, 0, 0.16);
	animation: slide-in 0.26s var(--ease) both;
}

.drawer.closing {
	animation: slide-out 0.18s ease-in both;
}

.drawer-backdrop.closing {
	animation: fade 0.18s ease-in reverse both;
}

@keyframes slide-in {
	from {
		transform: translateX(100%);
	}
}

@keyframes slide-out {
	to {
		transform: translateX(100%);
	}
}

@keyframes fade {
	from {
		opacity: 0;
	}
}

.drawer-head {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 56px;
	padding: 10px 20px;
	border-bottom: 1px solid var(--rule);
}

.drawer-head h2 {
	font-size: 16px;
}

.drawer-nav {
	display: flex;
	gap: 6px;
	margin-left: auto;
}

.drawer-body {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
}

.detail-facts {
	display: grid;
	grid-template-columns: max-content minmax(0, 1fr);
	gap: 6px 18px;
	margin-bottom: 22px;
	font-size: 13.5px;
}

.detail-facts dt {
	color: var(--soft);
}

.detail-facts dd {
	font-family: var(--mono);
	font-size: 12.5px;
	overflow-wrap: anywhere;
}

.detail-facts .error {
	color: var(--error);
	font-weight: 600;
}

.detail-facts .warn {
	color: var(--warn);
	font-weight: 600;
}

.detail-section + .detail-section {
	margin-top: 22px;
}

.detail-section h3 {
	margin-bottom: 8px;
	font-size: 13.5px;
}

.detail-block {
	padding: 12px 14px;
	border: 1px solid var(--rule);
	border-radius: 8px;
	background: var(--paper-raised);
	font-family: var(--mono);
	font-size: 12.5px;
	line-height: 1.6;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.json-key {
	color: light-dark(#1f4fd1, #8fb1ff);
}

.json-string {
	color: light-dark(#0f7a57, #6edbb8);
}

.json-number,
.json-boolean {
	color: light-dark(#a62a7a, #f08bc4);
}

.json-null {
	color: var(--soft);
}

/* ───────────── shared small pieces ───────────── */

/* A destructive action */
.button-danger {
	border-color: var(--error);
	background: none;
	color: var(--error);
	font-weight: 600;
}

.button-danger:hover:not(:disabled) {
	border-color: var(--error);
	background: var(--error);
	color: var(--paper);
}

/* Actions inside a row: text, not boxes, so a table stays calm */
.link-button {
	padding: 2px 4px;
	border: 0;
	border-radius: 4px;
	background: none;
	color: var(--live);
	font-weight: 600;
	cursor: pointer;
}

.link-button:hover {
	text-decoration: underline;
}

.link-button.is-danger {
	color: var(--error);
}

/* A short word attached to a name: "BullMQ", "paused" */
.tag {
	display: inline-block;
	padding: 1px 7px;
	border: 1px solid var(--rule);
	border-radius: 10px;
	color: var(--soft);
	font-size: 12px;
	line-height: 1.5;
	vertical-align: middle;
}

/* Buttons pinned to the bottom of a drawer */
.drawer-foot {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	padding: 12px 20px;
	border-top: 1px solid var(--rule);
}

/* An on/off switch around a real checkbox */
.switch {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	gap: 8px;
	color: var(--soft);
	white-space: nowrap;
	cursor: pointer;
	user-select: none;
}

.switch input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
}

.switch-track {
	position: relative;
	flex-shrink: 0;
	width: 30px;
	height: 18px;
	border-radius: 9px;
	background: var(--rule);
	transition: background-color 0.15s ease;
}

.switch-track::after {
	content: '';
	position: absolute;
	top: 2px;
	left: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--paper-raised);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
	transition: transform 0.15s ease;
}

.switch input:checked + .switch-track {
	background: var(--live);
}

.switch input:checked + .switch-track::after {
	transform: translateX(12px);
}

.switch input:checked ~ * {
	color: var(--ink);
}

.switch input:focus-visible + .switch-track {
	outline: 2px solid var(--live);
	outline-offset: 2px;
}

/* How far along a job is */
.meter {
	display: inline-block;
	width: 56px;
	height: 5px;
	margin-right: 8px;
	border-radius: 3px;
	background: var(--rule);
	overflow: hidden;
	vertical-align: middle;
}

.meter > span {
	display: block;
	height: 100%;
	background: var(--live);
}

.soft {
	color: var(--soft);
}

.detail-block.is-error {
	border-color: var(--error);
	color: var(--error);
}

/* ───────────── toasts ───────────── */

.toasts {
	position: fixed;
	bottom: 18px;
	right: 18px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	z-index: 10;
}

.toast {
	padding: 10px 14px;
	border-radius: 8px;
	background: var(--ink);
	color: var(--paper);
	transition: opacity 0.2s ease;
}

.toast.error {
	background: var(--error);
	color: #fff;
}

/* Phones: iOS Safari zooms the whole page into any text box whose font is under
   16px, so every field is 16px there. !important because each tool styles its
   own fields with more specific selectors at desktop sizes. */
@media (max-width: 760px) {
	input,
	select,
	textarea {
		font-size: 16px !important;
	}

	/* The drawer is full width; let its title and buttons share two lines if needed */
	.drawer-head {
		flex-wrap: wrap;
		padding: 10px 14px;
	}

	.drawer-body {
		padding: 16px 14px;
	}

	.drawer-foot {
		padding: 10px 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation: none !important;
		transition: none !important;
	}
}

