/*
	`--nav-background-color` and `--text-color` resolve to the same colour in
	the light theme (both #464b51), so a control painted with one on the other
	rendered as an unreadable black-on-black block. Content surfaces here use
	`--foreground-color`, which is the token that is defined to contrast with
	`--text-color` in both themes.
*/

/*
	The table was capped at a fixed `calc(100vh - …)`, and every child of <main>
	was separately made an equal-height scroll pane by general.css -- so the
	toolbar, the table and the pager each claimed a third of the screen and the
	log itself came out as a sliver of rows with blank space around it. The page
	is a document now (see `.page-flow`): the table is as tall as the rows on
	the page, and the page scrolls.
*/
main {
	padding: 1rem;
	color: var(--text-color);
}

main > * + * {
	margin-top: .75rem;
}

.logs-toolbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
	flex-wrap: wrap;
}

.logs-actions,
.logs-filters {
	display: flex;
	align-items: center;
	gap: .5rem;
	flex-wrap: wrap;
}

.logs-filters label {
	display: flex;
	align-items: center;
	gap: .4rem;
	font-size: .85rem;
	white-space: nowrap;
}

.logs-toolbar :where(button, select, a) {
	min-height: 2.3rem;
	border: 1px solid var(--border-color);
	border-radius: 4px;
	padding: .45rem .65rem;
	font: inherit;
	background: var(--foreground-color);
	color: var(--text-color);
	cursor: pointer;
}

.logs-actions #refresh-logs {
	background: var(--accent-color);
	/* The accent is the same yellow in both themes, so its ink is the one the
	   header already uses on it rather than a theme-flipping token. */
	color: var(--header-color);
	font-weight: 600;
}

.logs-toolbar a {
	display: inline-flex;
	align-items: center;
	text-decoration: none;
}

.logs-toolbar :where(button, a):hover {
	border-color: var(--accent-color);
}

.logs-toolbar button:disabled {
	opacity: .55;
	cursor: default;
}

.logs-table-wrap {
	/* Only sideways. A long message must not be able to force the page wide,
	   but the list of entries is the page and scrolls with it. */
	overflow-x: auto;
	border: 1px solid var(--border-color);
	border-radius: 4px;
	background: var(--foreground-color);
}

.logs-table {
	width: 100%;
	border-collapse: collapse;
	font-size: .85rem;
}

.logs-table th {
	position: sticky;
	top: 0;
	z-index: 1;
	padding: .55rem .6rem;
	background: var(--foreground-color);
	border-bottom: 1px solid var(--border-color);
	text-align: left;
}

.logs-table td {
	vertical-align: top;
	padding: .45rem .6rem;
	border-bottom: 1px solid var(--border-color);
}

.logs-table tr:last-child td {
	border-bottom: 0;
}

.log-col-time,
.log-time {
	width: 1%;
	white-space: nowrap;
}

.log-col-level,
.log-level {
	width: 1%;
	white-space: nowrap;
}

.log-summary {
	display: flex;
	align-items: baseline;
	gap: .5rem;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	color: inherit;
	text-align: left;
	overflow-wrap: anywhere;
}

.log-expand {
	cursor: pointer;
}

.log-expand:hover .log-chevron,
.log-expand:focus-visible .log-chevron {
	color: var(--accent-color);
}

.log-chevron {
	flex-shrink: 0;
	width: .9rem;
	color: var(--dimmed-text-color);
}

/* Aligns a summary with no chevron against the ones that have one. */
p.log-summary {
	padding-left: 1.4rem;
}

.log-detail-count {
	flex-shrink: 0;
	margin-left: auto;
	padding: .05rem .4rem;
	border: 1px solid var(--border-color);
	border-radius: 999px;
	font-size: .75rem;
	white-space: nowrap;
	color: var(--dimmed-text-color);
}

.log-details {
	margin: .5rem 0 .25rem 1.4rem;
	padding: .6rem .75rem;
	border-left: 2px solid var(--border-color);
	border-radius: 0 4px 4px 0;
	background: var(--background-color);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: .8rem;
	line-height: 1.45;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.log-level-badge {
	display: inline-block;
	min-width: 4.5rem;
	padding: .1rem .4rem;
	border-radius: 3px;
	background: var(--border-color);
	color: var(--text-color);
	font-size: .7rem;
	font-weight: 700;
	letter-spacing: .04em;
	text-align: center;
	text-transform: uppercase;
}

.log-warning .log-level-badge {
	background: var(--accent-color);
	color: var(--header-color);
}

.log-error .log-level-badge,
.log-critical .log-level-badge {
	background: var(--error-color);
	color: #fff;
}

.log-error .log-details,
.log-critical .log-details {
	border-left-color: var(--error-color);
}

.log-debug .log-level-badge {
	opacity: .75;
}

#logs-empty {
	padding: 2rem;
	text-align: center;
}

.logs-pagination {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
}

#logs-status {
	margin: 0;
	font-size: .85rem;
	color: var(--dimmed-text-color);
}

.logs-page-buttons {
	display: flex;
	align-items: center;
	gap: .4rem;
}

.logs-page-buttons button {
	min-width: 2.3rem;
	min-height: 2.3rem;
	border: 1px solid var(--border-color);
	border-radius: 4px;
	background: var(--foreground-color);
	color: var(--text-color);
	font: inherit;
	cursor: pointer;
}

.logs-page-buttons button:hover:not(:disabled) {
	border-color: var(--accent-color);
}

.logs-page-buttons button:disabled {
	opacity: .45;
	cursor: default;
}

#log-page-label {
	padding: 0 .5rem;
	font-size: .85rem;
	white-space: nowrap;
}

@media (max-width: 800px) {
	.logs-toolbar {
		align-items: stretch;
		flex-direction: column;
	}

	.logs-actions > * {
		flex: 1;
		justify-content: center;
	}

	.logs-pagination {
		justify-content: center;
	}
}
