/* ==========================================================================
   PDFJPG wizard app (js/pdfjpg-app.js) — production styles
   Mounted inside #pdfjpg-app on tool pages, below the static app shell.
   ========================================================================== */

#pdfjpg-app {
    display: flex; flex-direction: column;
    min-height: calc(100vh - 60px);
    position: relative;
}

/* working progress stripe */
.pa-stripe {
    height: 7px; flex-shrink: 0; display: none;
    background: repeating-linear-gradient(-55deg, #2563eb 0 10px, #bfdbfe 10px 20px);
    background-size: 28px 100%;
    animation: pa-stripemove 0.6s linear infinite;
}
.pa-stripe.on { display: block; }
@keyframes pa-stripemove { to { background-position: 28px 0; } }

.pa-view { flex: 1; position: relative; display: flex; flex-direction: column; }
.pa-view > .pa-panel, .pa-view > .pa-upload-wrap,
.pa-view > .pa-status-wrap, .pa-view > .pa-editor {
    animation: pa-viewin .3s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes pa-viewin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.pa-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: 10px; font-size: 0.9rem; font-weight: 600;
    border: 1px solid var(--as-border); background: #fff; color: var(--as-text);
    cursor: pointer; font-family: inherit; text-decoration: none;
    transition: transform .16s, box-shadow .16s, background .16s;
}
.pa-btn:hover { background: #f8fafc; }
.pa-btn.primary {
    border: none; color: #fff;
    background: linear-gradient(180deg, #3b82f6, #2563eb);
    box-shadow: 0 2px 8px rgba(37,99,235,.32), inset 0 1px 0 rgba(255,255,255,.22);
}
.pa-btn.primary:hover { background: linear-gradient(180deg, #4f8df7, #2563eb); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(37,99,235,.38); }
.pa-btn:active { transform: translateY(0) scale(.98); }
.pa-btn.big { padding: 13px 26px; font-size: 1rem; border-radius: 11px; }
.pa-btn.block { width: 100%; }

.pa-chip {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.8rem;
    box-shadow: inset 0 -2px 4px rgba(0,0,0,.13);
}
.pa-chip.ic.pop { animation: pa-pop .4s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes pa-pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- upload ---------- */
.pa-upload-wrap { flex: 1; padding: 24px 36px 30px; display: flex; }
.pa-upload-zone {
    flex: 1; border: 2px dashed #a8c3f0; border-radius: 18px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
    background: linear-gradient(180deg, rgba(255,255,255,.75), rgba(255,255,255,.35));
    transition: background .2s, border-color .2s; cursor: pointer;
    min-height: min(380px, calc(100vh - 200px));
}
.pa-upload-zone:hover, body.pa-dragging .pa-upload-zone { background: var(--as-accent-soft); border-color: #2563eb; }
.pa-cloud { font-size: 2.6rem; color: #2563eb; animation: pa-float 2.8s ease-in-out infinite; }
@keyframes pa-float { 50% { transform: translateY(-9px); } }
.pa-fmt-line { font-size: 0.9rem; color: var(--as-muted); }
.pa-fmt-line b { color: var(--as-text); }
.pa-fmt-badges { display: flex; gap: 6px; }
.pa-fmt-badge {
    font-size: 0.68rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; color: #fff;
    box-shadow: inset 0 -2px 3px rgba(0,0,0,.15);
}

/* ---------- status / working ---------- */
.pa-status-wrap {
    flex: 1; min-height: calc(100vh - 70px);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 20px;
}
.pa-doc-cards { display: flex; align-items: center; gap: 28px; }
.pa-doc-card {
    width: 190px; height: 260px; background: #fff; border-radius: 12px;
    box-shadow: 0 12px 34px rgba(15,23,42,.13);
    display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
.pa-doc-card.lg { width: 230px; height: 310px; }
.pa-doc-card img, .pa-doc-card canvas { max-width: 100%; max-height: 100%; }
.pa-mascot { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pa-face { font-size: 3.2rem; }
.pa-tag { font-size: 0.8rem; font-weight: 800; color: #fff; padding: 3px 12px; border-radius: 5px; }
.pa-tag.pdf { background: #ef4444; }
.pa-tag.img { background: #f59e0b; }
.pa-arrow-dot {
    width: 34px; height: 34px; border-radius: 50%; background: #1e3a8a; color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(30,58,138,.35); animation: pa-pulse 1.4s ease-in-out infinite;
}
@keyframes pa-pulse { 50% { transform: scale(1.12); } }
.pa-status-file { margin-top: 18px; font-size: 0.85rem; color: var(--as-muted); text-align: center; }
.pa-status-label { margin-top: 10px; font-size: 1.25rem; font-weight: 800; color: #1e40af; letter-spacing: -0.01em; }
.pa-tip-box {
    margin-top: 26px; max-width: 420px; text-align: center; font-size: 0.85rem; color: var(--as-text);
    background: #fff; border-radius: 12px; padding: 13px 18px;
    border: 1px solid transparent;
    background-image: linear-gradient(#fff,#fff), linear-gradient(90deg,#f43f5e,#f97316,#eab308,#22c55e,#3b82f6,#a855f7);
    background-origin: border-box; background-clip: padding-box, border-box;
    box-shadow: 0 5px 16px rgba(15,23,42,.07);
}

/* ---------- panel (options / done): main + right rail ---------- */
.pa-panel { display: flex; flex: 1; min-height: calc(100vh - 70px); }
.pa-panel-main {
    flex: 1; padding: 36px 32px; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.pa-panel-main.list { justify-content: flex-start; align-items: stretch; }
.pa-rail {
    width: clamp(280px, 32vw, 380px); flex-shrink: 0; background: #fff; border-left: 1px solid var(--as-border);
    padding: 30px 26px; box-shadow: -6px 0 24px rgba(15,23,42,.04);
}
.pa-rail-title {
    display: flex; align-items: center; gap: 10px;
    font-size: 1.3rem; font-weight: 800; margin-bottom: 16px; letter-spacing: -0.01em;
    color: var(--as-text);
}
.pa-back-link {
    display: inline-flex; align-items: center; gap: 7px;
    color: #2563eb; font-size: 0.875rem; font-weight: 600; text-decoration: none; margin-bottom: 16px;
}
.pa-back-link:hover { text-decoration: underline; }

.pa-radio {
    display: flex; gap: 11px; width: 100%; text-align: left; padding: 14px; margin-bottom: 11px;
    border: 1.5px solid var(--as-border); border-radius: 12px; background: #fff; cursor: pointer;
    font-family: inherit; transition: border-color .15s, background .15s, box-shadow .15s;
}
.pa-radio:hover { border-color: #93c5fd; }
.pa-radio.sel { border-color: #2563eb; background: var(--as-accent-soft); box-shadow: 0 0 0 3px rgba(37,99,235,.13); }
.pa-dot {
    width: 18px; height: 18px; border-radius: 50%; border: 2px solid #cbd5e1; flex-shrink: 0; margin-top: 2px;
    display: flex; align-items: center; justify-content: center;
}
.pa-radio.sel .pa-dot { border-color: #2563eb; }
.pa-radio.sel .pa-dot::after { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #2563eb; }
.pa-radio b { display: block; font-size: 0.92rem; margin-bottom: 2px; color: var(--as-text); }
.pa-radio span { font-size: 0.8rem; color: var(--as-muted); line-height: 1.45; }

.pa-opt-label { font-size: 0.78rem; font-weight: 700; color: var(--as-muted); display: block; margin: 14px 0 6px; }
.pa-seg { display: flex; gap: 8px; margin: 4px 0 10px; }
.pa-seg-btn {
    flex: 1; padding: 8px 0; border: 1.5px solid var(--as-border); border-radius: 9px; background: #fff;
    font-size: 0.82rem; font-weight: 700; color: var(--as-muted); cursor: pointer; font-family: inherit;
    transition: all .14s;
}
.pa-seg-btn.sel { border-color: #2563eb; color: #2563eb; background: var(--as-accent-soft); }
.pa-go { width: 100%; margin-top: 12px; padding: 15px; font-size: 1.02rem; border-radius: 12px; }

/* ---------- done: file list ---------- */
.pa-file-list {
    max-width: 760px; width: 100%; margin: 0 auto;
    background: #fff; border-radius: 14px; border: 1px solid var(--as-border);
    overflow: hidden; box-shadow: 0 3px 12px rgba(15,23,42,.05);
}
.pa-file-item {
    display: flex; align-items: center; gap: 14px; padding: 13px 18px;
    border-bottom: 1px solid #f1f5f9; transition: background .12s;
}
.pa-file-item:last-child { border-bottom: none; }
.pa-file-item:hover { background: #f8fafc; }
.pa-f-thumb {
    width: 46px; height: 60px; background: var(--as-bg); border-radius: 6px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;
    box-shadow: inset 0 0 0 1px rgba(15,23,42,.05);
}
.pa-f-thumb img { max-width: 100%; max-height: 100%; }
.pa-mini-tag {
    position: absolute; bottom: 2px; left: 2px;
    font-size: 0.5rem; font-weight: 800; color: #fff; background: #f59e0b;
    border-radius: 3px; padding: 1px 4px;
}
.pa-mini-tag.pdf { background: #ef4444; }
.pa-f-meta { flex: 1; min-width: 0; }
.pa-f-name { font-size: 0.85rem; font-weight: 600; color: var(--as-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pa-f-sub { font-size: 0.75rem; color: #16a34a; font-weight: 700; }
.pa-f-dl {
    width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--as-border); background: #fff;
    color: #475569; cursor: pointer; transition: all .14s;
}
.pa-f-dl:hover { color: #2563eb; border-color: #2563eb; }

.pa-rail-file { font-size: 0.85rem; color: var(--as-muted); margin-bottom: 4px; word-break: break-all; }
.pa-rail-count { font-size: 0.8rem; color: #94a3b8; margin-bottom: 16px; }
.pa-save-line { font-size: 0.9rem; margin-bottom: 16px; color: var(--as-text); }
.pa-save-line b { color: #16a34a; }
.pa-continue-title { font-size: 0.85rem; font-weight: 800; margin: 22px 0 10px; color: var(--as-text); }
.pa-continue {
    display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 13px; margin-bottom: 7px;
    border: 1px solid var(--as-border); border-radius: 11px; background: #fff;
    font-size: 0.87rem; font-weight: 600; color: var(--as-text); text-align: left;
    cursor: pointer; font-family: inherit; transition: all .13s;
}
.pa-continue:hover { border-color: #2563eb; background: var(--as-accent-soft); }
.pa-continue .pa-chip { width: 27px; height: 27px; font-size: 0.7rem; border-radius: 7px; }
.pa-chev { margin-left: auto; color: #94a3b8; font-size: 0.7rem; }
.pa-rail-actions { display: flex; gap: 8px; margin-top: 8px; }
.pa-rail-actions .pa-btn { flex: 1; }

/* ---------- organize editor ---------- */
.pa-editor { padding: 22px 26px 110px; }
.pa-editor-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.pa-hint { font-size: 0.8rem; color: #94a3b8; margin-left: 6px; }
#pa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.pa-page-card {
    background: #fff; border: 1px solid var(--as-border); border-radius: 12px; padding: 9px;
    position: relative; cursor: pointer; user-select: none;
    transition: box-shadow .15s, border-color .15s, transform .15s;
}
.pa-page-card:hover { box-shadow: 0 5px 16px rgba(15,23,42,.10); transform: translateY(-2px); }
.pa-page-card.selected { border-color: #2563eb; box-shadow: 0 0 0 2px #2563eb; }
.pa-page-card.drag-over { border-style: dashed; border-color: #2563eb; }
.pa-thumb {
    height: 150px; display: flex; align-items: center; justify-content: center;
    overflow: hidden; background: var(--as-bg); border-radius: 8px; pointer-events: none;
}
.pa-thumb canvas { max-width: 100%; max-height: 100%; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.pa-page-num {
    position: absolute; top: 14px; left: 14px;
    background: rgba(15,23,42,.62); color: #fff; font-size: 0.65rem; font-weight: 700;
    padding: 2px 7px; border-radius: 999px; pointer-events: none;
}
.pa-check {
    position: absolute; top: 12px; right: 12px; width: 20px; height: 20px; border-radius: 50%;
    background: #fff; border: 2px solid #cbd5e1; color: #fff; font-size: 0.6rem;
    display: flex; align-items: center; justify-content: center;
}
.pa-page-card.selected .pa-check { background: #2563eb; border-color: #2563eb; }
.pa-card-actions { display: flex; justify-content: center; gap: 5px; margin-top: 8px; }
.pa-mini {
    width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--as-border); background: #fff;
    color: var(--as-muted); font-size: 0.7rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all .13s;
}
.pa-mini:hover { color: #2563eb; border-color: #2563eb; }
.pa-mini.del:hover { color: #ef4444; border-color: #ef4444; }
.pa-add-card {
    border: 2px dashed #cbd5e1; border-radius: 12px; min-height: 200px; background: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    color: var(--as-muted); font-size: 0.8rem; font-weight: 700; cursor: pointer; font-family: inherit;
    transition: all .15s;
}
.pa-add-card:hover { border-color: #2563eb; color: #2563eb; background: var(--as-accent-soft); }
.pa-fab {
    position: fixed; right: 26px; bottom: 24px; z-index: 30;
    border-radius: 13px; padding: 15px 26px; font-size: 1rem;
    box-shadow: 0 8px 24px rgba(37,99,235,.35);
}

/* ---------- zoom / toast / drag overlay ---------- */
.pa-zoom {
    position: fixed; inset: 0; z-index: 1500; background: rgba(15,23,42,.78);
    display: none; align-items: center; justify-content: center; cursor: zoom-out;
}
.pa-zoom.show { display: flex; }
.pa-zoom canvas { max-width: 92vw; max-height: 92vh; border-radius: 8px; background: #fff; }
.pa-toast {
    position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(14px);
    background: var(--as-text); color: #fff; font-size: 0.875rem; padding: 10px 20px; border-radius: 10px;
    opacity: 0; pointer-events: none; transition: all .25s; z-index: 1600; max-width: 90vw;
}
.pa-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
body.pa-dragging::after {
    content: attr(data-dropmsg); position: fixed; inset: 0; z-index: 1400; pointer-events: none;
    background: rgba(37,99,235,.07); display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; font-weight: 800; color: #2563eb;
}

/* ---------- inputs ---------- */
.pa-input {
    width: 100%; padding: 10px 12px; margin: 4px 0 10px;
    border: 1.5px solid var(--as-border); border-radius: 9px;
    font-family: inherit; font-size: 0.9rem; color: var(--as-text);
}
.pa-input:focus { border-color: #2563eb; outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.13); }

/* ---------- crop editor ---------- */
.pa-crop-stage {
    position: relative; display: inline-block; max-width: 100%;
    overflow: hidden; border-radius: 8px;
    padding: 8px; /* room so edge handles stay grabbable */
    background: rgba(15, 23, 42, .06);
}
.pa-crop-stage img#pa-crop-img {
    max-width: 100%; max-height: 60vh; display: block;
    background: #fff; box-shadow: 0 12px 34px rgba(15,23,42,.13);
    user-select: none; -webkit-user-drag: none;
}
.pa-crop-box {
    position: absolute; border: 2px solid #2563eb;
    box-shadow: 0 0 0 9999px rgba(15,23,42,.45);
    cursor: move; touch-action: none;
}
.pa-h {
    position: absolute; width: 14px; height: 14px;
    background: #fff; border: 2px solid #2563eb; border-radius: 50%;
    touch-action: none;
}
.pa-h.tl { left: -8px; top: -8px; cursor: nwse-resize; }
.pa-h.br { right: -8px; bottom: -8px; cursor: nwse-resize; }
.pa-h.tr { right: -8px; top: -8px; cursor: nesw-resize; }
.pa-h.bl { left: -8px; bottom: -8px; cursor: nesw-resize; }
.pa-crop-thumbs { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.pa-crop-thumbs img {
    width: 52px; height: 52px; object-fit: cover; border-radius: 8px;
    cursor: pointer; border: 2px solid transparent;
}
.pa-crop-thumbs img.sel { border-color: #2563eb; }

/* ---------- sign editor ---------- */
.pa-sig-pad {
    width: 100%; height: auto; aspect-ratio: 560 / 260; background: #fff;
    border: 1.5px dashed #cbd5e1; border-radius: 12px;
    cursor: crosshair; touch-action: none; margin-bottom: 8px;
}
.pa-sig-box {
    position: absolute; border: 2px dashed #c026d3; border-radius: 4px;
    background: rgba(232,121,249,.10); cursor: move; touch-action: none;
}
.pa-sig-box .pa-h { border-color: #c026d3; }
.pa-page-pills { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.pa-pill {
    min-width: 34px; height: 34px; padding: 0 8px; border-radius: 9px;
    border: 1px solid var(--as-border); background: #fff; color: var(--as-muted);
    font-size: 0.8rem; font-weight: 700; cursor: pointer; font-family: inherit;
}
.pa-pill:hover { border-color: #2563eb; color: #2563eb; }
.pa-pill.sel { background: #2563eb; border-color: #2563eb; color: #fff; }

/* ---------- color theme ---------- */
.pa-theme-img {
    max-width: 100%; max-height: 46vh; border-radius: 12px;
    box-shadow: 0 12px 34px rgba(15,23,42,.13); background: #fff;
}
.pa-swatches { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; justify-content: center; }
.pa-swatch {
    width: 86px; height: 96px; border: none; border-radius: 12px; cursor: pointer;
    display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px;
    box-shadow: inset 0 -2px 6px rgba(0,0,0,.12), 0 2px 8px rgba(15,23,42,.10);
    transition: transform .15s;
    font-family: inherit;
}
.pa-swatch:hover { transform: translateY(-3px); }
.pa-swatch span {
    background: rgba(255,255,255,.92); color: var(--as-text);
    font-size: 0.68rem; font-weight: 700; border-radius: 6px; padding: 3px 7px;
}

/* SEO tips block shown under the app */
.pa-seo-extra { max-width: 880px; margin: 0 auto; padding: 0 24px 60px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
    .pa-panel { flex-direction: column; }
    /* options + primary CTA first on phones; preview below */
    .pa-rail { order: -1; width: 100%; border-left: none; border-bottom: 1px solid var(--as-border); box-shadow: none; }
    .pa-panel-main { min-height: auto; padding: 24px 16px; }
    .pa-upload-wrap { padding: 16px; }
    .pa-doc-cards { gap: 14px; }
    .pa-doc-card { width: 38vw; max-width: 190px; height: auto; aspect-ratio: 190 / 260; }
    .pa-toast { bottom: 88px; }
    .pa-fab { right: 16px; bottom: 16px; }
}
