/* Editor de mapa (/editor): barra de cima, ferramentas à esquerda, mapa no meio, painéis à direita.
   As cores e os temas vêm de styles.css. */

body.editor {
  display: grid;
  grid-template: "top top top" auto "tools stage side" minmax(0, 1fr) / 64px minmax(0, 1fr) 300px;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

.ed-top { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel-solid); border-bottom: 1px solid var(--line); }
.ed-back { color: var(--muted); font-size: 13px; text-decoration: none; white-space: nowrap; }
.ed-back:hover { color: var(--text); }
.ed-title { font-size: 15px; white-space: nowrap; }
.ed-name { flex: 0 0 190px; width: 190px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }
.ed-state { min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.ed-state.dirty { color: var(--warning-ink); font-weight: 600; }
.ed-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.ed-actions button, .ed-actions select { padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--tint-1); color: var(--text); font-size: 13px; white-space: nowrap; }
.ed-actions button:hover:not(:disabled), .ed-actions select:hover { background: var(--tint-2); }
.ed-actions button:disabled { opacity: 0.4; cursor: default; }
.ed-actions .primary { border-color: transparent; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.ed-actions .primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.1); }
.ed-sep { width: 1px; height: 22px; background: var(--line); }

.ed-tools { grid-area: tools; display: flex; flex-direction: column; gap: 4px; padding: 8px 6px; background: var(--panel-solid); border-right: 1px solid var(--line); overflow-y: auto; }
.ed-tool { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 5px; border: 1px solid transparent; border-radius: 10px; background: none; color: var(--muted); }
.ed-tool:hover { background: var(--tint-2); color: var(--text); }
.ed-tool[aria-pressed="true"] { border-color: var(--accent); background: rgba(91, 141, 239, 0.16); color: var(--text); }
.ed-tool-icon { font-size: 18px; line-height: 1.1; }
.ed-tool-name { font-size: 10px; font-weight: 600; line-height: 1.1; text-align: center; }
.ed-tool-key { font-size: 9px; opacity: 0.6; }

.ed-stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#map-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
#map-canvas.panning { cursor: grabbing; }
#map-canvas.tool-select { cursor: default; }
.ed-hint { position: absolute; top: 10px; left: 50%; max-width: calc(100% - 24px); margin: 0; padding: 6px 12px; transform: translateX(-50%); border-radius: 999px; background: rgba(13, 16, 23, 0.82); color: #eef0f4; font-size: 12px; pointer-events: none; }
.ed-status { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 14px; padding: 6px 10px; background: rgba(13, 16, 23, 0.86); color: #c8cedb; font-size: 12px; font-variant-numeric: tabular-nums; }
.ed-keys { flex: 1; overflow: hidden; opacity: 0.7; text-overflow: ellipsis; white-space: nowrap; }
#issues-toggle { padding: 4px 10px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: inherit; font-size: 12px; font-weight: 600; }
#issues-toggle.has-errors { background: var(--danger); color: #fff; }
#issues-toggle.has-warnings { background: #f2c230; color: #12151c; }
.ed-issues { position: absolute; right: 10px; bottom: 40px; width: min(420px, calc(100% - 20px)); max-height: 45%; margin: 0; padding: 6px; overflow-y: auto; list-style: none; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-solid); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4); }
.ed-issues[hidden] { display: none; }
.ed-issues button { display: flex; gap: 8px; width: 100%; padding: 7px 8px; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 13px; text-align: left; }
.ed-issues button:hover { background: var(--tint-2); }
.ed-issues .error::before { content: "⛔"; }
.ed-issues .warning::before { content: "⚠️"; }

.ed-side { grid-area: side; display: flex; flex-direction: column; min-height: 0; background: var(--panel-solid); border-left: 1px solid var(--line); overflow-y: auto; }
.ed-panel { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.ed-panel:empty { display: none; }
.ed-panel h2 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.ed-panel h3 { margin: 6px 0 0; font-size: 11px; font-weight: 700; color: var(--muted); }
.ed-panel p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.ed-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.ed-field input, .ed-field select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--text); font-size: 13px; }
.ed-field.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.ed-row { display: flex; gap: 8px; }
.ed-row > * { flex: 1; min-width: 0; }
.ed-panel button.plain { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--tint-1); color: var(--text); font-size: 13px; }
.ed-panel button.plain:hover { background: var(--tint-2); }
.ed-panel button.danger { color: var(--danger-ink); }
.ed-choice { display: flex; padding: 2px; border-radius: 999px; background: var(--tint-2); }
.ed-choice button { flex: 1; padding: 5px 8px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; }
.ed-choice button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.ed-palette { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ed-palette button { display: grid; place-items: center; aspect-ratio: 1; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--tint-1); }
.ed-palette button:hover { background: var(--tint-3); }
.ed-palette button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.ed-palette canvas { display: block; max-width: 100%; }
.ed-turn { width: 100%; margin-bottom: 4px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--tint-1); color: var(--text); font-size: 13px; font-weight: 600; text-align: left; }
.ed-turn:hover { background: var(--tint-2); }

.ed-dialog { display: flex; flex-direction: column; gap: 12px; width: min(520px, calc(100vw - 48px)); padding: 20px 22px; }
#publish-dialog { padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-solid); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); }
#publish-dialog::backdrop { background: rgba(10, 12, 18, 0.72); }
.ed-dialog h2 { margin: 0; font-size: 18px; }
.ed-dialog h3 { margin: 10px 0 4px; font-size: 13px; }
.ed-dialog p, .ed-dialog li { margin: 0; font-size: 13px; line-height: 1.45; }
.ed-dialog ul { margin: 0; padding-left: 18px; max-height: 180px; overflow-y: auto; }
.ed-dialog .note { color: var(--muted); }
.ed-dialog footer { display: flex; justify-content: flex-end; gap: 8px; }
.ed-dialog footer button { padding: 9px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--tint-1); color: var(--text); font-weight: 600; }
.ed-dialog footer .primary { border-color: transparent; background: var(--accent); color: var(--accent-ink); }

.ed-gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--bg); }
.ed-gate[hidden] { display: none; }
.ed-gate .card { display: flex; flex-direction: column; gap: 12px; max-width: 420px; padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-solid); text-align: center; }
.ed-gate .primary { padding: 10px 16px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; }
body.editor #toast { bottom: 52px; }

@media (max-width: 900px) {
  body.editor { grid-template: "top top" auto "tools stage" minmax(0, 1fr) "side side" minmax(0, 38%) / 56px minmax(0, 1fr); }
  .ed-top { flex-wrap: wrap; }
  .ed-keys { display: none; }
}
