/* ============================================================
   NEXORA · IDE / Editor Chrome CSS
   All visual styling for the code editor component:
     · Editor layout (gutter + scroll area)
     · Syntax token colors (dark + light)
     · Active-line highlight overlay
     · Find / Replace bar
     · Error gutter marks
   ============================================================ */

/* ── Editor shell ──────────────────────────────────────────── */

.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.6;
  tab-size: 2;
}

[data-theme="light"] .nx-editor {
  background: rgba(255, 255, 255, 0.6);
}

/* ── Gutter ────────────────────────────────────────────────── */

.nx-gutter {
  padding: 12px 10px 12px 14px;
  text-align: right;
  color: var(--text-3);
  background: rgba(255, 255, 255, 0.018);
  user-select: none;
  overflow: hidden;
  white-space: pre;
  font-variant-numeric: tabular-nums;
  min-width: 42px;
}

[data-theme="light"] .nx-gutter {
  background: rgba(0, 0, 0, 0.018);
}

.nx-gutter b {
  display: block;
  font-weight: 400;
  opacity: 0.45;
  transition: color var(--dur-fast), opacity var(--dur-fast);
  line-height: 1.6;
  font-size: 12px;
}

.nx-gutter b.active {
  color: var(--text-2);
  opacity: 0.9;
}

.nx-gutter b.err {
  color: var(--danger);
  opacity: 1;
}

/* ── Scroll surface ────────────────────────────────────────── */

.nx-scroll {
  position: relative;
  overflow: auto;
  min-width: 0;
}

/* ── Active-line overlay ───────────────────────────────────── */

.nx-active-line {
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.025);
  z-index: 0;
  transition: top 0.06s linear;
}

[data-theme="light"] .nx-active-line {
  background: rgba(0, 0, 0, 0.03);
}

/* ── Code & textarea ───────────────────────────────────────── */

.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;
  min-height: 100%;
  min-width: 100%;
  width: max-content;
}

.nx-code {
  pointer-events: none;
  color: var(--text-2);
  z-index: 1;
  position: relative;
}

.nx-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--text-1);
  outline: none;
  overflow: hidden;
  z-index: 2;
}

.nx-input::selection {
  background: rgba(100, 100, 200, 0.25);
  color: transparent;
}

[data-theme="light"] .nx-input::selection {
  background: rgba(0, 0, 0, 0.1);
}

/* ── Syntax token colors — Dark ────────────────────────────── */

.tk-key  { color: #b78cff; }               /* keywords */
.tk-str  { color: #3dd68c; }               /* strings */
.tk-num  { color: #ffc94d; }               /* numbers */
.tk-com  { color: #636e7e; font-style: italic; } /* comments */
.tk-fn   { color: #2fd2f2; }               /* functions */
.tk-tag  { color: #ff8fa3; }               /* HTML tags */
.tk-att  { color: #ffc94d; }               /* HTML attributes / dunders */
.tk-sel  { color: #2fd2f2; }               /* CSS selectors */
.tk-prop { color: #b78cff; }               /* CSS properties */
.tk-pre  { color: #ff9d5c; }               /* preprocessor / decorators */

/* ── Syntax token colors — Light ───────────────────────────── */

[data-theme="light"] .tk-key  { color: #7c3aed; }
[data-theme="light"] .tk-str  { color: #0e7a47; }
[data-theme="light"] .tk-num  { color: #b45309; }
[data-theme="light"] .tk-com  { color: #6b7280; font-style: italic; }
[data-theme="light"] .tk-fn   { color: #0369a1; }
[data-theme="light"] .tk-tag  { color: #be123c; }
[data-theme="light"] .tk-att  { color: #b45309; }
[data-theme="light"] .tk-sel  { color: #0369a1; }
[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: 10;
  display: none;
  gap: 0.35rem;
  align-items: center;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-md);
  background: var(--glass-bg-strong, rgba(20, 20, 30, 0.92));
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--depth-lg, 0 8px 32px rgba(0,0,0,.4)), 0 0 0 1px rgba(255,255,255,.08);
  max-width: calc(100% - 28px);
  flex-wrap: wrap;
}

[data-theme="light"] .nx-find {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 20px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.07);
}

.nx-find.is-open {
  display: flex;
}

.nx-find input {
  width: 140px;
  padding: 0.36rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-xs);
  outline: none;
  transition: border-color var(--dur-fast);
}

[data-theme="light"] .nx-find input {
  background: #f9f9f9;
  border-color: #d1d5db;
  color: #111;
}

.nx-find input:focus {
  border-color: rgba(106, 99, 255, 0.6);
}

.nx-find button {
  padding: 0.36rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-2);
  border-radius: var(--radius-xs);
  transition: color var(--dur-fast), background var(--dur-fast);
  white-space: nowrap;
}

.nx-find button:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.09);
}

.nx-find-count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-3);
  min-width: 40px;
  text-align: center;
}
