/* SandScript Playground Styles */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: #2800ba;
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.header {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.header-title {
  font-weight: 400;
}

.header-nav {
  display: flex;
  gap: 8px;
}

.header-button {
  background: none;
  border: none;
  color: #8080c0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 2px 6px;
}

.header-button:hover {
  color: #fff;
}

.header-button.active {
  background: #00d8d8;
  color: #000;
}

/* ==========================================================================
   Tab Content
   ========================================================================== */

.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
  gap: 24px;
}

.tab-content.active {
  display: flex;
}

.main {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 24px;
  gap: 24px;
  overflow: hidden;
}

/* ==========================================================================
   Memory Tab - Legend
   ========================================================================== */

.memory-map {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.memory-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #8080c0;
  padding: 2px 4px;
  margin: -2px -4px;
}

.legend-item:hover {
  color: #fff;
}

.legend-item.active {
  background: #00d8d8;
  color: #000;
}

.legend-item.active .legend-size {
  color: #006060;
}

.legend-label {
  flex: 1;
}

.legend-size {
  color: #6060a0;
}

/* ==========================================================================
   Memory Tab - Hexdump
   ========================================================================== */

.hexdump-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-top: -4px;
}

.hexdump-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 12px;
}

.hexdump-title {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hexdump-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hexdump-pagination button {
  background: #4020d0;
  border: none;
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
}

.hexdump-pagination button:hover {
  background: #5030e0;
}

.hexdump-pagination button:disabled {
  background: #3010a0;
  color: #6060a0;
  cursor: not-allowed;
}

.hexdump {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  overflow: auto;
  white-space: pre;
  flex: 1;
}

.hex-highlight {
  background: #ffeb3b;
  color: #000;
}

.hex-byte {
  cursor: pointer;
}

.hex-byte:hover {
  background: #00d8d8;
  color: #000;
}

/* ==========================================================================
   Memory Tab - Inspector
   ========================================================================== */

.inspector {
  width: 280px;
  flex-shrink: 0;
  font-size: 12px;
  overflow: auto;
}

.inspector-section {
  margin-bottom: 16px;
}

.inspector-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid #3810c0;
}

.inspector-label {
  color: #8080c0;
}

.inspector-value {
  font-family: 'JetBrains Mono', monospace;
}

.inspector-input {
  width: 100%;
  background: #1a0080;
  border: 1px solid #4020d0;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 3px;
  margin-top: 8px;
}

.inspector-input:focus {
  outline: none;
  border-color: #6040f0;
}

.inspector-input::placeholder {
  color: #6060a0;
}

.inspector-btn {
  background: #4020d0;
  border: none;
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  margin-top: 8px;
  margin-right: 4px;
}

.inspector-btn:hover {
  background: #5030e0;
}

.inspector-result {
  margin-top: 8px;
  padding: 6px 8px;
  background: #1a0080;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  word-break: break-all;
}

.inspector-result.error {
  color: #ff6b6b;
}

.inspector-result.success {
  color: #69db7c;
}

.inspector-label[data-highlight] {
  cursor: pointer;
  padding: 1px 3px;
  margin: -1px -3px;
}

.inspector-label[data-highlight]:hover {
  background: #00d8d8;
  color: #000;
}

.inspector-label.highlight-from-hex {
  background: #00d8d8;
  color: #000;
}

/* ==========================================================================
   Code Tab - Editor
   ========================================================================== */

.editor-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 12px;
  flex-shrink: 0;
}

.editor-title {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8080c0;
}

.editor-status {
  font-family: 'JetBrains Mono', monospace;
}

.editor-status.error {
  color: #ff6b6b;
}

.editor-status.success {
  color: #69db7c;
}

.editor-status.pending {
  color: #ffd93d;
}

.code-editor {
  flex: 1;
  min-height: 0;
  background: #2800ba;
  border: none;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  line-height: 1.5;
  padding: 0;
  overflow: auto;
  resize: none;
}

.code-editor:focus {
  outline: none;
}

.code-editor::selection {
  background: #ffeb3b;
  color: #000;
}

.code-editor::placeholder {
  color: #6060a0;
}

/* ==========================================================================
   Code Tab - Output Panel
   ========================================================================== */

.code-output {
  width: 380px;
  flex-shrink: 0;
  min-height: 0;
  overflow-y: auto;
  font-size: 12px;
}

.code-section {
  margin-bottom: 16px;
}

.code-section-title {
  color: #8080c0;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-object {
  margin-bottom: 12px;
  padding-left: 8px;
  border-left: 2px solid #4020d0;
}

.code-object.is-code-block {
  border-left-color: #00d8d8;
}

.code-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid #3810c0;
}

.code-row-label {
  color: #8080c0;
}

.code-row-value {
  font-family: 'JetBrains Mono', monospace;
}

/* ==========================================================================
   Code Tab - Instructions
   ========================================================================== */

.code-instruction {
  padding: 2px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.code-instruction[data-src] {
  cursor: pointer;
}

.code-instruction[data-src]:hover,
.code-instruction.highlight {
  background: #4020d0;
}

.code-instruction-index {
  color: #6060a0;
  display: inline-block;
  width: 28px;
}

.code-instruction-op {
  color: #00d8d8;
  display: inline-block;
  width: 120px;
}

.code-instruction-operands {
  color: #aaa;
}

.code-instruction.current {
  background: #00d8d8;
  color: #000;
}

.code-instruction.current .code-instruction-index,
.code-instruction.current .code-instruction-op,
.code-instruction.current .code-instruction-operands {
  color: #000;
}

/* ==========================================================================
   Code Tab - Execution Controls
   ========================================================================== */

.execution-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid #4020d0;
  margin-top: 12px;
  font-size: 12px;
  flex-shrink: 0;
}

.execution-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.execution-field label {
  color: #8080c0;
}

.execution-field input {
  width: 60px;
  background: #1a0080;
  border: 1px solid #4020d0;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 3px;
}

.execution-field input:focus {
  outline: none;
  border-color: #6040f0;
}

.execution-btn {
  background: #4020d0;
  border: none;
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.execution-btn:hover {
  background: #5030e0;
}

.execution-btn.primary {
  background: #00d8d8;
  color: #000;
}

.execution-btn.primary:hover {
  background: #00e8e8;
}

.execution-status {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
}

.execution-status.done {
  color: #69db7c;
}

.execution-status.paused {
  color: #ffd93d;
}

.execution-status.error {
  color: #ff6b6b;
}

/* ==========================================================================
   Code Tab - Runtime Panels (Scope & Pending)
   ========================================================================== */

.runtime-panels {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #4020d0;
  flex-shrink: 0;
  height: 180px;
}

.runtime-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.runtime-panel-title {
  color: #8080c0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.runtime-panel-content {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.scope-level {
  margin-bottom: 8px;
}

.scope-header {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: #00d8d8;
  margin-bottom: 4px;
}

.scope-header:hover {
  color: #fff;
}

.scope-toggle {
  width: 12px;
}

.scope-vars {
  padding-left: 16px;
}

.scope-var {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px solid #3810c0;
}

.scope-var-name {
  color: #fff;
}

.scope-var-value {
  color: #8080c0;
}

.scope-var-type {
  color: #6060a0;
  font-size: 10px;
}

.pending-item {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px solid #3810c0;
}

.pending-index {
  color: #6060a0;
  width: 24px;
}

.pending-value {
  flex: 1;
  color: #fff;
}

.pending-type {
  color: #6060a0;
  font-size: 10px;
}

.pending-push-form {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px solid #3810c0;
  margin-top: 8px;
}

.pending-push-form select {
  background: #1a0080;
  border: 1px solid #4020e0;
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 2px 4px;
}

.pending-push-form input {
  flex: 1;
  background: #1a0080;
  border: 1px solid #4020e0;
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 2px 6px;
  min-width: 0;
}

.pending-push-form button {
  background: #00d8d8;
  border: none;
  color: #000;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
}

.pending-push-form button:hover {
  background: #00ffff;
}

/* ==========================================================================
   Console Panel
   ========================================================================== */

.console-panel {
  background: #1a0080;
  border: 1px solid #4020e0;
  display: flex;
  flex-direction: column;
  min-height: 80px;
  max-height: 150px;
}

.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid #3810c0;
}

.console-title {
  color: #8080c0;
  font-size: 10px;
  text-transform: uppercase;
}

.console-clear {
  background: none;
  border: 1px solid #4020e0;
  color: #8080c0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 1px 6px;
  cursor: pointer;
}

.console-clear:hover {
  background: #3810c0;
  color: #fff;
}

.console-output {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.console-line {
  padding: 1px 0;
  color: #00d8d8;
}

.console-line.console-warn {
  color: #ffcc00;
}

.console-line.console-error {
  color: #ff6060;
}

/* ==========================================================================
   Shared
   ========================================================================== */

.empty-state {
  color: #6060a0;
  font-style: italic;
}

/* ==========================================================================
   FFI Tab
   ========================================================================== */

#tab-ffi {
  flex-direction: row;
  padding: 24px;
}

.ffi-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.ffi-history-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: 24px;
}

.ffi-section {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  padding: 12px;
}

.ffi-section-title {
  color: #8080c0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.ffi-section-content {
  font-size: 12px;
}

.ffi-namespace {
  margin-bottom: 12px;
}

.ffi-namespace-name {
  color: #00d8d8;
  margin-bottom: 4px;
}

.ffi-method {
  padding-left: 12px;
  color: #aaa;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.ffi-rule {
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  margin-bottom: 8px;
  font-size: 11px;
}

.ffi-rule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.ffi-rule-title {
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
}

.ffi-rule-actions {
  display: flex;
  gap: 4px;
}

.ffi-rule-btn {
  background: #4020d0;
  border: none;
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 2px;
  cursor: pointer;
}

.ffi-rule-btn:hover {
  background: #5030e0;
}

.ffi-rule-btn.danger {
  background: #802020;
}

.ffi-rule-btn.danger:hover {
  background: #a03030;
}

.ffi-rule-condition {
  color: #8080c0;
  padding: 2px 0;
  font-family: 'JetBrains Mono', monospace;
}

.ffi-rule-condition.active {
  color: #69db7c;
}

.ffi-rule-condition.inactive {
  color: #6060a0;
  text-decoration: line-through;
}

.ffi-history-content {
  flex: 1;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.ffi-history-entry {
  padding: 6px 8px;
  border-bottom: 1px solid #3810c0;
  display: flex;
  gap: 12px;
}

.ffi-history-time {
  color: #6060a0;
  flex-shrink: 0;
}

.ffi-history-call {
  flex: 1;
  color: #fff;
}

.ffi-history-result {
  color: #8080c0;
}

.ffi-history-rule {
  color: #69db7c;
  flex-shrink: 0;
}

.ffi-history-entry.pending {
  background: rgba(255, 217, 61, 0.1);
}

.ffi-history-entry.error .ffi-history-result {
  color: #ff6b6b;
}

.ffi-history-entry .ffi-history-output {
  color: #aaa;
  padding-left: 12px;
}

/* ==========================================================================
   FFI Approval UI (inline in code output)
   ========================================================================== */

.ffi-approval {
  background: rgba(255, 217, 61, 0.15);
  border: 1px solid #ffd93d;
  border-radius: 4px;
  padding: 12px;
  margin: 8px 0;
}

.ffi-approval-header {
  color: #ffd93d;
  font-size: 12px;
  margin-bottom: 8px;
}

.ffi-approval-detail {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #aaa;
  margin-bottom: 4px;
}

.ffi-approval-detail span {
  color: #fff;
}

.ffi-approval-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.ffi-approval-btn {
  background: #4020d0;
  border: none;
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
}

.ffi-approval-btn:hover {
  background: #5030e0;
}

.ffi-approval-btn.primary {
  background: #00d8d8;
  color: #000;
}

.ffi-approval-btn.primary:hover {
  background: #00e8e8;
}
