/* Variables */
:root {
  --font-mono: 'Monaco', 'Menlo', 'Consolas', monospace;
  --color-bg: #f5f5f5;
  --color-panel: #ffffff;
  --color-border: #ddd;
  --color-text: #333;
  --color-primary: #4a7aff;
  --color-primary-hover: #3a6aef;
  --color-highlight: #ffeb3b;
}

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

/* Layout */
body {
  font-family: system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  padding: 0.75rem 1rem;
  background: var(--color-panel);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Toolbar (inside header) */
#toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Buttons */
button {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#run-btn {
  background: #fd7e14;
  color: white;
}

#run-btn:hover:not(:disabled) {
  background: #e96b02;
}

#step-into-btn {
  background: #28a745;
  color: white;
}

#step-into-btn:hover:not(:disabled) {
  background: #218838;
}

#step-over-btn {
  background: #17a2b8;
  color: white;
}

#step-over-btn:hover:not(:disabled) {
  background: #138496;
}

#resume-btn {
  background: var(--color-primary);
  color: white;
}

#resume-btn:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

#stop-btn {
  background: #6c757d;
  color: white;
}

#stop-btn:hover:not(:disabled) {
  background: #5a6268;
}

#load-btn {
  background: #17a2b8;
  color: white;
}

#load-btn:hover:not(:disabled) {
  background: #138496;
}

#help-btn {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

#help-btn:hover:not(:disabled) {
  background: var(--color-bg);
}

/* Main Content - 2 Column Layout */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--color-border);
  padding: 1px;
}

/* Panes */
#code-pane,
#output-pane {
  background: var(--color-panel);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#code-pane h2,
#output-pane h2 {
  font-size: 0.875rem;
  font-weight: 500;
  color: #666;
  margin-bottom: 0.5rem;
}

/* Code Container - holds editor and display */
#code-container {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  position: relative;
}

/* Line Numbers */
.line-numbers {
  width: 3rem;
  padding: 0.75rem 0.5rem;
  background: #2d2d2d;
  color: #888;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  text-align: right;
  user-select: none;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
  border-right: none;
  border-radius: 4px 0 0 4px;
}

.line-numbers div {
  height: 1.5em;
}

/* Debug Panel - Stack Frames */
#debug-panel {
  background: #1e1e1e;
  border-top: 2px solid var(--color-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.debug-panel-header {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  background: #252525;
  border-bottom: 1px solid #444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#debug-stack-frames {
  flex: 1;
  overflow: auto;
  padding: 0.5rem;
}

/* Debug Mode - Code Pane Split */
#code-pane.debug-mode #code-container {
  flex: 1;
  min-height: 50%;
}

#code-pane.debug-mode #debug-panel {
  flex: 0 0 auto;
  max-height: 50%;
  min-height: 150px;
}

/* Interpreter Pane Header */
.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.pane-header h2 {
  font-size: 0.875rem;
  font-weight: 500;
  color: #666;
  margin: 0;
}

#line-count {
  font-size: 0.75rem;
  color: #888;
  font-family: 'Berkeley Mono', monospace;
}

.interpreter-tabs {
  display: flex;
  gap: 2px;
  background: #333;
  padding: 3px;
  border-radius: 6px;
}

/* Code Pane Tabs */
.code-tabs {
  display: flex;
  gap: 2px;
  background: #e0e0e0;
  padding: 3px;
  border-radius: 6px;
}

.code-tab-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: transparent;
  color: #666;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.code-tab-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #333;
}

.code-tab-btn.active {
  background: #fff;
  color: #333;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Language Help Fullscreen */
#language-help {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-panel);
  z-index: 50;
}

#help-iframe {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  display: block;
}

/* Hide main content when help is shown */
body.help-active #main-content {
  display: none !important;
}

body.help-active #language-help {
  display: block !important;
}

/* Hide toolbar buttons when help is shown (except those we want) */
body.help-active #toolbar {
  display: none;
}

/* Remove border appearance when help is shown */
body.help-active {
  background: var(--color-panel);
  overflow: hidden;
  position: relative;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
  main {
    flex-direction: column;
  }
}
