/* minikotlin playground — two-pane layout: editor on the left,
 * output on the right. Mirrors miniswift.run's playground rhythm
 * (toolbar + workspace + statusbar) with the Kotlin magenta→orange
 * accent. The compiler doesn't run in-browser yet — the editor
 * shows the source for the selected pre-compiled sample, and Run
 * fetches the matching .wasm and invokes its CALL specs. */

:root {
  --bg:        #0A0B0C;
  --surface:   #0F1112;
  --surface2:  #151718;
  --border:    #1E2022;
  --line-soft: #21262D;

  --accent:       #C757BC;
  --accent-warm:  #E07758;
  --accent-soft:  rgba(199, 87, 188, 0.10);

  --t1: #E8E8E8;
  --t2: #888;
  --t3: #555;

  --green: #98C379;
  --red:   #ff7676;
  --amber: #f9b04a;

  --mono: "JetBrains Mono", "SF Mono", Menlo, monospace;
  --sans: -apple-system, "Inter", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--t1);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}
a { color: inherit; text-decoration: none; }

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.toolbar .brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 14px; letter-spacing: -0.02em;
}
.toolbar .brand .logo {
  width: 24px; height: 24px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-warm));
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 14px;
}
.toolbar .brand .name-accent { color: var(--accent); }
.toolbar .sep {
  width: 1px; height: 22px;
  background: var(--border);
  margin: 0 4px;
}
.toolbar-spacer { flex: 1; }

.run-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 16px; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent-warm));
  color: #fff; border: 0;
  cursor: pointer; transition: filter 0.15s, transform 0.1s;
}
.run-btn:hover { filter: brightness(1.1); }
.run-btn:active { transform: translateY(1px); }
.run-btn:disabled {
  background: var(--surface2);
  color: var(--t3);
  cursor: not-allowed;
  filter: none;
}
.run-btn svg { width: 9px; height: 10px; }
.run-btn .kbd {
  display: inline-block;
  font-family: var(--mono); font-size: 10px;
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 5px; border-radius: 3px;
  margin-left: 2px;
}

.example-select {
  font-family: inherit; font-size: 12.5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--t1);
  padding: 6px 10px; border-radius: 7px;
  cursor: pointer;
  min-width: 220px;
}
.example-select:focus { outline: none; border-color: var(--accent); }
.example-select:hover { border-color: var(--t2); }

.status-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px; border-radius: 99px;
  font-size: 11.5px; font-family: var(--mono);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--t2);
}
.status-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--t3);
  transition: background 0.2s, box-shadow 0.2s;
}
.status-badge.idle .dot { background: var(--t3); }
.status-badge.busy .dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.status-badge.ok   .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-badge.err  .dot { background: var(--red);   box-shadow: 0 0 8px var(--red); }
.status-badge.busy { color: var(--amber); }
.status-badge.ok   { color: var(--green); }
.status-badge.err  { color: var(--red); }

/* ── Workspace ────────────────────────────────────────────────────────────── */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4px minmax(0, 1fr);
  overflow: hidden;
}
.divider {
  background: var(--border);
  cursor: col-resize;
  transition: background 0.15s;
}
.divider:hover { background: var(--accent); }

.pane {
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.pane-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 12px; color: var(--t1);
  flex-shrink: 0;
}
.pane-header svg {
  width: 14px; height: 14px;
  color: var(--t2);
}
.pane-header .filename { font-weight: 500; }
.pane-header .meta {
  margin-left: auto;
  font-size: 11px; color: var(--t3);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Monaco host. Monaco mounts inside this and absolute-fills it. */
.monaco-host {
  flex: 1; min-height: 0;
  background: var(--surface);
}

.modified-badge {
  margin-left: 4px;
  font-family: var(--mono); font-size: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px; border-radius: 99px;
  letter-spacing: 0.04em;
}

.ghost-btn {
  display: inline-flex; align-items: center;
  font-family: inherit; font-size: 12px; font-weight: 500;
  padding: 6px 12px; border-radius: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--t2);
  cursor: pointer; transition: all 0.15s;
  text-decoration: none;
}
.ghost-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Output pane */
.output {
  flex: 1; overflow: auto;
  padding: 14px 18px;
  font-family: var(--mono); font-size: 12.5px;
  line-height: 1.6;
  background: #08090a;
}
.output .placeholder {
  color: var(--t3);
  text-align: center;
  padding: 60px 20px;
  font-size: 13px;
}
.output .placeholder kbd {
  display: inline-block;
  font-family: var(--mono); font-size: 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 4px;
  color: var(--t2);
  margin: 0 2px;
}

.run-summary {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 11.5px;
  color: var(--t2);
}
.run-summary .count {
  font-weight: 700; font-size: 14px;
  color: var(--t1);
}
.run-summary.ok  .count { color: var(--green); }
.run-summary.err .count { color: var(--red); }
.run-summary .when {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--t3);
}

.calls-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.calls-table th, .calls-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.calls-table th {
  font-size: 10px; font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--surface);
}
.calls-table tr:last-child td { border-bottom: 0; }
.calls-table .pill {
  display: inline-block;
  font-size: 9.5px;
  padding: 2px 7px; border-radius: 99px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.calls-table .pill.ok   { background: rgba(152, 195, 121, 0.15); color: var(--green); }
.calls-table .pill.err  { background: rgba(255, 118, 118, 0.15); color: var(--red);   }
.calls-table .pill.idle { background: rgba(199, 87, 188, 0.10);  color: var(--accent);}
.calls-table td.spec   { color: var(--t1); }
.calls-table td.want   { color: var(--t2); font-variant-numeric: tabular-nums; }
.calls-table td.got    { color: var(--t2); font-variant-numeric: tabular-nums; }
.calls-table td.got.diff { color: var(--red); }

.error-block {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(255, 118, 118, 0.06);
  border: 1px solid rgba(255, 118, 118, 0.20);
  border-radius: 8px;
  font-family: var(--mono); font-size: 11.5px;
  color: var(--red);
  white-space: pre-wrap;
}
.error-block .label {
  display: block;
  margin-bottom: 4px;
  font-size: 10px; font-weight: 600;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stdout-block {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--bg-soft, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
}
.stdout-block .label {
  display: block;
  margin-bottom: 4px;
  font-size: 10px; font-weight: 600;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stdout-block pre {
  margin: 0;
  font-family: var(--mono); font-size: 11.5px;
  color: var(--t1);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Terminal-style output for auto-main / REPL mode — used when the
 * source has `fun main()` and no explicit CALL directives so we
 * skip the test-runner table entirely and show just the program
 * output. The bar at the top mimics a shell prompt; no "expected vs
 * got" framing — this is just `node ./hello.kt` output for the
 * pasted code. */
.terminal-block {
  margin-top: 4px;
  background: #0d0d10;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.10));
  border-radius: 8px;
  overflow: hidden;
}
.terminal-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--mono); font-size: 11px;
  color: var(--t2);
}
.terminal-bar .when { color: var(--t3, var(--t2)); opacity: 0.75; }
.terminal-block pre {
  margin: 0;
  padding: 12px 14px;
  font-family: var(--mono); font-size: 12px;
  color: #e6e6e6;
  background: transparent;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.4em;
}
.terminal-block pre.dim,
.terminal-block pre .dim { color: var(--t3, var(--t2)); opacity: 0.65; }

.cov-hint {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(199, 87, 188, 0.20);
  border-radius: 8px;
  font-size: 12px; color: var(--t1);
  line-height: 1.7;
}
.cov-hint strong { color: var(--accent); font-weight: 600; }
.cov-hint code   {
  font-family: var(--mono); font-size: 11px;
  color: var(--accent);
  background: rgba(199, 87, 188, 0.18);
  padding: 1px 5px; border-radius: 3px;
}
.cov-hint a {
  color: var(--accent); font-weight: 500;
  text-decoration: none;
}
.cov-hint a:hover { text-decoration: underline; }

/* ── Statusbar ────────────────────────────────────────────────────────────── */
.statusbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 28px; padding: 0 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 11px; color: var(--t3);
  flex-shrink: 0;
}
.statusbar .kbd {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 3px;
  color: var(--t2);
  margin: 0 2px;
}
.statusbar .sep { color: var(--border); margin: 0 8px; }
.statusbar a { color: var(--t2); }
.statusbar a:hover { color: var(--accent); }

/* Responsive */
@media (max-width: 760px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 4px minmax(0, 1fr);
  }
  .divider { cursor: row-resize; }
  .toolbar { flex-wrap: wrap; height: auto; padding: 8px; gap: 8px; }
  .example-select { min-width: 140px; }
  .statusbar { display: none; }
}
