/* ── Reset & Variáveis ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1e1e2e;
  --surface: #2a2a3d;
  --surface2: #313147;
  --border: #44446a;
  --accent: #7c6ff7;
  --accent2: #56cfb2;
  --text: #cdd6f4;
  --text-dim: #888ab0;
  --error: #f38ba8;
  --warn: #fab387;
  --ok: #a6e3a1;
  --info: #89dceb;
  --keyword: #cba6f7;
  --font-mono: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --font-ui: 'Segoe UI', system-ui, sans-serif;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .03em;
}

.logo svg { width: 28px; height: 28px; }

.badge {
  background: var(--accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Menu Ajuda ── */
.help-menu { position: relative; }

.help-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .82rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .15s;
}

.help-btn:hover { background: var(--border); }

.help-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 210px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 200;
}

.help-menu.open .help-dropdown { display: block; }

.help-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: .83rem;
  color: var(--text);
  transition: background .12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-radius: 0;
}

.help-dropdown-item:hover { background: var(--surface2); }

.help-dropdown-item .item-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.help-dropdown .sep-line {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Exemplos expandíveis dentro do dropdown */
.help-examples-list { display: none; background: var(--bg); }
.help-examples-list.open { display: block; }

.help-examples-list .help-dropdown-item {
  padding-left: 32px;
  font-size: .8rem;
  color: var(--accent2);
}

/* ── Toolbar ── */
.toolbar {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

button {
  font-family: var(--font-ui);
  font-size: .82rem;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .15s, transform .1s;
}

button:active { transform: scale(.96); }

.btn-run { background: var(--accent); color: #fff; font-weight: 600; }
.btn-run:hover { background: #6a5fe5; }

.btn-clear {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-clear:hover { background: var(--border); color: var(--text); }

.btn-example {
  background: var(--surface);
  color: var(--accent2);
  border: 1px solid var(--border);
  font-size: .78rem;
}
.btn-example:hover { background: var(--border); }

.btn-save {
  background: var(--surface);
  color: var(--ok);
  border: 1px solid var(--border);
  font-size: .82rem;
}
.btn-save:hover { background: var(--border); color: #fff; }

.btn-save-as {
  background: var(--surface);
  color: var(--ok);
  border: 1px solid var(--border);
  font-size: .82rem;
  opacity: .8;
}
.btn-save-as:hover { background: var(--border); color: #fff; opacity: 1; }

.btn-load {
  background: var(--surface);
  color: var(--info);
  border: 1px solid var(--border);
  font-size: .82rem;
}
.btn-load:hover { background: var(--border); color: #fff; }

.sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

.status-indicator {
  margin-left: auto;
  font-size: .78rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}
.status-dot.error { background: var(--error); }
.status-dot.running { background: var(--warn); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ── Main ── */
.main { display: flex; flex: 1; overflow: hidden; }

/* ── Editor ── */
.editor-pane {
  display: flex;
  flex-direction: column;
  width: 52%;
  border-right: 2px solid var(--border);
  min-width: 300px;
}

.pane-title {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 5px 14px;
  font-size: .72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
  flex-shrink: 0;
}

.editor-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.line-numbers {
  background: var(--surface2);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  font-family: var(--font-mono);
  font-size: .88rem;
  line-height: 1.55;
  color: var(--text-dim);
  text-align: right;
  user-select: none;
  white-space: pre;
  overflow: hidden;
  min-width: 44px;
}

#editor {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .88rem;
  line-height: 1.55;
  border: none;
  outline: none;
  resize: none;
  padding: 14px 16px;
  tab-size: 4;
  overflow-y: auto;
  white-space: pre;
  overflow-x: auto;
  caret-color: var(--accent);
}

/* ── Diagnostics bar ── */
.diagnostics {
  background: var(--surface2);
  border-top: 1px solid var(--border);
  padding: 4px 14px;
  font-size: .74rem;
  min-height: 24px;
  color: var(--text-dim);
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-direction: column;
  overflow-y: auto;
  max-height: 90px;
}

.diag-ok    { color: var(--ok); }
.diag-error { color: var(--error); }
.diag-warn  { color: var(--warn); }
.diag-info  { color: var(--info); }
.diag-fix   { color: var(--accent2); font-style: italic; margin-left: 14px; }

/* ── Console ── */
.console-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 260px;
}

#console-output {
  flex: 1;
  background: #12121e;
  font-family: var(--font-mono);
  font-size: .86rem;
  line-height: 1.6;
  padding: 14px 16px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.console-line     { display: block; }
.console-out      { color: var(--text); }
.console-in       { color: var(--accent2); }
.console-err      { color: var(--error); }
.console-err-hint { color: var(--warn); font-style: italic; padding-left: 10px; }
.console-sys      { color: var(--text-dim); font-style: italic; }
.console-sep      { color: var(--border); }

/* ── Input bar ── */
.input-bar {
  background: var(--surface2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 6px 12px;
  gap: 8px;
  flex-shrink: 0;
}

.input-bar label {
  font-size: .75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

#user-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .86rem;
  padding: 5px 10px;
  outline: none;
}
#user-input:focus    { border-color: var(--accent); }
#user-input:disabled { opacity: .4; cursor: not-allowed; }

.btn-send { background: var(--accent2); color: #12121e; font-weight: 700; padding: 6px 12px; }
.btn-send:hover    { background: #45bfa2; }
.btn-send:disabled { opacity: .4; cursor: not-allowed; }

/* ── Modal ── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 560px;
  width: 92%;
  max-height: 82vh;
  overflow-y: auto;
}

.modal-box h2 { color: var(--accent); margin-bottom: 14px; font-size: 1.1rem; }

.modal-box table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.modal-box th {
  text-align: left;
  color: var(--text-dim);
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}
.modal-box td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--surface2);
  vertical-align: top;
}
.modal-box td:first-child {
  font-family: var(--font-mono);
  color: var(--keyword);
  white-space: nowrap;
}

.close-btn { margin-top: 16px; }

.modal-box h3 { color: var(--accent2); margin: 18px 0 8px; font-size: .9rem; }

.modal-box pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
  margin-bottom: 10px;
}

/* ── Scrollbars ── */
::-webkit-scrollbar         { width: 7px; height: 7px; }
::-webkit-scrollbar-track   { background: transparent; }
::-webkit-scrollbar-thumb   { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Modal Feedback ── */
.feedback-form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }

.feedback-form label {
  font-size: .8rem;
  color: var(--text-dim);
  margin-bottom: 2px;
  display: block;
}

.feedback-form input,
.feedback-form textarea,
.feedback-form select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .88rem;
  padding: 8px 12px;
  outline: none;
  transition: border .15s;
}

.feedback-form input:focus,
.feedback-form textarea:focus,
.feedback-form select:focus {
  border-color: var(--accent);
}

.feedback-form textarea { resize: vertical; min-height: 90px; }

.feedback-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.btn-send-feedback {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .85rem;
}
.btn-send-feedback:hover { background: #6a5fe5; }

.feedback-success {
  text-align: center;
  padding: 24px 0;
  color: var(--ok);
  font-size: 1rem;
}

/* ── Responsivo ── */
@media (max-width: 700px) {
  .main { flex-direction: column; }
  .editor-pane {
    width: 100%;
    border-right: none;
    border-bottom: 2px solid var(--border);
    height: 50%;
  }
  .console-pane { height: 50%; }
}
