/* style.css — Clean minimal styling for network graph app */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* --- Toolbar --- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #ddd;
  align-items: center;
  z-index: 10;
}

.toolbar .separator {
  width: 1px;
  height: 28px;
  background: #ddd;
  margin: 0 4px;
}

.toolbar button {
  padding: 6px 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: #333;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.toolbar button:hover {
  background: #f0f0f0;
  border-color: #aaa;
}

.toolbar button.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.toolbar button.algo {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #475569;
}

.toolbar button.algo:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.toolbar button.export {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.toolbar button.export:hover {
  background: #dcfce7;
}

.toolbar button.danger {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.toolbar button.danger:hover {
  background: #fee2e2;
}

.toolbar .toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  user-select: none;
}

.toolbar .toggle input {
  cursor: pointer;
  accent-color: #2563eb;
}

.toolbar .toggle:hover {
  background: #e2e8f0;
}

/* --- Canvas area --- */

.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #fff;
}

.canvas-container canvas {
  display: block;
  cursor: crosshair;
}

.canvas-container.mode-move canvas {
  cursor: grab;
}

.canvas-container.mode-move.dragging canvas {
  cursor: grabbing;
}

.canvas-container.mode-select canvas {
  cursor: default;
}

.canvas-container.mode-delete canvas {
  cursor: not-allowed;
}

/* --- Results panel --- */

.results-panel {
  background: #fff;
  border-top: 1px solid #ddd;
  padding: 10px 16px;
  font-size: 14px;
  min-height: 44px;
  max-height: 120px;
  overflow-y: auto;
  color: #555;
}

.results-panel .result-text {
  line-height: 1.5;
}

.results-panel .result-text strong {
  color: #2563eb;
}

.results-panel:empty::before {
  content: "Run an algorithm to see results here.";
  color: #aaa;
  font-style: italic;
}

/* --- Modal overlay for algorithm node selection --- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  min-width: 280px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.modal h3 {
  margin-bottom: 12px;
  font-size: 16px;
  color: #333;
}

.modal label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.modal select,
.modal input[type="text"] {
  padding: 5px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  margin-left: 8px;
}

.modal input[type="text"] {
  width: 110px;
}

.modal .modal-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 8px;
}

.modal .modal-buttons {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal .modal-buttons button {
  padding: 6px 16px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
}

.modal .modal-buttons button.primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.modal .modal-buttons button.primary:hover {
  background: #1d4ed8;
}

/* --- Weight input popup --- */

.weight-input-popup {
  display: none;
  position: absolute;
  z-index: 50;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.weight-input-popup.visible {
  display: flex;
  align-items: center;
  gap: 6px;
}

.weight-input-popup input {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  text-align: center;
}

.weight-input-popup input[type="text"] {
  width: 56px;
}

/* --- Activity table --- */

.activity-table-wrap {
  background: #fff;
  border-top: 1px solid #ddd;
  max-height: 240px;
  display: flex;
  flex-direction: column;
}

.activity-table-header {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  padding: 8px 16px 4px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.activity-table-scroll {
  overflow-y: auto;
  padding: 0 16px 12px;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: #333;
}

.activity-table th {
  text-align: left;
  font-weight: 600;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 10px;
  background: #f8fafc;
  position: sticky;
  top: 0;
}

.activity-table td {
  border-bottom: 1px solid #f1f5f9;
  padding: 4px 10px;
  vertical-align: middle;
}

.activity-table td.numeric {
  font-variant-numeric: tabular-nums;
}

.activity-table td.activity-name {
  font-weight: 600;
  color: #2563eb;
}

.activity-table td.muted {
  color: #94a3b8;
}

.activity-table input.cost-input {
  width: 80px;
  padding: 3px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.activity-table-empty {
  padding: 14px 4px 4px;
  color: #94a3b8;
  font-size: 13px;
  font-style: italic;
}

.activity-table-empty em {
  font-style: normal;
  font-weight: 600;
  color: #2563eb;
}

.weight-input-popup button {
  padding: 4px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  border-color: #2563eb;
}

/* --- Step controls --- */

.step-controls {
  display: none;
  background: #fff;
  border-top: 1px solid #ddd;
}

.step-controls.visible {
  display: block;
}

.step-controls-row {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.step-controls button {
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
  white-space: nowrap;
}

.step-controls button:hover:not(:disabled) {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.step-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.step-controls button#step-play.playing {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.step-controls .step-speed-label {
  font-size: 13px;
  color: #475569;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.step-controls select {
  padding: 5px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}

.step-controls .step-counter {
  margin-left: 4px;
  color: #475569;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.step-controls .step-close {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 18px;
  line-height: 1;
}

.step-description {
  padding: 12px 16px;
  font-size: 14px;
  color: #1f2937;
  line-height: 1.55;
  min-height: 50px;
  max-height: 110px;
  overflow-y: auto;
}

.step-description strong {
  color: #2563eb;
}

.step-description:empty::before {
  content: "Run an algorithm to start a step-by-step walkthrough.";
  color: #94a3b8;
  font-style: italic;
}

/* --- Teaching mode (1.6× sizing, tuned for back-of-room readability) --- */

body.teaching-mode .toolbar {
  padding: 14px 20px;
  gap: 10px;
}

body.teaching-mode .toolbar button {
  padding: 10px 20px;
  font-size: 19px;
  border-radius: 8px;
}

body.teaching-mode .toolbar .toggle {
  padding: 10px 14px;
  font-size: 19px;
  gap: 10px;
  border-radius: 8px;
}

body.teaching-mode .toolbar .toggle input {
  transform: scale(1.4);
  margin: 0 4px;
}

body.teaching-mode .toolbar .separator {
  height: 38px;
}

body.teaching-mode .results-panel {
  font-size: 21px;
  min-height: 64px;
  max-height: 180px;
  padding: 14px 20px;
}

body.teaching-mode .step-controls-row {
  padding: 12px 20px;
  gap: 12px;
}

body.teaching-mode .step-controls button {
  padding: 10px 18px;
  font-size: 18px;
  border-radius: 8px;
}

body.teaching-mode .step-controls .step-speed-label,
body.teaching-mode .step-controls .step-counter {
  font-size: 18px;
}

body.teaching-mode .step-controls select {
  padding: 8px 10px;
  font-size: 18px;
}

body.teaching-mode .step-controls .step-close {
  font-size: 24px;
  padding: 6px 14px;
}

body.teaching-mode .step-description {
  font-size: 22px;
  line-height: 1.45;
  padding: 14px 20px;
  min-height: 50px;
  max-height: 150px;
}

/* When step controls are active, the results panel duplicates the step text
   — hide it in teaching mode so the canvas keeps its room. */
body.teaching-mode.steps-active .results-panel {
  display: none;
}

/* Empty activity-table hint takes a noticeable chunk in teaching mode; trim it. */
body.teaching-mode .activity-table-empty {
  padding: 8px 4px 4px;
  font-size: 14px;
}

body.teaching-mode .activity-table-wrap {
  max-height: 320px;
}

body.teaching-mode .activity-table-header {
  font-size: 18px;
  padding: 12px 20px 6px;
}

body.teaching-mode .activity-table {
  font-size: 18px;
}

body.teaching-mode .activity-table th {
  padding: 10px 14px;
  font-size: 17px;
}

body.teaching-mode .activity-table td {
  padding: 8px 14px;
}

body.teaching-mode .activity-table input.cost-input {
  width: 110px;
  padding: 6px 10px;
  font-size: 18px;
}

body.teaching-mode .weight-input-popup {
  padding: 12px;
  gap: 10px;
}

body.teaching-mode .weight-input-popup input {
  width: 100px;
  padding: 8px 12px;
  font-size: 18px;
}

body.teaching-mode .weight-input-popup input[type="text"] {
  width: 90px;
}

body.teaching-mode .weight-input-popup button {
  padding: 8px 14px;
  font-size: 16px;
}

body.teaching-mode .modal h3 {
  font-size: 22px;
}

body.teaching-mode .modal label,
body.teaching-mode .modal select,
body.teaching-mode .modal input[type="text"] {
  font-size: 18px;
}

body.teaching-mode .modal .modal-buttons button {
  padding: 10px 22px;
  font-size: 17px;
}

/* Make the teaching toggle visually distinct so the user can see at a glance */
.toolbar .teaching-toggle {
  background: #fef3c7;
  border-color: #fbbf24;
  color: #92400e;
}

.toolbar .teaching-toggle:hover {
  background: #fde68a;
}

body.teaching-mode .toolbar .teaching-toggle {
  background: #fbbf24;
  color: #78350f;
  border-color: #d97706;
}
