/*
 * The operations panel's own styles.
 *
 * A file rather than a `<style>` block, so the browser caches it and a
 * reviewer finds it. Every colour is one of Unfold's variables, so the panel
 * follows the admin's theme, dark mode included. Class names are `ops-*`:
 * Unfold ships a prebuilt Tailwind, so a utility class it does not already use
 * would silently do nothing here.
 */

.ops {
	/* Amber, which Unfold's palette does not ship: a warning is not orange,
	 * because orange is a source refusing us. */
	--ops-warn: oklch(76.9% 0.188 70.08);
	--ops-warn-ink: oklch(55.5% 0.163 48.998);
	--ops-line: var(--color-base-200);
	--ops-soft: var(--color-base-100);
	--ops-surface: #fff;
	--ops-ink: var(--color-font-default-light);
	--ops-strong: var(--color-font-important-light);
	--ops-muted: var(--color-font-subtle-light);
	--ops-accent: var(--color-primary-600);
	display: flex;
	flex-direction: column;
	gap: 20px;
	color: var(--ops-ink);
	font-size: 14px;
}

.dark .ops {
	--ops-warn-ink: oklch(82.8% 0.189 84.429);
	--ops-line: var(--color-base-800);
	--ops-soft: var(--color-base-800);
	--ops-surface: var(--color-base-900);
	--ops-ink: var(--color-font-default-dark);
	--ops-strong: var(--color-font-important-dark);
	--ops-muted: var(--color-font-subtle-dark);
	--ops-accent: var(--color-primary-400);
}

/* The heading and the live switch ------------------------------------- */

.ops-top {
	display: flex;
	flex-wrap: wrap;
	gap: 12px 20px;
	align-items: center;
	justify-content: space-between;
	border-bottom: 1px solid var(--ops-line);
}

/* The tabs: the overview and the two sections. Underlined rather than
 * segmented, so they read as where you are and not as a filter on it. */
.ops-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	align-self: flex-end;
}

.ops-tab {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-bottom: -1px;
	padding: 8px 12px;
	border-bottom: 2px solid transparent;
	font-size: 14px;
	font-weight: 500;
	color: var(--ops-muted);
	text-decoration: none;
	white-space: nowrap;
}

.ops-tab .material-symbols-outlined {
	font-size: 18px;
}

.ops-tab:hover {
	color: var(--ops-strong);
}

.ops-tab[aria-current] {
	border-bottom-color: var(--ops-accent);
	color: var(--ops-strong);
	font-weight: 600;
}

.ops-description {
	margin: 0;
	max-width: 80ch;
	font-size: 13px;
	color: var(--ops-muted);
}

.ops-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	padding-bottom: 8px;
}

.ops-seg {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 2px;
	padding: 2px;
	border-radius: 7px;
	background: var(--ops-soft);
}

.ops-seg a {
	border: 0;
	background: none;
	padding: 4px 10px;
	border-radius: 5px;
	font-size: 12.5px;
	color: var(--ops-muted);
	cursor: pointer;
	white-space: nowrap;
	text-decoration: none;
}

.ops-seg a:hover {
	color: var(--ops-strong);
}

.ops-seg [aria-current] {
	background: var(--ops-surface);
	color: var(--ops-strong);
	font-weight: 600;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.ops-button {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--ops-line);
	background: var(--ops-surface);
	color: var(--ops-strong);
	border-radius: 6px;
	padding: 5px 12px;
	font-size: 12.5px;
	cursor: pointer;
	text-decoration: none;
}

.ops-live {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	border: 0;
	background: none;
	color: var(--ops-muted);
	font-size: 12.5px;
	cursor: pointer;
	font-variant-numeric: tabular-nums;
}

.ops-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--color-green-500);
}

.ops-live.off .ops-dot {
	background: var(--color-base-400);
}

/* The screen ----------------------------------------------------------- */

/* The last card stops short of the window's edge, like the cards between. */
.ops-body {
	display: flex;
	flex-direction: column;
	gap: 24px;
	padding-bottom: 32px;
}

/* What a refresh puts back; it takes no room of its own. */
.ops-block {
	display: contents;
}

/* Sections -------------------------------------------------------------- */

.ops-section-head {
	margin-bottom: 10px;
}

.ops-section-head h2 {
	margin: 0;
	font-size: 14px;
	font-weight: 600;
	color: var(--ops-strong);
}

/* On the overview a card's title opens its tab. */
.ops-section-head a {
	color: inherit;
	text-decoration: none;
}

.ops-section-head a:hover {
	color: var(--ops-accent);
}

/* Blocks inside one card — a note over a table, a summary over a chart —
 * are spaced like lines of a paragraph, not run together. */
.ops-panel,
.ops-timeline {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* A card: a section's panel, the overview's status and each of its figures. */
.ops-panel,
.ops-status,
.ops-figure {
	background: var(--ops-surface);
	border: 1px solid var(--ops-line);
	border-radius: 10px;
	min-width: 0;
}

.ops-panel {
	padding: 16px;
}

/* Two cards to a row on the overview; one when the screen is narrow. */
.ops-columns {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 20px 16px;
}

@media (max-width: 1000px) {
	.ops-columns {
		grid-template-columns: minmax(0, 1fr);
	}
}

.ops-chart {
	position: relative;
	width: 100%;
	height: var(--chart-height, 240px);
}

/* Half a row wide, so shorter than on its tab. */
.ops-columns .ops-chart {
	height: 170px;
}

.ops-chart.chart-failed::after {
	content: "This chart could not be drawn.";
	color: var(--ops-muted);
}

/* The crawler's switches: its state and its own switch across the top, a
 * row per Product under them, each with a switch at its end. */
.ops-control {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.ops-control-head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.ops-control-state {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.ops-control-headline {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	color: var(--ops-strong);
}

.ops-control-headline .ops-dot-pausing,
.ops-control-headline .ops-dot-paused {
	background: var(--color-orange-500);
}

.ops-control-headline .ops-dot-stopped {
	background: var(--color-red-500);
}

.ops-control-warn {
	color: var(--color-red-600);
}

.ops-switch-form {
	margin: 0;
}

.ops-button .material-symbols-outlined {
	font-size: 18px;
	margin-right: 4px;
}

.ops-button-stop {
	border-color: var(--color-orange-500);
	color: var(--color-orange-600);
}

.ops-button-go {
	border-color: var(--color-green-600);
	background: var(--color-green-600);
	color: #fff;
}

.ops-button:disabled,
.ops-switch:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.ops-control-cell {
	width: 1%;
	text-align: right;
}

.ops-switch {
	position: relative;
	width: 34px;
	height: 20px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: var(--color-base-300);
	cursor: pointer;
	transition: background 0.15s;
}

.ops-switch[aria-checked="true"] {
	background: var(--color-green-600);
}

.ops-switch-knob {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	transition: transform 0.15s;
}

.ops-switch[aria-checked="true"] .ops-switch-knob {
	transform: translateX(14px);
}

.dark .ops-switch {
	background: var(--color-base-700);
}

.ops-table .ops-status-paused {
	color: var(--color-orange-600);
}

/* The crawler's last hour: a line on what runs now, and a lane per kind of
 * work. Its height follows its lanes, set by timeline.js, and moves only when
 * a lane comes or goes. */
.ops-timeline-summary {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 4px 16px;
	font-variant-numeric: tabular-nums;
}

.ops-timeline-now {
	margin: 0;
	font-size: 13px;
	color: var(--ops-strong);
}

.ops-timeline-chart {
	height: var(--chart-height, 160px);
}

/* The overview -------------------------------------------------------- */

/* Now and what needs attention: the crawler on the left, the findings on the
 * right; one column on a narrow screen. */
.ops-status {
	display: grid;
	grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr);
	overflow: hidden;
}

@media (max-width: 1000px) {
	.ops-status {
		grid-template-columns: minmax(0, 1fr);
	}
}

.ops-status-now,
.ops-status-findings {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 16px;
	min-width: 0;
}

.ops-status-now {
	border-right: 1px solid var(--ops-line);
}

.ops-status-now p,
.ops-finding p,
.ops-figure p {
	margin: 0;
}

.ops-status-findings h2 {
	margin: 0 0 2px;
	font-size: 14px;
	font-weight: 600;
	color: var(--ops-strong);
}

.ops-finding {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 8px 10px;
	border-radius: 8px;
	font-size: 13px;
}

.ops-finding > div {
	flex: 1;
	min-width: 0;
}

.ops-finding-title {
	font-weight: 600;
	color: var(--ops-strong);
}

.ops-finding a {
	white-space: nowrap;
	font-size: 12.5px;
	color: var(--ops-accent);
	text-decoration: none;
}

.ops-finding .material-symbols-outlined {
	font-size: 18px;
}

.ops-finding-fail {
	background: color-mix(in srgb, var(--color-red-500) 10%, transparent);
}

.ops-finding-fail .material-symbols-outlined {
	color: var(--color-red-600);
}

.ops-finding-warn {
	background: color-mix(in srgb, var(--ops-warn) 16%, transparent);
}

.ops-finding-warn .material-symbols-outlined {
	color: var(--ops-warn-ink);
}

.ops-finding-fine {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin: 2px 0 0;
	font-size: 12.5px;
	color: var(--ops-muted);
}

.ops-finding-fine .material-symbols-outlined {
	font-size: 16px;
	color: var(--color-green-600);
}

/* The figures: a tile each, as many to a row as fit. */
.ops-figures {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 12px;
}

.ops-figure {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 14px 16px;
}

.ops-figure-label {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12.5px;
	color: var(--ops-muted);
}

.ops-figure-label .material-symbols-outlined {
	font-size: 16px;
}

.ops-figure-value {
	font-size: 24px;
	font-weight: 600;
	color: var(--ops-strong);
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.01em;
}

.ops-figure-value small {
	font-size: 13px;
	font-weight: 500;
	color: var(--ops-muted);
}

.ops-figure-fail .ops-figure-value {
	color: var(--color-red-600);
}

/* A bar split into parts; the rest of it empty. */
.ops-meter-wrap {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ops-meter {
	display: flex;
	height: 18px;
	border-radius: 6px;
	overflow: hidden;
	background: var(--ops-soft);
}

/* Under a figure, and a backfill's progress: a thin rule rather than a bar. */
.ops-figure .ops-meter,
.ops-progress-bar {
	display: flex;
	height: 6px;
	border-radius: 3px;
	overflow: hidden;
	background: var(--ops-soft);
}

.ops-meter i {
	display: block;
	height: 100%;
}

/* Table cells that are not text: a progress bar, a spark of bars. */
.ops-progress {
	min-width: 170px;
}

.ops-progress-bar i {
	display: block;
	height: 100%;
	border-radius: 3px;
	background: var(--ops-accent);
}

.ops-progress-bar i.done {
	background: var(--color-green-600);
}

.ops-progress-text {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	margin-top: 3px;
	font-size: 11.5px;
	color: var(--ops-muted);
	white-space: nowrap;
}

.ops-spark {
	display: inline-flex;
	align-items: flex-end;
	gap: 2px;
	height: 22px;
	min-width: 110px;
}

.ops-spark i {
	display: block;
	width: 6px;
	min-height: 1px;
	border-radius: 1px;
	background: var(--spark);
}

.ops-spark i.none {
	background: var(--ops-line);
}

/* Notes and banners ----------------------------------------------------- */

.ops-note {
	margin: 0;
	font-size: 12.5px;
	color: var(--ops-muted);
}

/* The crawler's tasks on the Crawler tab: one row per task, the newest
 * first. A failed one says so in red, a running one in the primary colour;
 * the error, when there is one, sits under its row in full. */
.ops-table-wrap {
	overflow-x: auto;
}

.ops-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

.ops-table th {
	text-align: left;
	font-weight: 600;
	color: var(--ops-muted);
	padding: 6px 12px 6px 0;
	white-space: nowrap;
}

.ops-table td {
	padding: 6px 12px 6px 0;
	border-top: 1px solid var(--ops-line);
	vertical-align: top;
	font-variant-numeric: tabular-nums;
}

.ops-table td.mono {
	font-family: var(--font-mono, ui-monospace, monospace);
	overflow-wrap: anywhere;
}

.ops-table .ops-status-failed {
	color: var(--color-red-600);
	font-weight: 600;
}

.ops-table .ops-status-running {
	color: var(--color-primary-600);
	font-weight: 600;
}

/* Where a request's answer came from, on the Requests tab: ktMINE in its
 * chart colour, what went wrong in the status colours, a miss muted. */
.ops-table .ops-status-ktmine,
.ops-table .ops-status-direct {
	color: #e8793f;
	font-weight: 600;
}

.ops-table .ops-status-spent {
	color: var(--color-orange-600);
	font-weight: 600;
}

.ops-table .ops-status-unreachable {
	color: var(--color-red-600);
	font-weight: 600;
}

.ops-table .ops-status-nobody {
	color: var(--ops-muted);
}

.ops-filters {
	margin-bottom: 12px;
	flex-wrap: wrap;
}

.ops-table .ops-error {
	color: var(--ops-muted);
	font-size: 12px;
	overflow-wrap: anywhere;
}

/* A row that is a record, or stands for some: the whole row opens it. */
.ops-row-link {
	cursor: pointer;
}

.ops-row-link:hover td {
	background: var(--ops-line);
}

.ops-row-link a {
	color: inherit;
	text-decoration: none;
}

.ops-row-link:hover a {
	text-decoration: underline;
}

/* A satellite list in the sidebar — a patent's parties under Patents — set in
 * under the list it hangs off, behind a rule, so a subject reads as one
 * document and what belongs to it. The id outranks Unfold's `-mx-3 px-3`.
 * The rule runs under the centre of the document's icon and the title lines
 * up with the document's. Unfold's inset cancels out; its icon (`w-[18px]`)
 * and gap (`mr-3`) do not, so an upgrade that moves them is one place to
 * follow. */
#nav-sidebar-apps {
	--nav-icon: 18px;
	--nav-gap: 12px;
	--nav-nested-rule: var(--color-base-200);
	--nav-nested-ink: var(--color-font-subtle-light);
	--nav-nested-accent: var(--color-primary-600);
}

.dark #nav-sidebar-apps {
	--nav-nested-rule: var(--color-base-800);
	--nav-nested-ink: var(--color-font-subtle-dark);
	--nav-nested-accent: var(--color-primary-500);
}

#nav-sidebar-apps a[data-nav-nested] {
	height: 30px;
	margin-left: calc(var(--nav-icon) / 2);
	padding-left: calc(var(--nav-icon) / 2 + var(--nav-gap) - 1px);
	border-left: 1px solid var(--nav-nested-rule);
	border-radius: 0 var(--border-radius, 6px) var(--border-radius, 6px) 0;
	font-size: 13px;
	color: var(--nav-nested-ink);
}

#nav-sidebar-apps a[data-nav-nested].active,
#nav-sidebar-apps a[data-nav-nested]:hover {
	color: var(--nav-nested-accent);
}

/* The active satellite takes the accent on its stretch of the rule too. */
#nav-sidebar-apps a[data-nav-nested].active {
	border-left-color: var(--nav-nested-accent);
}

/* A little air above the next subject, after the last of a document's
 * satellites, so five subjects read as five blocks. */
#nav-sidebar-apps li:has(> a[data-nav-nested]) + li:has(> a:not([data-nav-nested])) {
	margin-top: 6px;
}
