/* ============================================
   Editor kode (CodeMirror 6) — kulit bersama
   untuk editor materi (.code-run) & codelab.
   Warna internal editor diatur di editor-src/cm.mjs (tema CM);
   file ini hanya mengurus kotak pembungkus + fallback.
   ============================================ */

.pyc-code {
  position: relative;
  margin: 0;
}
.pyc-code--cm .cm-editor {
  border-radius: 10px;
  overflow: hidden;
}
/* CodeMirror lahir di slide yang display:none → jangan biarkan tinggi 0 */
.pyc-code--cm .cm-editor,
.pyc-code--cm .cm-scroller {
  min-height: 3.4em;
}

/* label kecil "Python" di sudut editor — muncul saat hover, sembunyi saat mengetik
   supaya tidak pernah menutupi kode */
.pyc-code--cm::after {
  content: "Python";
  position: absolute;
  top: 6px;
  right: 10px;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s ease;
  font-family: var(--font-mono);
  font-size: .62rem;
  font-weight: 600;
  color: var(--ink-2);
  background: rgba(11, 18, 32, .9);
  padding: 1px 6px;
  border-radius: 4px;
}
.pyc-code--cm:hover::after { opacity: 1; }
.pyc-code--cm:focus-within::after { opacity: 0; }

/* fallback contenteditable (kalau bundle CM gagal dimuat) */
.pyc-code--plain {
  caret-color: var(--mint, #2fd69e);
}
.pyc-code--plain code {
  outline: none;
  cursor: text;
}
.pyc-code--ro code { cursor: default; }

/* ---------- kotak input inline (pengganti prompt popup) ---------- */
.code-run__stdin {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.code-run__stdin-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-3);
}
.code-run__stdin-field {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-mono);
  font-size: .85rem;
  line-height: 1.5;
  color: var(--code-bg);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  resize: vertical;
}
.code-run__stdin-field:focus {
  outline: none;
  border-color: var(--mint, #2fd69e);
  box-shadow: 0 0 0 3px rgba(47, 214, 158, .18);
}

/* input inline di dalam terminal output (mode interaktif) — mirip terminal asli */
.code-run__terminal-input {
  font-family: var(--font-mono);
  font-size: inherit;
  color: var(--mint, #2fd69e);
  background: transparent;
  border: none;
  border-bottom: 1px dashed rgba(47, 214, 158, .5);
  padding: 0 2px;
  min-width: 8ch;
  caret-color: var(--mint, #2fd69e);
}
.code-run__terminal-input:focus { outline: none; border-bottom-color: var(--mint, #2fd69e); }

/* ---------- editor di dalam blok materi (.code-run) ---------- */
.code-run .pyc-code--cm { margin-bottom: 0; }
.code-run--cm .code-run__bar {
  margin-top: 8px;
  border-radius: var(--radius-sm, 8px);
}
.code-run--edited.code-run--cm .pyc-code--cm .cm-gutters {
  box-shadow: inset 3px 0 0 var(--mint, #2fd69e);
}

/* ---------- editor di dalam codelab ---------- */
.codelab-editor .pyc-code--cm .cm-scroller { max-height: 38vh; }
.codelab-step--locked .pyc-code--cm { opacity: .55; filter: saturate(.5); }

@media (max-width: 640px) {
  .pyc-code--cm .cm-editor { font-size: .82rem; }
  .pyc-code--cm::after { display: none; }
}

/* ---------- Workspace Editor (VS Code style untuk proyek mandiri) ---------- */
.code-run--workspace {
  margin: 16px 0 24px;
  border: 1px solid #1d3047;
  border-radius: 8px;
  overflow: hidden;
  background: #0b1726;
}
.code-run--workspace .code-run__tabbar {
  display: flex;
  align-items: center;
  background: #08121e;
  border-bottom: 1px solid #1d3047;
  padding: 0 10px;
}
.code-run--workspace .code-run__tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--line);
  background: #0b1726;
  border-right: 1px solid #1d3047;
  border-left: 1px solid #1d3047;
  border-top: 2px solid var(--mint, #2fd69e);
  margin-top: -1px;
}
.code-run--workspace .code-run__tab-file { font-weight: 500; }
.code-run--workspace .code-run__tab-lang {
  font-size: .65rem;
  font-weight: 600;
  color: var(--ink-3);
  }
.code-run--workspace .pyc-code--cm .cm-editor {
  border: none;
  border-radius: 0;
  background: #0b1726;
}
.code-run--workspace .pyc-code--cm .cm-scroller {
  min-height: 380px;
  max-height: 52vh;
  border-radius: 0;
}
.code-run--workspace .code-run__bar {
  background: #08121e;
  border-top: 1px solid #1d3047;
  border-radius: 0;
  margin-top: 0;
  padding: 8px 14px;
}
.code-run--workspace .code-run__focus-btn {
  font-family: inherit;
  font-size: .75rem;
  font-weight: 600;
  color: #8a95a3;
  background: transparent;
  border: 1px solid #2c4560;
  border-radius: 6px;
  padding: 5px 11px;
  cursor: pointer;
  transition: all .15s ease;
}
.code-run--workspace .code-run__focus-btn:hover {
  color: var(--line);
  border-color: var(--mint, #2fd69e);
}
.code-run--workspace .code-run__term-bar {
  display: flex;
  align-items: center;
  background: #050914;
  border-top: 1px solid #1d3047;
  padding: 6px 14px;
}
.code-run--workspace .code-run__term-title {
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 700;
  color: var(--ink-3);
  }
.code-run--workspace .code-run__output {
  margin-top: 0 !important;
  border-radius: 0;
  border-left: none;
  border-top: 1px solid rgba(30, 41, 59, .5);
  background: #08121e;
  color: #a7f3d0;
  min-height: 120px;
  max-height: 36vh;
}
.code-run--workspace-focus {
  position: fixed !important;
  inset: 16px !important;
  z-index: 1200 !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  max-height: calc(100vh - 32px) !important;
  box-shadow: 0 0 0 100vmax rgba(2, 6, 23, .88) !important;
  border-color: rgba(47, 214, 158, .4) !important;
}
.code-run--workspace-focus .pyc-code--cm {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
}
.code-run--workspace-focus .pyc-code--cm .cm-editor {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
}
.code-run--workspace-focus .pyc-code--cm .cm-scroller {
  flex: 1 !important;
  min-height: 0 !important;
  max-height: none !important;
}
.code-run--workspace-focus .code-run__output {
  max-height: 28vh !important;
  flex-shrink: 0 !important;
}
