/**
 * Компонент Python Sandbox (Pyodide) — общий для всех app
 * NeuroEGE
 */

.python-sandbox {
  display: flex;
  flex-direction: column;
  background: #1e2228;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  min-height: 320px;
}

.python-sandbox__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.python-sandbox__header-title {
  flex-shrink: 0;
}

.python-sandbox__header-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.python-sandbox__data-tab {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.python-sandbox__data-tab:hover {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.3);
}

.python-sandbox__data-tab--active {
  color: var(--green, #05b87d);
  background: rgba(5, 184, 125, 0.15);
  border-color: rgba(5, 184, 125, 0.4);
}

.python-sandbox__panel {
  display: flex;
  flex: 1;
  min-width: 0;
  width: 100%;
}

#python-sandbox-panel-py {
  align-items: stretch;
}

.python-sandbox__panel--hidden {
  display: none !important;
}

.python-sandbox__data-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem;
  gap: 0.5rem;
}

.python-sandbox__txt {
  flex: 1;
  min-height: 176px;
  max-height: 400px;
  margin: 0;
  padding: 0.75rem;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--white);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  overflow: auto;
  white-space: pre;
}

.python-sandbox__ods-wrap {
  flex: 1;
  min-height: 176px;
  max-height: 400px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.python-sandbox__ods-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.python-sandbox__ods-table th,
.python-sandbox__ods-table td {
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: right;
}

.python-sandbox__ods-table th {
  background: rgba(0, 0, 0, 0.3);
  font-weight: 600;
  color: var(--text-muted);
}

.python-sandbox__ods-table td {
  color: var(--white);
}

.python-sandbox__copy-btn {
  align-self: flex-start;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.python-sandbox__copy-btn:hover {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.4);
}

.python-sandbox__editor-wrap {
  display: flex;
  flex: 0 0 auto;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
}

/* CodeMirror (подсветка Python) — ширина 100%, высота задаётся динамически в pyodide_sandbox.js */
.python-sandbox__editor-wrap .CodeMirror {
  flex: 1;
  min-width: 0;
  min-height: 0;
  font-size: 0.875rem;
  line-height: 1.5;
}
.python-sandbox__editor-wrap .CodeMirror-gutters {
  background: rgba(0, 0, 0, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.python-sandbox__editor-wrap .CodeMirror .python-sandbox__error-line {
  background: rgba(248, 113, 113, 0.25) !important;
}
.python-sandbox__editor-wrap .CodeMirror-cursor {
  border-left-color: var(--white);
}

/* Замена оранжевой подсветки на зелёную #05b87d */
.python-sandbox__editor-wrap .CodeMirror span.cm-keyword,
.python-sandbox__editor-wrap .CodeMirror span.cm-link,
.python-sandbox__editor-wrap .CodeMirror span.cm-atom,
.python-sandbox__editor-wrap .CodeMirror span.cm-builtin,
.python-sandbox__editor-wrap .CodeMirror span.cm-special,
.python-sandbox__editor-wrap .CodeMirror span.cm-property,
.python-sandbox__editor-wrap .CodeMirror span.cm-meta {
  color: #05b87d !important;
}

.python-sandbox__lines {
  flex-shrink: 0;
  padding: 1rem 0.5rem 1rem 1rem;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.15);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  text-align: right;
  user-select: none;
  overflow-x: hidden;
  overflow-y: auto;
  white-space: pre;
}

.python-sandbox__editor {
  flex: 1;
  min-height: 180px;
  padding: 1rem;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--white);
  background: transparent;
  border: none;
  resize: vertical;
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.python-sandbox__editor:focus {
  outline: none;
}

.python-sandbox__editor::placeholder {
  color: var(--text-muted);
}

.python-sandbox__toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.python-sandbox__toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.python-sandbox__action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.python-sandbox__action-icon {
  display: block;
  flex-shrink: 0;
}

.python-sandbox__action:hover {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.4);
}

.python-sandbox__run {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--green);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.python-sandbox__run-icon {
  font-size: 0.75rem;
  margin-left: 0.15em;
}

.python-sandbox__run:hover:not(:disabled) {
  opacity: 0.9;
}

.python-sandbox__run:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.python-sandbox__status {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.python-sandbox__output {
  max-height: 200px;
  overflow: auto;
  padding: 0.75rem 1rem;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  white-space: pre-wrap;
  word-break: break-word;
}

.python-sandbox__output:empty {
  display: none;
}

.python-sandbox__output.error {
  color: #f87171;
}

/* Светлая тема */
[data-theme="light"] .python-sandbox {
  background: #e8e8ed;
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .python-sandbox__header {
  background: rgba(0, 0, 0, 0.06);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror-gutters {
  background: rgba(0, 0, 0, 0.05);
  border-right-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror-cursor {
  border-left-color: var(--white);
}

[data-theme="light"] .python-sandbox__lines {
  background: rgba(0, 0, 0, 0.05);
  border-right-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .python-sandbox__toolbar {
  background: rgba(0, 0, 0, 0.06);
  border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .python-sandbox__action {
  border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .python-sandbox__action:hover {
  border-color: rgba(0, 0, 0, 0.4);
}

/* Светлая тема: зелёная подсветка */
[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror .python-sandbox__error-line {
  background: rgba(239, 68, 68, 0.15) !important;
}

[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-keyword,
[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-string-2,
[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-meta,
[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-builtin {
  color: #05b87d !important;
}

[data-theme="light"] .python-sandbox__output {
  background: rgba(0, 0, 0, 0.04);
  border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .python-sandbox__data-tab {
  color: rgba(0, 0, 0, 0.6);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .python-sandbox__data-tab:hover {
  color: inherit;
  border-color: rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .python-sandbox__data-tab--active {
  color: #05b87d;
  background: rgba(5, 184, 125, 0.12);
  border-color: rgba(5, 184, 125, 0.35);
}

[data-theme="light"] .python-sandbox__txt {
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
}

[data-theme="light"] .python-sandbox__ods-wrap {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .python-sandbox__ods-table th,
[data-theme="light"] .python-sandbox__ods-table td {
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .python-sandbox__ods-table th {
  background: rgba(0, 0, 0, 0.04);
  color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .python-sandbox__copy-btn {
  border-color: rgba(0, 0, 0, 0.15);
  color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .python-sandbox__copy-btn:hover {
  color: inherit;
  border-color: rgba(0, 0, 0, 0.25);
}
