/* Copyright 2023 by Paulo Queiroga. All rights reserved.
   Use of this source code is governed by the license that can be found in the LICENSE file. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1f2328;
  --ink-soft: #57606a;
  --line: #d8dee4;
  --accent: #0050ef;   /* the blue from the stage palette */
  --danger: #a20025;   /* the red from the stage palette */
  --ok: #2d7600;       /* the green from the stage palette */
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---------------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.toolbar h1 {
  margin: 0 8px 0 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.group {
  display: flex;
  gap: 6px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

button {
  font: inherit;
  padding: 5px 11px;
  color: var(--ink);
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

button:hover:not(:disabled) { background: #f0f2f5; }
button:active:not(:disabled) { background: #e6e9ee; }

button:disabled {
  color: #a5adb8;
  cursor: default;
}

button.primary {
  color: #fff;
  background: var(--accent);
  border-color: #001dbc;
}

button.primary:hover { background: #0047d6; }

button.danger {
  color: var(--danger);
  border-color: #e3b7c4;
}

button.danger:hover { background: #fdf0f3; }

/* ------------------------------------------------------------------ layout */

main {
  display: flex;
  flex: 1;
  min-height: 0;
}

.canvas-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px) 0 0 / 20px 20px,
    #fff;
}

svg.canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

#sidebar {
  width: 320px;
  flex: none;
  overflow-y: auto;
  padding: 4px 14px 24px;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

#sidebar section { margin-top: 18px; }

#sidebar h2 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--ink-soft);
}

footer {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--panel);
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------------- fields */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
}

input[type="text"], select {
  font: inherit;
  width: 100%;
  padding: 5px 8px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

input[type="text"]:focus, select:focus {
  outline: 2px solid rgba(0, 80, 239, 0.35);
  border-color: var(--accent);
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.hint.is-ok { color: var(--ok); }

.value {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

/* -------------------------------------------------------------------- chips */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.chips li {
  display: flex;
  align-items: stretch;
}

.chip {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 12px;
}

.chip-remove {
  margin-left: -1px;
  padding: 3px 7px;
  font-size: 12px;
  line-height: 1;
  color: var(--danger);
  border-radius: 12px;
}

.link-button {
  padding: 0;
  text-align: left;
  color: var(--accent);
  background: none;
  border: none;
  text-decoration: underline;
}

/* ------------------------------------------------------------------- stages */

.stage-list {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

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

.swatch {
  width: 14px;
  height: 14px;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 3px;
}

.stage-row .count {
  min-width: 22px;
  font-size: 12px;
  text-align: right;
  color: var(--ink-soft);
}

.stage-row.is-locked .locked-name {
  flex: 1;
  font-size: 13px;
  font-style: italic;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------- issues */

.issues {
  margin: 0;
  padding: 0;
  list-style: none;
}

.issue {
  padding: 5px 0 5px 9px;
  margin-bottom: 5px;
  font-size: 12px;
  border-left: 3px solid var(--line);
}

.issue.is-error { border-left-color: var(--danger); }
.issue.is-warning { border-left-color: #f0a30a; }
.issue .link-button { font-size: 12px; }

.keys {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--ink-soft);
}

.keys li { margin-bottom: 3px; }

/* ------------------------------------------------------------------ diagram */

.stage-label, .node-label {
  pointer-events: none;
  user-select: none;
}

.node-shape { cursor: crosshair; }

.node-hit {
  fill: transparent;
  cursor: crosshair;
}

.node-halo {
  fill: none;
  stroke: #1f2328;
  stroke-width: 1.5;
  stroke-dasharray: 3 2;
}

.node.is-drop-target .node-shape {
  stroke: #1f2328;
  stroke-width: 2.5;
}

.node.is-synthetic .node-hit { cursor: pointer; }

.link-line {
  stroke: rgb(0, 0, 0);
  stroke-width: 1;
  pointer-events: none;
}

.link-hit {
  stroke: transparent;
  stroke-width: 10;
  pointer-events: stroke;
  cursor: pointer;
}

.link.is-selected .link-line {
  stroke: var(--danger);
  stroke-width: 2.5;
}

.link-draft {
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  pointer-events: none;
}

/* -------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 42px;
  max-width: 560px;
  padding: 9px 15px;
  transform: translate(-50%, 12px);
  color: #fff;
  background: #1f2328;
  border-radius: 7px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s, transform 0.16s;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error { background: var(--danger); }
.toast.is-ok { background: var(--ok); }
