/* Modern Cyber-Terminal Dark Theme */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-hover: #1f293d;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(6, 182, 212, 0.3);

  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.4);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.4);
  --accent-violet: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Fira Code', monospace;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(6, 182, 212, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
}

.app-container {
  max-width: 1540px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px var(--accent-cyan-glow);
}

.brand h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-badges {
  display: flex;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.badge-glow {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-emerald);
}

.badge-tech {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.3);
  color: var(--accent-cyan);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* Main Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 20px;
}

@media (max-width: 1080px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Panels */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
}

.tag {
  font-size: 0.72rem;
  padding: 4px 8px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-sm);
  color: var(--accent-violet);
  font-family: var(--font-mono);
}

/* Presets */
.presets-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  background: rgba(6, 182, 212, 0.15);
  border-color: var(--accent-cyan);
  color: #fff;
  transform: translateY(-1px);
}

.chip-danger:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: var(--accent-rose);
  color: var(--accent-rose);
}

/* Code Input Area */
.input-wrapper {
  position: relative;
}

.code-input {
  width: 100%;
  background: #060910;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  padding: 14px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.code-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px var(--accent-cyan-glow);
}

/* Buttons */
.action-bar {
  display: flex;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-cyan-glow);
  flex: 1;
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
}

.btn-sm:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-accent {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* Error Card */
.error-card {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: shake 0.3s ease-in-out;
}

.hidden {
  display: none !important;
}

.error-header {
  display: flex;
  justify-content: space-between;
}

.error-title {
  color: var(--accent-rose);
  font-weight: 700;
  font-size: 0.85rem;
}

.error-pos {
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.error-msg {
  color: #fda4af;
  font-size: 0.85rem;
}

.error-diagnostic {
  background: #020617;
  padding: 10px;
  border-radius: var(--radius-sm);
  color: #f43f5e;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Metrics Banner */
.metrics-card {
  background: linear-gradient(180deg, rgba(6, 182, 212, 0.05), rgba(17, 24, 39, 0.4));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-display {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.result-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-value {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-shadow: 0 0 15px var(--accent-cyan-glow);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-key {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Environment Store */
.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.env-table-wrapper {
  background: #060910;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  max-height: 180px;
  overflow-y: auto;
}

.env-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.env-tag {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #c4b5fd;
  display: flex;
  gap: 6px;
}

.env-tag .var-name {
  color: #fff;
  font-weight: 600;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.3);
  font-weight: 600;
}

.tab-content {
  flex: 1;
  min-height: 480px;
}

.tab-pane {
  display: none;
  height: 100%;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Stack Animator Controls */
.animator-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #060910;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.playback-buttons {
  display: flex;
  gap: 6px;
}

.slider-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 320px;
}

.step-slider {
  flex: 1;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.step-indicator {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 80px;
  text-align: right;
}

/* Current Step Snapshot */
.current-step-card {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.step-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 3px 8px;
  background: #020617;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.step-opcode {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-cyan);
  font-size: 1rem;
}

.step-arg {
  font-family: var(--font-mono);
  color: var(--accent-amber);
  font-size: 0.95rem;
}

.step-action {
  font-size: 0.88rem;
  color: #e2e8f0;
}

/* Stack Visualizer Stage */
.stack-visualizer-container {
  background: #060910;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.stack-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.stack-view-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stack-depth {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-emerald);
}

.stack-visual-stage {
  flex: 1;
  min-height: 280px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid var(--accent-cyan);
  padding-bottom: 12px;
}

.stack-bottom-line {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  margin-top: 6px;
}

.stack-frame {
  width: 80%;
  max-width: 380px;
  padding: 12px 20px;
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.15), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  animation: stack-push 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.stack-frame.top-frame {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 15px var(--accent-emerald-glow);
}

@keyframes stack-push {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.frame-index {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.frame-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.frame-top-tag {
  font-size: 0.68rem;
  padding: 2px 6px;
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Tables (Bytecode & Tokens) */
.table-container {
  background: #060910;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-y: auto;
  max-height: 480px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.data-table th {
  background: #0d131f;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  font-family: var(--font-mono);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.row-active td {
  background: rgba(6, 182, 212, 0.15) !important;
  color: var(--accent-cyan) !important;
  font-weight: 600;
}

.token-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.token-NUMBER { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.token-IDENTIFIER { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.token-OP { background: rgba(6, 182, 212, 0.15); color: #38bdf8; }
.token-DELIM { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

/* AST Visualizer */
.ast-tree-container {
  background: #060910;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  overflow: auto;
  max-height: 480px;
  font-family: var(--font-mono);
}

.ast-node {
  border-left: 2px solid rgba(6, 182, 212, 0.3);
  margin-left: 18px;
  padding-left: 14px;
  margin-top: 8px;
}

.ast-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  font-size: 0.82rem;
}

.ast-node-BinaryOpNode .ast-label { border-color: rgba(6, 182, 212, 0.4); color: var(--accent-cyan); }
.ast-node-UnaryOpNode .ast-label { border-color: rgba(245, 158, 11, 0.4); color: var(--accent-amber); }
.ast-node-NumberNode .ast-label { border-color: rgba(16, 185, 129, 0.4); color: var(--accent-emerald); }
.ast-node-VariableNode .ast-label { border-color: rgba(139, 92, 246, 0.4); color: var(--accent-violet); }
.ast-node-AssignNode .ast-label { border-color: rgba(244, 63, 94, 0.4); color: var(--accent-rose); }

/* RPN Chips */
.rpn-container {
  background: #060910;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rpn-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.rpn-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.rpn-token-chip {
  padding: 8px 16px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rpn-index {
  font-size: 0.7rem;
  color: var(--accent-cyan);
}

.empty-state {
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 16px;
  text-align: center;
}
