/* Editor de PDF y conversores (PDF a Word, PDF a JPG) — RapidTools. Se carga después de tools.css. */

/* ---------- editor ---------- */
.ed { display: flex; flex-direction: column; gap: 12px; }
.ed__file { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.ed__file b { font-size: 15.5px; overflow-wrap: anywhere; }
.ed__file small { color: var(--muted); font-size: 13.5px; }
.ed__file .btn { margin-left: auto; min-height: 38px; padding: 0 14px; font-size: 14px; }

.ed__bar { position: sticky; top: 66px; z-index: 20; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); user-select: none; -webkit-user-select: none; }
.ed__tools { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.tb { flex: none; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 64px; min-height: 54px; padding: 6px 8px; border: 1px solid transparent; border-radius: 12px; background: var(--bg2); color: var(--ink2); font-size: 12.5px; font-weight: 650; cursor: pointer; }
.tb .ico { width: 20px; height: 20px; }
.tb:hover { color: var(--ink); }
.tb[aria-pressed="true"] { background: var(--acc-soft); color: var(--acc-text); border-color: color-mix(in srgb, var(--acc) 45%, transparent); }
.tb--sep { margin-left: 6px; }
.ed__opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 40px; }
.ed__opts label, .opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 650; color: var(--ink2); }
.ed__opts select { min-height: 38px; width: auto; padding: 4px 10px; font-size: 14.5px; }
.ed__opts input[type=color] { width: 38px; height: 38px; padding: 2px; border: 1px solid var(--line2); border-radius: 10px; background: var(--panel); cursor: pointer; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line2); cursor: pointer; padding: 0; }
.sw[hidden] { display: none; }
.opt[hidden], .ed__opts [hidden] { display: none !important; }
.ib[aria-pressed="true"] { background: var(--acc-soft); color: var(--acc-text); border-color: var(--acc); }
.ib b { font-size: 16px; }
.ed__opts .grow { flex: 1; }
.ed__opts .btn { min-height: 38px; padding: 0 12px; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }

.ed__pages { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 16px 0 6px; background: var(--bg2); border-radius: 16px; min-width: 0; }
.pg { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 12px; }
.pg__bar { display: flex; align-items: center; gap: 6px; width: 100%; max-width: 900px; font-size: 14px; color: var(--ink2); }
.pg__bar .grow { flex: 1; }
.pg__bar .ib { width: 34px; height: 34px; }
.pg__bar .ib .ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pg__box { position: relative; max-width: 100%; }
.pg__in { position: absolute; left: 50%; top: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .18), 0 6px 22px rgba(0, 0, 0, .1); }
.pg__cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pg__ov { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.ed[data-tool="mover"] .pg__ov, .ed[data-tool="texto"] .pg__ov { touch-action: pan-x pan-y; }
.ed[data-tool="texto"] .pg__ov { cursor: text; }
.ed[data-tool="tapar"] .pg__ov, .ed[data-tool="resaltar"] .pg__ov, .ed[data-tool="dibujar"] .pg__ov { cursor: crosshair; }
.ed.is-busy .pg__ov { pointer-events: none; }

.an { position: absolute; touch-action: none; }
.an--text { white-space: pre; line-height: 1.2; min-width: 6px; min-height: 1.2em; cursor: move; outline: none; color: #111; }
.an--text[contenteditable="true"] { cursor: text; outline: 1.5px dashed var(--acc); outline-offset: 2px; user-select: text; -webkit-user-select: text; touch-action: auto; }
.an--rect { background: #fff; cursor: move; }
.an--hl { mix-blend-mode: multiply; opacity: .55; cursor: move; }
.an--img { cursor: move; display: block; }
.an--draw { inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.an--draw path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.an--draw .hit { stroke: transparent; pointer-events: none; }
.ed:not([data-tool="dibujar"]) .an--draw .hit { pointer-events: stroke; cursor: move; }
.an.is-sel { outline: 2px solid var(--acc); outline-offset: 2px; }
.an--hl.is-sel { opacity: .75; }
.an--draw.is-sel { outline: 0; filter: drop-shadow(0 0 2px var(--acc)) drop-shadow(0 0 2px var(--acc)); }
.an__h { position: absolute; right: -11px; bottom: -11px; width: 20px; height: 20px; border-radius: 50%; background: var(--acc); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); cursor: nwse-resize; touch-action: none; }
.an__h::before { content: ""; position: absolute; inset: -10px; }

.ed__out { position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg); user-select: none; -webkit-user-select: none; }
.ed__out .status { flex: 1 1 220px; }
.ed__out .grp { display: flex; flex-wrap: wrap; gap: 8px; }
.ed__out .grp .btn--ghost { min-height: 42px; padding: 0 12px; font-size: 14px; }
.ed__out .chk { flex: 1 1 100%; font-size: 13.5px; min-height: 0; padding: 0; }
.short { display: none; }
/* Celular: barras finitas para que se vea el documento. */
@media (max-width: 640px) {
  .ed__bar { top: 58px; padding: 6px; gap: 6px; border-radius: 14px; }
  .tb { min-width: 52px; min-height: 46px; padding: 4px 6px; font-size: 11px; gap: 2px; }
  .tb .ico { width: 18px; height: 18px; }
  .ed__opts { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; min-height: 36px; gap: 8px; }
  .ed__opts .lbl, .ed__opts .btn span, .ed__opts .grow, .hint { display: none; }
  .ed__opts .opt { flex: none; }
  .ed__opts select { min-height: 34px; padding: 2px 6px; font-size: 14px; }
  .ed__opts input[type=color] { width: 34px; height: 34px; }
  .ed__opts .btn { flex: none; min-height: 34px; padding: 0 9px; }
  .ed__opts .ib { width: 34px; height: 34px; }
  .sw { width: 24px; height: 24px; }
  .pg { padding: 0 6px; }
  .ed__pages { border-radius: 12px; }
  .ed__out { padding: 8px; gap: 6px; border-radius: 14px; flex-wrap: nowrap; }
  .ed__out .status, .ed__out .chk { position: absolute; left: 8px; right: 8px; bottom: calc(100% + 6px); padding: 8px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 13px; }
  .ed__out .status:empty { display: none; }
  .ed__out .chk:not([hidden]) ~ .status:not(:empty) { bottom: calc(100% + 64px); }
  .ed__out .chk small { display: none; }
  .ed__out .grp { flex: 1 1 auto; flex-wrap: nowrap; gap: 6px; }
  .ed__out .grp .btn { flex: 1; min-height: 42px; padding: 0 6px; font-size: 13.5px; }
  .ed__out .btn--acc { flex: none; min-height: 42px; padding: 0 14px; font-size: 15px; }
  .long { display: none; } .short { display: inline; }
  .ed__tools { scrollbar-width: none; }
  .toast { bottom: 84px; }
}

/* firma */
.sig { border: 0; border-radius: 20px; padding: 20px; width: min(640px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); box-shadow: var(--shadow-lg); }
.sig::backdrop { background: rgba(0, 0, 0, .5); }
.sig h2 { font-size: 20px; margin: 0 0 4px; }
.sig p { margin: 0 0 12px; color: var(--ink2); font-size: 14.5px; }
.sig canvas { display: block; width: 100%; aspect-ratio: 5 / 2; border-radius: 14px; border: 1.5px dashed var(--line2); background: #fff; touch-action: none; cursor: crosshair; }
.sig .bar { margin-top: 12px; }

/* ---------- conversores ---------- */
.prev { margin-top: 14px; }
.prev textarea { width: 100%; min-height: 260px; max-height: 60vh; padding: 14px; border-radius: 12px; border: 1px solid var(--line2); background: var(--bg2); color: var(--ink); font: 14px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace; resize: vertical; }
.prev__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 13.5px; font-weight: 650; color: var(--ink2); }
.prev__head .btn { min-height: 36px; padding: 0 12px; font-size: 13.5px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; margin: 14px 0 4px; }
.thumbs figure { margin: 0; text-align: center; }
.thumbs canvas { width: 100%; height: auto; border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); background: #fff; }
.thumbs figcaption { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.thumbs__more { grid-column: 1 / -1; margin: 0; font-size: 13.5px; color: var(--muted); }
.thumbs:empty { display: none; }
