/* ===========================================================================
   Design-Tokens
   =========================================================================== */
:root {
	--bg: #16161A;
	--bg-elev: #1F1F23;
	--bg-elev-2: #2A2A30;
	--surface: #1B1B1E;
	--border: #2E2E34;
	--border-soft: #232328;

	--text: #E5E3DA;
	--text-dim: #A6A39A;
	--text-faint: #6E6C66;

	--accent: #7F77DD;
	/* Lila wie die Knoten */
	--accent-2: #1D9E75;
	/* Teal fuer Aktionen */
	--warn: #EF9F27;
	/* Orange fuer Highlights */
	--err: #E24B4A;
	--ok: #97C459;

	--radius: 6px;
	--radius-sm: 4px;
	--shadow-pop: 0 8px 28px rgba(0, 0, 0, .45);
	--mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
	--sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family: var(--sans);
	font-size: 14px;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}


/* ===========================================================================
   Grid-Layout
   =========================================================================== */
.app {
	display: grid;
	grid-template-columns: 350px 1fr;
	grid-template-rows: 48px 1fr 220px;
	grid-template-areas:
		"header header"
		"sidebar main"
		"status  status";
	height: 100vh;
}

header.topbar {
	grid-area: header;
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 0 16px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

header.topbar h1 {
	font-size: 15px;
	font-weight: 600;
	margin: 0;
	letter-spacing: 0.3px;
}

header.topbar h1 .brand {
	color: var(--accent);
}

header.topbar .meta {
	margin-left: auto;
	display: flex;
	gap: 14px;
	align-items: center;
	font-size: 12px;
	color: var(--text-dim);
}

#graph-name {
	color: var(--text);
	font-weight: 500;
}

.clean {
	color: var(--text-faint);
}

.dirty {
	color: var(--warn);
}


aside.sidebar {
	grid-area: sidebar;
	background: var(--surface);
	border-right: 1px solid var(--border);
	overflow-y: auto;
	padding: 16px;
}

.section {
	margin-bottom: 22px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.section:last-child {
	margin-bottom: 0;
}

.section h2 {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.8px;
	color: var(--text-faint);
	margin: 0 0 2px 0;
}

.section .row {
	display: flex;
	gap: 8px;
}

.section .row>* {
	flex: 1;
	min-width: 0;
}

.section .row.tight>.grow-2 {
	flex: 2;
}

/* Hint-Box unter dem Ausfuehren-Button */
.algo-hint {
	margin-top: 4px;
	padding: 8px 10px;
	font-size: 11.5px;
	line-height: 1.4;
	color: var(--text-faint);
	background: transparent;
	border-radius: var(--radius-sm);
	border: 1px dashed var(--border);
	min-height: 1em;
	font-family: var(--mono);
	transition: border-color 150ms, background-color 150ms, color 150ms;
}

.algo-hint:empty {
	visibility: hidden;
}

.algo-hint.active {
	color: var(--accent-2);
	border-color: var(--accent-2);
	border-style: solid;
	background: rgba(29, 158, 117, 0.08);
}

.algo-hint.active strong {
	color: var(--text);
	font-weight: 600;
}


main.canvas {
	grid-area: main;
	position: relative;
	background: var(--bg);
	overflow: hidden;
}

#cy {
	position: absolute;
	inset: 0;
}

/* ===========================================================================
   Schwebende Canvas-Toolbar (oben mittig)
   =========================================================================== */
.canvas-toolbar {
	position: absolute;
	top: 12px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 10;
	display: flex;
	gap: 8px;
	align-items: stretch;
	padding: 6px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-pop);
}

/* Bootstrap-artige Input-Group: gemeinsame Border zwischen den Items */
.btn-group {
	display: inline-flex;
	align-items: stretch;
}

.btn-group>* {
	border-radius: 0;
	margin: 0;
}

.btn-group>*:not(:first-child) {
	border-left: none;
}

.btn-group>*:first-child {
	border-top-left-radius: var(--radius-sm);
	border-bottom-left-radius: var(--radius-sm);
}

.btn-group>*:last-child {
	border-top-right-radius: var(--radius-sm);
	border-bottom-right-radius: var(--radius-sm);
}

/* Segmented Control: zwei Modus-Buttons, der aktive ist hervorgehoben */
.mode-switch .mode-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 14px;
	font-size: 13px;
	color: var(--text-dim);
	background: var(--bg-elev);
	border-color: var(--border);
}

.mode-switch .mode-btn:hover {
	color: var(--text);
	background: var(--bg-elev-2);
	border-color: var(--border);
}

.mode-switch .mode-btn .mode-icon {
	display: inline-block;
	width: 14px;
	text-align: center;
	font-weight: 700;
	color: var(--text-faint);
	transition: color 150ms;
}

.mode-switch .mode-btn.active {
	background: var(--accent-2);
	border-color: var(--accent-2);
	color: #fff;
	font-weight: 500;
	cursor: default;
}

.mode-switch .mode-btn.active .mode-icon {
	color: #fff;
}

/* Input-Group-Addon mit Checkbox (an die Bootstrap-Optik angelehnt) */
.input-group-text {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 6px;
	margin-bottom: 0;
	padding: 0 12px;
	background: var(--bg-elev);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	color: var(--text);
	font-size: 13px;
	cursor: pointer;
	user-select: none;
	transition: opacity 150ms, color 150ms;
	white-space: nowrap;
}

.input-group-text input[type="checkbox"] {
	margin: 0;
}

/* Checkbox-Addon ausgrauen, solange der Kanten-Modus nicht aktiv ist. */
.canvas-toolbar:not(.edge-mode) .input-group-text {
	opacity: 0.45;
	pointer-events: none;
	color: var(--text-faint);
}

/* Details-Overlay (z.B. Floyd-Warshall-Matrix) */
#details {
	position: absolute;
	right: 12px;
	top: 70px;
	max-width: 60%;
	max-height: 70%;
	overflow: auto;
	background: var(--bg-elev);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 10px;
	box-shadow: var(--shadow-pop);
	font-family: var(--mono);
	font-size: 12px;
}

#details:empty {
	display: none;
}

table.matrix {
	border-collapse: collapse;
}

table.matrix th,
table.matrix td {
	padding: 4px 9px;
	text-align: right;
	border-bottom: 1px solid var(--border-soft);
}

table.matrix th {
	color: var(--text-dim);
	font-weight: 500;
}

table.matrix tbody th {
	text-align: left;
	color: var(--accent);
}


footer.status {
	grid-area: status;
	background: var(--bg-elev);
	border-top: 1px solid var(--border);
	font-family: var(--mono);
	font-size: 12px;
	color: var(--text-dim);
	overflow-y: auto;
	padding: 6px 14px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

footer.status .entry {
	padding: 4px 0;
	border-bottom: 1px solid var(--border-soft);
	white-space: pre-wrap;
	word-break: break-word;
	display: flex;
	align-items: baseline;
	gap: 12px;
	color: var(--text-dim);
}

footer.status .entry:last-child {
	border-bottom: none;
}

footer.status .entry .ts {
	color: var(--text-faint);
	flex: 0 0 auto;
	font-variant-numeric: tabular-nums;
}

footer.status .entry .msg {
	flex: 1;
}

footer.status .entry.ok {
	color: var(--ok);
}

footer.status .entry.ok .ts {
	color: var(--ok);
	opacity: 0.55;
}

footer.status .entry.error {
	color: var(--err);
}

footer.status .entry.error .ts {
	color: var(--err);
	opacity: 0.55;
}

/* Scrollbar in der Konsole dezent stylen */
footer.status::-webkit-scrollbar {
	width: 8px;
}

footer.status::-webkit-scrollbar-track {
	background: transparent;
}

footer.status::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 4px;
}

footer.status::-webkit-scrollbar-thumb:hover {
	background: var(--bg-elev-2);
}


/* ===========================================================================
   Form-Elemente
   =========================================================================== */
button,
select,
input[type="text"],
input[type="number"],
input[type="file"] {
	background: var(--bg-elev);
	border: 1px solid var(--border);
	color: var(--text);
	padding: 6px 10px;
	border-radius: var(--radius-sm);
	font-family: inherit;
	font-size: 13px;
	outline: none;
	transition: border-color 120ms, background 120ms;
}

button {
	cursor: pointer;
	background: var(--bg-elev-2);
}

button:hover,
select:hover {
	border-color: var(--accent);
}

button:active {
	transform: translateY(1px);
}

button.primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
	font-weight: 500;
}

button.primary:hover {
	filter: brightness(1.08);
}

button.danger {
	background: transparent;
	border-color: var(--err);
	color: var(--err);
}

button.danger:hover {
	background: rgba(226, 75, 74, .1);
}

button.active {
	background: var(--accent-2);
	border-color: var(--accent-2);
	color: #fff;
}

button:disabled,
select:disabled,
input:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

select {
	width: 100%;
}

input[type="file"] {
	display: none;
}

label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 12px;
	color: var(--text-dim);
	margin-bottom: 8px;
}

label input {
	color: var(--text);
}

label.inline {
	flex-direction: row;
	align-items: center;
	gap: 8px;
}

input[type="checkbox"] {
	accent-color: var(--accent);
}


/* ===========================================================================
   Dialog
   =========================================================================== */
dialog {
	background: var(--bg-elev);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 0;
	color: var(--text);
	min-width: 340px;
	max-width: 90vw;
	box-shadow: var(--shadow-pop);
}

dialog::backdrop {
	background: rgba(0, 0, 0, 0.55);
	backdrop-filter: blur(2px);
}

.dlg-head {
	padding: 12px 16px;
	border-bottom: 1px solid var(--border);
	font-weight: 600;
	font-size: 14px;
}

.dlg-body {
	padding: 16px;
}

.dlg-body label {
	display: grid;
	grid-template-columns: 80px 1fr;
	align-items: center;
	gap: 10px;
	margin-bottom: 10px;
}

.dlg-foot {
	padding: 12px 16px;
	border-top: 1px solid var(--border);
	display: flex;
	gap: 8px;
	justify-content: flex-end;
}


/* ===========================================================================
   Icon-Buttons (mit SVG vor dem Text)
   =========================================================================== */
.btn-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
}

.btn-svg {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
	color: var(--accent);
	transition: color 120ms;
}

.btn-icon:hover .btn-svg {
	color: var(--text);
}

/* In primary-Buttons soll das Icon mit dem Text mitziehen (weiss) */
.btn-icon.primary .btn-svg,
.btn-icon.primary:hover .btn-svg {
	color: currentColor;
}

/* Kleiner gedimmter Hilfstext */
.help-content .dim.small {
	font-size: 11.5px;
	color: var(--text-faint);
	margin-top: 8px;
}


/* ===========================================================================
   Breite Dialog-Variante (Anleitung, Doku)
   =========================================================================== */
dialog.wide {
	width: min(800px, 92vw);
}

.help-content {
	max-height: 70vh;
	overflow-y: auto;
}

.help-content h3 {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.6px;
	color: var(--accent);
	margin: 18px 0 6px 0;
}

.help-content h3:first-child {
	margin-top: 0;
}

.help-content p {
	margin: 0 0 10px 0;
	line-height: 1.55;
	color: var(--text-dim);
}

.help-content ul {
	margin: 0 0 10px 0;
	padding-left: 20px;
	color: var(--text-dim);
}

.help-content li {
	margin: 4px 0;
	line-height: 1.5;
}

.help-content strong {
	color: var(--text);
	font-weight: 600;
}

.help-content code {
	font-family: var(--mono);
	font-size: 12px;
	padding: 1px 5px;
	background: var(--bg);
	border-radius: 3px;
	color: var(--text);
}

.help-content pre {
	margin: 6px 0 12px 0;
	padding: 10px 12px;
	background: var(--bg);
	border: 1px solid var(--border-soft);
	border-radius: var(--radius-sm);
	font-family: var(--mono);
	font-size: 11.5px;
	line-height: 1.55;
	color: var(--text-dim);
	overflow-x: auto;
	white-space: pre;
}

.help-content pre code {
	padding: 0;
	background: transparent;
	font-size: inherit;
	color: inherit;
}

.help-content table {
	width: 100%;
	border-collapse: collapse;
	margin: 6px 0 12px 0;
	font-size: 12px;
}

.help-content thead th {
	text-align: left;
	padding: 6px 10px;
	color: var(--text-dim);
	font-weight: 600;
	border-bottom: 1px solid var(--border);
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.4px;
}

.help-content tbody td {
	padding: 6px 10px;
	border-bottom: 1px solid var(--border-soft);
	color: var(--text-dim);
	vertical-align: top;
}

.help-content tbody tr:last-child td {
	border-bottom: none;
}

.help-content tbody td:first-child {
	color: var(--text);
	font-weight: 500;
}

.help-content kbd {
	display: inline-block;
	padding: 1px 6px;
	background: var(--bg-elev-2);
	border: 1px solid var(--border);
	border-bottom-width: 2px;
	border-radius: 3px;
	font-family: var(--mono);
	font-size: 11px;
	color: var(--text);
	margin: 0 1px;
	vertical-align: baseline;
}

.help-content::-webkit-scrollbar {
	width: 8px;
}

.help-content::-webkit-scrollbar-track {
	background: transparent;
}

.help-content::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 4px;
}

.help-content::-webkit-scrollbar-thumb:hover {
	background: var(--bg-elev-2);
}