/* ══════════════════════════════════════════════════════════════════
   AF Contabilidade — Gerador de Contratos
   Paleta da marca (tendências 2026):
   --petrol  #0D2538  Azul Petróleo Profundo (autoridade institucional)
   --bronze  #B89765  Bronze Acetinado (prestígio, premium discreto)
   --cloud   #F4F5F0  Off-white "Cloud Dancer" (Pantone 2026)
   ══════════════════════════════════════════════════════════════════ */
:root {
  --petrol: #0d2538;
  --petrol-2: #163a52;
  --bronze: #b89765;
  --bronze-2: #d4b98a;
  --cloud: #f4f5f0;
  --ink: #1c2430;
  --ink-soft: #4a5568;
  --line: #dfe2d9;
  --page-w: 860px;               /* pré-visualização MAIOR (pedido) */
  --shadow: 0 10px 34px rgba(13, 37, 56, 0.16);
  font-size: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--cloud); color: var(--ink); font-family: "Inter", system-ui, sans-serif; }

/* ───────────────────────── HEADER ───────────────────────── */
.site-header {
  background: var(--petrol);
  color: #fff;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 18px rgba(13, 37, 56, 0.35);
}
.header-inner {
  max-width: 1400px; margin: 0 auto; padding: -0px 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  width: 96px; height: 96px; border-radius: 12px; overflow: hidden;   /* ~2x maior */
  background: linear-gradient(135deg, var(--petrol-2), var(--petrol));
  border: 1px solid rgba(184, 151, 101, 0.55);
  display: flex; align-items: center; justify-content: center;
}
.brand-logo img { width: 200%; height: 200%; object-fit: contain; background: #fff; }
.brand-monogram { font-family: "Playfair Display", Georgia, serif; font-weight: 800; font-size: 2.4rem; color: var(--bronze); letter-spacing: 0.5px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 1.08rem; letter-spacing: 0.2px; }
.brand-sub { font-size: 0.78rem; color: var(--bronze-2); letter-spacing: 1.6px; text-transform: uppercase; }
.header-nav { display: flex; gap: 10px; flex-wrap: wrap; }
.nav-btn {
  background: transparent; color: #d9e2ea; border: 1px solid rgba(255,255,255,0.22);
  padding: 10px 18px; border-radius: 10px; font-size: 0.92rem; font-weight: 600; cursor: pointer;
  transition: all .18s ease;
}
.nav-btn:hover { border-color: var(--bronze); color: #fff; }
.nav-btn.active { background: var(--bronze); border-color: var(--bronze); color: var(--petrol); }

/* ───────────────────────── LAYOUT ───────────────────────── */
.app-layout {
  max-width: 1400px; margin: 0 auto; padding: 26px;
  display: grid; grid-template-columns: 330px 1fr; gap: 26px; align-items: start;
}
@media (max-width: 1020px) { .app-layout { grid-template-columns: 1fr; } }

/* ───────────────────────── SIDEBAR ───────────────────────── */
.sidebar { position: sticky; top: 92px; max-height: calc(100vh - 116px); overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding-right: 4px; }
.sidebar-section {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  box-shadow: 0 3px 14px rgba(13,37,56,0.06);
}
.section-title {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 1.6px;
  color: var(--petrol); border-bottom: 2px solid var(--bronze); padding-bottom: 8px; margin-bottom: 14px;
}
.field-label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); margin: 12px 0 5px; }
.field-input, .field-textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px;
  font: inherit; font-size: 0.88rem; color: var(--ink); background: var(--cloud);
  transition: border-color .15s ease;
}
.field-input:focus, .field-textarea:focus { outline: none; border-color: var(--bronze); background: #fff; }
.field-textarea { resize: vertical; }

.logo-upload-area {
  border: 2px dashed rgba(184,151,101,0.6); border-radius: 12px; min-height: 108px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden;
  background: var(--cloud); transition: border-color .15s ease;
}
.logo-upload-area:hover { border-color: var(--bronze); }
.logo-placeholder { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 0.85rem; padding: 14px; text-align: center; }
.logo-placeholder small { font-size: 0.7rem; color: #8a94a3; max-width: 220px; }
.logo-preview-img { max-width: 100%; max-height: 140px; object-fit: contain; padding: 8px; }
.btn-remove-logo { margin-top: 8px; background: none; border: none; color: #a33; font-size: 0.8rem; cursor: pointer; }
.legal-note p { font-size: 0.74rem; line-height: 1.55; color: var(--ink-soft); }

/* ───────────────────────── PREVIEW ───────────────────────── */
.preview-panel { min-width: 0; }
.preview-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.preview-label { font-family: "Playfair Display", serif; font-weight: 700; font-size: 1.25rem; color: var(--petrol); }
.preview-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.edit-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 0.86rem; font-weight: 600; color: var(--petrol); cursor: pointer; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; padding: 10px 18px;
  font-size: 0.9rem; font-weight: 700; cursor: pointer; transition: all .18s ease; border: 1px solid transparent;
}
.btn-outline { background: #fff; color: var(--petrol); border-color: var(--line); }
.btn-outline:hover { border-color: var(--bronze); }
.btn-primary { background: var(--petrol); color: #fff; }
.btn-primary:hover { background: var(--petrol-2); }
.pdf-hint { font-size: 0.78rem; color: var(--ink-soft); margin: 2px 0 16px; }

/* ───────────────────────── PÁGINAS (A4) ───────────────────────── */
.pages { display: flex; flex-direction: column; gap: 30px; align-items: center; }
.page {
  position: relative;
  width: var(--page-w);
  max-width: 100%;
  aspect-ratio: 210 / 297;              /* proporção A4 na tela */
  background: #fff;
  box-shadow: var(--shadow);
  border-top: 6px solid var(--petrol);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.page-inner { position: relative; z-index: 2; display: flex; flex-direction: column; height: 100%; padding: 4.6% 6.5% 3.4%; }

/* marca-d'água (logo bem transparente ao fundo, TODAS as páginas) */
.page-watermark {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.page-watermark img { width: 62%; max-height: 62%; object-fit: contain; opacity: 0.055; filter: grayscale(30%); }
.page-watermark .wm-monogram {
  font-family: "Playfair Display", serif; font-weight: 800; font-size: 15rem; color: var(--petrol); opacity: 0.045; letter-spacing: 6px;
}

/* cabeçalho de página (logo em TODAS) */
.page-head { display: flex; align-items: center; gap: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--bronze); }
.page-head .ph-logo { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; border-radius: 8px; overflow: hidden; background: var(--petrol); flex: 0 0 auto; }
.page-head .ph-logo img { width: 200%; height: 200%; object-fit: contain; background: #fff; }
.page-head .ph-logo span { font-family: "Playfair Display", serif; font-weight: 800; color: var(--bronze); font-size: 1.3rem; }
.page-head .ph-title { flex: 1; min-width: 0; }
.page-head .ph-company { font-weight: 800; color: var(--petrol); font-size: 1.02rem; letter-spacing: 0.3px; }
.page-head .ph-doc { font-size: 0.72rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 1.4px; margin-top: 2px; }
.page-head .ph-num { font-size: 0.72rem; color: var(--bronze); font-weight: 700; white-space: nowrap; }

/* corpo */
.page-main { flex: 1; overflow: hidden; padding-top: 14px; display: flex; flex-direction: column; }
.page-body { font-size: 0.86rem; line-height: 1.62; color: var(--ink); }
.page-body[contenteditable="true"] { outline: 2px dashed rgba(184,151,101,0.5); outline-offset: 6px; border-radius: 4px; }
.page-body h1.doc-title {
  font-family: "Playfair Display", serif; text-align: center; color: var(--petrol);
  font-size: 1.28rem; letter-spacing: 0.6px; margin: 6px 0 14px; text-transform: uppercase;
}
.page-body h2 {
  font-size: 0.9rem; color: var(--petrol); margin: 14px 0 6px; letter-spacing: 0.3px;
  border-left: 4px solid var(--bronze); padding-left: 9px; text-transform: uppercase;
}
.page-body p { margin: 7px 0; text-align: justify; }
.page-body ul { margin: 6px 0 6px 22px; }
.page-body li { margin: 3px 0; text-align: justify; }
.page-body .partes { background: var(--cloud); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.page-body .partes p { margin: 5px 0; }
.page-body .destaque { color: var(--petrol); font-weight: 700; }
.page-body [data-f] { color: var(--petrol-2); font-weight: 600; }

/* assinaturas (sem testemunhas — pedido) */
.sig-area { margin-top: 28px; }
.sig-close { margin: 14px 0 0; text-align: justify; }
/* "assinatura em todas": só as vias, empurradas pro pé da página */
.sig-area.sig-compact { margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--line); }
.sig-area.sig-compact .sig-grid { margin-top: 8px; }
.sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8%; margin-top: 34px; }
.sig { text-align: center; }
.sig .sig-line { border-top: 1.5px solid var(--ink); margin-bottom: 7px; }
.sig .sig-name { font-weight: 700; font-size: 0.85rem; color: var(--petrol); }
.sig .sig-role { font-size: 0.74rem; color: var(--ink-soft); margin-top: 2px; }
.sig-place { text-align: center; margin-top: 26px; font-size: 0.88rem; }

/* botão remover página (só na tela, aparece ao passar o mouse) */
.page-remove {
  position: absolute; top: 10px; right: 10px; z-index: 6;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: #a33;
  cursor: pointer; font-size: 0.9rem; line-height: 1; font-weight: 700;
  opacity: 0; transition: opacity .15s ease; box-shadow: 0 2px 8px rgba(13,37,56,.14);
}
.page:hover .page-remove { opacity: 1; }
.page-remove:hover { background: #a33; color: #fff; border-color: #a33; }

/* rodapé de página */
.page-foot {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line); padding-top: 8px; margin-top: 10px;
  font-size: 0.68rem; color: var(--ink-soft); letter-spacing: 0.4px;
}
.page-foot .pf-brand { color: var(--bronze); font-weight: 700; }

/* ───────────────────────── FOOTER site ───────────────────────── */
.site-footer { max-width: 1400px; margin: 10px auto 30px; padding: 0 26px; }
.site-footer p { font-size: 0.72rem; color: var(--ink-soft); line-height: 1.6; }

/* ───────────────────────── IMPRESSÃO / PDF ───────────────────────── */
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff; }
  .site-header, .sidebar, .preview-toolbar, .pdf-hint, .site-footer, .page-remove, .no-print { display: none !important; }
  .app-layout { display: block; padding: 0; max-width: none; }
  .pages { gap: 0; display: block; }
  .page {
    width: 210mm; height: 297mm; aspect-ratio: auto; max-width: none;
    box-shadow: none; border-top-width: 5mm; border-top-color: var(--petrol);
    page-break-after: always; break-after: page; margin: 0;
  }
  .page:last-child { page-break-after: auto; }
  .page-inner { padding: 12mm 16mm 9mm; }
  .page-body { font-size: 10.3pt; }
  .page-body[contenteditable="true"] { outline: none; }
  .page-watermark img { opacity: 0.05; }
  .page-watermark .wm-monogram { opacity: 0.04; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
