/* ============================================================
   Tutorial VM Styles
   Layout: instructions (left, full height) | editor+terminal (right, stacked)
   Always dark-mode for the workspace panels.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ───────────────────────────────────────────
   Dark mode toggle pill (in tutorial navbar)
─────────────────────────────────────────── */
.tvm-dark-toggle-wrap {
  display: inline-flex;
  align-items: center;
}

.tvm-dark-toggle-track {
  display: inline-block;
  width: 34px;
  height: 18px;
  background: #555;
  border-radius: 9px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

#darkModeToggle:checked + .tvm-dark-toggle-track {
  background: #0078d4;
}

.tvm-dark-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
}

#darkModeToggle:checked + .tvm-dark-toggle-track .tvm-dark-toggle-thumb {
  left: 18px;
}

/* ─────────────────────────────────────────── */

/* Lock the page — no scrolling on the tutorial layout */
html, body {
  height: 100%;
  overflow: hidden !important;
  margin: 0;
  padding: 0;
}

/* Root container fills the space below the fixed navbar */
.tvm-root {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #141414;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Main flex container — horizontal split */
.tvm-container {
  display: flex;
  flex-direction: row;
  height: 100%;
  width: 100%;
}

/* ───────────────────────────────────────────
   Left: Instructions Panel (full height)
─────────────────────────────────────────── */
.tvm-instructions-panel {
  flex: 0 0 38%;  /* overridden to px by splitter drag */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #1c1c1e;
  border-right: 1px solid #2a2a2e;
}

.tvm-step-nav-bar {
  flex-shrink: 0;
  padding: 10px 20px;
  background: #141416;
  border-bottom: 1px solid #2a2a2e;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tvm-step-content-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 20px;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3e transparent;
}

.tvm-step-content-wrap::-webkit-scrollbar { width: 8px; }
.tvm-step-content-wrap::-webkit-scrollbar-track { background: #252528; border-radius: 4px; }
.tvm-step-content-wrap::-webkit-scrollbar-thumb { background: #555566; border-radius: 4px; }
.tvm-step-content-wrap::-webkit-scrollbar-thumb:hover { background: #7777aa; }

/* Step content typography */
.tvm-step-content h2 {
  margin: 0 0 16px;
  color: #e8e8f0;
  font-size: 1.35em;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tvm-step-content h3 {
  color: #7ec8e3;
  font-size: 1.05em;
  font-weight: 600;
  margin: 20px 0 8px;
}

.tvm-step-instructions p {
  line-height: 1.7;
  margin: 10px 0;
  color: #c8c8d8;
  font-size: 0.95em;
}

.tvm-step-instructions code {
  background: #2a2a38;
  color: #f0a070;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'Fira Code', 'Cascadia Code', Menlo, monospace;
  border: 1px solid #3a3a48;
}

.tvm-step-instructions pre {
  background: #141418;
  padding: 14px 18px;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid #2a2a38;
  margin: 14px 0;
}

.tvm-step-instructions pre code {
  background: none;
  border: none;
  padding: 0;
  color: #d0d0e8;
  font-size: 0.9em;
}

.tvm-step-instructions ul,
.tvm-step-instructions ol {
  padding-left: 22px;
  margin: 10px 0;
}

.tvm-step-instructions li {
  margin: 6px 0;
  line-height: 1.65;
  color: #c8c8d8;
  font-size: 0.95em;
}

.tvm-step-instructions a { color: #7ec8e3; }
.tvm-step-instructions strong { color: #f0f0ff; font-weight: 600; }

/* Tables */
.tvm-step-instructions table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.9em;
}

.tvm-step-instructions thead tr {
  background: #2a2a40;
}

.tvm-step-instructions th {
  padding: 8px 12px;
  text-align: left;
  color: #e0e0ff;
  font-weight: 600;
  border-bottom: 2px solid #3a3a58;
}

.tvm-step-instructions td {
  padding: 7px 12px;
  color: #c8c8d8;
  border-bottom: 1px solid #2a2a38;
  vertical-align: middle;
}

.tvm-step-instructions tr:nth-child(even) td {
  background: #1e1e2a;
}

.tvm-step-instructions td code,
.tvm-step-instructions th code {
  font-size: 0.92em;
}

.tvm-step-instructions blockquote {
  border-left: 3px solid #0078d4;
  margin: 14px 0;
  padding: 10px 18px;
  background: rgba(0, 120, 212, 0.08);
  border-radius: 0 6px 6px 0;
  color: #a0a0c0;
}

/* ───────────────────────────────────────────
   Horizontal splitter (between left & right)
─────────────────────────────────────────── */
.tvm-hsplitter {
  flex: 0 0 4px;
  flex-shrink: 0;
  background: #2a2a2e;
  cursor: col-resize;
  transition: background 0.15s;
  position: relative;
  z-index: 10;
}
.tvm-hsplitter:hover,
.tvm-hsplitter.active {
  background: #0078d4;
}

/* ───────────────────────────────────────────
   Right: Workspace (editor top, terminal bottom)
─────────────────────────────────────────── */
.tvm-workspace {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #141414;
}

/* Editor Panel */
.tvm-editor-panel {
  flex: 0 0 60%;  /* overridden to px by splitter drag */
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #1e1e1e;
  border-bottom: 1px solid #2a2a2e;
}

.tvm-editor-tabs {
  display: flex;
  background: #161618;
  border-bottom: 1px solid #2a2a2e;
  overflow-x: auto;
  min-height: 36px;
  flex-shrink: 0;
  scrollbar-width: none;
}
.tvm-editor-tabs::-webkit-scrollbar { display: none; }

.tvm-tab {
  padding: 7px 16px;
  color: #888;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.15s, background 0.15s;
  user-select: none;
  border-right: 1px solid #2a2a2e;
  letter-spacing: 0.01em;
}

.tvm-tab.active {
  color: #e8e8f0;
  background: #1e1e1e;
  border-bottom: 2px solid #0078d4;
}

.tvm-tab:hover:not(.active) {
  color: #c0c0d0;
  background: #222228;
}

.tvm-tab-close {
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 3px;
}

.tvm-tab:hover .tvm-tab-close { opacity: 0.5; }
.tvm-tab-close:hover { opacity: 1 !important; color: #e0e0f0; background: #383848; }

.tvm-tab.saved { border-bottom-color: #4caf50 !important; }

.tvm-editor-container {
  flex: 1;
  min-height: 0;
}

/* Vertical splitter (between editor and terminal) */
.tvm-vsplitter {
  flex: 0 0 4px;
  background: #2a2a2e;
  cursor: row-resize;
  transition: background 0.15s;
  z-index: 10;
  flex-shrink: 0;
}
.tvm-vsplitter:hover,
.tvm-vsplitter.active {
  background: #0078d4;
}

/* Terminal Panel */
.tvm-terminal-panel {
  flex: 1 1 0;  /* takes remaining space after editor */
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #141414;
}

.tvm-terminal-header {
  background: #161618;
  color: #888;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid #2a2a2e;
  min-height: 34px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
}

.tvm-terminal-header::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #4caf50;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
  flex-shrink: 0;
}

.tvm-terminal-container {
  flex: 1;
  min-height: 0;
  padding: 6px 6px 4px;
  background: #0e0e10;
}

.tvm-terminal-container .xterm { height: 100%; }
.tvm-terminal-container .xterm-viewport { scrollbar-width: thin; scrollbar-color: #333 transparent; }

/* ───────────────────────────────────────────
   Step Navigation
─────────────────────────────────────────── */
.tvm-step-nav {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.tvm-step-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #3a3a44;
  background: transparent;
  color: #666;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.15s;
}

.tvm-step-btn:hover {
  border-color: #7ec8e3;
  color: #7ec8e3;
}

.tvm-step-btn.active {
  background: #0078d4;
  border-color: #0078d4;
  color: #fff;
  box-shadow: 0 0 8px rgba(0, 120, 212, 0.35);
}

/* ───────────────────────────────────────────
   Previous / Next — pinned footer bar
─────────────────────────────────────────── */
.tvm-step-controls-bar {
  flex-shrink: 0;
  padding: 10px 20px;
  background: #141416;
  border-top: 1px solid #2a2a2e;
}

.tvm-step-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tvm-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.01em;
}

.tvm-btn:active { transform: scale(0.97); }

.tvm-btn-prev,
.tvm-btn-next {
  background: #0078d4;
  color: #fff;
}

.tvm-btn-prev:hover,
.tvm-btn-next:hover {
  background: #1a8ae6;
}

/* ───────────────────────────────────────────
   Test My Work button & results panel
─────────────────────────────────────────── */
.tvm-btn-test {
  background: #1a7f3c;
  color: #fff;
}
.tvm-btn-test:hover { background: #22a04e; }

.tvm-test-panel {
  margin-top: 20px;
  border-top: 1px solid #2a2a38;
  padding-top: 16px;
}

.tvm-test-running {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #8080a0;
  font-size: 0.9em;
  padding: 10px 0;
}

.tvm-test-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #3a3a48;
  border-top-color: #1a7f3c;
  border-radius: 50%;
  animation: tvm-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.tvm-test-summary {
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 0.95em;
}
.tvm-test-summary.all-pass {
  background: rgba(26,127,60,.18);
  color: #4caf50;
  border: 1px solid rgba(76,175,80,.3);
}
.tvm-test-summary.partial {
  background: rgba(230,160,30,.12);
  color: #e6a01e;
  border: 1px solid rgba(230,160,30,.28);
}

.tvm-test-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tvm-test-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 5px;
  background: #1a1a22;
  border: 1px solid #2a2a38;
  line-height: 1.4;
}
.tvm-test-item.pass { border-color: rgba(76,175,80,.25); background: rgba(26,127,60,.08); }
.tvm-test-item.fail { border-color: rgba(239,83,80,.25); background: rgba(180,40,40,.08); }

.tvm-test-icon {
  font-weight: 700;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  margin-top: 1px;
}
.tvm-test-item.pass .tvm-test-icon { color: #4caf50; }
.tvm-test-item.fail .tvm-test-icon { color: #ef5350; }
.tvm-test-item.unknown .tvm-test-icon { color: #888; }

.tvm-test-desc { color: #c8c8d8; font-size: 0.92em; }

/* ───────────────────────────────────────────
   Loading Overlay
─────────────────────────────────────────── */
.tvm-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #141414;
  color: #b0b0c0;
  z-index: 100;
  gap: 20px;
}

.tvm-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #2a2a38;
  border-top-color: #0078d4;
  border-radius: 50%;
  animation: tvm-spin 0.75s linear infinite;
}

@keyframes tvm-spin { to { transform: rotate(360deg); } }

.tvm-loading-text {
  font-size: 14px;
  font-weight: 500;
  color: #8080a0;
}

/* ───────────────────────────────────────────
   Error State
─────────────────────────────────────────── */
.tvm-error {
  padding: 60px 40px;
  text-align: center;
  background: #141414;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.tvm-error h3 { font-size: 1.4em; color: #ef5350; }
.tvm-error p { color: #808090; max-width: 500px; line-height: 1.65; font-size: 0.95em; }
.tvm-error-hint code { background: #2a2a38; padding: 2px 8px; border-radius: 4px; color: #f0a070; }
.tvm-error button {
  margin-top: 12px;
  padding: 10px 28px;
  background: #0078d4;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s;
}
.tvm-error button:hover { background: #1a8ae6; }

/* ───────────────────────────────────────────
   Responsive
─────────────────────────────────────────── */
@media (max-width: 900px) {
  .tvm-container { flex-direction: column; }
  .tvm-instructions-panel { flex: 0 0 40%; border-right: none; border-bottom: 1px solid #2a2a2e; }
  .tvm-hsplitter { cursor: row-resize; }
  .tvm-workspace { flex-direction: column; }
  .tvm-vsplitter { cursor: row-resize; }
}

/* ───────────────────────────────────────────
   Layout overrides
─────────────────────────────────────────── */
.tutorial-page {
  /* Pin to exact viewport edges below the fixed navbar — robust in fullscreen */
  position: fixed !important;
  top: 50px !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden;
}

.tutorial-page .container {
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
  height: 100%;
}

#tutorial-container {
  height: 100%;
}


/* ───────────────────────────────────────────
   Light Mode Overrides  (html:not(.dark-mode))
   Matches site's cookie-based theme toggle.
   Terminal and editor panels stay dark —
   conventional for code editors / terminals.
─────────────────────────────────────────── */

html:not(.dark-mode) .tvm-root {
  background: #f0f0f4;
}

/* Instructions panel */
html:not(.dark-mode) .tvm-instructions-panel {
  background: #ffffff;
  border-right-color: #d0d0da;
}

html:not(.dark-mode) .tvm-step-nav-bar {
  background: #f5f5f8;
  border-bottom-color: #d0d0da;
}

html:not(.dark-mode) .tvm-step-controls-bar {
  background: #f5f5f8;
  border-top-color: #d0d0da;
}

/* Scrollbar */
html:not(.dark-mode) .tvm-step-content-wrap {
  scrollbar-color: #b0b0c0 transparent;
}
html:not(.dark-mode) .tvm-step-content-wrap::-webkit-scrollbar-track { background: #e8e8f0; }
html:not(.dark-mode) .tvm-step-content-wrap::-webkit-scrollbar-thumb { background: #b0b0c4; }
html:not(.dark-mode) .tvm-step-content-wrap::-webkit-scrollbar-thumb:hover { background: #7777aa; }

/* Typography */
html:not(.dark-mode) .tvm-step-content h2 {
  color: #111120;
}

html:not(.dark-mode) .tvm-step-content h3 {
  color: #0060a8;
}

html:not(.dark-mode) .tvm-step-instructions p {
  color: #383848;
}

html:not(.dark-mode) .tvm-step-instructions code {
  background: #eaeaf4;
  color: #b03010;
  border-color: #c8c8d8;
}

html:not(.dark-mode) .tvm-step-instructions pre {
  background: #f0f0f8;
  border-color: #d0d0e0;
}

html:not(.dark-mode) .tvm-step-instructions pre code {
  color: #222236;
}

html:not(.dark-mode) .tvm-step-instructions li {
  color: #383848;
}

html:not(.dark-mode) .tvm-step-instructions a { color: #0060a8; }
html:not(.dark-mode) .tvm-step-instructions strong { color: #0a0a20; }

/* Tables */
html:not(.dark-mode) .tvm-step-instructions thead tr {
  background: #e0e0ef;
}

html:not(.dark-mode) .tvm-step-instructions th {
  color: #111120;
  border-bottom-color: #b0b0cc;
}

html:not(.dark-mode) .tvm-step-instructions td {
  color: #383848;
  border-bottom-color: #d0d0e0;
}

html:not(.dark-mode) .tvm-step-instructions tr:nth-child(even) td {
  background: #f5f5ff;
}

html:not(.dark-mode) .tvm-step-instructions blockquote {
  background: rgba(0, 100, 180, 0.07);
  color: #505070;
}

/* Workspace + editor + terminal (VSCode light palette) */
html:not(.dark-mode) .tvm-workspace {
  background: #ffffff;
}

html:not(.dark-mode) .tvm-editor-panel {
  background: #ffffff;
  border-bottom-color: #d4d4d4;
}

html:not(.dark-mode) .tvm-editor-tabs {
  background: #f3f3f3;
  border-bottom-color: #d4d4d4;
}

html:not(.dark-mode) .tvm-tab {
  color: #6e6e6e;
  border-right-color: #d4d4d4;
}

html:not(.dark-mode) .tvm-tab.active {
  color: #333;
  background: #ffffff;
}

html:not(.dark-mode) .tvm-tab:hover:not(.active) {
  color: #333;
  background: #e8e8e8;
}

html:not(.dark-mode) .tvm-tab-close:hover {
  background: #d0d0d0;
  color: #333;
}

html:not(.dark-mode) .tvm-terminal-header {
  background: #f3f3f3;
  color: #5a5a5a;
  border-bottom-color: #d4d4d4;
}

html:not(.dark-mode) .tvm-terminal-container {
  background: #ffffff;
}

/* Splitter */
html:not(.dark-mode) .tvm-hsplitter {
  background: #d0d0da;
}

/* Step nav dots */
html:not(.dark-mode) .tvm-step-btn {
  border-color: #c0c0c8;
  color: #333;
  background: #f5f5f7;
}

html:not(.dark-mode) .tvm-step-btn.active {
  background: #0078d4;
  border-color: #0078d4;
  color: #fff;
}

html:not(.dark-mode) .tvm-step-btn:hover:not(.active) {
  border-color: #0060a8;
  color: #0060a8;
}

html:not(.dark-mode) .tvm-step-btn.active:hover {
  background: #006cbf;
  border-color: #006cbf;
  color: #fff;
}

/* Test results */
html:not(.dark-mode) .tvm-test-panel {
  border-top-color: #d0d0e0;
}

html:not(.dark-mode) .tvm-test-running {
  color: #6060a0;
}

html:not(.dark-mode) .tvm-test-spinner {
  border-color: #d0d0e0;
  border-top-color: #1a7f3c;
}

html:not(.dark-mode) .tvm-test-item {
  background: #f4f4fa;
  border-color: #d0d0e0;
}

html:not(.dark-mode) .tvm-test-item.pass { border-color: rgba(76,175,80,.4); background: rgba(26,127,60,.06); }
html:not(.dark-mode) .tvm-test-item.fail { border-color: rgba(239,83,80,.4); background: rgba(180,40,40,.06); }

html:not(.dark-mode) .tvm-test-desc { color: #383848; }

/* Loading overlay */
html:not(.dark-mode) .tvm-loading {
  background: #f0f0f4;
  color: #4a4a5a;
}

html:not(.dark-mode) .tvm-loading-spinner {
  border-color: #d0d0e0;
  border-top-color: #0078d4;
}

html:not(.dark-mode) .tvm-loading-text {
  color: #5a5a80;
}

/* Error state */
html:not(.dark-mode) .tvm-error {
  background: #f0f0f4;
}

html:not(.dark-mode) .tvm-error p { color: #505060; }
html:not(.dark-mode) .tvm-error-hint code { background: #eaeaf4; color: #b03010; }

/* Responsive border on narrow screens */
@media (max-width: 900px) {
  html:not(.dark-mode) .tvm-instructions-panel { border-bottom-color: #d0d0da; }
}
