/*
 * labete.dev queues (on top of tools.css)
 * The queues are a list down the left; the chosen queue fills the rest: its
 * actions, status tabs with counts, a filter and the jobs. Failed counts are the
 * one thing in red on the list, because they are what someone opens this to find.
 */

/* ───────────── top bar ───────────── */

.redis {
	flex: 1 1 auto;
	min-width: 0;
	/* With the bar's own gap, a long name ends well clear of the controls */
	margin-right: 24px;
	overflow: hidden;
	color: var(--soft);
	font-family: var(--mono);
	font-size: 12.5px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* The controls keep their size; the connection name gives way (with an ellipsis) */
.bar-top .bar-actions {
	flex-shrink: 0;
}

.bar-actions form {
	display: contents;
}

.bar-actions .button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.refresh-icon {
	width: 14px;
	height: 14px;
}

.refresh-icon.is-spinning {
	animation: spin 0.8s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

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

.workspace {
	flex: 1;
	min-height: 0;
	display: grid;
	grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
}

/* ───────────── queue list ───────────── */

.queues {
	display: flex;
	flex-direction: column;
	min-height: 0;
	border-right: 1px solid var(--rule);
}

.queue-find {
	padding: 12px 12px 6px;
}

.queue-find input,
.jobs-filter-field input {
	width: 100%;
	height: 32px;
	padding: 0 10px;
	border: 1px solid var(--rule);
	border-radius: 6px;
	background: var(--paper-raised);
	color: var(--ink);
	font: inherit;
}

.queues-count {
	padding: 0 14px 8px;
	color: var(--soft);
	font-size: 12.5px;
}

.queue-list {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 0 6px 12px;
}

.queues-note {
	padding: 10px 8px;
	color: var(--soft);
}

.queue-item {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 1px 10px;
	width: 100%;
	padding: 9px 10px;
	border: 0;
	border-radius: 6px;
	background: none;
	text-align: left;
	cursor: pointer;
}

.queue-item:hover {
	background: var(--wash);
}

.queue-item.active {
	background: var(--select);
	box-shadow: inset 2px 0 0 var(--live);
}

.queue-name {
	overflow: hidden;
	font-weight: 600;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* The number of failed jobs, only when there are some */
.queue-failed {
	color: var(--error);
	font-family: var(--mono);
	font-size: 12.5px;
	font-weight: 600;
	text-align: right;
}

.queue-meta,
.queue-summary {
	grid-column: 1 / -1;
	overflow: hidden;
	color: var(--soft);
	font-size: 12.5px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.queue-item.paused .queue-name {
	color: var(--soft);
}

/* ───────────── the selected queue ───────────── */

.queue-main {
	position: relative;
	min-width: 0;
	min-height: 0;
	overflow-y: auto;
}

.queue-main > .empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 60%;
	padding: 24px;
	text-align: center;
}

.queue-view {
	padding: 20px 24px 28px;
}

.queue-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin-bottom: 14px;
}

.queue-head h1 {
	min-width: 0;
	font-size: 22px;
	font-weight: 700;
	letter-spacing: -0.015em;
	overflow-wrap: anywhere;
}

.tag-paused {
	border-color: var(--warn);
	color: var(--warn);
}

.queue-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 18px;
}

.clean-failed {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.clean-failed input,
.clean-failed select,
.jobs-filter select {
	height: 30px;
	padding: 0 8px;
	border: 1px solid var(--rule);
	border-radius: 6px;
	background: var(--paper-raised);
	color: var(--ink);
	font: inherit;
}

.clean-failed input {
	width: 64px;
}

/* Status tabs: the counts are part of the label */
.status-tabs {
	display: flex;
	gap: 4px;
	margin-bottom: 14px;
	border-bottom: 1px solid var(--rule);
	overflow-x: auto;
}

.tab {
	padding: 8px 12px 9px;
	border: 0;
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
	background: none;
	color: var(--soft);
	white-space: nowrap;
	cursor: pointer;
}

.tab b {
	margin-left: 4px;
	font-family: var(--mono);
	font-size: 12.5px;
	font-weight: 500;
}

.tab[aria-selected='true'] {
	border-bottom-color: var(--ink);
	color: var(--ink);
	font-weight: 600;
}

.tab[data-status='failed'] b {
	color: var(--error);
}

/* Filter */
.jobs-filter {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 10px;
}

.jobs-filter-field {
	flex: 0 1 320px;
	min-width: 180px;
}

.jobs-filter-field input {
	font-family: var(--mono);
	font-size: 13px;
}

.jobs-filter-status {
	color: var(--soft);
	font-size: 13px;
}

.jobs-filter-status.is-partial {
	color: var(--warn);
}

/* Jobs */
.jobs {
	overflow-x: auto;
}

.jobs-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13.5px;
}

.jobs-table th {
	padding: 8px 10px;
	border-bottom: 1px solid var(--rule);
	color: var(--soft);
	font-size: 12.5px;
	font-weight: 600;
	text-align: left;
	white-space: nowrap;
}

.jobs-table td {
	padding: 8px 10px;
	border-bottom: 1px solid var(--rule);
	vertical-align: middle;
}

.jobs-table tbody tr[data-job-id] {
	cursor: pointer;
}

.jobs-table tbody tr[data-job-id]:hover {
	background: var(--wash);
}

.jobs-table .col-id {
	font-family: var(--mono);
	font-size: 12.5px;
	white-space: nowrap;
}

.jobs-table .col-name {
	max-width: 280px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.jobs-table .col-attempts,
.jobs-table .col-created {
	color: var(--soft);
	font-family: var(--mono);
	font-size: 12.5px;
	white-space: nowrap;
}

.jobs-table .col-progress {
	font-family: var(--mono);
	font-size: 12.5px;
	white-space: nowrap;
}

.jobs-table .col-actions {
	text-align: right;
	white-space: nowrap;
}

/* Row actions show on hover and focus; touch screens always show them */
@media (hover: hover) {
	.jobs-table .col-actions .link-button {
		opacity: 0;
	}

	.jobs-table tr:hover .link-button,
	.jobs-table tr:focus-within .link-button {
		opacity: 1;
	}
}

.jobs-note {
	padding: 22px 4px;
	color: var(--soft);
}

.jobs-note.is-error {
	color: var(--error);
}

.pagination {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 14px;
	color: var(--soft);
	font-size: 13px;
}

/* Job drawer: a status word in its own colour */
.status-word.is-failed {
	color: var(--error);
	font-weight: 600;
}

.status-word.is-completed {
	color: var(--live);
	font-weight: 600;
}

.status-word.is-delayed,
.status-word.is-waiting {
	color: var(--warn);
	font-weight: 600;
}

/* ───────────── login ───────────── */

.login {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 28px;
	min-height: 100vh;
	padding: 12vh 20px 40px;
}

.login-panel {
	width: min(440px, 100%);
}

.login-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 18px;
}

.login-panel h1 {
	margin-bottom: 6px;
	font-size: 24px;
	letter-spacing: -0.015em;
}

.login-panel > p {
	margin-bottom: 22px;
	color: var(--soft);
	line-height: 1.5;
}

.field {
	display: block;
	margin-bottom: 16px;
}

.field span {
	display: block;
	margin-bottom: 6px;
	font-weight: 600;
}

.field input {
	width: 100%;
	height: 38px;
	padding: 0 12px;
	border: 1px solid var(--rule);
	border-radius: 6px;
	background: var(--paper-raised);
	color: var(--ink);
	font: inherit;
}

.field input#redisUrl {
	font-family: var(--mono);
	font-size: 13px;
}

.field small {
	display: block;
	margin-top: 5px;
	color: var(--soft);
	font-size: 12.5px;
}

.login .button-strong {
	width: 100%;
	height: 40px;
}

.login-error {
	margin-top: 14px;
	color: var(--error);
}

.recent {
	width: min(440px, 100%);
}

.recent h2 {
	margin-bottom: 8px;
	font-size: 14px;
}

.recent-item {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: 2px 12px;
	padding: 10px 0;
	border-top: 1px solid var(--rule);
}

.recent-item:last-child {
	border-bottom: 1px solid var(--rule);
}

.recent-label {
	display: block;
	overflow: hidden;
	font-weight: 600;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.recent-url {
	grid-column: 1;
	overflow: hidden;
	color: var(--soft);
	font-family: var(--mono);
	font-size: 12px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.recent-item .button {
	grid-column: 2;
	grid-row: 1 / span 2;
}

.recent-fill {
	display: block;
	width: 100%;
	min-width: 0;
	padding: 0;
	border: 0;
	background: none;
	text-align: left;
	cursor: pointer;
}

/* ───────────── narrow screens ───────────── */

@media (max-width: 760px) {
	.app {
		height: auto;
		min-height: 100dvh;
	}

	.bar-top {
		flex-wrap: wrap;
	}

	.redis {
		order: 3;
		flex-basis: 100%;
		margin-right: 0;
	}

	.workspace {
		display: block;
	}

	.queues {
		max-height: 40vh;
		border-right: 0;
		border-bottom: 1px solid var(--rule);
	}

	.queue-view {
		padding: 16px 14px 24px;
	}

	.jobs-table .col-attempts,
	.jobs-table .col-progress {
		display: none;
	}
}
