/* Gabinete 5 — Gerador/editor v0.7
   Camada canônica da workspace. O documento A4 não é responsivo: apenas o canvas é escalado. */

/* ---------- Página / chrome ---------- */
#page-gerar{container-type:inline-size;container-name:generator}
.app.generator-page-active .topbar{height:68px;padding:12px 24px}
.app.generator-page-active .topbar p{display:none}
.app.generator-page-active .topbar h2{font-size:22px}
.app.generator-page-active .topbar-title-row{gap:9px}

#page-gerar.active{
  max-width:none;width:100%;height:calc(100vh - 68px);margin:0;
  padding:12px 16px 16px;display:grid;grid-template-rows:auto minmax(0,1fr);gap:10px;
  overflow:hidden;background:var(--bg)
}

.draft-workflow-bar{
  min-height:52px;display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:16px;
  padding:8px 10px 8px 14px;background:#fff;border:1px solid var(--line);border-radius:12px;
  box-shadow:0 1px 4px rgba(25,38,44,.025)
}
.workflow-title,.workflow-state,.workflow-actions{display:flex;align-items:center;min-width:0}
.workflow-title{gap:8px}.workflow-title .status-dot{flex:0 0 auto;margin:0}
.workflow-title>div{display:flex;flex-direction:column;min-width:0}
.workflow-title strong{font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.workflow-title small{font-size:9px;color:var(--muted);margin-top:1px}
.workflow-state{gap:8px}.workflow-actions{gap:7px}
.workflow-info{background:transparent;color:#6e7c82;font-size:9.5px;padding:6px 4px;border-radius:6px;white-space:nowrap}
.workflow-info:hover{background:#f3f6f5;color:#315e53}
.workflow-actions .secondary{padding:7px 10px;font-size:10px;white-space:nowrap}

/* ---------- Workspace ---------- */
.generator-grid{
  display:grid;grid-template-columns:clamp(380px,30cqw,460px) minmax(0,1fr);gap:12px;
  min-height:0;height:100%;align-items:stretch
}
.generator-controls.guided-redesign,
.preview-card{
  min-width:0;min-height:0;height:100%;background:#fff;border:1px solid var(--line);border-radius:12px;
  box-shadow:0 1px 4px rgba(25,38,44,.025);overflow:hidden
}

/* ---------- Composição guiada: 4 regiões reais ---------- */
.generator-controls.guided-redesign{
  position:relative;top:auto;padding:0;max-height:none;display:grid;
  grid-template-rows:auto auto minmax(0,1fr) auto
}
.guide-panel-head{padding:14px 16px 8px;background:#fff}
.guided-topline{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.guided-topline h3{font-size:18px;line-height:1.2;margin:1px 0 0}
.guided-topline .eyebrow{margin-bottom:6px}
.guided-intro{font-size:10.5px;line-height:1.45;margin:5px 0 0;max-width:48ch}
.compact-preview-button{display:none;padding:7px 9px;font-size:10px;white-space:nowrap}

.guided-stepper{
  display:flex;align-items:flex-start;gap:0;margin:0;padding:5px 16px 13px;background:#fff;border-bottom:1px solid #edf1f0;
  overflow:visible
}
.guide-step{
  position:relative;flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;gap:5px;
  padding:0 3px;background:transparent;border:0;border-radius:0;text-align:center;color:#67767c;overflow:visible
}
.guide-step::after{content:"";position:absolute;z-index:0;top:13px;left:calc(50% + 14px);right:calc(-50% + 14px);height:2px;background:#dfe7e4}
.guide-step:last-child::after{display:none}
.guide-step>span{
  position:relative;z-index:1;display:grid;place-items:center;flex:0 0 28px;width:28px;height:28px;border-radius:50%;
  border:2px solid #cfdad6;background:#fff;color:#4d7569;font-size:10px;font-weight:850
}
.guide-step div{min-width:0;width:100%}.guide-step strong{display:block;font-size:9px;line-height:1.2;white-space:normal}.guide-step small{display:none}
.guide-step.active{color:#214f42}.guide-step.active>span{background:#2f6658;border-color:#2f6658;color:#fff;box-shadow:0 0 0 4px rgba(47,102,88,.09)}
.guide-step.done>span{background:#dcece7;border-color:#a9cbbf;color:#24594b}.guide-step.done::after{background:#a9cbbf}

.guide-scroll{min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;padding:13px 16px 16px;background:#fff}
.guided-stage{border:1px solid #dfe6e4;border-radius:11px;background:#fff;overflow:hidden}
.guided-stage-head{padding:12px 13px 10px;gap:12px}
.guided-stage-head h4{font-size:15px}.guided-stage-head p{font-size:9.5px}.guide-progress{width:82px}
.guide-pane{padding:14px 13px 16px;min-height:0}
.selected-model-card{grid-template-columns:40px 1fr auto;gap:9px;padding:11px}
.selected-model-icon{width:38px;height:38px}.selected-model-card strong{font-size:11.5px}
.guide-note{font-size:9.5px;padding:8px 10px;margin-top:9px}
.guide-question-head>div strong{font-size:13px}.guide-question-head>div small{font-size:9.5px}
.large-choice-row{margin-top:13px}.guide-choice{min-height:66px;padding:12px}.guide-choice strong{font-size:13px}
.guided-impact{margin-top:10px;padding:10px 11px}.impact-columns{gap:10px;margin-top:7px}.impact-reason{margin-top:6px}
.generator-controls.guided-redesign .privacy-strip{margin:10px 0 0;padding:9px 10px;font-size:9px;line-height:1.4}
.guided-nav{
  position:relative;bottom:auto;z-index:1;margin:0;padding:10px 14px;background:#fff;border-top:1px solid #e5ebea;
  box-shadow:none;display:flex;align-items:center;justify-content:space-between;gap:10px
}
.guided-nav button{min-width:104px;padding:9px 12px}.guided-nav button:disabled{opacity:.42;cursor:not-allowed}

/* ---------- Preview toolbar ---------- */
.preview-card{padding:0;display:flex;flex-direction:column}
.preview-toolbar{
  flex:0 0 46px;min-height:46px;padding:6px 9px 6px 12px;background:#fbfcfc;border-bottom:1px solid var(--line);
  display:flex;align-items:center;justify-content:space-between;gap:10px
}
.preview-toolbar-left{display:flex;align-items:center;gap:9px;min-width:0}
.guided-preview-title{display:flex;flex-direction:column;line-height:1.08;min-width:0}
.guided-preview-title strong{font-size:11px;white-space:nowrap}.guided-preview-title small{font-size:8px;color:var(--muted);margin-top:2px}
.preview-actions{display:flex;align-items:center;justify-content:flex-end;gap:6px;min-width:0;flex-wrap:nowrap}
.preview-actions .preview-action,.preview-actions .icon-button{height:34px;min-height:34px;border-radius:8px;padding:6px 9px;font-size:10px;white-space:nowrap}
.preview-actions .preview-action:not(.contextual-action){min-width:34px}
.preview-actions .icon-button{width:34px;padding:0;font-size:17px}
.preview-actions .action-label{display:none}
.guided-preview-return{display:none}
.guided-preview-zoom{display:none;align-items:center;gap:5px;margin:0;font-size:9px;color:#66757b;font-weight:700;white-space:nowrap}
.guided-preview-zoom select{width:auto;border:1px solid #d7e0e2;border-radius:7px;padding:6px 22px 6px 7px;background:#fff;font-size:9px}
.guided-preview-open-editor{display:none;padding:8px 11px;font-size:10px;white-space:nowrap}

/* ---------- Canvas / A4 canônico ---------- */
.editor-workspace{flex:1;min-height:0;height:auto;display:block;overflow:hidden;background:#e8edef}
.app:not(.editor-focus) #page-gerar .draft-structure,
.app.guided-preview-focus #page-gerar .draft-structure{display:none}
.app:not(.editor-focus) #page-gerar .comments-panel{display:none}
.paper-wrap{
  height:100%;max-height:none;min-height:0;padding:18px 20px 46px;overflow:auto;overscroll-behavior:contain;
  scrollbar-gutter:stable;background:#e8edef
}
.paper-scaler{position:relative;margin:0 auto;flex:0 0 auto}
.paper{
  --page-margin-top:25.4mm;--page-margin-right:21.9mm;--page-margin-bottom:25.4mm;--page-margin-left:33.2mm;
  --paragraph-left-indent:0mm;--first-line-indent:12.5mm;--line-spacing:1.5;--paragraph-before:0mm;--paragraph-after:0mm;
  --document-font:"Times New Roman",Times,serif;--document-font-size:11pt;
  box-sizing:border-box;width:210mm;min-width:210mm;max-width:none;min-height:297mm;margin:0;
  padding:var(--page-margin-top) var(--page-margin-right) var(--page-margin-bottom) var(--page-margin-left);
  background:#fff;box-shadow:0 5px 20px rgba(20,30,35,.13);color:#111;outline:none;
  font-family:var(--document-font);font-size:var(--document-font-size);line-height:var(--line-spacing);tab-size:4;
  transform-origin:top left;will-change:transform
}
.paper.page-landscape{width:297mm;min-width:297mm;min-height:210mm}
.paper p{
  font-family:inherit;font-size:inherit;text-align:justify;padding-left:var(--paragraph-left-indent);
  text-indent:var(--first-line-indent);line-height:var(--line-spacing);margin-top:var(--paragraph-before);margin-bottom:var(--paragraph-after)
}
.paper .style-quote,.app.editor-focus .paper p.style-quote,.app.guided-preview-focus .paper p.style-quote{
  padding-left:50mm;margin-left:0;margin-right:0;text-indent:0;font-size:11pt;line-height:1.5;text-align:justify
}
.paper.editable{box-shadow:0 0 0 2px rgba(47,102,88,.16),0 5px 20px rgba(20,30,35,.13)}
.guide-change-flash{animation:g5GuideChangeFlash 1.55s ease-out}
@keyframes g5GuideChangeFlash{0%{background:#e5f4ee;box-shadow:0 0 0 6px rgba(47,102,88,.10)}100%{background:transparent;box-shadow:none}}

/* ---------- Prévia em foco ---------- */
body.guided-preview-focus-body,body.editor-focus-body{overflow:hidden}
.app.guided-preview-focus,.app.editor-focus{display:block;min-height:100vh}
.app.guided-preview-focus>.sidebar,.app.guided-preview-focus main>.topbar,
.app.editor-focus>.sidebar,.app.editor-focus main>.topbar{display:none}
.app.guided-preview-focus main,.app.editor-focus main{height:100vh}
.app.guided-preview-focus .page,.app.editor-focus .page{display:none}
.app.guided-preview-focus #page-gerar,.app.editor-focus #page-gerar{
  display:block;position:fixed;inset:0;z-index:70;width:auto;max-width:none;height:100vh;margin:0;padding:0;background:#e8edef;overflow:hidden
}
.app.guided-preview-focus .draft-workflow-bar,.app.editor-focus .draft-workflow-bar,
.app.guided-preview-focus .generator-controls,.app.editor-focus .generator-controls{display:none}
.app.guided-preview-focus .generator-grid,.app.editor-focus .generator-grid{display:block;height:100vh}
.app.guided-preview-focus .preview-card,.app.editor-focus .preview-card{height:100vh;border:0;border-radius:0;box-shadow:none;display:flex;flex-direction:column;overflow:hidden}
/* O stylesheet legado possui alturas responsivas com !important. Em foco, a workspace precisa vencer essas regras. */
.app.guided-preview-focus #page-gerar .preview-card,.app.editor-focus #page-gerar .preview-card{height:100vh!important;min-height:0!important;max-height:none!important}
.app.guided-preview-focus #paperViewport,.app.editor-focus #paperViewport{height:100%!important;max-height:none!important;min-height:0!important}
.app.guided-preview-focus .preview-toolbar,.app.editor-focus .preview-toolbar{flex:0 0 54px;min-height:54px;padding:8px 14px;background:#fff;position:relative;z-index:8}
.app.guided-preview-focus .guided-preview-return,.app.editor-focus .guided-preview-return{display:inline-flex}
.app.guided-preview-focus .guided-preview-title,.app.editor-focus .guided-preview-title{display:flex}
.app.guided-preview-focus .guided-preview-zoom{display:flex}
.app.guided-preview-focus #expandGuidedPreview,.app.editor-focus #expandGuidedPreview{display:none}
.app.guided-preview-focus .guided-preview-open-editor{display:inline-flex}
.app.guided-preview-focus .preview-actions .action-label,.app.editor-focus .preview-actions .action-label{display:inline}
.app.guided-preview-focus .editor-workspace{display:block;flex:1;min-height:0;overflow:hidden}
.app.guided-preview-focus .paper-wrap{height:100%;max-height:none;padding:24px 36px 64px;background:#e6ebed}

/* ---------- Editor completo em foco ---------- */
.app.editor-focus .guided-preview-zoom,.app.editor-focus .guided-preview-open-editor{display:none}
.app.editor-focus #fullEditorToolbar{display:flex;flex:0 0 auto;position:relative;top:auto;min-height:46px;padding:6px 10px;background:#f6f8f8;z-index:7;box-shadow:0 1px 0 var(--line)}
.app.editor-focus #editorRuler{display:grid;flex:0 0 auto}
.app.editor-focus .editor-workspace{
  position:relative;display:grid;grid-template-columns:220px minmax(0,1fr);flex:1;min-height:0;height:auto;overflow:hidden;background:#e7ecee
}
.app.editor-focus .editor-workspace.structure-collapsed{grid-template-columns:minmax(0,1fr)}
.app.editor-focus .editor-workspace.structure-collapsed .draft-structure{display:none}
.app.editor-focus .editor-workspace.comments-open{grid-template-columns:220px minmax(0,1fr) 340px}
.app.editor-focus .editor-workspace.structure-collapsed.comments-open{grid-template-columns:minmax(0,1fr) 340px}
.app.editor-focus .draft-structure{display:block;height:100%;overflow:auto;position:relative;top:auto;background:#fafbfb}
.app.editor-focus .comments-panel{height:100%;overflow:auto}
.app.editor-focus .paper-wrap{height:100%;max-height:none;padding:28px 38px 70px;background:#e7ecee}
.app.editor-focus .paper{font-size:var(--document-font-size);padding:var(--page-margin-top) var(--page-margin-right) var(--page-margin-bottom) var(--page-margin-left)}

/* ---------- Container queries: largura útil, não viewport ---------- */
@container generator (max-width:1200px){
  .generator-grid{grid-template-columns:clamp(360px,34cqw,420px) minmax(0,1fr)}
  .workflow-info{display:none}
  .guided-stage-head{padding-right:11px}.guide-progress{width:66px}
}
@container generator (max-width:1000px){
  .generator-grid{grid-template-columns:350px minmax(0,1fr)}
  .workflow-title small{display:none}
  .preview-actions{gap:4px}.preview-actions .preview-action{padding-left:7px;padding-right:7px}
}
@container generator (max-width:880px){
  .generator-grid{grid-template-columns:1fr}
  .generator-controls.guided-redesign{width:100%}
  .compact-preview-button{display:inline-flex}
}
/* :where wrapper for browsers that do not accept ancestor ampersand in container rules */
@container generator (max-width:880px){
  /* Vence a regra legada #page-gerar.active .preview-card sem recorrer a !important. */
  #page-gerar.active #generatorWorkspace>.preview-card{display:none}
  .compact-preview-button{display:inline-flex}
}
.app.guided-preview-focus #page-gerar #generatorWorkspace>.preview-card,
.app.editor-focus #page-gerar #generatorWorkspace>.preview-card{display:flex}

@container generator (max-width:560px){
  .draft-workflow-bar{grid-template-columns:minmax(0,1fr) auto;gap:8px}.workflow-state{display:none}.workflow-actions .secondary{font-size:9px}
  .guided-stepper{overflow-x:auto;justify-content:flex-start;scrollbar-width:thin}.guide-step{flex:0 0 72px}.guide-step::after{right:-36px}
  .guided-form-grid,.large-choice-row,.guide-review-grid,.impact-columns{grid-template-columns:1fr}
}

/* ---------- Viewport realmente pequeno ---------- */
@media(max-width:680px){
  .app.generator-page-active .topbar{height:auto;padding:12px 14px}
  #page-gerar.active{height:auto;min-height:calc(100vh - 120px);padding:10px;overflow:visible;display:block}
  .draft-workflow-bar{margin-bottom:10px}
  .generator-grid{min-height:650px}
  .generator-controls.guided-redesign{min-height:650px}
  .app.guided-preview-focus .paper-wrap,.app.editor-focus .paper-wrap{padding-left:12px;padding-right:12px}
  .app.editor-focus .editor-workspace,.app.editor-focus .editor-workspace.comments-open,.app.editor-focus .editor-workspace.structure-collapsed.comments-open{grid-template-columns:1fr}
  .app.editor-focus .draft-structure,.app.editor-focus .comments-panel{position:absolute;top:0;bottom:0;width:min(330px,90vw);z-index:20;box-shadow:0 8px 30px rgba(0,0,0,.18)}
  .app.editor-focus .draft-structure{left:0}.app.editor-focus .comments-panel{right:0}
}

/* ---------- Impressão: transformação visual nunca vai ao PDF ---------- */
@media print{
  body.print-draft #minutePreview{transform:none!important}
  body.print-draft #paperScaler{width:auto!important;height:auto!important;margin:0!important}
}
