/* Editor de PDF (ferramenta 36) — só o que falta em ferramentas.css. A interface usa os tokens do tema (claro e escuro).
   As cores fixas daqui são "tinta": o papel do PDF é sempre branco e as cores das marcações são as que vão para o arquivo. */

.epdf [hidden] { display: none !important }
.epdf { display: grid; gap: 20px; min-width: 0 }
.epdf > * { min-width: 0 }
.epdf-privacidade { margin: 0 }

/* ── abrir ── */
.epdf-abrir { display: grid; gap: 18px }
.epdf-abrir > h2 { margin-bottom: 0 }
.epdf-soltar {
  padding: 18px; border: 2px dashed var(--linha-forte); border-radius: var(--raio-p);
  background: color-mix(in srgb, var(--rio) 4%, var(--cartao)); transition: border-color .15s ease, background-color .15s ease;
}
.epdf-soltar input[type="file"] { width: 100%; max-width: 100%; min-height: 48px; font: inherit; color: var(--tinta) }
.epdf-soltar input[type="file"]::file-selector-button {
  min-height: 44px; margin-right: 12px; padding: .5em 1.2em; border: 1px solid var(--linha-forte); border-radius: 999px;
  background: var(--cartao); color: var(--tinta); font: inherit; font-weight: 600; cursor: pointer;
}
.epdf-arrastando .epdf-soltar, .epdf-arrastando .epdf-palco { border-color: var(--ipe); background: color-mix(in srgb, var(--ipe) 8%, var(--cartao)) }
.epdf-carga { display: grid; gap: 6px }
.epdf-carga progress { width: 100%; height: 10px; accent-color: var(--ipe) }
.epdf-passos { padding-left: 1.3em }
.epdf-passos li + li { margin-top: .35em }
.epdf-limites summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--tinta) }
.epdf-limites ul { padding-left: 1.2em; display: grid; gap: .4em }

/* ── barras ── */
.epdf-editor { display: grid; gap: 12px; min-width: 0 }
.epdf-barras {
  position: sticky; top: var(--topo-h); z-index: 30; display: grid; gap: 0; min-width: 0;
  background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--raio-p); box-shadow: var(--sombra);
}
.epdf-topo, .epdf-ferramentas, .epdf-opcoes { display: flex; align-items: center; gap: 4px; padding: 6px 8px; min-width: 0 }
.epdf-topo { flex-wrap: nowrap }
.epdf-inferior { display: flex; flex-direction: column-reverse; min-width: 0; border-top: 1px solid var(--linha) }
.epdf-ferramentas, .epdf-opcoes { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin }
.epdf-opcoes { min-height: 58px; border-top: 1px solid var(--linha); flex-wrap: nowrap; gap: 10px }
.epdf-nome { flex: 1 1 60px; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .9375rem }
.epdf-sep { flex: none; width: 1px; height: 28px; background: var(--linha); margin: 0 4px }
.epdf-pagina-atual, .epdf-zoom-valor { flex: none; margin: 0; font-size: .875rem; font-variant-numeric: tabular-nums; color: var(--grafite); white-space: nowrap }
.epdf-zoom-valor { min-width: 3.2em; text-align: center }
.epdf-zoom { display: inline-flex; align-items: center; gap: 4px }
.epdf-baixar { flex: none; gap: 6px; min-height: 44px; margin-left: 4px }
.epdf-baixar[disabled] { cursor: not-allowed }
.epdf-dica { flex: none; max-width: 22em; margin: 0; font-size: .8125rem; line-height: 1.3; color: var(--grafite) }
.epdf-grupo { display: inline-flex; align-items: center; gap: 4px; flex: none }
.epdf-grupo label { font-size: .8125rem; color: var(--grafite) }
.epdf-so-estreito { display: none }
#epdf-imagem-arquivo { position: fixed !important; left: 0; top: 0 }

.epdf-ic { width: 22px; height: 22px; flex: none }
.epdf-bt {
  flex: none; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 64px; min-height: 48px; padding: 4px 8px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--tinta); font: inherit; font-size: .75rem; line-height: 1.1; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.epdf-bt:hover { background: color-mix(in srgb, var(--tinta) 8%, transparent) }
.epdf-bt:focus-visible, .epdf-cor:focus-visible, .epdf-select:focus-visible { outline: 3px solid var(--ipe); outline-offset: 2px }
.epdf-bt[aria-pressed="true"] { background: color-mix(in srgb, var(--ipe) 14%, var(--cartao)); border-color: var(--ipe); color: var(--tinta) }
.epdf-bt[disabled] { opacity: .4; cursor: not-allowed }
.epdf-bt-so-icone { min-width: 44px; min-height: 44px; padding: 0 }
.epdf-bt-texto { flex-direction: row; min-width: 44px; min-height: 44px; padding: 0 12px; font-size: .875rem; font-weight: 600; white-space: nowrap; border-color: var(--linha) }
.epdf-bt-carimbo { letter-spacing: .04em }
.epdf-bt-negrito { font-weight: 800; font-size: 1.05rem; min-width: 44px; padding: 0 }
.epdf-select {
  min-height: 44px; min-width: 64px; padding: 0 8px; border: 1px solid var(--linha-forte); border-radius: 8px;
  background: var(--campo); color: var(--tinta); font: inherit; font-size: .9375rem;
}
.epdf-cores { gap: 2px }
.epdf-cor {
  position: relative; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.epdf-cor::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--epdf-tinta); border: 1px solid var(--linha-forte) }
.epdf-cor[aria-pressed="true"]::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; border: 3px solid var(--ipe) }
.epdf-cor-preto { --epdf-tinta: #111111 }
.epdf-cor-azul { --epdf-tinta: #1447b8 }
.epdf-cor-vermelho { --epdf-tinta: #c81e1e }
.epdf-cor-verde { --epdf-tinta: #157a3c }
.epdf-cor-amarelo { --epdf-tinta: #ffd500 }
.epdf-cor-laranja { --epdf-tinta: #f08000 }
.epdf-cor-rosa { --epdf-tinta: #e83e8c }
.epdf-cor-branco { --epdf-tinta: #ffffff }
.epdf-outra-cor { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none }
.epdf-outra-cor input { width: 32px; height: 32px; padding: 0; border: 1px solid var(--linha-forte); border-radius: 6px; background: var(--campo); cursor: pointer }

/* ── palco e páginas ── */
.epdf-palco {
  display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding: 12px 8px 24px; min-width: 0; overflow-x: auto;
  background: var(--papel-2); border: 1px solid var(--linha); border-radius: var(--raio-p); outline: none;
}
.epdf-pagina {
  position: relative; flex: none; margin: 0 auto; background: #ffffff; box-shadow: 0 1px 3px rgb(0 0 0 / .25), 0 6px 18px -8px rgb(0 0 0 / .4);
  scroll-margin-top: calc(var(--topo-h) + 190px); overflow: hidden;
}
.epdf-tela { position: absolute; inset: 0; width: 100%; height: 100%; display: block }
.epdf-carregando::after {
  content: "Carregando a página…"; position: absolute; inset: 0; display: grid; place-items: center; color: #5e584f; font-size: .875rem; pointer-events: none;
}
.epdf-camada { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none }
.epdf-modo-colocar .epdf-camada { cursor: crosshair }
.epdf-modo-texto .epdf-camada { cursor: text }
.epdf-modo-desenhar .epdf-camada { cursor: crosshair; touch-action: pinch-zoom }
.epdf-fonte { font-family: Helvetica, Arial, "Liberation Sans", "Nimbus Sans", sans-serif }
.epdf-camada text { white-space: pre; pointer-events: none }
.epdf-camada image { pointer-events: none }
.epdf-multiplicar { mix-blend-mode: multiply }
.epdf-obj { cursor: move; outline: none }
.epdf-modo-desenhar .epdf-obj { pointer-events: none }
.epdf-obj.epdf-sel, .epdf-obj.epdf-sel * { touch-action: none }
.epdf-oculto { display: none }
.epdf-toque-caixa { fill: transparent; stroke: none; pointer-events: all }
.epdf-toque-traco { fill: none; stroke: transparent; pointer-events: stroke }
.epdf-moldura { fill: none; stroke: #1447b8; stroke-width: 1.5px; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; pointer-events: none }
.epdf-foco .epdf-moldura { stroke: #b8336a; stroke-width: 2.5px; stroke-dasharray: none }
.epdf-alca-ponto { fill: #ffffff; stroke: #1447b8; stroke-width: 2px; vector-effect: non-scaling-stroke; pointer-events: none }
.epdf-alca { fill: transparent; stroke: none; pointer-events: all; touch-action: none; cursor: nwse-resize }
.epdf-alca[data-alca="ne"], .epdf-alca[data-alca="sw"] { cursor: nesw-resize }
.epdf-alca[data-alca="p1"], .epdf-alca[data-alca="p2"] { cursor: crosshair }
.epdf-digitar {
  position: absolute; z-index: 2; margin: 0; padding: 0; border: 0; border-radius: 0; outline: 2px dashed #1447b8; outline-offset: 2px;
  background: rgb(255 255 255 / .6); line-height: 1.2; white-space: pre; overflow: hidden; resize: none; box-sizing: content-box; min-width: 2em;
  caret-color: #b8336a;
}

/* ── diálogo da assinatura ── */
.epdf-dialogo {
  width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--linha-forte); border-radius: var(--raio-p);
  background: var(--cartao); color: var(--tinta); box-shadow: var(--sombra-alta); overflow: auto;
}
.epdf-dialogo::backdrop { background: rgb(0 0 0 / .55) }
.epdf-dialogo-corpo { display: grid; gap: 14px; padding: 18px }
.epdf-dialogo-corpo h2 { font-size: 1.3rem; margin: 0 }
.epdf-quadro {
  display: block; width: 100%; height: 200px; border: 2px solid var(--linha-forte); border-radius: 8px; background: #ffffff;
  touch-action: none; cursor: crosshair;
}
.epdf-quadro:focus-visible { outline: 3px solid var(--ipe); outline-offset: 2px }
.epdf-dialogo-linha { display: flex; flex-wrap: wrap; align-items: center; gap: 10px }
.epdf-dialogo-linha input[type="range"] { flex: 1 1 120px; min-height: 44px; accent-color: var(--ipe) }
.epdf-dialogo-linha label { font-size: .875rem; color: var(--grafite) }
.epdf-guardar .campo-ajuda { grid-column: 2 }
.epdf-guardada { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--linha); border-radius: 8px }
.epdf-guardada p { margin: 0 }
.epdf-guardada img { width: auto; max-width: 100%; height: 70px; object-fit: contain; object-position: left center; background: #ffffff; border-radius: 6px; padding: 4px }
.epdf-aviso-legal { margin: 0; font-size: .875rem }
.epdf-dialogo .acoes { margin: 0 }

/* ── celular: ferramentas presas embaixo, zoom nas opções ── */
@media (max-width: 767.98px) {
  .epdf-so-largo { display: none }
  .epdf-so-estreito { display: inline-flex }
  .epdf-topo { gap: 0; padding: 4px; flex-wrap: wrap; justify-content: space-between }
  .epdf-topo .epdf-sep { display: none }
  .epdf-topo .epdf-bt-so-icone { min-width: 40px }
  .epdf-sep { margin: 0 2px }
  .epdf-nome { display: none }
  .epdf-pagina-atual { flex: 1 1 auto; text-align: center; font-size: .8125rem }
  .epdf-baixar { padding-inline: .8em; margin-left: 0 }
  .epdf-inferior {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; flex-direction: column; border-top: 1px solid var(--linha-forte);
    background: var(--cartao); box-shadow: 0 -6px 18px -10px rgb(0 0 0 / .45); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .epdf-opcoes { border-top: 0; border-bottom: 1px solid var(--linha); min-height: 54px; padding: 4px 8px }
  .epdf-ferramentas { padding: 4px 6px; gap: 2px }
  .epdf-bt { min-width: 60px }
  .epdf-bt-so-icone, .epdf-bt-texto, .epdf-bt-negrito { min-width: 44px }
  .epdf-dica { max-width: 15em; font-size: .75rem }
  .epdf-palco { padding: 8px 4px 16px }
  .epdf-pagina { scroll-margin-top: calc(var(--topo-h) + 70px) }
  .epdf-aberto body { padding-bottom: 132px }
}

@media (prefers-reduced-motion: reduce) { .epdf-soltar { transition: none } }
@media print { .epdf-barras, .epdf-abrir, .epdf-privacidade { display: none !important } }
