/* BestConverter PDF Editor */
:root { --ed-bg: #EEF0F7; --ed-bar: #fff; --ed-border: #E3E6F0; --ed-text: #141A33; --ed-muted: #6B7590; --ed-primary: #4F6BFF; --ed-primary-50: #EEF2FF; --ed-danger: #E5484D; }
html, body { height: 100%; }
body.editor-body { margin: 0; background: var(--ed-bg); font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ed-text); overflow: hidden; -webkit-user-select: none; user-select: none; }
button { font-family: inherit; }
[hidden] { display: none !important; }
.ed-app { display: grid; grid-template-rows: 56px 64px auto 1fr; height: 100vh; height: 100dvh; }

/* top bar */
.ed-top { display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--ed-bar); border-bottom: 1px solid var(--ed-border); }
.ed-top .brand { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; color: var(--ed-text); text-decoration: none; letter-spacing: -.02em; }
.ed-top .brand b { font-weight: 800; } .ed-top .brand span { font-weight: 500; }
.ed-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ed-name input { font: 500 15px Inter, sans-serif; border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; min-width: 120px; max-width: 320px; background: transparent; color: var(--ed-text); }
.ed-name input:hover, .ed-name input:focus { border-color: var(--ed-border); background: #fff; outline: none; }
.ed-name small { color: var(--ed-muted); font-size: 12px; white-space: nowrap; }
.ed-top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.ed-ibtn { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; border: 0; background: none; border-radius: 8px; color: var(--ed-text); cursor: pointer; font-size: 11px; min-width: 56px; }
.ed-ibtn:hover { background: var(--ed-primary-50); color: var(--ed-primary); }
.ed-ibtn svg { width: 22px; height: 22px; }
.ed-btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; border: 1px solid transparent; cursor: pointer; }
.ed-btn-primary { background: var(--ed-primary); color: #fff; }
.ed-btn-primary:hover { background: #3B55E6; }
.ed-btn-ghost { background: #fff; border-color: var(--ed-border); color: var(--ed-text); }
.ed-btn-ghost:hover { border-color: var(--ed-primary); color: var(--ed-primary); }
.ed-btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.ed-btn-danger { background: #FFF0F0; color: var(--ed-danger); border-color: #FFD6D6; }

/* toolbar */
.ed-tools { display: flex; align-items: center; gap: 2px; padding: 0 10px; background: var(--ed-bar); border-bottom: 1px solid var(--ed-border); overflow-x: auto; scrollbar-width: thin; }
.ed-tool { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; width: 60px; height: 54px; border: 0; background: none; border-radius: 10px; color: var(--ed-text); cursor: pointer; font-size: 11px; flex: none; position: relative; }
.ed-tool svg { width: 21px; height: 21px; }
.ed-tool span { font-size: 10.5px; }
.ed-tool:hover { background: #F3F5FB; }
.ed-tool.active { background: var(--ed-primary); color: #fff; }
.ed-tool:disabled { opacity: .35; cursor: default; }
.ed-tool:disabled:hover { background: none; }
.ed-sep { width: 1px; height: 32px; background: var(--ed-border); margin: 0 6px; flex: none; }
.ed-tools .spacer { flex: 1; }

/* body */
.ed-body { display: grid; grid-template-columns: 200px minmax(0, 1fr); min-height: 0; position: relative; }
.ed-body.no-thumbs { grid-template-columns: minmax(0, 1fr); }
.ed-side { background: #F7F8FC; border-right: 1px solid var(--ed-border); overflow: auto; padding: 16px 0; }
.ed-body.no-thumbs .ed-side { display: none; }
.ed-thumb { width: 120px; margin: 0 auto 18px; cursor: pointer; text-align: center; }
.ed-thumb canvas, .ed-thumb .ph { display: block; width: 120px; border: 2px solid transparent; border-radius: 4px; background: #fff; box-shadow: 0 1px 4px rgba(20, 26, 51, .12); }
.ed-thumb .ph { height: 160px; }
.ed-thumb.current canvas, .ed-thumb.current .ph { border-color: var(--ed-primary); }
.ed-thumb span { display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 600; background: #DDE1EE; color: var(--ed-muted); border-radius: 4px; padding: 2px 10px; }
.ed-thumb.current span { background: var(--ed-primary); color: #fff; }

.ed-main { position: relative; overflow: auto; padding: 28px 24px 120px; scroll-behavior: auto; }
.ed-pages { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.ed-page { position: relative; background: #fff; box-shadow: 0 2px 10px rgba(20, 26, 51, .14); flex: none; }
.ed-page canvas.pg { display: block; }
.ed-page .pg-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ed-muted); font-size: 13px; }
.ed-page svg.ov { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; touch-action: none; }
.ed-page svg.ov.tool-select { cursor: default; }
.ed-page svg.ov.tool-pan { cursor: grab; }
.ed-page svg.ov.tool-draw { cursor: crosshair; }
.ed-page svg.ov.tool-text, .ed-page svg.ov.tool-edittext { cursor: text; }
.ed-page svg.ov.tool-stamp { cursor: copy; }
.ed-page svg.ov.tool-eraser { cursor: not-allowed; }
.ov .annot { cursor: move; }
.ov .annot.hl { mix-blend-mode: multiply; }
.ov .sel-box { fill: none; stroke: var(--ed-primary); stroke-dasharray: 4 3; pointer-events: none; }
.ov .handle { fill: #fff; stroke: var(--ed-primary); stroke-width: 1.5; cursor: nwse-resize; }
.ov .handle.ne, .ov .handle.sw { cursor: nesw-resize; }
.ov .handle.n, .ov .handle.s { cursor: ns-resize; }
.ov .handle.e, .ov .handle.w { cursor: ew-resize; }
.ov .text-fo div { font-family: Arial, "Liberation Sans", Helvetica, sans-serif; line-height: 1.2; white-space: pre-wrap; word-wrap: break-word; outline: none; padding: 2px; min-height: 1em; cursor: move; -webkit-user-select: none; user-select: none; }
.ov .text-fo div.editing { cursor: text; -webkit-user-select: text; user-select: text; outline: 1.5px solid var(--ed-primary); background: rgba(255, 255, 255, .6); }
.ov .hit { fill: transparent; stroke: transparent; }
.ov .search-hit { fill: #FFD400; opacity: .45; mix-blend-mode: multiply; pointer-events: none; }
.ov .edittext-hint { fill: rgba(79, 107, 255, .12); stroke: var(--ed-primary); stroke-width: 1; pointer-events: none; }

/* floating property bar */
.ed-props { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--ed-border); border-radius: 14px; padding: 8px 12px; box-shadow: 0 10px 30px rgba(20, 26, 51, .16); z-index: 5; font-size: 13px; white-space: nowrap; }
.ed-props label { display: inline-flex; align-items: center; gap: 6px; color: var(--ed-muted); }
.ed-props input[type=color] { width: 28px; height: 28px; border: 1px solid var(--ed-border); border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; }
.ed-props input[type=range] { width: 90px; accent-color: var(--ed-primary); }
.ed-props select, .ed-props input[type=number] { font: inherit; border: 1px solid var(--ed-border); border-radius: 8px; padding: 4px 6px; background: #fff; }
.ed-props .tg { border: 1px solid var(--ed-border); background: #fff; border-radius: 8px; width: 30px; height: 28px; cursor: pointer; font-weight: 800; }
.ed-props .tg.on { background: var(--ed-primary-50); border-color: var(--ed-primary); color: var(--ed-primary); }
.ed-props .del { border: 1px solid #FFD6D6; background: #FFF0F0; color: var(--ed-danger); border-radius: 8px; height: 28px; padding: 0 10px; cursor: pointer; font-weight: 600; }

/* zoom bar */
.ed-zoom { position: absolute; right: 22px; bottom: 22px; display: flex; align-items: center; gap: 2px; background: #fff; border: 1px solid var(--ed-border); border-radius: 12px; padding: 4px; box-shadow: 0 6px 20px rgba(20, 26, 51, .12); z-index: 5; }
.ed-zoom button { border: 0; background: none; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 16px; color: var(--ed-text); }
.ed-zoom button:hover { background: var(--ed-primary-50); color: var(--ed-primary); }
.ed-zoom span { font-size: 12px; font-weight: 600; min-width: 44px; text-align: center; }
.ed-pageinfo { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(20, 26, 51, .78); color: #fff; font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px; z-index: 5; pointer-events: none; opacity: 0; transition: .2s; }
.ed-pageinfo.show { opacity: 1; }

/* search panel */
.ed-search { position: absolute; right: 22px; top: 14px; display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--ed-border); border-radius: 12px; padding: 6px 8px; box-shadow: 0 6px 20px rgba(20, 26, 51, .12); z-index: 6; }
.ed-search input { font: inherit; border: 1px solid var(--ed-border); border-radius: 8px; padding: 6px 10px; width: 200px; }
.ed-search span { font-size: 12px; color: var(--ed-muted); min-width: 50px; text-align: center; }
.ed-search button { border: 0; background: none; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; }
.ed-search button:hover { background: var(--ed-primary-50); }

/* modals */
.ed-modal { position: fixed; inset: 0; background: rgba(20, 26, 51, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.ed-dialog { background: #fff; border-radius: 20px; width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow: auto; padding: 24px; box-shadow: 0 30px 80px rgba(20, 26, 51, .3); }
.ed-dialog.wide { max-width: 960px; }
.ed-dialog h3 { margin: 0 0 14px; font-size: 18px; }
.ed-dialog .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ed-dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.ed-dialog .muted { color: var(--ed-muted); font-size: 13px; }
.ed-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.ed-tabs button { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--ed-border); background: #fff; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ed-muted); }
.ed-tabs button.active { background: var(--ed-primary-50); border-color: var(--ed-primary); color: var(--ed-primary); }
.sig-pad { width: 100%; height: 170px; border: 1.5px dashed #C7CEEA; border-radius: 12px; background: #FAFBFF; touch-action: none; display: block; }
.sig-type { font-family: "Brush Script MT", "Segoe Script", "Apple Chancery", cursive; font-size: 36px; width: 100%; padding: 10px 14px; border: 1px solid var(--ed-border); border-radius: 12px; box-sizing: border-box; }
.ed-pagesgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; max-height: 60vh; overflow: auto; padding: 4px; }
.ed-pg { border: 1px solid var(--ed-border); border-radius: 10px; padding: 8px; text-align: center; background: #fff; cursor: grab; position: relative; }
.ed-pg.dragging { opacity: .4; }
.ed-pg canvas { width: 100%; height: auto; display: block; border-radius: 4px; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); transition: transform .2s; }
.ed-pg.deleted canvas { opacity: .25; }
.ed-pg .n { position: absolute; top: 12px; left: 12px; font-size: 11px; font-weight: 700; background: #fff; border: 1px solid var(--ed-border); border-radius: 6px; padding: 1px 6px; }
.ed-pg .acts { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }
.ed-pg .acts button { border: 1px solid var(--ed-border); background: #fff; border-radius: 8px; width: 30px; height: 28px; cursor: pointer; }
.ed-pg .acts button:hover { border-color: var(--ed-primary); color: var(--ed-primary); }

/* loading / landing */
.ed-loading { position: fixed; inset: 0; background: rgba(238, 240, 247, .9); display: grid; place-items: center; z-index: 60; }
.ed-loading .card { background: #fff; border-radius: 24px; padding: 40px 48px; width: 100%; max-width: 560px; text-align: center; box-shadow: 0 30px 80px rgba(20, 26, 51, .2); }
.ed-loading .ring { width: 110px; height: 110px; border-radius: 50%; background: #fff; box-shadow: 0 8px 24px rgba(20, 26, 51, .12); display: grid; place-items: center; margin: 0 auto 22px; color: var(--ed-primary); }
.ed-loading .ring svg { width: 46px; height: 46px; }
.ed-loading h3 { margin: 0 0 16px; font-size: 20px; }
.ed-loading h3 b { color: var(--ed-primary); }
.ed-loading .bar { height: 14px; border-radius: 10px; background: #EDEFF7; overflow: hidden; }
.ed-loading .bar i { display: block; height: 100%; width: 0; background: var(--ed-primary); border-radius: 10px; transition: width .2s; }
.ed-landing { position: fixed; inset: 0; background: var(--ed-bg); display: grid; place-items: center; z-index: 55; padding: 20px; }
.ed-landing .drop { background: #fff; border-radius: 24px; padding: 40px; width: 100%; max-width: 620px; text-align: center; box-shadow: 0 30px 80px rgba(20, 26, 51, .14); }
.ed-landing .dz { border: 2px dashed #C7CEEA; border-radius: 18px; padding: 44px 20px; background: #FAFBFF; }
.ed-landing .dz.drag { border-color: var(--ed-primary); background: var(--ed-primary-50); }
.ed-landing h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.02em; }
.ed-landing p { color: var(--ed-muted); margin: 0 0 20px; }
.ed-toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #141A33; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 70; opacity: 0; transition: .2s; pointer-events: none; }
.ed-toast.show { opacity: 1; }

@media (max-width: 900px) {
  .ed-app { grid-template-rows: 52px 60px auto 1fr; }
  .ed-body, .ed-body.no-thumbs { grid-template-columns: minmax(0, 1fr); }
  .ed-side { position: absolute; left: 0; top: 0; bottom: 0; width: 160px; z-index: 4; box-shadow: 4px 0 20px rgba(0, 0, 0, .1); }
  .ed-body.no-thumbs .ed-side { display: none; }
  .ed-thumb { width: 100px; } .ed-thumb canvas, .ed-thumb .ph { width: 100px; }
  .ed-ibtn { min-width: 44px; } .ed-ibtn span { display: none; }
  .ed-name small { display: none; }
  .ed-main { padding: 14px 8px 120px; }
  .ed-props { left: 8px; right: 8px; transform: none; overflow-x: auto; }
  .ed-search { left: 8px; right: 8px; } .ed-search input { flex: 1; width: auto; }
}

/* crop */
.ed-subbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #F7F8FC; border-bottom: 1px solid var(--ed-border); font-size: 13px; overflow-x: auto; white-space: nowrap; }
.ed-subbar label { display: inline-flex; align-items: center; gap: 4px; color: var(--ed-muted); }
.ed-subbar input { width: 64px; font: inherit; border: 1px solid var(--ed-border); border-radius: 8px; padding: 4px 6px; }
.ed-subbar .spacer { flex: 1; }
.ed-page svg.ov.tool-crop { cursor: crosshair; }
.ov .crop-mask { fill: rgba(20, 26, 51, .5); pointer-events: none; }
.ov .crop-area { fill: transparent; stroke: #fff; cursor: move; }
.ov .crop-guide { stroke: rgba(255, 255, 255, .45); pointer-events: none; }
.ov .crop-h { fill: #fff; stroke: var(--ed-primary); }
.ov .crop-h.nw, .ov .crop-h.se { cursor: nwse-resize; } .ov .crop-h.ne, .ov .crop-h.sw { cursor: nesw-resize; }
.ov .crop-h.n, .ov .crop-h.s { cursor: ns-resize; } .ov .crop-h.e, .ov .crop-h.w { cursor: ew-resize; }
.ov .crop-label { fill: #fff; font-family: Inter, sans-serif; font-weight: 600; paint-order: stroke; stroke: rgba(20, 26, 51, .6); stroke-width: 3px; pointer-events: none; }

/* thumbnail quick actions */
.ed-thumb .th-wrap { position: relative; display: inline-block; }
.ed-thumb .th-acts { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.ed-thumb:hover .th-acts, .ed-thumb.current .th-acts { opacity: 1; }
.ed-thumb .th-acts button { width: 28px; height: 26px; border-radius: 7px; border: 1px solid var(--ed-border); background: #fff; color: var(--ed-text); cursor: pointer; font-size: 14px; line-height: 1; box-shadow: 0 2px 6px rgba(20, 26, 51, .12); }
.ed-thumb .th-acts button:hover { border-color: var(--ed-primary); color: var(--ed-primary); }
.ed-thumb .th-acts button.del:hover { border-color: var(--ed-danger); color: var(--ed-danger); }
@media (hover: none) { .ed-thumb .th-acts { opacity: 1; } }

/* compact toolbar: buttons size to their label */
.ed-tool { width: auto; min-width: 48px; padding: 0 7px; }
.ed-sep { margin: 0 3px; }
@media (max-width: 1280px) { .ed-tool { padding: 0 5px; min-width: 44px; } .ed-tool span { font-size: 10px; } }
