/* Vista Editar: Word-style editor (views/editar.js). Modes on .editor-word: modo-documento (light sheet + ribbon +
   side panel), modo-markdown (text), modo-lado (text + preview). */

.editar-container { max-width: 1600px; margin: 0 auto; padding: 1rem; }
.editor-cab { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding-bottom: .8rem; border-bottom: 1px solid var(--color-border); }
.editor-cab-titulo { flex: 1; min-width: 220px; }
.editor-cab-titulo h1.page-title { margin: 0; font-size: var(--fs-13); color: var(--color-title); }
.editor-caminho { color: var(--color-muted); font-size: var(--fs-6); }
.editor-sujo { color: var(--color-warn-fg); font-size: var(--fs-7); }
.editor-cab .editor-mensagem { width: 16rem; flex: 0 1 16rem; max-width: 100%; padding: .45rem .6rem; border: 1px solid var(--color-border); border-radius: var(--radius-1); background: var(--color-panel-soft); color: inherit; font: inherit; font-size: var(--fs-7); }

.editor-barra { display: flex; align-items: stretch; gap: .5rem; margin: .6rem 0; flex-wrap: wrap; }
.editor-fita { display: flex; flex-wrap: wrap; flex: 1; padding: .3rem .4rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-2, 10px); }
.editor-grupo { display: flex; flex-direction: column; align-items: center; padding: 0 .55rem; border-right: 1px solid var(--color-border); }
.editor-grupo:last-child { border-right: 0; }
.editor-grupo[hidden] { display: none; }
.editor-grupo-linha { display: flex; align-items: center; gap: 2px; min-height: 32px; }
.editor-grupo small { color: var(--color-muted); font-size: var(--fs-4); margin-top: 2px; }
.editor-btn { width: 32px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: none; color: var(--color-fg); cursor: pointer; }
.editor-btn:hover:not(:disabled) { background: var(--color-accent-soft); }
.editor-btn.activo { background: var(--color-accent-soft); color: var(--color-accent); }
.editor-btn:disabled { opacity: .35; cursor: default; }
.editor-btn:focus-visible, .editor-modos button:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.editor-estilo { height: 30px; min-width: 9.5rem; padding: 0 .5rem; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-panel-soft); color: inherit; font: inherit; font-size: var(--fs-7); }
.editor-modos { display: inline-flex; align-self: center; border: 1px solid var(--color-border); border-radius: 8px; overflow: hidden; }
.editor-modos button { border: 0; background: none; color: var(--color-muted); font: inherit; font-size: var(--fs-7); padding: .4rem .75rem; cursor: pointer; }
.editor-modos button[aria-pressed="true"] { background: var(--color-accent-soft); color: var(--color-accent); font-weight: 600; }
.editor-pedido { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 0 .6rem; padding: .5rem .7rem; background: var(--color-surface); border: 1px solid var(--color-line-strong, var(--color-border)); border-radius: 8px; }
.editor-pedido[hidden] { display: none; }
.editor-pedido label { display: flex; align-items: center; gap: .5rem; flex: 1; font-size: var(--fs-7); }
.editor-pedido input { flex: 1; min-width: 14rem; padding: .4rem .55rem; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-panel-soft); color: inherit; font: inherit; }

.editor-palco { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 0; min-height: 70vh; border: 1px solid var(--color-border); border-radius: var(--radius-2, 10px); overflow: hidden; }
.editor-mesa { background: #050e18; padding: 28px 16px 48px; overflow: auto; }
.editor-folha { width: 820px; max-width: 100%; margin: 0 auto; background: var(--color-folha); color: #1d2833; border-radius: 4px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); padding: 56px 72px; }
.editor-lado { border-left: 1px solid var(--color-border); background: var(--color-panel-soft); padding: 14px; overflow: auto; font-size: var(--fs-7); }
.editor-lado h3 { display: flex; align-items: center; gap: .45rem; margin: 0 0 .5rem; font-size: var(--fs-7); color: var(--color-title); }
.editor-lado h3 + * { margin-bottom: 1.2rem; }
.editor-estrutura button, .editor-fontes button { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--color-fg); font: inherit; padding: .25rem .45rem; border-radius: 6px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-estrutura button.nivel-2 { padding-left: 1rem; }
.editor-estrutura button.nivel-3 { padding-left: 1.6rem; color: var(--color-muted); }
.editor-estrutura button:hover, .editor-fontes button:hover { background: var(--color-accent-soft); }
.editor-fontes { margin: 0; padding-left: 1.6rem; color: var(--color-accent); }
.editor-fontes button { font-family: var(--font-mono); font-size: var(--fs-5); color: var(--color-muted); white-space: normal; word-break: break-all; }
.editor-rodape { display: flex; gap: 1.2rem; flex-wrap: wrap; padding: .45rem .2rem; color: var(--color-muted); font-size: var(--fs-6); }
.editor-guarda { margin-left: auto; }

/* Modes */
.editor-word .editar-textarea, .editor-word .editar-preview { display: none; }
.editor-word.modo-markdown .editor-palco, .editor-word.modo-lado .editor-palco { grid-template-columns: minmax(0, 1fr); border: 0; overflow: visible; }
.editor-word.modo-lado .editor-palco { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.editor-word:not(.modo-documento) .editor-mesa, .editor-word:not(.modo-documento) .editor-lado,
.editor-word:not(.modo-documento) .editor-fita, .editor-word:not(.modo-documento) .editor-rodape { display: none; }
.editor-word.modo-markdown .editar-textarea, .editor-word.modo-lado .editar-textarea, .editor-word.modo-lado .editar-preview { display: block; }
.editar-textarea { min-height: 70vh; width: 100%; box-sizing: border-box; font-family: var(--font-mono); font-size: var(--fs-8); padding: .75rem; border: 1px solid var(--color-border); border-radius: var(--radius-1); background: var(--color-panel-soft); color: inherit; resize: vertical; line-height: 1.6; }
.editar-preview { min-height: 70vh; padding: 1rem; border: 1px solid var(--color-border); border-radius: var(--radius-1); overflow-y: auto; background: var(--color-bg); }

/* The document on the sheet (ProseMirror) */
.editor-documento { outline: none; white-space: pre-wrap; word-wrap: break-word; font-family: var(--font-system); font-size: var(--fs-reading); line-height: 1.65; counter-reset: fonte; min-height: 50vh; }
.editor-documento h1, .editor-documento h2, .editor-documento h3, .editor-documento h4 { color: #0b1520; line-height: 1.3; }
.editor-documento h1 { font-size: var(--fs-h1); margin: 0 0 18px; }
.editor-documento h2 { font-size: var(--fs-h3); margin: 28px 0 10px; }
.editor-documento h3 { font-size: var(--fs-reading); margin: 22px 0 8px; }
.editor-documento p { margin: 0 0 14px; }
.editor-documento a { color: #0d6f86; }
.editor-documento code { background: var(--color-folha-codigo); border-radius: 4px; padding: 1px 4px; font-size: var(--fs-base); }
.editor-documento pre { background: var(--color-folha-bloco); border: 1px solid #dbe3ea; border-radius: 6px; padding: 10px 12px; white-space: pre-wrap; font-size: var(--fs-compact); }
.editor-documento pre code { background: none; padding: 0; }
.editor-documento pre.editor-mermaid { border-left: 3px solid #1aa6c4; }
.editor-documento blockquote { margin: 0 0 14px; padding-left: 14px; border-left: 3px solid #c9d6e0; color: #44515d; }
.editor-documento ul, .editor-documento ol { padding-left: 26px; margin: 0 0 14px; }
.editor-documento li.editor-tarefa { list-style: none; position: relative; }
.editor-documento li.editor-tarefa::before { content: '☐'; position: absolute; left: -20px; }
.editor-documento li.editor-tarefa.feita::before { content: '☑'; }
.editor-documento img { max-width: 100%; }
.editor-documento table { width: 100%; border-collapse: collapse; margin: 8px 0 18px; font-size: var(--fs-base); table-layout: fixed; }
.editor-documento th, .editor-documento td { border: 1px solid #d5dde5; padding: 7px 9px; text-align: left; vertical-align: top; position: relative; }
.editor-documento th { background: var(--color-folha-codigo); font-weight: 600; }
.editor-documento .selectedCell::after { content: ''; position: absolute; inset: 0; background: rgba(26, 166, 196, .14); pointer-events: none; }
.editor-documento ::selection { background: #bfe9f3; }
.editor-documento .ProseMirror-selectednode { outline: 2px solid #1aa6c4; }
.editor-citacao { display: inline-block; margin: 0 1px; padding: 0 5px; border-radius: 9px; background: #dff4f9; color: #0d6f86; font-size: var(--fs-micro); font-weight: 700; line-height: 16px; vertical-align: super; cursor: help; }
.editor-citacao::after { counter-increment: fonte; content: counter(fonte); }
.editor-wikilink { color: #0d6f86; border-bottom: 1px dashed #0d6f86; }
.editor-nota { color: #0d6f86; font-size: var(--fs-micro); }
.editor-html { color: #7a5a00; background: var(--color-folha-html); }
.editor-bruto { margin: 0 0 14px; border: 1px dashed #c3ceda; border-radius: 6px; background: var(--color-folha-bruto); color: #44515d; }
.editor-bruto-rotulo { display: block; padding: 3px 10px; border-bottom: 1px dashed #c3ceda; font-size: var(--fs-micro); color: #6a7783; }
.editor-bruto pre { margin: 0; border: 0; background: none; white-space: pre-wrap; font-size: var(--fs-small); }
.editor-documento .ProseMirror-gapcursor { display: none; }

@media (max-width: 1100px) {
  .editor-palco { grid-template-columns: minmax(0, 1fr); }
  .editor-lado { display: none; }
  .editor-folha { padding: 32px 24px; }
}

.editar-alert {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-1);
  border-left: 4px solid;
}

.editar-alert.erro {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-fg);
  color: var(--color-danger-fg);
}

.editar-alert.aviso {
  background: var(--color-warn-bg);
  border-color: var(--color-warn-fg);
  color: var(--color-warn-fg);
}

.editar-alert.info {
  background: var(--color-info-bg);
  border-color: var(--color-info-fg);
  color: var(--color-info-fg);
}

.editar-alert ul {
  margin: 0.5rem 0 0 1.5rem;
  padding: 0;
}

.editar-alert-buttons {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

/* Vista Histórico */

.historico-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.historico-header {
  margin-bottom: 1rem;
}

.historico-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: var(--fs-16);
}

.historico-lista {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.historico-item {
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-1);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.15s;
}

.historico-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.historico-item:hover {
  background: var(--color-sidebar-bg);
}

.historico-item.active {
  background: var(--color-accent-soft);
  border-color: var(--color-accent);
}

.historico-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: var(--fs-7);
  color: var(--color-muted);
  margin-bottom: 0.25rem;
}

.historico-mensagem {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.historico-commit {
  font-family: var(--font-mono);
  font-size: var(--fs-7);
  color: var(--color-muted);
}

.historico-preview {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-1);
  background: var(--color-bg);
}

.historico-preview h2 {
  margin: 0 0 1rem 0;
  font-size: var(--fs-13);
}

.historico-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

/* Option A page polish: the history header uses the shared page title */
.historico-header h1.page-title {
  color: var(--color-title);
  font-size: var(--fs-17);
  letter-spacing: -.03em;
  line-height: 1.2;
}

@media (max-width: 600px) {
  .historico-header h1.page-title { font-size: var(--fs-15); }
}
