/* ── Advanced PDF Editor ─────────────────────────────────────────────── */

.pxe-max { max-width: 1400px; margin: 0 auto; }

/* Resume banner */
.pxe-resume { display: flex; align-items: center; gap: 12px; background: var(--teal-d); border: 1px solid rgba(14,92,86,.25); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-size: .84rem; color: var(--ink); }
.pxe-resume i { color: var(--teal); font-size: 1.1rem; }
.pxe-resume .pxe-resume-text { flex: 1; }
.pxe-resume button { border: none; border-radius: 8px; padding: 7px 14px; font-size: .78rem; font-weight: 700; cursor: pointer; }
.pxe-resume .pxe-resume-yes { background: var(--teal); color: #fff; }
.pxe-resume .pxe-resume-yes i { color: #fff; }
.pxe-resume .pxe-resume-no  { background: transparent; color: var(--sub); border: 1px solid var(--border); }

/* Shell layout */
.pxe-shell { display: none; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); }
.pxe-shell.active { display: flex; flex-direction: column; }

/* Toolbar — two-row layout on all screen sizes */
.pxe-toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; border-bottom: 1px solid var(--border); background: var(--card); position: sticky; top: 0; z-index: 30; }

/* Row 1: tools scroll horizontally */
.pxe-toolbar-tools-row { display: flex; align-items: center; gap: 4px; padding: 8px 10px; overflow-x: auto; scrollbar-width: thin; flex-wrap: nowrap; }
.pxe-toolbar-tools-row::-webkit-scrollbar { height: 3px; }
.pxe-toolbar-tools-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Row 2: zoom left, Apply changes right */
.pxe-toolbar-bottom-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--border); }
.pxe-toolbar-bottom-row .pxe-toolbar-spacer { flex: 1; }
.pxe-toolbar-bottom-row .pxe-apply { flex-shrink: 0; }
.pxe-tool { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; font-size: .62rem; font-weight: 600; color: var(--sub); cursor: pointer; transition: background .15s, color .15s, border-color .15s; min-width: 52px; }
.pxe-tool i { font-size: 1rem; }
.pxe-tool:hover { background: var(--teal-d); color: var(--teal); }
.pxe-tool.active { background: var(--teal-d); color: var(--teal); border-color: var(--teal); }
.pxe-tool:disabled { opacity: .4; cursor: not-allowed; }
.pxe-toolbar-sep { width: 1px; height: 30px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.pxe-toolbar-spacer { flex: 1; }

.pxe-zoom { display: inline-flex; align-items: center; gap: 4px; }
.pxe-zoom button { background: var(--card); border: 1px solid var(--border); border-radius: 7px; width: 28px; height: 28px; font-size: .8rem; color: var(--ink); cursor: pointer; }
.pxe-zoom button:hover { border-color: var(--teal); color: var(--teal); }
.pxe-zoom .pxe-zoom-val { font-size: .72rem; font-weight: 700; color: var(--ink); min-width: 44px; text-align: center; }

.pxe-apply { background: var(--orange); border: none; color: #fff; font-weight: 700; font-size: .8rem; padding: 9px 18px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; transition: background .15s, transform .15s; white-space: nowrap; flex-shrink: 0; }
.pxe-apply:hover:not(:disabled) { background: var(--orange-h); transform: translateY(-1px); }
.pxe-apply:disabled { opacity: .45; cursor: not-allowed; }
.pxe-apply .pxe-credit-badge { background: rgba(255,255,255,.22); border-radius: 6px; padding: 1px 7px; font-size: .68rem; }

/* Body: thumbnails | pages | properties */
.pxe-body { display: flex; min-height: 480px; max-height: calc(100vh - 170px); }

.pxe-thumbs { width: 118px; flex-shrink: 0; overflow-y: auto; border-right: 1px solid var(--border); padding: 10px 8px; background: var(--card); }
.pxe-thumb { border: 2px solid var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 8px; cursor: pointer; position: relative; background: #fff; transition: border-color .15s; }
.pxe-thumb:hover { border-color: var(--teal); }
.pxe-thumb.active { border-color: var(--orange); }
.pxe-thumb canvas { display: block; width: 100%; height: auto; }
.pxe-thumb .pxe-thumb-num { position: absolute; bottom: 3px; right: 5px; background: rgba(0,0,0,.55); color: #fff; font-size: .6rem; font-weight: 700; border-radius: 4px; padding: 0 5px; }

.pxe-pages { flex: 1; overflow: auto; background: #e9e5df; padding: 18px; }
.pxe-page { position: relative; margin: 0 auto 18px; box-shadow: 0 2px 12px rgba(0,0,0,.18); background: #fff; }
.pxe-page .pxe-pdf-canvas { position: absolute; inset: 0; z-index: 1; }
.pxe-page .canvas-container { position: absolute !important; inset: 0; z-index: 2; }
.pxe-page .pxe-page-num { position: absolute; top: -1px; left: -1px; transform: translateY(-100%); font-size: .62rem; font-weight: 700; color: var(--sub); background: transparent; padding: 2px 2px; }

/* Properties panel */
.pxe-props { width: 230px; flex-shrink: 0; overflow-y: auto; border-left: 1px solid var(--border); padding: 14px 12px; background: var(--card); }
.pxe-props h4 { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--sub); margin: 0 0 10px; }
.pxe-prop { margin-bottom: 12px; }
.pxe-prop label { display: block; font-size: .66rem; font-weight: 700; color: var(--sub); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.pxe-prop select, .pxe-prop input[type=number] { width: 100%; border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; font-size: .78rem; color: var(--ink); background: var(--card); outline: none; box-sizing: border-box; }
.pxe-prop select:focus, .pxe-prop input:focus { border-color: var(--teal); }
.pxe-prop-row { display: flex; gap: 8px; align-items: center; }
.pxe-prop-row input[type=color] { width: 34px; height: 30px; border: 1px solid var(--border); border-radius: 6px; padding: 2px; cursor: pointer; background: none; flex-shrink: 0; }
.pxe-prop-row input[type=range] { flex: 1; accent-color: var(--teal); }
.pxe-range-val { font-size: .7rem; font-weight: 700; color: var(--ink); min-width: 30px; text-align: right; }

.pxe-style-btns { display: flex; gap: 5px; }
.pxe-style-btn { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: 7px; padding: 5px 0; font-size: .78rem; color: var(--ink); cursor: pointer; }
.pxe-style-btn.on { background: var(--teal-d); border-color: var(--teal); color: var(--teal); }

.pxe-del-btn { width: 100%; background: transparent; border: 1px solid rgba(220,53,69,.4); color: #cc2222; border-radius: 8px; padding: 8px 0; font-size: .76rem; font-weight: 700; cursor: pointer; margin-top: 4px; }
.pxe-del-btn:hover { background: rgba(220,53,69,.08); }

.pxe-props-empty { font-size: .72rem; color: var(--sub); line-height: 1.6; padding: 6px 2px; }

/* Elements list */
.pxe-el-list { margin-top: 6px; max-height: 200px; overflow-y: auto; }
.pxe-el-item { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 7px; font-size: .72rem; color: var(--ink); background: var(--teal-d); margin-bottom: 4px; cursor: pointer; }
.pxe-el-item:hover { background: rgba(14,92,86,.14); }
.pxe-el-item .pxe-el-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pxe-el-item .pxe-el-page { font-size: .62rem; color: var(--sub); flex-shrink: 0; }
.pxe-el-item .pxe-el-del { color: var(--err); cursor: pointer; font-size: .78rem; flex-shrink: 0; }

/* Find & Replace panel */
.pxe-find-panel { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--teal-d); flex-wrap: wrap; }
.pxe-find-panel input[type=text] { flex: 1; min-width: 140px; border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px; font-size: .78rem; color: var(--ink); background: var(--card); outline: none; }
.pxe-find-panel input[type=text]:focus { border-color: var(--teal); }
.pxe-find-btn { background: var(--card); border: 1px solid var(--border); border-radius: 7px; padding: 6px 12px; font-size: .74rem; font-weight: 700; color: var(--ink); cursor: pointer; }
.pxe-find-btn:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.pxe-find-btn:disabled { opacity: .45; cursor: not-allowed; }
.pxe-find-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.pxe-find-primary:hover:not(:disabled) { background: #0a4440; color: #fff; }
.pxe-find-count { font-size: .72rem; font-weight: 700; color: var(--teal); white-space: nowrap; }
.pxe-find-close { background: none; border: none; color: var(--sub); font-size: .85rem; cursor: pointer; padding: 4px 6px; }

/* Text-snap ghost overlay */
.pxe-ghost-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.pxe-ghost { position: absolute; background: rgba(14,92,86,.14); border: 1.5px dashed var(--teal); border-radius: 3px; }
.pxe-ghost.flash { background: rgba(255,196,0,.40); border: 2px solid #e0a800; border-radius: 3px; }

/* Signature modal */
.pxe-modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.pxe-modal { background: var(--card); border-radius: 14px; width: 520px; max-width: 100%; box-shadow: 0 18px 60px rgba(0,0,0,.35); overflow: hidden; }
.pxe-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 800; font-size: .9rem; color: var(--ink); }
.pxe-modal-head i { color: var(--teal); margin-right: 6px; }
.pxe-modal-tabs { display: flex; gap: 2px; padding: 10px 18px 0; }
.pxe-modal-tab { background: none; border: none; border-bottom: 2.5px solid transparent; padding: 8px 14px; font-size: .78rem; font-weight: 700; color: var(--sub); cursor: pointer; }
.pxe-modal-tab.active { color: var(--teal); border-bottom-color: var(--teal); }
.pxe-sigtab { padding: 16px 18px; }
#sigDrawCanvas { border: 1.5px dashed var(--border); border-radius: 10px; width: 100%; height: 160px; cursor: crosshair; background: #fff; touch-action: none; display: block; }
.pxe-sig-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.pxe-sig-row input[type=color] { width: 34px; height: 30px; border: 1px solid var(--border); border-radius: 6px; padding: 2px; cursor: pointer; background: none; }
.pxe-sig-input { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: .9rem; color: var(--ink); background: var(--card); outline: none; box-sizing: border-box; }
.pxe-sig-input:focus { border-color: var(--teal); }
.pxe-sig-select { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: .8rem; color: var(--ink); background: var(--card); }
.pxe-sig-preview { margin-top: 12px; min-height: 70px; display: flex; align-items: center; justify-content: center; font-size: 2.1rem; color: #1a2b8f; border: 1.5px dashed var(--border); border-radius: 10px; background: #fff; padding: 8px; overflow: hidden; }
.pxe-sig-img { max-width: 100%; max-height: 140px; margin-top: 12px; border: 1.5px dashed var(--border); border-radius: 10px; padding: 6px; background: #fff; }
.pxe-sig-saved-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.pxe-sig-saved { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--border); border-radius: 10px; padding: 8px 10px; cursor: pointer; background: #fff; transition: border-color .15s; }
.pxe-sig-saved:hover { border-color: var(--teal); }
.pxe-sig-saved.selected { border-color: var(--orange); box-shadow: 0 0 0 2px rgba(255,80,0,.15); }
.pxe-sig-saved img { height: 44px; max-width: 70%; object-fit: contain; flex: 1; }
.pxe-sig-saved .pxe-el-del { color: var(--err); cursor: pointer; padding: 4px; }
.pxe-modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); }
.pxe-sig-save-check { display: flex; align-items: center; gap: 7px; font-size: .76rem; color: var(--sub); cursor: pointer; }
.pxe-sig-save-check input { accent-color: var(--teal); }

/* Link object display note */
.pxe-link-hint { font-size: .7rem; color: var(--sub); background: var(--teal-d); border-radius: 7px; padding: 7px 10px; margin-bottom: 10px; line-height: 1.5; }

/* Status strip */
.pxe-status { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-top: 1px solid var(--border); font-size: .68rem; color: var(--sub); flex-wrap: wrap; min-width: 0; }
.pxe-status #docName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 40%; }
.pxe-status .pxe-save-state { display: inline-flex; align-items: center; gap: 5px; }
.pxe-status .pxe-save-state.saved i { color: var(--teal); }
.pxe-status .pxe-save-state.saving i { color: var(--orange); }

/* Download card */
.pxe-download-card { margin-top: 16px; }
.btn-download { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--teal); color: #fff; border: none; font-weight: 700; font-size: .84rem; padding: 11px 22px; border-radius: 9px; text-decoration: none; transition: background .15s, transform .15s; }
.btn-download:hover { background: #0a4440; color: #fff; transform: translateY(-1px); }

.pxe-close-doc { background: none; border: 1px solid var(--border); border-radius: 7px; color: var(--sub); font-size: .68rem; font-weight: 700; padding: 4px 10px; cursor: pointer; margin-left: 10px; }
.pxe-close-doc:hover { border-color: var(--err); color: var(--err); }

.pxe-apply .pxe-credit-badge.over { background: rgba(220,53,69,.85); }

@media (max-width: 960px) {
    .pxe-thumbs { display: none; }
    .pxe-props { width: 200px; }
    .pxe-tool { min-width: 46px; padding: 5px 7px; }
}
@media (max-width: 680px) {
    .pxe-body { flex-direction: column; max-height: none; }
    .pxe-props { width: 100%; border-left: none; border-top: 1px solid var(--border); }
    .pxe-pages { max-height: 60vh; }

    /* Resume banner — wrap filename onto its own line, buttons below */
    .pxe-resume { flex-wrap: wrap; gap: 8px; padding: 12px 12px; }
    .pxe-resume > i { flex-shrink: 0; align-self: center; }
    .pxe-resume .pxe-resume-text { flex: 1 1 auto; min-width: 0; word-break: break-word; }
    .pxe-resume .pxe-resume-yes,
    .pxe-resume .pxe-resume-no  { flex: 1; text-align: center; }

    /* Tool icons: icon-only on mobile */
    .pxe-tool { min-width: 36px; padding: 5px 6px; font-size: 0; gap: 0; flex-shrink: 0; }
    .pxe-tool i { font-size: .95rem; }
    .pxe-toolbar-sep { flex-shrink: 0; }

    /* Apply full-width on mobile */
    .pxe-toolbar-bottom-row .pxe-apply { flex: 1; justify-content: center; padding: 10px 16px; }

    /* cv-wrap padding */
    .cv-wrap { padding: 0 12px 40px; }
    .tool-card { padding: 18px 14px; }

    /* Status bar — stack into two rows */
    .pxe-status { flex-wrap: wrap; row-gap: 4px; padding: 8px 12px; }
    .pxe-status #docName { max-width: 55%; }
    .pxe-status .pxe-toolbar-spacer { display: none; }
    .pxe-status .pxe-save-state { margin-left: auto; }
    .pxe-close-doc { width: 100%; margin-left: 0; text-align: center; justify-content: center; display: flex; align-items: center; gap: 5px; }
}
