/* ============================================================
   SIGN PDF – Styles  (matches mypdf.guru design system)
   ============================================================ */

body {
    background: linear-gradient(135deg, #0f1419 0%, #1a2332 50%, #0f1419 100%) !important;
}

/* ── Container ─────────────────────────────────────────────── */
.sign-pdf-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 40px;
    color: var(--text-primary);
}

/* ── Header ─────────────────────────────────────────────────── */
.header-section {
    text-align: center;
    margin-bottom: 36px;
}
.header-section h1 {
    font-size: 2.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 12px;
}
.header-section h1 i { color: #f79112; }
.subtitle { color: var(--text-secondary); font-size: 1.15rem; }

/* ── Upload Section ──────────────────────────────────────────── */
.upload-section {
    background: rgba(255,255,255,.05);
    border: 2px solid var(--primary-light);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 36px;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
}

.drop-zone-pdf {
    border: 3px dashed var(--primary-light);
    border-radius: 15px;
    padding: 40px 30px;
    text-align: center;
    cursor: pointer;
    transition: all .3s ease;
    background: rgba(255,255,255,.03);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
}
.drop-zone-pdf:hover {
    border-color: #f79112;
    background: rgba(247,145,18,.08);
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(247,145,18,.25);
}
.drop-zone-pdf.drag-over {
    border-color: #f79112;
    background: rgba(247,145,18,.14);
    transform: scale(1.01);
}
.upload-content { display: flex; flex-direction: column; align-items: center; }
.upload-icon { margin-bottom: 18px; }
.upload-icon i { font-size: 3.2rem; color: #f79112; animation: bounce 2.2s infinite; }
@keyframes bounce {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-10px); }
}
.drop-zone-pdf h3 { font-size: 1.45rem; margin-bottom: 8px; }
.drop-zone-pdf p  { color: var(--text-secondary); margin-bottom: 14px; }
.supported-formats small { color: #f79112; font-size: .9rem; }

/* progress bar inside drop zone */
.upload-progress-container { width: 100%; margin-top: 18px; }
.upload-progress-bar {
    width: 100%; height: 28px;
    background: rgba(255,255,255,.05);
    border: 2px solid var(--primary-light);
    border-radius: 14px; overflow: hidden;
}
.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #f79112);
    transition: width .3s ease;
    border-radius: 14px;
}
.upload-progress-text { margin-top: 8px; font-weight: 600; font-size: .95rem; text-align: center; }

/* ── Editor Section ──────────────────────────────────────────── */
.editor-section {
    display: flex;
    flex-direction: column;
    animation: fadeInUp .4s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Toolbar ─────────────────────────────────────────────────── */
.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,.06);
    border: 2px solid var(--primary-light);
    border-radius: 14px;
    padding: 12px 18px;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
    backdrop-filter: blur(8px);
}
.toolbar-left  { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.tb-filename { font-weight: 600; font-size: .95rem; display: flex; align-items: center; gap: 7px; }
.tb-filename i { color: #f79112; }
.tb-sig-count { color: var(--text-secondary); font-size: .85rem; }
.tb-label { display: inline; }

.toolbar-btn {
    background: rgba(255,255,255,.05);
    border: 2px solid var(--primary-light);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 7px 14px;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 600;
    transition: all .25s ease;
    display: flex; align-items: center; gap: 6px;
    font-family: inherit;
}
.toolbar-btn:hover { background: rgba(255,255,255,.1); border-color: #f79112; }
.tb-danger:hover { border-color: #f79112; color: #f79112; }

.btn-download-sign {
    background: var(--accent-color);
    color: white; border: none;
    padding: 10px 22px; border-radius: 50px;
    cursor: pointer; font-size: 1rem; font-weight: 600;
    transition: all .3s ease;
    display: flex; align-items: center; gap: 8px;
    box-shadow: 0 4px 14px rgba(74,144,226,.35);
    font-family: inherit;
}
.btn-download-sign:hover:not(:disabled) {
    background: #f79112;
    box-shadow: 0 6px 20px rgba(247,145,18,.55);
    transform: translateY(-2px);
}
.btn-download-sign:disabled { opacity: .45; cursor: not-allowed; }

/* ── Two-column Editor Layout ────────────────────────────────── */
.editor-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* ── Left Panel ──────────────────────────────────────────────── */
.sig-panel {
    width: 310px;
    flex-shrink: 0;
    background: rgba(255,255,255,.05);
    border: 2px solid var(--primary-light);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
}

.sig-panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
    color: var(--text-primary);
}
.sig-panel-title i { color: #f79112; }

/* Tabs */
.sig-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
    background: rgba(0,0,0,.2);
    border-radius: 10px;
    padding: 5px;
}
.sig-tab {
    flex: 1; padding: 8px 6px;
    background: transparent; border: none;
    border-radius: 8px; color: var(--text-secondary);
    cursor: pointer; font-size: .88rem; font-weight: 600;
    transition: all .25s ease;
    display: flex; align-items: center; justify-content: center; gap: 5px;
    font-family: inherit;
}
.sig-tab:hover { color: var(--text-primary); background: rgba(255,255,255,.07); }
.sig-tab.active {
    background: rgba(247,145,18,.18);
    color: #f79112;
    border: 1px solid rgba(247,145,18,.4);
}

/* Tab content */
.sig-tab-content { display: none; animation: fadeIn .25s ease; }
.sig-tab-content.active { display: block; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Section Labels */
.section-label {
    font-size: .82rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-muted);
    display: flex; align-items: center; gap: 6px;
    margin: 0 0 10px;
}
.section-label i { color: #f79112; font-size: .85rem; }

/* Ink style grid */
.ink-section { margin-bottom: 16px; }
.ink-style-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
}
.ink-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: rgba(255,255,255,.05);
    border: 2px solid var(--primary-light);
    border-radius: 8px;
    padding: 5px 2px 6px;
    cursor: pointer; transition: all .25s ease;
    color: var(--text-secondary); font-size: .68rem; font-weight: 600;
    font-family: inherit;
    overflow: hidden;
    min-width: 0;
}
.ink-btn:hover { border-color: #f79112; background: rgba(247,145,18,.1); }
.ink-btn.active {
    border-color: #f79112;
    background: rgba(247,145,18,.2);
    color: #f79112;
}
.ink-preview-canvas {
    border-radius: 4px;
    background: #ffffff;
    display: block;
    /* Fill the button width; JS sets buffer size, CSS scales display */
    width: 100%;
    height: 22px;
    max-width: 100%;
}

/* Color row */
.color-section { margin-bottom: 16px; }
.color-row {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.color-dot {
    width: 26px; height: 26px; border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer; transition: all .2s ease;
    padding: 0;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.active { border-color: #f79112; box-shadow: 0 0 0 2px rgba(247,145,18,.4); }
.color-dot-type { width: 26px; height: 26px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: all .2s ease; padding: 0; }
.color-dot-type:hover { transform: scale(1.15); }
.color-dot-type.active { border-color: #f79112; box-shadow: 0 0 0 2px rgba(247,145,18,.4); }
.color-picker-input {
    width: 30px; height: 26px; border-radius: 6px;
    border: 2px solid var(--primary-light);
    cursor: pointer; padding: 2px;
    background: rgba(255,255,255,.05);
}

/* Drawing canvas */
.draw-canvas-wrap {
    position: relative;
    margin-bottom: 10px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--primary-light);
    background: rgba(255,255,255,.96);
    cursor: crosshair;
}
#sig-draw-canvas {
    display: block;
    width: 100%;
    height: 140px;
    touch-action: none;
}
.draw-hint {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    color: rgba(0,0,0,.25); font-size: 1.1rem; font-weight: 500;
    pointer-events: none;
    transition: opacity .3s ease;
    user-select: none;
}
.draw-hint.hidden { opacity: 0; }

/* Type tab */
.type-input-wrap { margin-bottom: 14px; }
#sig-text-input {
    width: 100%; padding: 11px 14px;
    background: rgba(255,255,255,.06);
    border: 2px solid var(--primary-light);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem; font-family: inherit;
    transition: border-color .25s ease;
    outline: none;
}
#sig-text-input:focus {
    border-color: #f79112;
    background: rgba(255,255,255,.09);
    box-shadow: 0 0 0 3px rgba(247,145,18,.15);
}
#sig-text-input::placeholder { color: var(--text-muted); }

.font-section { margin-bottom: 14px; }
.font-options { display: flex; flex-direction: column; gap: 6px; }
.font-btn {
    background: rgba(255,255,255,.92);
    border: 2px solid rgba(255,255,255,.3);
    border-radius: 8px;
    padding: 7px 14px;
    cursor: pointer; transition: all .25s ease;
    text-align: left; font-family: inherit;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.font-btn:hover {
    border-color: #f79112;
    background: #ffffff;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(247,145,18,.25);
}
.font-btn.active {
    border-color: #f79112;
    background: #fff8f0;
    box-shadow: 0 2px 10px rgba(247,145,18,.3), inset 0 0 0 1px rgba(247,145,18,.4);
}
/* Dark cursive text on the now-white button background */
.font-sample { font-size: 1.3rem; color: #1a1a2e; line-height: 1; }

.type-preview-wrap {
    position: relative;
    border: 2px solid var(--primary-light);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255,255,255,.96);
    margin-bottom: 10px;
    min-height: 70px;
    display: flex; align-items: center; justify-content: center;
}
#sig-type-canvas { display: block; width: 100%; }
.type-preview-hint {
    position: absolute;
    color: rgba(0,0,0,.25); font-size: .9rem;
    pointer-events: none;
}

/* Image tab */
.image-upload-zone {
    border: 2px dashed var(--primary-light);
    border-radius: 10px;
    padding: 30px 16px;
    text-align: center;
    cursor: pointer;
    transition: all .3s ease;
    background: rgba(255,255,255,.03);
    margin-bottom: 12px;
}
.image-upload-zone i { font-size: 2.2rem; color: #f79112; display: block; margin-bottom: 10px; }
.image-upload-zone p { color: var(--text-secondary); font-size: .9rem; margin-bottom: 4px; }
.image-upload-zone small { color: var(--text-muted); font-size: .78rem; }
.image-upload-zone:hover { border-color: #f79112; background: rgba(247,145,18,.08); }

#sig-image-preview-wrap {
    text-align: center;
    padding: 12px;
    background: rgba(255,255,255,.96);
    border-radius: 10px;
    margin-bottom: 10px;
}
#sig-image-preview {
    max-width: 100%; max-height: 120px;
    object-fit: contain; border-radius: 6px;
    display: block; margin: 0 auto 8px;
}
/* Remove button sits on white preview background — needs dark text */
#remove-sig-image-btn {
    color: #1a1a2e;
    border-color: #c0c0c0;
    background: transparent;
    font-weight: 600;
}
#remove-sig-image-btn:hover {
    background: #f79112;
    color: #ffffff;
    border-color: #f79112;
}

/* Buttons */
.btn-sm {
    padding: 7px 14px; font-size: .88rem;
    border-radius: 8px;
    font-family: inherit;
}
.btn-secondary {
    background: transparent; color: var(--text-primary);
    border: 2px solid var(--primary-light);
    cursor: pointer; font-weight: 600;
    transition: all .25s ease;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn-secondary:hover { background: var(--primary-light); border-color: #f79112; }

/* Place Button */
.place-sig-section {
    margin-top: 18px; padding-top: 16px;
    border-top: 2px solid var(--primary-light);
}
.placement-info {
    background: rgba(247,145,18,.12);
    border: 1px solid rgba(247,145,18,.35);
    border-radius: 8px; padding: 9px 12px;
    color: #f79112; font-size: .85rem; font-weight: 600;
    display: flex; align-items: center; gap: 7px;
    margin-bottom: 10px;
    animation: pulse-border 1.8s infinite;
}
@keyframes pulse-border {
    0%,100% { box-shadow: 0 0 0 0 rgba(247,145,18,.3); }
    50%      { box-shadow: 0 0 0 5px rgba(247,145,18,0); }
}
.btn-place-sig {
    width: 100%; padding: 13px 16px;
    background: linear-gradient(135deg, #f79112, #ff6b35);
    color: white; border: none; border-radius: 10px;
    cursor: pointer; font-size: 1rem; font-weight: 700;
    transition: all .3s ease;
    display: flex; align-items: center; justify-content: center; gap: 9px;
    box-shadow: 0 4px 14px rgba(247,145,18,.35);
    font-family: inherit;
}
.btn-place-sig:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(247,145,18,.5);
}
.btn-place-sig:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-place-sig.active-placement {
    background: linear-gradient(135deg, #4a90e2, #357abd);
    box-shadow: 0 4px 14px rgba(74,144,226,.35);
}
.btn-cancel-place {
    width: 100%; margin-top: 8px; padding: 9px 16px;
    background: transparent; color: var(--text-secondary);
    border: 2px solid var(--primary-light);
    border-radius: 10px; cursor: pointer; font-size: .9rem; font-weight: 600;
    transition: all .25s ease;
    display: flex; align-items: center; justify-content: center; gap: 7px;
    font-family: inherit;
}
.btn-cancel-place:hover { border-color: #f79112; color: #f79112; }

/* Placed signatures list */
.placed-list-panel {
    margin-top: 20px; padding-top: 16px;
    border-top: 2px solid var(--primary-light);
}
.placed-list-title {
    font-size: .95rem; font-weight: 700;
    display: flex; align-items: center; gap: 7px;
    margin-bottom: 12px; color: var(--text-primary);
}
.placed-list-title i { color: #f79112; }
.placed-count-badge {
    background: #f79112; color: white;
    border-radius: 50%; width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; margin-left: auto;
}
.placed-sigs-list { display: flex; flex-direction: column; gap: 8px; }
.placed-sig-item {
    background: rgba(255,255,255,.04);
    border: 2px solid var(--primary-light);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; transition: all .25s ease;
}
.placed-sig-item:hover { border-color: #f79112; background: rgba(247,145,18,.07); }
.placed-sig-item.active-item { border-color: #f79112; background: rgba(247,145,18,.12); }
.placed-sig-thumb {
    width: 50px; height: 28px; object-fit: contain;
    background: white; border-radius: 4px; flex-shrink: 0;
}
.placed-sig-meta { flex: 1; min-width: 0; }
.placed-sig-page { font-size: .8rem; color: #f79112; font-weight: 700; }
.placed-sig-info { font-size: .75rem; color: var(--text-muted); }
.placed-sig-actions {
    display: flex; align-items: center; gap: 5px; flex-shrink: 0;
}
.placed-sig-del {
    width: 24px; height: 24px; border-radius: 50%;
    background: rgba(247,145,18,.12); border: 1px solid rgba(247,145,18,.35);
    color: #f79112; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; transition: all .2s ease; flex-shrink: 0;
    padding: 0;
}
.placed-sig-del:hover { background: #f79112; color: white; }
.placed-sig-dup {
    width: 24px; height: 24px; border-radius: 50%;
    background: rgba(74,144,226,.15); border: 1px solid rgba(74,144,226,.3);
    color: #4a90e2; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: .72rem; transition: all .2s ease; flex-shrink: 0;
    padding: 0;
}
.placed-sig-dup:hover { background: #f79112; border-color: #f79112; color: white; }

/* ── Right Panel: PDF Viewer ─────────────────────────────────── */
.pdf-viewer-panel {
    flex: 1;
    min-width: 0;
}

.pdf-canvas-wrap {
    position: relative;
    border-radius: 12px;
    /* overflow: visible so resize handles & delete buttons aren't clipped */
    overflow: visible;
    border: 2px solid var(--primary-light);
    background: #525659;
    display: inline-block;
    width: 100%;
    box-shadow: var(--shadow-lg);
}
.pdf-canvas-wrap.placement-mode {
    cursor: crosshair;
    border-color: #f79112;
    box-shadow: 0 0 0 3px rgba(247,145,18,.3);
}

#pdf-render-canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 10px;
    /* Promote canvas to its own GPU compositing layer */
    transform: translateZ(0);
    will-change: auto;
}

/* Signature overlay layer */
.sig-overlay-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

/* Individual signature overlay */
.sig-overlay-item {
    position: absolute;
    cursor: move;
    pointer-events: all;
    user-select: none;
    box-sizing: border-box;
    touch-action: none;
    /* Isolate repaints to this element only */
    contain: layout style;
}
.sig-overlay-item .sig-overlay-img {
    width: 100%; height: 100%;
    object-fit: contain;
    pointer-events: none;
    display: block;
}
.sig-overlay-item .sig-border {
    position: absolute; inset: 0;
    border: 2px dashed transparent;
    border-radius: 3px;
    transition: border-color .2s ease;
    pointer-events: none;
}
.sig-overlay-item:hover .sig-border,
.sig-overlay-item.selected .sig-border {
    border-color: #f79112;
}

/* Delete button on overlay */
.sig-overlay-del {
    position: absolute; top: -12px; right: -12px;
    width: 26px; height: 26px; border-radius: 50%;
    background: #f79112; color: white;
    border: 2.5px solid #ffffff;
    display: none; align-items: center; justify-content: center;
    font-size: .8rem; cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,.45), 0 0 0 1px rgba(247,145,18,.5);
    z-index: 100; padding: 0;
    transition: all .18s ease;
    pointer-events: all;
    line-height: 1;
}
.sig-overlay-del:hover {
    transform: scale(1.2);
    background: #e08000;
    box-shadow: 0 4px 14px rgba(224,128,0,.6);
}
.sig-overlay-item:hover .sig-overlay-del,
.sig-overlay-item.selected .sig-overlay-del { display: flex; }

/* Duplicate button on overlay (top-left) */
.sig-overlay-dup {
    position: absolute; top: -12px; left: -12px;
    width: 26px; height: 26px; border-radius: 50%;
    background: #4a90e2; color: white;
    border: 2.5px solid #ffffff;
    display: none; align-items: center; justify-content: center;
    font-size: .72rem; cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,.45), 0 0 0 1px rgba(74,144,226,.5);
    z-index: 100; padding: 0;
    transition: all .18s ease;
    pointer-events: all;
    line-height: 1;
}
.sig-overlay-dup:hover {
    transform: scale(1.2);
    background: #f79112;
    box-shadow: 0 4px 14px rgba(247,145,18,.55);
}
.sig-overlay-item:hover .sig-overlay-dup,
.sig-overlay-item.selected .sig-overlay-dup { display: flex; }
/* Also show dup during resize/drag */
.sig-overlay-item.resizing .sig-overlay-dup,
.sig-overlay-item.dragging .sig-overlay-dup { display: flex; }

/* Apply to all pages badge */
.sig-overlay-allpages {
    position: absolute; bottom: -10px; left: 50%;
    transform: translateX(-50%);
    background: #f79112; color: white;
    border-radius: 4px; padding: 1px 6px;
    font-size: .65rem; font-weight: 700; white-space: nowrap;
    display: none; pointer-events: none;
    z-index: 10;
}
.sig-overlay-item.apply-all .sig-overlay-allpages { display: block; }

/* Resize handles */
.sig-resize-handle {
    position: absolute;
    width: 14px; height: 14px;
    background: #ffffff; border: 2.5px solid #f79112;
    border-radius: 3px; z-index: 50;
    display: none;
    transition: background .15s ease, transform .15s ease;
    pointer-events: all;
    touch-action: none;
    box-shadow: 0 1px 5px rgba(0,0,0,.35);
}
.sig-resize-handle:hover { transform: scale(1.35); background: #f79112; }
/* Show handles on hover, when selected, when dragging, or when resizing */
.sig-overlay-item:hover .sig-resize-handle,
.sig-overlay-item.selected .sig-resize-handle,
.sig-overlay-item.resizing .sig-resize-handle,
.sig-overlay-item.dragging .sig-resize-handle { display: block; }
/* Also keep delete button visible during these states */
.sig-overlay-item.resizing .sig-overlay-del,
.sig-overlay-item.dragging .sig-overlay-del { display: flex; }
/* Keep dashed border visible during resize/drag */
.sig-overlay-item.resizing .sig-border,
.sig-overlay-item.dragging .sig-border { border-color: #f79112; }
.sig-resize-handle.nw { top: -7px;    left: -7px;   cursor: nw-resize; }
.sig-resize-handle.ne { top: -7px;    right: -7px;  cursor: ne-resize; }
.sig-resize-handle.sw { bottom: -7px; left: -7px;   cursor: sw-resize; }
.sig-resize-handle.se { bottom: -7px; right: -7px;  cursor: se-resize; }

/* All-pages toggle */
.sig-overlay-toggle {
    position: absolute; bottom: -28px; left: 50%;
    transform: translateX(-50%);
    background: rgba(26,35,58,.92);
    border: 1px solid var(--primary-light);
    border-radius: 6px; padding: 3px 9px;
    display: none; align-items: center; gap: 5px;
    font-size: .7rem; color: var(--text-secondary);
    white-space: nowrap; z-index: 20;
    cursor: pointer; pointer-events: all;
    transition: all .2s ease;
}
.sig-overlay-toggle:hover { border-color: #f79112; color: #f79112; }
.sig-overlay-item:hover .sig-overlay-toggle,
.sig-overlay-item.selected .sig-overlay-toggle { display: flex; }
.sig-overlay-toggle input[type="checkbox"] { accent-color: #f79112; cursor: pointer; }

/* Placement cursor preview */
.placement-cursor {
    position: absolute;
    pointer-events: none;
    z-index: 100;
    transform: translate(-50%, -50%);
    opacity: .75;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,.4));
}
.placement-cursor img {
    max-width: 160px; max-height: 70px;
    object-fit: contain;
    display: block;
}

/* Page navigation bar */
.page-nav-bar {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    padding: 14px 0 4px;
}
.page-nav-btn {
    background: rgba(255,255,255,.06);
    border: 2px solid var(--primary-light);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 8px 18px; font-size: .9rem; font-weight: 600;
    cursor: pointer; transition: all .25s ease;
    display: flex; align-items: center; gap: 7px;
    font-family: inherit;
}
.page-nav-btn:hover:not(:disabled) { background: rgba(255,255,255,.12); border-color: #f79112; }
.page-nav-btn:disabled { opacity: .35; cursor: not-allowed; }
.page-nav-text { font-size: .95rem; font-weight: 500; display: flex; align-items: center; gap: 5px; }

/* Editable page-number input — looks like inline text until focused */
.page-num-input {
    width: 2.8em;
    padding: 2px 4px;
    text-align: center;
    font-size: .95rem; font-weight: 700;
    color: #f79112;
    background: transparent;
    border: none;
    border-bottom: 2px solid rgba(247,145,18,.4);
    border-radius: 0;
    outline: none;
    font-family: inherit;
    cursor: text;
    transition: border-color .2s ease, background .2s ease;
    /* hide browser spinner arrows */
    -moz-appearance: textfield;
}
.page-num-input::-webkit-outer-spin-button,
.page-num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.page-num-input:focus {
    background: rgba(247,145,18,.1);
    border-bottom-color: #f79112;
    border-radius: 4px 4px 0 0;
}

/* ── Progress Bar ────────────────────────────────────────────── */
.progress-container { margin-top: 24px; animation: fadeIn .3s ease; }
.progress-bar {
    width: 100%; height: 28px;
    background: rgba(255,255,255,.05);
    border: 2px solid var(--primary-light);
    border-radius: 14px; overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #f79112);
    transition: width .3s ease;
    border-radius: 14px;
}
.progress-text { margin-top: 8px; font-weight: 600; font-size: .95rem; text-align: center; }

/* ── Modal ───────────────────────────────────────────────────── */
.pdf-modal-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,.65);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.pdf-modal {
    background: var(--primary-dark);
    border: 2px solid var(--primary-light);
    border-radius: 16px; padding: 0;
    max-width: 440px; width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    animation: modalIn .2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.9); }
    to   { opacity: 1; transform: scale(1); }
}
.pdf-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 2px solid var(--primary-light);
}
.pdf-modal-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.pdf-modal-close {
    background: none; border: none; color: var(--text-secondary);
    cursor: pointer; font-size: 1.1rem; padding: 4px;
    transition: color .2s ease;
}
.pdf-modal-close:hover { color: #f79112; }
.pdf-modal-message { padding: 20px; color: var(--text-secondary); line-height: 1.6; }
.pdf-modal-actions { padding: 14px 20px 18px; text-align: right; }
.pdf-modal-actions .btn-primary {
    background: var(--accent-color); color: white;
    border: none; border-radius: 8px;
    padding: 10px 24px; cursor: pointer; font-size: 1rem; font-weight: 600;
    transition: all .25s ease; font-family: inherit;
}
.pdf-modal-actions .btn-primary:hover { background: #f79112; }

/* ── Blog / Complete guide ───────────────────────────────────── */
.sign-pdf-guide {
    background: rgba(255,255,255,.05);
    border: 2px solid var(--primary-light);
    border-radius: 20px; padding: 40px;
    box-shadow: var(--shadow-md); margin: 36px 0;
    backdrop-filter: blur(10px);
    content-visibility: auto;
    contain-intrinsic-size: 0 800px;
    /* Same width as instructions-section and faq-section (container width) */
}
.sign-pdf-guide h2 {
    font-size: 1.85rem; font-weight: 800; margin-bottom: 28px;
    text-align: center;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    flex-wrap: wrap;
}
.sign-pdf-guide h2 i { color: #f79112; }
.sign-pdf-guide .guide-block {
    margin-bottom: 28px;
}
.sign-pdf-guide .guide-block:last-of-type { margin-bottom: 0; }
.sign-pdf-guide h3 {
    font-size: 1.25rem; font-weight: 700; margin-bottom: 12px;
    color: #f79112;
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
}
.sign-pdf-guide h3 i {
    font-size: 1.1em;
    opacity: .95;
}
.sign-pdf-guide h4 {
    font-size: 1.05rem; font-weight: 600; margin: 18px 0 8px;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
}
.sign-pdf-guide h4 i {
    color: #f79112;
    font-size: .95em;
    opacity: .9;
    width: 1.2em;
    text-align: center;
}
.sign-pdf-guide p {
    color: var(--text-secondary); line-height: 1.75; margin: 0 0 12px;
    font-size: 1rem;
}
.sign-pdf-guide .guide-block > p:last-child { margin-bottom: 0; }

/* ── How-to / FAQ (reuse watermark styles) ───────────────────── */
.instructions-section {
    background: rgba(255,255,255,.05);
    border: 2px solid var(--primary-light);
    border-radius: 20px; padding: 40px;
    box-shadow: var(--shadow-md); margin: 36px 0;
    backdrop-filter: blur(10px);
    /* Skip rendering until scrolled into view — saves GPU/CPU on load */
    content-visibility: auto;
    contain-intrinsic-size: 0 400px;
}
.instructions-section h2 {
    font-size: 2rem; font-weight: 800; margin-bottom: 30px;
    text-align: center;
    display: flex; align-items: center; justify-content: center; gap: 14px;
}
.instructions-section h2 i { color: #f79112; }
.steps-container {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px;
}
.step-item {
    display: flex; flex-direction: column; align-items: center;
    text-align: center; gap: 16px; padding: 20px;
    background: rgba(255,255,255,.03); border: 2px solid var(--primary-light);
    border-radius: 12px; transition: all .3s ease;
}
.step-item:hover { transform: translateY(-4px); box-shadow: 0 10px 25px rgba(247,145,18,.25); border-color: #f79112; }
.step-number {
    width: 48px; height: 48px;
    background: linear-gradient(135deg,#f79112,#ff6b35);
    color: white; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; font-weight: 700;
    box-shadow: 0 4px 14px rgba(247,145,18,.4);
}
.step-content h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.step-content p  { color: var(--text-secondary); margin: 0; line-height: 1.6; font-size: .95rem; }

.faq-section {
    background: rgba(255,255,255,.05);
    border: 2px solid var(--primary-light);
    border-radius: 20px; padding: 40px;
    box-shadow: var(--shadow-md); margin-bottom: 40px;
    backdrop-filter: blur(10px);
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}
.faq-section h2 {
    font-size: 2rem; font-weight: 800; margin-bottom: 28px;
    text-align: center;
    display: flex; align-items: center; justify-content: center; gap: 14px;
}
.faq-section h2 i { color: #f79112; }
.faq-container { max-width: 860px; margin: 0 auto; }
.faq-item-pdf {
    margin-bottom: 12px;
    border: 2px solid var(--primary-light); border-radius: 8px;
    overflow: hidden; background: rgba(255,255,255,.03); transition: all .3s ease;
}
.faq-item-pdf:hover { border-color: #f79112; }
.faq-question-pdf {
    padding: 14px 14px 14px 40px;
    background: rgba(255,255,255,.05); cursor: pointer;
    font-weight: 600; color: var(--text-primary);
    position: relative; font-size: 1.05rem; transition: all .3s ease;
}
.faq-question-pdf::before {
    content: '+'; position: absolute; left: 14px; top: 50%;
    transform: translateY(-50%); font-size: 1.4rem;
    color: #f79112; transition: transform .3s ease;
}
.faq-item-pdf.active .faq-question-pdf { background: rgba(247,145,18,.18); border-bottom: 2px solid #f79112; }
.faq-item-pdf.active .faq-question-pdf::before { content: '-'; transform: translateY(-50%) rotate(180deg); }
.faq-answer-pdf { max-height: 0; overflow: hidden; transition: all .45s ease; padding: 0 14px; background: rgba(255,255,255,.03); }
.faq-item-pdf.active .faq-answer-pdf { max-height: 300px; padding: 14px; }
.faq-answer-pdf p { margin: 0; line-height: 1.65; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

/* ── 1024px: wide tablet ── */
@media (max-width: 1024px) {
    .sig-panel { width: 280px; }
}

/* ── 900px: stack editor to single column ── */
@media (max-width: 900px) {
    .editor-layout { flex-direction: column; }
    .sig-panel { width: 100%; max-width: 640px; margin: 0 auto; flex-shrink: unset; }
    .pdf-viewer-panel { width: 100%; }
    /* Font options: 2-column grid so all 5 fonts fit compactly */
    .font-options { display: grid; grid-template-columns: repeat(2, 1fr); }
    .sig-tabs .sig-tab { font-size: .84rem; }
    .ink-style-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* ── 768px: tablet portrait ── */
@media (max-width: 768px) {
    .header-section h1 { font-size: 1.9rem; flex-direction: column; gap: 8px; }
    .subtitle { font-size: 1rem; }

    /* On mobile: 1) PDF preview  2) Signature settings  3) Toolbar */
    .editor-layout      { order: 1; }
    .editor-toolbar     { order: 2; }
    .progress-container { order: 3; }

    /* Within the editor-layout, show PDF viewer before sig panel */
    .editor-layout { display: flex; flex-direction: column; }
    .pdf-viewer-panel { order: 1; }
    .sig-panel        { order: 2; }

    /* Gap between sig-panel and the toolbar below it */
    .editor-toolbar { margin-top: 16px; }

    /* Toolbar stacks vertically */
    .editor-toolbar { flex-direction: column; gap: 8px; align-items: stretch; padding: 10px 14px; }
    .toolbar-left { justify-content: flex-start; min-width: 0; overflow: hidden; }
    .toolbar-right { justify-content: stretch; gap: 8px; }
    /* Trash button: small circle, icon only */
    .toolbar-right .toolbar-btn {
        flex: 0 0 40px; width: 40px; height: 40px;
        padding: 0; border-radius: 50%; justify-content: center;
    }
    .toolbar-right .toolbar-btn .tb-label { display: none; }
    /* Download button fills the rest */
    .toolbar-right .btn-download-sign { flex: 1; justify-content: center; }
    /* Truncate long filenames */
    #toolbar-filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; display: inline-block; }
    .tb-label { display: none; }

    .steps-container { grid-template-columns: 1fr; }
    .instructions-section, .faq-section, .sign-pdf-guide { padding: 26px 18px; }
    .instructions-section h2, .faq-section h2, .sign-pdf-guide h2 { font-size: 1.5rem; }
    .sign-pdf-guide h3 { font-size: 1.15rem; }
    .sign-pdf-guide h4 { font-size: 1rem; }
}

/* ── 600px: large phones / small tablets ── */
@media (max-width: 600px) {
    .sign-pdf-container { padding: 16px 14px 32px; }
    .header-section h1 { font-size: 1.75rem; }

    .upload-section { padding: 20px 16px; }
    .drop-zone-pdf { padding: 36px 20px; }

    .sig-panel { padding: 16px; max-width: 100%; }
    .ink-btn span { font-size: .63rem; }

    /* Taller draw canvas for comfortable finger signing */
    #sig-draw-canvas { height: 165px; }

    .page-nav-bar { padding: 10px 12px; gap: 8px; }
    .page-nav-btn { padding: 7px 14px; font-size: .85rem; }
    .page-nav-text { font-size: .85rem; }
}

/* ── 480px: phones ── */
@media (max-width: 480px) {
    .sign-pdf-container { padding: 12px 10px 28px; }
    .header-section h1 { font-size: 1.55rem; gap: 6px; }
    .subtitle { font-size: .9rem; }

    /* Upload */
    .upload-section { padding: 14px 12px; backdrop-filter: none; }
    .drop-zone-pdf { padding: 30px 14px; }
    .drop-zone-pdf h3 { font-size: 1.2rem; }
    .upload-icon i { font-size: 2.4rem; }

    /* Toolbar */
    .editor-toolbar { padding: 10px 12px; }
    .tb-sig-count { display: none; }
    #toolbar-filename { max-width: 160px; }

    /* Sig panel */
    .sig-panel { padding: 12px; border-radius: 12px; backdrop-filter: none; max-width: 100%; }
    .sig-panel-title { font-size: 1rem; margin-bottom: 12px; }

    /* Tabs */
    .sig-tab { padding: 8px 4px; font-size: .78rem; gap: 3px; }

    /* Ink style */
    .ink-style-grid { gap: 3px; }
    .ink-btn { padding: 4px 1px 5px; }
    .ink-btn span { font-size: .6rem; }
    .ink-preview-canvas { height: 18px; }

    /* Color dots */
    .color-dot, .color-dot-type { width: 22px; height: 22px; }

    /* Draw canvas */
    #sig-draw-canvas { height: 155px; }

    /* Font options: single column on small phones */
    .font-options { grid-template-columns: 1fr; gap: 5px; }
    .font-sample { font-size: 1.15rem; }

    /* Type input */
    #sig-text-input { padding: 9px 12px; font-size: .95rem; }

    /* Image zone */
    .image-upload-zone { padding: 22px 12px; }
    .image-upload-zone i { font-size: 1.8rem; }

    /* Place / cancel buttons */
    .btn-place-sig { padding: 11px 14px; font-size: .95rem; }

    /* Placed sigs */
    .placed-sig-thumb { width: 40px; height: 22px; }
    .placed-sig-info { display: none; }

    /* Page nav */
    .page-nav-bar { padding: 8px 10px; }
    .page-nav-btn { padding: 6px 12px; font-size: .82rem; }

    /* Download button */
    .btn-download-sign { font-size: .9rem; padding: 9px 16px; }

    /* Instructions & FAQ */
    .instructions-section, .faq-section, .sign-pdf-guide { padding: 20px 14px; backdrop-filter: none; }
    .instructions-section h2, .faq-section h2, .sign-pdf-guide h2 { font-size: 1.35rem; }
    .sign-pdf-guide h3 { font-size: 1.1rem; }
    .sign-pdf-guide h4 { font-size: .95rem; }
    .steps-container { gap: 14px; }
    .step-item { padding: 14px; }
    .faq-section h2 { font-size: 1.35rem; }
}

/* ── 360px: very small phones ── */
@media (max-width: 360px) {
    .header-section h1 { font-size: 1.3rem; }
    .sig-tab i { display: none; }
    .sig-tab { font-size: .74rem; }
    .ink-btn span { display: none; }
    .ink-style-grid { gap: 2px; }
    .page-nav-btn { padding: 5px 10px; font-size: .8rem; }
    .btn-place-sig { font-size: .88rem; }
    #toolbar-filename { max-width: 120px; }
}

/* ═══════════════════════════════════════════════════════════════
   PERFORMANCE — mobile & low-end GPU hints
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Disable expensive hover box-shadows on touch devices */
    .sig-panel:hover,
    .upload-section:hover { box-shadow: var(--shadow-md); }

    /* Kill expensive transition on cards — repaints are slow on mobile */
    .faq-item-pdf,
    .step-item,
    .placed-sig-item { transition: none; }

    /* Disable transform hover lifts — causes layer promotion churn */
    .btn-place-sig:hover:not(:disabled),
    .btn-download-sign:hover:not(:disabled) {
        transform: none;
        box-shadow: none;
    }

    /* PDF canvas: GPU compositing layer for smooth scroll */
    #pdf-render-canvas {
        transform: translateZ(0);
        will-change: auto;
    }

    /* Placement cursor: own layer so it never triggers page repaint */
    .placement-cursor {
        transform: translateZ(0);
        will-change: transform;
    }
}

@media (max-width: 480px) {
    /* Remove backdrop-filter on everything — extremely expensive on low-end */
    .editor-toolbar,
    .pdf-canvas-wrap { backdrop-filter: none; -webkit-backdrop-filter: none; }

    /* Disable all non-critical animations on tiny screens */
    .editor-section,
    .sig-tab-content { animation: none; }
}
