/*
 * El banco de nginx (js/demos/nginx-bench.js): barra de estado de nginx, columna de trabajo (editor encima del
 * terminal) junto al panel, y las soluciones paso a paso. Y el editor (js/ui/editor.js) con su resaltado.
 */

/* ------------------------------------------------------- barra de estado */
.lab {
  --editor-h: clamp(260px, 42vh, 460px);
  --term-h: clamp(240px, 36vh, 400px);
}

.lab__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  font-size: 0.86rem;
}

.lab__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.lab__dot.is-ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.lab__dot.is-bad {
  background: var(--drop);
  box-shadow: 0 0 0 3px var(--drop-soft);
}

.lab__conf {
  color: var(--text-muted);
}

.lab__conf.is-pending {
  color: var(--warn);
  font-weight: 600;
}

.lab__conf.is-synced::before {
  content: '✓ ';
  color: var(--ok);
}

/* Editor y terminal en una columna; el panel al lado, tan alto como los dos. */
.lab__work {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.lab__grid > .lab__panel {
  max-height: calc(var(--editor-h) + var(--term-h) + var(--space-3) + 70px);
}

@container main (max-width: 980px) {
  .lab__grid > .lab__panel {
    max-height: none;
  }
}

/* ---------------------------------------------------------------- editor */
.editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--term-bg);
  overflow: hidden;
}

.editor:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-2);
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.editor__tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.editor__select {
  min-width: 0;
  max-width: 100%;
  flex: 1 1 220px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.editor__state {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
}

.editor__state.is-clean {
  color: var(--ok);
  background: var(--ok-soft);
}

.editor__state.is-dirty {
  color: var(--warn);
  background: var(--warn-soft);
}

.editor__actions {
  display: flex;
  gap: var(--space-1);
  margin-left: auto;
}

.editor__scroll {
  position: relative;
  display: flex;
  height: var(--editor-h);
  overflow: auto;
  overscroll-behavior: contain;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  tab-size: 4;
}

.editor__gutter {
  position: sticky;
  left: 0;
  z-index: 1;
  flex: none;
  margin: 0;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  min-height: 100%;
  height: max-content;
  background: var(--term-bg);
  border-right: 1px solid var(--border);
  color: var(--term-dim);
  text-align: right;
  user-select: none;
  font: inherit;
}

.editor__ln {
  display: block;
}

.editor__ln.is-error {
  color: var(--on-accent);
  background: var(--drop);
  border-radius: 3px;
  padding: 0 3px;
  margin-right: -3px;
}

.editor__code {
  position: relative;
  flex: 1 0 auto;
  min-width: 0;
}

/* El resaltado y el textarea se superponen exactamente: misma fuente, mismo relleno, sin ajuste de línea. */
.editor__hl,
.editor__input {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  font: inherit;
  line-height: inherit;
  white-space: pre;
  tab-size: 4;
  letter-spacing: 0;
}

.editor__hl {
  color: var(--term-fg);
  pointer-events: none;
}

.editor__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  caret-color: var(--term-caret);
  border-radius: 0;
  box-shadow: none;
}

.editor__input::selection {
  background: var(--accent-soft);
  color: transparent;
}

@media (max-width: 640px), (pointer: coarse) {
  .editor__scroll {
    font-size: 16px;
  }
}

.hl-c {
  color: var(--hl-comment);
  font-style: italic;
}
.hl-d {
  color: var(--hl-directive);
  font-weight: 600;
}
.hl-s {
  color: var(--hl-string);
}
.hl-v {
  color: var(--hl-variable);
}
.hl-k {
  color: var(--hl-keyword);
}
.hl-n {
  color: var(--hl-number);
}
.hl-p {
  color: var(--text-muted);
  font-weight: 700;
}

.editor__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  min-height: 32px;
  padding: 4px var(--space-3);
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.editor__path {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.editor__hint {
  margin-left: auto;
}

.editor__error {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px var(--space-2);
  color: var(--drop);
  font-family: var(--font-mono);
}

.editor__error strong {
  font-weight: 700;
}

/* ------------------------------------------------- soluciones paso a paso */
.tasks__solution {
  flex-basis: 100%;
}

.solution {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
  padding-left: 1.4em;
}

.solution li {
  display: grid;
  gap: 4px;
  justify-items: start;
}

.solution__what {
  color: var(--text-soft);
}

.solution__cmd {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.solution__code {
  margin: 0;
  max-width: 100%;
  overflow-x: auto;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--term-bg);
  color: var(--term-fg);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  tab-size: 4;
}
