/* Theme variables */
:root {
	--bg-color: white;
	--text-color: #333;
	--text-secondary: #555;
	--text-muted: #666;
	--border-color: #cecece;
	--border-light: #ddd;
	--bg-subtle: #f5f5f5;
	--bg-word: #fffa;
	--bg-word-correct: #0f04;
	--border-word-correct: #4d4;
	--table-header-bg: #f5f5f5;
	background-color: var(--bg-color);
	color: var(--text-color);
}

[data-theme="dark"] {
	--bg-color: #1a1a1a;
	--text-color: #e0e0e0;
	--text-secondary: #b0b0b0;
	--text-muted: #888;
	--border-color: #444;
	--border-light: #333;
	--bg-subtle: #2a2a2a;
	--bg-word: #3a3a3a;
	--bg-word-correct: #0f06;
	--border-word-correct: #4d4;
	--table-header-bg: #2a2a2a;
	background-color: var(--bg-color);
	color: var(--text-color);
}

body {
	background-color: var(--bg-color);
	color: var(--text-color);
	transition: background-color 0.3s ease, color 0.3s ease;
	margin: 0;
	padding: 0;
}

/* Theme-aware link colors */
a {
	color: rgb(0, 100, 200);
}

a:visited {
	color: rgb(0, 80, 160);
}

[data-theme="dark"] a {
	color: #6eb9ff;
}

[data-theme="dark"] a:visited {
	color: #9dc8ff;
}

.table {
	table-layout: fixed;
	border-collapse: collapse;
	width: 100%;
}

.table td, .table th {
	border: 1px solid var(--border-color);
	padding: 0.3em 0.6em;
	vertical-align: top;
}

.table p {
	margin: 0.3em 0;
}

strong {
	font-weight: 600;
}

.table ol {
	margin: 0.6em 0 0 0;
	padding-left: 1.2em;
}

.table td > em {
	display: block;
	margin-top: 0.6em;
}

.table ol li {
	margin-top: 0.2em;
	margin-bottom: 0.2em;
}

.table small {
	opacity: 0.8;
	margin-left: 1em;
}

.weight-details {
	display: inline-block;
	color: #666;
	font-size: 0.9em;
}

[data-theme="dark"] .weight-details {
	color: #aaa;
}

/* Classification-based indicators */
.indicator-true-positive {
	background-color: #ff02;  /* Light orange - TP but correction not in suggestions */
}
.indicator-tp-first {
	background-color: #0f04;  /* Light green - TP with correction in first position */
}
.indicator-tp-found {
	background-color: #6f03;  /* Light olive - TP with correction found elsewhere */
}
.indicator-false-negative {
	background-color: #f006;  /* Strong red - error word incorrectly classified as correct */
}
.indicator-true-negative {
	background-color: #0f06;  /* Strong green - correct word correctly classified */
}
.indicator-false-positive {
	background-color: #f006;  /* Strong red - correct word incorrectly classified as error */
}
.indicator-default {
	background-color: #ccc3;  /* Gray - fallback */
}

.word {
	display: inline-block;
	padding: 0.2em;
	border: 1px solid var(--border-color);
	background-color: var(--bg-word);
	border-radius: 4px;
}
.word.word-correct {
	background-color: var(--bg-word-correct);
	border-color: var(--border-word-correct);
}
.right {
	text-align: right;
}
.stats-table {
	border-collapse: collapse;
	margin: 0.5em 0;
	font-size: 0.9em;
}
.stats-table th, .stats-table td {
	border: 1px solid var(--border-color);
	padding: 0.25em 0.4em;
}
.stats-table td {
	text-align: right;
}
.stats-table th {
	text-align: left;
	background-color: var(--table-header-bg);
	max-width: 150px;
	word-wrap: break-word;
}
button {
	background-color: #4a90e2;
	color: white;
	border: none;
	padding: 0.5em 1em;
	border-radius: 4px;
	cursor: pointer;
	font-size: 1em;
	margin: 0.5em 0.25em;
}
button:hover {
	background-color: #357abd;
}
[data-theme="dark"] button {
	background-color: #5a9fe2;
}
[data-theme="dark"] button:hover {
	background-color: #4a8fd2;
}
h1 {
	margin-top: 1em;
	font-size: 2em;
	color: var(--text-color);
}
h2 {
	margin-top: 1.5em;
	font-size: 1.3em;
	color: var(--text-secondary);
}
.loading {
	margin-top: 2em;
	font-size: 1.5em;
	color: var(--text-color);
	text-align: center;
	padding: 2em;
}
.error-message {
	margin: 2em auto;
	padding: 2em;
	max-width: 600px;
	background-color: #fee;
	border: 2px solid #c33;
	border-radius: 8px;
	color: #800;
}
.error-message h2 {
	margin-top: 0;
	color: #c33;
}
.error-message pre {
	background-color: #fff;
	padding: 1em;
	border-radius: 4px;
	overflow-x: auto;
	color: #333;
}
.error-message code {
	background-color: #fff;
	padding: 0.2em 0.4em;
	border-radius: 3px;
	color: #333;
}
.container {
	padding: 1.5em;
	max-width: 100%;
}

.config-block {
	background-color: var(--bg-subtle);
	border: 1px solid var(--border-light);
	border-radius: 4px;
	padding: 0.7em;
	margin: 1em 0;
	overflow-x: auto;
	width: fit-content;
	max-width: 100%;
}
.config-block pre {
	margin: 0;
	font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
	font-size: 0.65em;
	line-height: 1.3;
}
.accuracy-stats-container {
	display: flex;
	gap: 1em;
	align-items: flex-start;
}
.accuracy-stats-container > * {
	flex: 1;
}
.metrics-box ul {
	list-style: none;
	padding: 0;
	margin: 0;
}
.metrics-box li {
	margin-bottom: 0.8em;
}
.metrics-box li strong {
	display: inline-block;
	min-width: 6em;
	font-size: 1.05em;
}
.metrics-box li small {
	display: block;
	color: var(--text-muted);
	font-size: 0.85em;
	margin-top: 0.2em;
	margin-left: 0;
	opacity: 1;
}

/* Theme toggle button */
.theme-toggle {
	position: fixed;
	top: 1em;
	right: 1em;
	z-index: 1000;
	background-color: #4a90e2;
	color: white;
	border: none;
	padding: 0.6em 1em;
	border-radius: 4px;
	cursor: pointer;
	font-size: 0.9em;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
	display: flex;
	align-items: center;
	gap: 0.5em;
}

.theme-toggle:hover {
	background-color: #357abd;
}

[data-theme="dark"] .theme-toggle {
	background-color: #5a9fe2;
}

[data-theme="dark"] .theme-toggle:hover {
	background-color: #4a8fd2;
}

.variant-selector {
	position: fixed;
	top: 4.5em;
	right: 1em;
	z-index: 999;
	background-color: var(--bg-subtle);
	border: 1px solid var(--border-light);
	border-radius: 4px;
	padding: 0.6em 0.8em;
	display: flex;
	align-items: center;
	gap: 0.6em;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.variant-selector label {
	font-weight: 600;
	color: var(--text-color);
	font-size: 0.9em;
}

.variant-selector select {
	padding: 0.3em 0.6em;
	border: 1px solid var(--border-color);
	border-radius: 4px;
	background-color: var(--bg-color);
	color: var(--text-color);
	font-size: 0.9em;
	cursor: pointer;
}

.variant-selector select:hover {
	border-color: #4a90e2;
}

.variant-selector select:focus {
	outline: none;
	border-color: #4a90e2;
	box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
	.accuracy-stats-container {
		flex-direction: column;
	}

	.accuracy-stats-container > * {
		width: 100%;
	}

	/* Prevent horizontal scrolling on mobile */
	body {
		overflow-x: hidden;
	}

	.container {
		padding: 0.5em;
	}

	.stats-table {
		font-size: 0.8em;
		display: block;
		overflow-x: auto;
		max-width: 100%;
	}

	.table {
		font-size: 0.85em;
	}

	.table td, .table th {
		padding: 0.2em 0.3em;
		word-break: break-word;
	}

	.config-block {
		font-size: 0.8em;
	}

	h1 {
		font-size: 1.5em;
	}

	h2 {
		font-size: 1.1em;
	}

	.theme-toggle {
		top: 0.5em;
		right: 0.5em;
		padding: 0.5em 0.8em;
		font-size: 0.8em;
	}

	.variant-selector {
		top: 3.5em;
		right: 0.5em;
		padding: 0.5em 0.6em;
		font-size: 0.8em;
	}

	.variant-selector label {
		font-size: 0.85em;
	}

	.variant-selector select {
		font-size: 0.85em;
		padding: 0.3em 0.5em;
	}
}
