/**
 * Python Trace Panel — визуализация переменных при пошаговом выполнении.
 */

.python-trace-panel {
  display: flex;
  flex-direction: column;
  background: var(--idle-chrome-bg, #1a1f25);
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 0.5rem;
  max-height: 320px;
}

/* Внутри output-stack: терминал сверху, resizer, трассировка снизу */
.python-sandbox__output-stack--trace {
  min-height: 0;
}

.python-sandbox__output-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.python-sandbox__trace-splitter {
  flex: 0 0 6px;
  margin: 0;
  padding: 0;
  cursor: ns-resize;
  touch-action: none;
  background: rgba(52, 211, 153, 0.12);
  border: solid rgba(52, 211, 153, 0.22);
  border-width: 1px 0;
  box-sizing: border-box;
}

.python-sandbox__trace-splitter:hover,
.python-sandbox__trace-splitter:focus-visible,
.python-sandbox__trace-splitter--dragging {
  background: rgba(52, 211, 153, 0.28);
}

.python-sandbox__trace-splitter:focus-visible {
  outline: 2px solid var(--green, #34d399);
  outline-offset: -1px;
}

.python-sandbox__trace-splitter[hidden] {
  display: none !important;
}

.python-sandbox__output-stack--trace .python-trace-panel {
  flex: 0 0 160px;
  min-height: 80px;
  max-height: none;
  margin-top: 0;
  border-radius: 0 0 8px 8px;
  border-top: none;
}

body.python-trace-split-active,
body.python-trace-split-active .python-sandbox__trace-splitter {
  cursor: ns-resize;
  user-select: none;
}

.python-trace-panel[hidden] {
  display: none !important;
}

.python-trace-panel__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(52, 211, 153, 0.1);
  border-bottom: 1px solid rgba(52, 211, 153, 0.2);
  flex-shrink: 0;
}

.python-trace-panel__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--green, #34d399);
}

.python-trace-panel__step-label {
  font-size: 0.75rem;
  color: var(--text-muted, #94a3b8);
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.python-trace-panel__close {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text-muted, #94a3b8);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.python-trace-panel__close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.python-trace-panel__controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.python-trace-panel__btn {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  font-size: 0.875rem;
  color: var(--green, #34d399);
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
}

.python-trace-panel__btn:hover:not(:disabled) {
  background: rgba(52, 211, 153, 0.22);
}

.python-trace-panel__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.python-trace-panel__btn--play {
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
}

.python-trace-panel__slider {
  flex: 1;
  min-width: 0;
  height: 4px;
  margin: 0 0.35rem;
  accent-color: var(--green, #34d399);
  cursor: pointer;
}

.python-trace-panel__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.35rem 0.5rem;
  min-height: 0;
}

.python-trace-vars {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
}

.python-trace-vars__th {
  text-align: left;
  padding: 0.25rem 0.5rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.python-trace-vars__row td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: top;
}

.python-trace-vars__name {
  color: var(--green, #34d399);
  font-weight: 500;
  white-space: nowrap;
  width: 1%;
}

.python-trace-vars__value {
  color: #e2e8f0;
  word-break: break-all;
}

.python-trace-vars__empty td {
  padding: 0.5rem;
  text-align: center;
  color: var(--text-muted, #94a3b8);
  font-style: italic;
  font-family: system-ui, sans-serif;
}

.python-trace-panel__output {
  flex-shrink: 0;
  max-height: 4rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #a7f3d0;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  white-space: pre-wrap;
  word-break: break-all;
}

.python-trace-panel__output:empty {
  display: none;
}

/* Подсвечиваемая строка в редакторе */
.python-sandbox__trace-line {
  background: rgba(52, 211, 153, 0.15) !important;
  border-left: 3px solid var(--green, #34d399) !important;
}

/* Light theme */
[data-theme="light"] .python-trace-panel {
  background: #f0fdf4;
  border-color: rgba(21, 128, 61, 0.2);
}

[data-theme="light"] .python-trace-panel__header {
  background: rgba(21, 128, 61, 0.08);
  border-bottom-color: rgba(21, 128, 61, 0.15);
}

[data-theme="light"] .python-trace-vars__value {
  color: #1e293b;
}

[data-theme="light"] .python-trace-panel__output {
  color: #065f46;
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .python-sandbox__trace-line {
  background: rgba(21, 128, 61, 0.1) !important;
  border-left-color: #16a34a !important;
}
