/* DC360 Flowcharts - front-end styling */

.dc360-editor,
.dc360-flowcharts-page {
	--dc360-primary: #2f6fed;
	--dc360-primary-dark: #1f4fb8;
	--dc360-danger: #d64545;
	--dc360-ink: #1f2733;
	--dc360-muted: #6b7686;
	--dc360-border: #d7dce3;
	--dc360-bg: #f6f8fb;
	--dc360-card-bg: #ffffff;
	color: var(--dc360-ink);
	font-size: 15px;
}

.dc360-editor * ,
.dc360-flowcharts-page * {
	box-sizing: border-box;
}

.visually-hidden {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* Buttons */

.dc360-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	padding: 0.5em 0.9em;
	border: 1px solid var(--dc360-border);
	border-radius: 8px;
	background: #fff;
	color: var(--dc360-ink);
	font-size: 0.95em;
	cursor: pointer;
	text-decoration: none;
	line-height: 1.2;
}

.dc360-btn:hover {
	border-color: var(--dc360-primary);
	color: var(--dc360-primary-dark);
}

.dc360-btn-primary {
	background: var(--dc360-primary);
	border-color: var(--dc360-primary);
	color: #fff;
}

.dc360-btn-primary:hover {
	background: var(--dc360-primary-dark);
	border-color: var(--dc360-primary-dark);
	color: #fff;
}

.dc360-btn-danger {
	color: var(--dc360-danger);
	border-color: #f0c4c4;
}

.dc360-btn-danger:hover {
	background: var(--dc360-danger);
	border-color: var(--dc360-danger);
	color: #fff;
}

.dc360-btn-small {
	padding: 0.3em 0.6em;
	font-size: 0.85em;
}

.dc360-upload-label input {
	display: none;
}

/* Toolbar */

.dc360-editor {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.dc360-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.6rem 0.8rem;
	background: var(--dc360-card-bg);
	border: 1px solid var(--dc360-border);
	border-radius: 10px;
}

.dc360-toolbar-title input {
	font-size: 1.1em;
	font-weight: 600;
	padding: 0.4em 0.6em;
	border: 1px solid transparent;
	border-radius: 6px;
	min-width: 220px;
}

.dc360-toolbar-title input:hover,
.dc360-toolbar-title input:focus {
	border-color: var(--dc360-border);
	background: var(--dc360-bg);
}

.dc360-toolbar-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
}

.dc360-guest-note {
	color: var(--dc360-muted);
	font-size: 0.9em;
	font-style: italic;
}

/* Mode select (Flowcharts only / Flowcharts + Python) - a dropdown rather
   than a segmented toggle so it stays compact in the toolbar; the mode
   itself and how it's applied (CSS class on the editor root) are unchanged
   from the original toggle, only the control that sets it is different. */

.dc360-mode-select-wrap {
	display: inline-flex;
}

.dc360-mode-select {
	padding: 0.45em 1.8em 0.45em 0.7em;
	border: 1px solid var(--dc360-border);
	border-radius: 8px;
	background: #fff;
	color: var(--dc360-ink);
	font-size: 0.9em;
	line-height: 1.2;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23555' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.6em center;
	background-size: 10px 7px;
}

.dc360-mode-select:hover {
	background-color: var(--dc360-bg);
}

.dc360-mode-select:focus-visible {
	outline: 2px solid var(--dc360-primary);
	outline-offset: 1px;
}

/* Mode 1: "Flowcharts only" - hide the Python panel, Download Python, and
   the While/For/Call palette items. Nothing here touches the underlying
   flowchart data: a saved flowchart that already uses those block types
   (built while in "Flowcharts + Python" mode) still renders and can still
   be edited normally - only *adding new* While/For/Call blocks, and any
   view of the generated Python, is hidden. */

.dc360-editor.dc360-mode-flowcharts-only .dc360-python-only {
	display: none !important;
}

.dc360-editor.dc360-mode-flowcharts-only .dc360-pane-python {
	display: none;
}

.dc360-editor.dc360-mode-flowcharts-only .dc360-panes {
	grid-template-columns: 1fr;
}

.dc360-status {
	min-height: 1.6em;
	padding: 0 0.2rem;
	color: #1a7f37;
	font-weight: 600;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.dc360-status.is-visible {
	opacity: 1;
}

.dc360-status.is-error {
	color: var(--dc360-danger);
}

/* Panes */

.dc360-panes {
	display: grid;
	grid-template-columns: 1fr 420px;
	gap: 0.75rem;
	align-items: stretch;
}

@media (max-width: 960px) {
	.dc360-panes {
		grid-template-columns: 1fr;
	}
}

.dc360-pane {
	background: var(--dc360-card-bg);
	border: 1px solid var(--dc360-border);
	border-radius: 10px;
	overflow: hidden;
	display: flex;
	min-height: 560px;
}

.dc360-pane-python {
	flex-direction: column;
	min-height: 560px;
}

.dc360-pane-header,
.dc360-pane-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.6rem 0.8rem;
	border-bottom: 1px solid var(--dc360-border);
}

.dc360-pane-footer {
	border-top: 1px solid var(--dc360-border);
	border-bottom: none;
	justify-content: center;
}

.dc360-pane-header h2 {
	font-size: 1em;
	margin: 0;
}

#dc360-python-code {
	flex: 1 1 auto;
	width: 100%;
	border: none;
	resize: none;
	padding: 0.9rem;
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
	font-size: 0.92em;
	line-height: 1.5;
	tab-size: 4;
	background: #0f172a;
	color: #e2e8f0;
}

.dc360-errors {
	margin: 0;
	padding: 0.6rem 0.9rem;
	background: #fff5f5;
	border-top: 1px solid #f0c4c4;
	color: #8a2b2b;
	font-size: 0.9em;
	max-height: 40vh;
	overflow-y: auto;
}

.dc360-errors ul {
	margin: 0;
	padding-left: 1.1em;
}

/* Palette */

.dc360-pane-flowchart {
	display: grid;
	grid-template-columns: 200px 1fr;
}

.dc360-palette {
	border-right: 1px solid var(--dc360-border);
	padding: 0.75rem;
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	background: var(--dc360-bg);
	overflow-y: auto;
}

.dc360-palette-heading {
	margin: 0 0 0.25rem;
	font-weight: 700;
	font-size: 0.85em;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--dc360-muted);
}

.dc360-palette-item {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5em 0.6em;
	border: 1px solid var(--dc360-border);
	border-radius: 8px;
	background: #fff;
	cursor: grab;
	font-size: 0.88em;
	text-align: left;
}

.dc360-palette-item:hover {
	border-color: var(--dc360-primary);
}

.dc360-palette-hint {
	font-size: 0.78em;
	color: var(--dc360-muted);
	margin: 0.4rem 0;
}

.dc360-palette-tools {
	margin-top: auto;
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	padding-top: 0.5rem;
	border-top: 1px solid var(--dc360-border);
}

.dc360-shape {
	display: inline-block;
	width: 22px;
	height: 16px;
	flex: none;
	background: #dbe6ff;
	border: 1.5px solid var(--dc360-primary);
}

.dc360-shape-terminator { border-radius: 999px; }
.dc360-shape-process { border-radius: 3px; }
.dc360-shape-call { border-radius: 3px; box-shadow: inset 3px 0 0 var(--dc360-primary), inset -3px 0 0 var(--dc360-primary); }
.dc360-shape-io { clip-path: polygon(15% 0, 100% 0, 85% 100%, 0 100%); }
.dc360-shape-decision { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }

/* Canvas */

.dc360-canvas-wrap {
	position: relative;
	overflow: auto;
	background:
		linear-gradient(90deg, rgba(0,0,0,0.035) 1px, transparent 1px) 0 0 / 24px 24px,
		linear-gradient(rgba(0,0,0,0.035) 1px, transparent 1px) 0 0 / 24px 24px,
		#fbfcfe;
}

#dc360-canvas {
	display: block;
	cursor: grab;
}

.dc360-node-shape {
	fill: #eef4ff;
	stroke: var(--dc360-primary);
	stroke-width: 2;
}

.dc360-node-end .dc360-node-shape,
.dc360-node-start .dc360-node-shape {
	fill: #dff5e6;
	stroke: #1a7f37;
}

.dc360-node-decision .dc360-node-shape {
	fill: #fff3d6;
	stroke: #b5820a;
}

.dc360-node-while .dc360-node-shape,
.dc360-node-for .dc360-node-shape {
	fill: #ffe6f0;
	stroke: #c23b7a;
}

.dc360-node-call .dc360-node-shape {
	fill: #ece7ff;
	stroke: #5b3fd6;
}

.dc360-call-bar {
	stroke: #5b3fd6;
	stroke-width: 2;
}

.dc360-node {
	cursor: grab;
}

.dc360-node.is-selected .dc360-node-shape {
	stroke-width: 3.5;
	filter: drop-shadow(0 0 0 3px rgba(47,111,237,0.25));
}

.dc360-node-badge-bg {
	fill: var(--dc360-primary);
}

.dc360-node-badge-text {
	fill: #fff;
	font: 700 8.5px sans-serif;
	letter-spacing: 0.03em;
	pointer-events: none;
	user-select: none;
}

.dc360-node-text {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	font-size: 12.5px;
	line-height: 1.25;
	color: var(--dc360-ink);
	overflow: hidden;
	word-break: break-word;
	font-family: "SFMono-Regular", Consolas, monospace;
	pointer-events: none;
	user-select: none;
}

.dc360-port {
	fill: #fff;
	stroke: var(--dc360-muted);
	stroke-width: 1.5;
	cursor: crosshair;
}

.dc360-port-out {
	fill: var(--dc360-primary);
	stroke: var(--dc360-primary-dark);
}

.dc360-port:hover {
	r: 9;
}

.dc360-conn-line {
	fill: none;
	stroke: #7a8699;
	stroke-width: 2;
}

.dc360-conn-hit {
	fill: none;
	stroke: transparent;
	stroke-width: 16;
	cursor: pointer;
}

.dc360-conn.is-selected .dc360-conn-line {
	stroke: var(--dc360-primary);
	stroke-width: 3;
}

.dc360-conn-label {
	font-size: 11px;
	font-weight: 700;
	fill: #40506b;
	paint-order: stroke;
	stroke: #fff;
	stroke-width: 3;
}

.dc360-conn-ghost {
	fill: none;
	stroke: var(--dc360-primary);
	stroke-width: 2;
	stroke-dasharray: 6 4;
}

#dc360-arrow path {
	fill: #7a8699;
}

/* Node text modal */

.dc360-modal {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2000;
}

.dc360-modal[hidden] {
	display: none;
}

.dc360-modal-content {
	background: #fff;
	border-radius: 10px;
	padding: 1.25rem;
	width: min(420px, 90vw);
	box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.dc360-modal-content h3 {
	margin-top: 0;
}

.dc360-modal-content textarea {
	width: 100%;
	font-family: "SFMono-Regular", Consolas, monospace;
	padding: 0.6em;
	border: 1px solid var(--dc360-border);
	border-radius: 6px;
}

.dc360-modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

/* "My Flowcharts" list page */

.dc360-page-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 1rem;
	gap: 1rem;
	flex-wrap: wrap;
}

.dc360-search-form {
	display: flex;
	gap: 0.5rem;
	margin-bottom: 1.25rem;
}

.dc360-search-form input {
	padding: 0.5em 0.7em;
	border: 1px solid var(--dc360-border);
	border-radius: 8px;
	min-width: 220px;
}

.dc360-empty {
	color: var(--dc360-muted);
	padding: 2rem 0;
	text-align: center;
}

.dc360-card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 1rem;
}

.dc360-card {
	background: var(--dc360-card-bg);
	border: 1px solid var(--dc360-border);
	border-radius: 10px;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

.dc360-card-title {
	font-size: 1.05em;
	margin: 0;
}

.dc360-card-desc {
	color: var(--dc360-muted);
	font-size: 0.9em;
	margin: 0;
}

.dc360-card-meta {
	font-size: 0.8em;
	color: var(--dc360-muted);
	margin: 0;
}

.dc360-card-actions {
	margin-top: auto;
	display: flex;
	gap: 0.5rem;
	padding-top: 0.5rem;
}

.dc360-card-actions form {
	margin: 0;
}

/* Admin field: monospace python preview */
textarea.font-monospace {
	font-family: "SFMono-Regular", Consolas, monospace;
}

/* Character picker */

.dc360-character-picker {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2100;
	padding: 1rem;
}

.dc360-character-picker[hidden] {
	display: none;
}

.dc360-character-picker-inner {
	background: #fff;
	border-radius: 14px;
	padding: 1.75rem;
	width: min(560px, 94vw);
	max-height: 90vh;
	overflow-y: auto;
	box-shadow: 0 20px 60px rgba(0,0,0,0.3);
	text-align: center;
}

.dc360-character-picker-inner h2 {
	margin-top: 0;
}

.dc360-character-picker-inner > p {
	color: var(--dc360-muted);
	margin-top: 0;
}

.dc360-character-options {
	display: flex;
	justify-content: center;
	gap: 1.25rem;
	flex-wrap: wrap;
	margin-top: 1rem;
}

.dc360-character-option {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
	width: 180px;
	padding: 1rem 0.75rem;
	border: 2px solid var(--dc360-border);
	border-radius: 12px;
	background: var(--dc360-bg);
	cursor: pointer;
	font: inherit;
}

.dc360-character-option:hover,
.dc360-character-option:focus-visible {
	border-color: var(--dc360-primary);
	background: #eef4ff;
}

.dc360-character-option img {
	max-width: 100%;
	max-height: 160px;
	object-fit: contain;
}

.dc360-character-option span {
	font-weight: 600;
	color: var(--dc360-ink);
}

/* Persistent character avatar + speech bubble ("guide") */

.dc360-character-guide {
	display: flex;
	align-items: flex-start;
	gap: 0.6rem;
	margin: 0.5rem 0;
}

.dc360-character-guide[hidden] {
	display: none;
}

.dc360-character-avatar {
	width: 44px;
	height: 44px;
	object-fit: contain;
	object-position: top center;
	flex: none;
	border-radius: 50%;
	background: #eef4ff;
	border: 2px solid var(--dc360-primary);
	padding: 2px;
}

.dc360-speech-bubble {
	position: relative;
	background: #fff;
	border: 1px solid var(--dc360-border);
	border-radius: 10px;
	padding: 0.5em 0.7em;
	font-size: 0.8em;
	color: var(--dc360-ink);
	flex: 1;
}

.dc360-speech-bubble::before {
	content: "";
	position: absolute;
	left: -6px;
	top: 12px;
	width: 10px;
	height: 10px;
	background: #fff;
	border-left: 1px solid var(--dc360-border);
	border-bottom: 1px solid var(--dc360-border);
	transform: rotate(45deg);
}

/* Run: input prompt modal */

#dc360-run-input-modal .dc360-modal-content label {
	display: block;
	margin-bottom: 0.4rem;
	font-weight: 600;
}

#dc360-run-input-value {
	width: 100%;
	padding: 0.5em 0.6em;
	border: 1px solid var(--dc360-border);
	border-radius: 6px;
	font-size: 1em;
}

/* Run: output panel */

.dc360-run-output {
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	width: min(420px, calc(100vw - 2rem));
	max-height: min(50vh, 420px);
	background: #fff;
	border: 1px solid var(--dc360-border);
	border-radius: 10px;
	box-shadow: 0 12px 40px rgba(0,0,0,0.2);
	z-index: 1900;
	display: flex;
	flex-direction: column;
}

.dc360-run-output[hidden] {
	display: none;
}

.dc360-run-output-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.6rem 0.8rem;
	border-bottom: 1px solid var(--dc360-border);
}

.dc360-run-output-header-title {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	min-width: 0;
}

.dc360-run-output-header h3 {
	margin: 0;
	font-size: 0.95em;
}

/* The chosen character's face, shown next to the Run Output heading once
   the flowchart has printed at least one line - happy while nothing has
   gone wrong yet in this run, confused as soon as something has (see
   dc360-app.js's updateRunOutputCharacter()). */
.dc360-run-output-character {
	width: 28px;
	height: 28px;
	object-fit: contain;
	object-position: top center;
	flex: none;
	border-radius: 50%;
	background: #eef4ff;
	border: 2px solid var(--dc360-primary);
	padding: 1px;
}

.dc360-run-output-character[hidden] {
	display: none;
}

#dc360-run-output-log {
	margin: 0;
	padding: 0.7rem 0.9rem;
	overflow-y: auto;
	font-family: "SFMono-Regular", Consolas, monospace;
	font-size: 0.85em;
	white-space: pre-wrap;
	word-break: break-word;
}

/* Shown while Run is paused waiting for the student to confirm the output
   they just saw is correct (Continue) or stop to go edit the flowchart
   (Stop) - see dc360-app.js's pauseOnRunOutput(). */
.dc360-run-output-actions {
	display: flex;
	justify-content: flex-end;
	gap: 0.5rem;
	padding: 0.6rem 0.8rem;
	border-top: 1px solid var(--dc360-border);
}

.dc360-run-output-actions[hidden] {
	display: none;
}

/* Run: character reaction overlay */

.dc360-reaction-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.6);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2200;
	padding: 1rem;
}

.dc360-reaction-overlay[hidden] {
	display: none;
}

.dc360-reaction-card {
	background: #fff;
	border-radius: 14px;
	padding: 1.75rem;
	width: min(420px, 94vw);
	max-height: 85vh;
	display: flex;
	flex-direction: column;
	text-align: center;
	box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.dc360-reaction-card .dc360-btn {
	flex: none;
}

.dc360-reaction-image-wrap {
	position: relative;
	display: inline-block;
}

.dc360-reaction-image-wrap img {
	max-width: 100%;
	max-height: 260px;
	object-fit: contain;
}

.dc360-reaction-token {
	position: absolute;
	top: -0.5rem;
	right: -0.5rem;
	background: #ffc83d;
	color: #5c4200;
	font-weight: 700;
	font-size: 0.75em;
	padding: 0.3em 0.6em;
	border-radius: 999px;
	box-shadow: 0 4px 10px rgba(0,0,0,0.2);
	white-space: nowrap;
}

.dc360-reaction-card p {
	font-size: 1.05em;
	font-weight: 600;
}

.dc360-reaction-issues {
	text-align: left;
	color: var(--dc360-muted);
	font-size: 0.85em;
	margin: 0 0 1rem;
	padding-left: 1.2em;
	flex: 1 1 auto;
	min-height: 0;
	max-height: 45vh;
	overflow-y: auto;
}

.dc360-reaction-issues:empty {
	display: none;
	flex: none;
}

.dc360-reaction-image-wrap,
.dc360-reaction-card p {
	flex: none;
}
