/* Panel lateral de artefactos (Fase 3A) — sistema 4d3 */

.artifact-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  min-height: 0;
  z-index: 2;
  position: relative;
}
.artifact-panel[hidden] {
  display: none;
}
.artifact-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--pastel-green) 0%,
    var(--pastel-blue) 50%,
    var(--pastel-coral) 100%
  );
}

.artifact-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
}

.artifact-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  color: var(--pastel-blue);
}
.artifact-icon [data-lucide] { width: 1.125rem; height: 1.125rem; }

.artifact-title {
  flex: 1;
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 0.875rem;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artifact-versions-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}
.artifact-versions-nav .icon-btn { width: 26px; height: 26px; }

.artifact-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.artifact-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}
.artifact-tab {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 0;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.artifact-tab:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}
.artifact-tab.active {
  background: var(--bg-elev);
  color: var(--accent-strong);
  border-color: var(--accent);
}

.artifact-body {
  flex: 1;
  overflow: auto;
  padding: 14px;
  min-height: 0;
}

.artifact-body pre {
  margin: 0;
  padding: 12px;
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: var(--radius-sm);
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  line-height: 1.5;
}

.artifact-body .artifact-md {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.55;
}

.artifact-body .artifact-iframe {
  display: block;
  width: 100%;
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
}

.artifact-body .artifact-svg,
.artifact-body .artifact-mermaid {
  display: flex;
  justify-content: center;
}

.artifact-foot {
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
}

.artifact-error {
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 10px;
  border: 1px solid var(--danger);
  border-left: 3px solid var(--danger);
  border-radius: 0;
  background: var(--danger-soft);
}

/* -------------------------------------------------------------------------- */
/* Indicador del kernel en el composer                                         */
/* -------------------------------------------------------------------------- */
.kernel-indicator {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border-strong);
  border-radius: 0;
  background: var(--bg-elev);
  color: var(--fg-muted);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.kernel-indicator [data-lucide] { width: 0.9375rem; height: 0.9375rem; }
.kernel-indicator[data-status="ready"],
.kernel-indicator[data-status="idle"] {
  color: var(--accent-normal-strong);
  border-color: var(--pastel-green);
}
.kernel-indicator[data-status="busy"] {
  color: var(--accent-strong);
  border-color: var(--pastel-blue);
  animation: spin 1.4s linear infinite;
}
.kernel-indicator[data-status="off"] { color: var(--fg-subtle); }
.kernel-indicator:hover { background: var(--bg-sunken); }

/* -------------------------------------------------------------------------- */
/* Panel del kernel: variables vivas                                           */
/* -------------------------------------------------------------------------- */
.kernel-vars-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 14px;
  max-height: 180px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0;
}
.kernel-vars-list li {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.kernel-vars-list li:last-child { border-bottom: 0; }

.kernel-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}
.kernel-buttons .btn {
  padding: 8px 14px;
  font-size: 0.75rem;
}
.kernel-hint {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-top: 6px;
}

/* -------------------------------------------------------------------------- */
/* Panel de ejecución de código                                                */
/* -------------------------------------------------------------------------- */
.code-execution-panel .ce-code {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  max-height: 180px;
  overflow: auto;
  margin: 0 0 8px 0;
}
.code-execution-panel .ce-output {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.code-execution-panel .ce-output-label {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  margin-bottom: 4px;
}
.code-execution-panel .ce-stdout {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: transparent;
  color: var(--fg);
  white-space: pre-wrap;
}
.code-execution-panel .ce-stderr {
  margin: 8px 0 0 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--danger);
  white-space: pre-wrap;
}
.code-execution-panel .ce-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 8px;
  border-left: 3px solid var(--danger);
  margin-top: 8px;
}
.code-execution-panel .ce-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.code-execution-panel .ce-files .att-chip {
  text-decoration: none;
  color: inherit;
}

/* -------------------------------------------------------------------------- */
/* Preview inline: imágenes/archivos generados se muestran bajo la burbuja,    */
/* fuera del panel colapsable, para que el usuario los vea sin desplegar nada. */
/* -------------------------------------------------------------------------- */
.ce-preview-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 4px;
}
.ce-preview-figure {
  margin: 0;
  display: inline-flex;
  flex-direction: column;
  max-width: 100%;
}
.ce-preview-img-link {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--white);
  text-decoration: none;
  transition: border-color var(--transition);
}
.ce-preview-img-link:hover { border-color: var(--accent); }
.ce-preview-img {
  display: block;
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
  background: var(--white);
}
.ce-preview-caption {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-top: 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.ce-preview-chip {
  text-decoration: none;
  color: inherit;
}

@media (max-width: 768px) {
  .artifact-panel {
    position: fixed;
    inset: 4px 0 0 0;
    z-index: 5;
    border-left: 0;
  }
  body.artifact-open .sidebar { transform: translateX(-100%); }
}
