/* ============================================================
   NEXORA · Component / Code editor (shared: Code Lab + Robotic Lab)
   Textarea + syntax-highlight overlay + gutter.
   ============================================================ */

.nx-editor {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: rgba(3, 6, 16, 0.34);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
}

[data-theme="light"] .nx-editor {
  background: rgba(255, 255, 255, 0.5);
}

/* Gutter */
.nx-gutter {
  padding: 12px 10px 12px 14px;
  text-align: right;
  color: var(--text-3);
  background: rgba(255, 255, 255, 0.02);
  user-select: none;
  overflow: hidden;
  white-space: pre;
  font-variant-numeric: tabular-nums;
}

.nx-gutter b {
  display: block;
  font-weight: 400;
  opacity: 0.55;
  transition: color var(--dur-fast), opacity var(--dur-fast);
}

.nx-gutter b.active {
  color: var(--accent-2);
  opacity: 1;
}

.nx-gutter b.err {
  color: var(--danger);
  opacity: 1;
}

/* Scroll surface */
.nx-scroll {
  position: relative;
  overflow: auto;
  min-width: 0;
}

.nx-code,
.nx-input {
  margin: 0;
  padding: 12px 16px;
  font: inherit;
  line-height: inherit;
  tab-size: inherit;
  white-space: pre;
  word-wrap: normal;
  overflow-wrap: normal;
  border: 0;
}

.nx-code {
  pointer-events: none;
  color: var(--text-2);
  min-height: 100%;
  min-width: 100%;
  width: max-content;
}

.nx-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--accent-2);
  outline: none;
  overflow: hidden;
  z-index: 1;
}

.nx-input::selection {
  background: rgba(106, 99, 255, 0.38);
  color: transparent;
}

.nx-input::placeholder {
  color: var(--text-3);
}

/* ---------- Token colors (theme-aware) ---------------------- */

.tk-key { color: #b78cff; font-weight: 500; }
.tk-str { color: #3dd68c; }
.tk-num { color: #ffc94d; }
.tk-com { color: var(--text-3); font-style: italic; }
.tk-fn  { color: #2fd2f2; }
.tk-tag { color: #ff8fa3; }
.tk-att { color: #ffc94d; }
.tk-sel { color: #2fd2f2; }
.tk-prop { color: #b78cff; }
.tk-pre { color: #ff9d5c; }

[data-theme="light"] .tk-key { color: #7c3aed; }
[data-theme="light"] .tk-str { color: #128a52; }
[data-theme="light"] .tk-num { color: #b45309; }
[data-theme="light"] .tk-fn  { color: #0e7490; }
[data-theme="light"] .tk-tag { color: #be123c; }
[data-theme="light"] .tk-att { color: #b45309; }
[data-theme="light"] .tk-sel { color: #0e7490; }
[data-theme="light"] .tk-prop { color: #7c3aed; }
[data-theme="light"] .tk-pre { color: #c2410c; }

/* ---------- Find / replace bar ------------------------------- */

.nx-find {
  position: absolute;
  top: 8px;
  right: 14px;
  z-index: 4;
  display: none;
  gap: 0.35rem;
  align-items: center;
  padding: 0.4rem;
  border-radius: var(--radius-md);
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--depth-lg), var(--glass-edge);
}

.nx-find.is-open {
  display: flex;
}

.nx-find input {
  width: 130px;
  padding: 0.35rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.06);
  border: 0;
  border-radius: var(--radius-xs);
  outline: none;
}

.nx-find input:focus {
  box-shadow: 0 0 0 2px rgba(106, 99, 255, 0.4);
}

.nx-find button {
  padding: 0.35rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-2);
  border-radius: var(--radius-xs);
  transition: color var(--dur-fast), background var(--dur-fast);
}

.nx-find button:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.08);
}

.nx-find .nx-find-count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-3);
  min-width: 42px;
  text-align: center;
}
