/* styles.css — Panel y Config. El Overlay tiene su propio overlay.css. */

:root {
  --bg: #0e0e10;
  --surface: #18181b;
  --surface-2: #1f1f23;
  --border: #2f2f35;
  --text: #efeff1;
  --muted: #adadb8;
  --accent: #9147ff;
  --accent-hover: #a970ff;
  --lobster: #e63946;
  --ok: #00c28c;
  --warn: #ffb31a;
  --err: #ff5a5f;
  --code-bg: #0b0b0d;
  --radius: 8px;
  --mono: ui-monospace, "Cascadia Code", "Consolas", "Menlo", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.offline body::before {
  content: attr(data-offline); /* lo pone common.js, con la URL del servidor */
  overflow-wrap: anywhere;
  display: block;
  padding: 6px 10px;
  background: var(--err);
  color: #fff;
  font-weight: 600;
  text-align: center;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 14px; }
h3 { font-size: 13px; margin: 14px 0 6px; }
p { margin: 6px 0; }
a { color: var(--accent-hover); }

code, pre, textarea.code { font-family: var(--mono); font-size: 12px; }
code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
pre {
  margin: 6px 0 0;
  padding: 8px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre;
}

button {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
button:hover:not(:disabled) { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.danger { background: var(--err); border-color: var(--err); color: #fff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 1px;
}

input, textarea, select {
  font: inherit;
  width: 100%;
  background: var(--code-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}
textarea.code { resize: vertical; min-height: 150px; tab-size: 2; line-height: 1.5; }

/* ---------------- Autocompletado (editor.js) ---------------- */

.editor { position: relative; }
/* El borde va en .editor-body para que los numeros queden dentro de la caja */
.editor-body {
  display: flex;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.editor-body:focus-within { outline: 2px solid var(--accent-hover); outline-offset: 1px; }
.editor-body textarea.code {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  padding-left: 8px;
  white-space: pre;
  overflow: auto;
}
.editor-body textarea.code:focus-visible { outline: none; }
.gutter {
  flex: none;
  overflow: hidden;
  padding: 6px 6px 6px 0; /* mismo padding vertical que el textarea */
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: #5c5c66;
  background: var(--surface);
  border-right: 1px solid var(--border);
  user-select: none;
}
.gutter .active { color: var(--text); }
.gutter .error { color: #fff; background: var(--err); border-radius: 0 3px 3px 0; margin-right: -6px; padding-right: 6px; font-weight: 700; }
.editor-body { position: relative; }
.editor-body .gutter, .editor-body textarea.code { position: relative; z-index: 1; }
.error-band {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(255, 90, 95, 0.16);
  border-top: 1px solid rgba(255, 90, 95, 0.35);
  border-bottom: 1px solid rgba(255, 90, 95, 0.35);
}
.ac {
  position: absolute;
  z-index: 10;
  margin: 0;
  padding: 3px;
  list-style: none;
  min-width: 170px;
  max-width: 100%;
  max-height: 172px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  font-family: var(--mono);
  font-size: 12px;
}
.ac li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.ac li:hover { background: #34343c; }
.ac li[aria-selected="true"] { background: var(--accent); color: #fff; }
.ac li img { width: 16px; height: 16px; object-fit: contain; }
.ac .ac-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ac .ac-kind { font-family: system-ui, sans-serif; font-size: 10px; opacity: 0.65; }
.ac .ac-fn .ac-label { color: #e0a6ff; }
.ac .ac-name .ac-label { color: #ffd479; }
.ac li[aria-selected="true"] .ac-label { color: #fff; }
.ac-help {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  padding: 5px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--muted);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-2);
  color: var(--muted);
}
.pill.publishing { background: #1d3b2f; color: var(--ok); }
.pill.voting { background: #3a2d10; color: var(--warn); }
.pill.executing { background: #3b1a45; color: #e0a6ff; }
.pill.paused { background: #401a1c; color: var(--err); }

.muted { color: var(--muted); }
.small { font-size: 11px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 8px; }

.notice {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.notice.ok { border-color: var(--ok); color: #b5f5df; }
.notice.err { border-color: var(--err); color: #ffc9ca; }
.notice.warn { border-color: var(--warn); color: #ffe2a8; }
.notice:empty { display: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card.winner { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }

details > summary { cursor: pointer; color: var(--muted); font-size: 12px; }

/* ---------------- Panel ---------------- */

.panel { max-width: 318px; margin: 0 auto; display: flex; flex-direction: column; min-height: 100vh; }
.panel header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px 0;
}
.panel header .title { display: flex; align-items: center; gap: 8px; }
.panel header h1 { font-size: 15px; flex: 1; }
.panel header .timer { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.panel .me { margin: 4px 0 6px; }

.tabs { display: flex; gap: 2px; margin: 0 -10px; padding: 0 6px; }
.tabs button {
  flex: 1;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--muted);
  padding: 7px 2px;
  font-size: 12px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .badge {
  display: inline-block;
  min-width: 16px;
  margin-left: 3px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
}

.panel main { padding: 10px; flex: 1; }

.sub-head { display: flex; gap: 6px; align-items: baseline; }
.sub-head .author { font-weight: 700; }
.sub-comment { margin: 4px 0 6px; }
.votes { font-family: var(--mono); font-weight: 700; color: var(--warn); }

.fn-list { list-style: none; margin: 0; padding: 0; }
.fn-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.fn-list li:last-child { border-bottom: none; }
.fn-list .sig { font-family: var(--mono); font-weight: 700; color: #e0a6ff; }
.fn-list button { padding: 1px 6px; font-size: 11px; margin-left: 4px; }
.fn-list .off { opacity: 0.45; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips code { font-size: 11px; display: inline-flex; align-items: center; gap: 4px; }
.chips .pose-thumb { width: 20px; height: 20px; object-fit: contain; }
.easing-list { list-style: none; margin: 6px 0; padding: 0; }
.easing-list li { padding: 2px 0; font-size: 12px; }
.easing-list code { color: #ffd479; }

/* ---------------- Dialogo propio (common.js: ask) ---------------- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
}
.dialog {
  width: min(360px, 100%);
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.dialog-text { margin: 0 0 12px; white-space: pre-wrap; }
.dialog-buttons { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------- Panel: pestana Moderar ---------------- */

.mod-kill { display: flex; flex-direction: column; gap: 4px; }
.mod-kill button { width: 100%; margin-top: 4px; }
.mod-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mod-actions button { width: 100%; }
.mod-actions .wide { grid-column: 1 / -1; }
.mod-sub pre { max-height: 200px; overflow: auto; }

/* ---------------- Config ---------------- */

.config { max-width: 980px; margin: 0 auto; padding: 16px; }
.config > header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.config > header h1 { font-size: 20px; flex: 1; }
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.config .card h2 { margin-bottom: 10px; }
.field { display: grid; grid-template-columns: 1fr 110px; gap: 8px; align-items: center; margin-bottom: 8px; }
.field .hint { grid-column: 1 / -1; margin-top: -6px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 10px; }
.checks label { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }
.checks input { width: auto; }
.checks .thumb { width: 22px; height: 22px; object-fit: contain; border-radius: 4px; background: var(--surface-2); }
.checks .tag { font-size: 10px; color: var(--ok); }
.checks .play { padding: 0 6px; font-size: 11px; }

.sub-row { display: flex; gap: 10px; align-items: flex-start; }
.sub-row > button { flex: none; }
.sub-row pre { max-height: 260px; overflow: auto; }

.kill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.kill.on { border-color: var(--err); background: #2a1416; }
.kill .grow strong { display: block; font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.ok { color: var(--ok); }
td.err { color: var(--err); }
