/* ================================================================
   editor.css — Standalone Node Editor styles
   ================================================================ */

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --border:    #30363d;
  --text:      #e6edf3;
  --text-dim:  #8b949e;
  --accent:    #00e5ff;
}

html, body {
  height: 100%;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ---------- Toolbar ---------- */
#editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 44px;
  flex-shrink: 0;
}

#editor-toolbar h1 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

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

.tb-btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.tb-btn:hover {
  background: rgba(0, 229, 255, 0.08);
  border-color: var(--accent);
}
.tb-btn-primary {
  background: rgba(0, 229, 255, 0.12);
  border-color: rgba(0, 229, 255, 0.3);
  color: var(--accent);
}

#save-status {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-right: 0.5rem;
}

/* ---------- Editor canvas container ---------- */
#editor-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

#rete {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

/* Rete creates an inner wrapper that must fill the container */
#rete > div {
  width: 100% !important;
  height: 100% !important;
}

/* ---------- Rete.js node theming ---------- */
#rete .node {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  position: relative !important;
}
#rete .node.selected {
  border-color: var(--accent) !important;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2) !important;
}
#rete .node .title {
  color: var(--accent) !important;
  font-size: 0.78rem !important;
}
#rete .socket {
  background: var(--accent) !important;
  width: 16px !important;
  height: 16px !important;
}
#rete .connection .main-path {
  stroke: var(--accent) !important;
  stroke-width: 2px !important;
}

/* ---------- Node value badges ---------- */
.nv-badge {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: #00e5ff;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  padding: 1px 7px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

/* ---------- Node sparkline (ODE node) ---------- */
.nv-spark {
  display: block;
  margin: 4px auto 2px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.3);
}

/* ---------- Output node graph ---------- */
.nv-output-graph {
  margin: 2px auto 4px;
  padding: 0;
}
.nv-output-canvas {
  display: block;
  margin: 0 auto;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
}

/* ---------- Edge value labels (inside .area, moves with pan/zoom) ---------- */
.rete-edge-labels {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}
.rete-edge-val {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(13, 17, 23, 0.92);
  border: 1px solid rgba(0, 229, 255, 0.25);
  color: #00e5ff;
  font-size: 0.6rem;
  font-weight: 600;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

/* ---------- Node inline controls ---------- */
.nv-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
}
.nv-ctrl-label {
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  min-width: 36px;
}
.nv-ctrl-input {
  width: 64px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-size: 0.68rem;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  padding: 2px 4px;
  outline: none;
}
.nv-ctrl-input:focus {
  border-color: var(--accent);
}

/* ---------- Rete context menu (node picker) ---------- */
.rete-ctx-menu {
  position: fixed;
  z-index: 9999;
  width: 260px;
  max-height: 380px;
  background: #111518;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.rete-ctx-menu.hidden { display: none; }

.rete-ctx-search {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
}
.rete-ctx-search::placeholder { color: var(--text-dim); }

.rete-ctx-list {
  overflow-y: auto;
  flex: 1;
}

.rete-ctx-group {
  padding: 0.35rem 0.65rem 0.2rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  background: rgba(0, 229, 255, 0.04);
  border-top: 1px solid var(--border);
}
.rete-ctx-group:first-child { border-top: none; }

.rete-ctx-item {
  padding: 0.38rem 0.65rem;
  font-size: 0.74rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}
.rete-ctx-item:hover {
  background: rgba(0, 229, 255, 0.12);
  color: #fff;
}
.rete-ctx-delete {
  color: #f85149;
}
.rete-ctx-delete:hover {
  background: rgba(248, 81, 73, 0.18);
  color: #ff6e67;
}

.rete-ctx-empty {
  padding: 0.8rem 0.65rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ---------- Editor sidebar (constants + re-run) ---------- */
#editor-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.es-section {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.es-section:last-child { border-bottom: none; }

/* Allow Model Constants section to scroll if many sliders */
.es-section:first-child {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.es-section h3 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.es-hint {
  font-size: 0.66rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.es-status {
  font-size: 0.64rem;
  color: var(--text-dim);
  margin-top: 6px;
  min-height: 1.2em;
}

.vs-empty {
  font-size: 0.64rem;
  color: var(--text-dim);
  text-align: center;
  padding: 0.5rem 0;
}

/* Slider groups inside editor sidebar */
#editor-sidebar .slider-group {
  margin-bottom: 0.4rem;
}
#editor-sidebar .slider-group label {
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
}
#editor-sidebar .slider-group .slider-val {
  color: var(--accent);
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.62rem;
}
#editor-sidebar .slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 4px;
}

/* ---------- Rubber-band selection box ---------- */
.rete-select-box {
  position: fixed;
  border: 1px solid var(--accent);
  background: rgba(0, 229, 255, 0.06);
  z-index: 9998;
  pointer-events: none;
}

/* ---------- Text control input (name field) ---------- */
.nv-ctrl-text {
  width: 80px;
  font-family: inherit;
  font-size: 0.65rem;
}

/* ---------- Context menu label item ---------- */
.rete-ctx-label {
  color: var(--accent);
}
.rete-ctx-label:hover {
  background: rgba(0, 229, 255, 0.12);
}
.rete-ctx-copy:hover {
  background: rgba(0, 229, 255, 0.12);
}
