/* ==========================================================================
   eSign: open a document, place a signature, download it.
   Left: the tools. Right: the pages, each with a layer the placed items sit on.
   ========================================================================== */

.es-page { display:grid; gap:16px; min-width:0; }
.es-head { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:flex-end; gap:12px; }
.es-head h2 { margin:0 0 4px; font-size:24px; color: var(--text-primary); }
.es-head p { margin:0; color: var(--text-secondary); font-size:13.5px; max-width:720px; }
.es-head-actions { display:flex; gap:8px; flex-wrap:wrap; }
.es-loading { padding:40px; text-align:center; color: var(--text-secondary); }

.es-drop { display:grid; justify-items:center; gap:8px; padding:56px 20px; text-align:center; cursor:pointer;
    border:2px dashed var(--border-strong, #cbd5e1); border-radius:20px; background: var(--bg-raised); color: var(--text-secondary);
    transition: border-color .15s, background .15s; }
.es-drop:hover, .es-drop:focus-visible, .es-drop.is-over { border-color: var(--accent); background: var(--accent-soft, rgba(13,110,100,.06)); outline:none; }
.es-drop strong { font-size:17px; color: var(--text-primary); }
.es-drop-icon { font-size:42px; }
.es-drop-steps { margin-top:8px; font-size:13px; }
.es-drop-steps b { display:inline-grid; place-items:center; width:22px; height:22px; border-radius:50%; background: var(--accent); color:#fff; font-size:12px; }
.es-privacy { margin:0; font-size:12.5px; color: var(--text-secondary); text-align:center; }

.es-work { display:grid; grid-template-columns:260px minmax(0, 1fr); gap:16px; align-items:start; }
/* Stays in view below the app's top bar while the pages scroll. */
.es-tools { position:sticky; top:calc(var(--header-height, 60px) + 12px); display:grid; gap:14px; padding:16px; border:1px solid var(--border); border-radius:16px; background: var(--bg-raised);
    max-height:calc(100vh - var(--header-height, 60px) - 24px); overflow:auto; }
.es-doc-name { font-weight:700; font-size:13.5px; color: var(--text-primary); overflow-wrap:anywhere; display:grid; gap:2px; }
.es-doc-name small { font-weight:400; color: var(--text-secondary); font-size:12px; }
.es-field { display:grid; gap:5px; font-size:12.5px; font-weight:700; color: var(--text-secondary); }
.es-field input, .es-field select { padding:8px 10px; border-radius:10px; border:1px solid var(--border); background: var(--bg-sunken); color: var(--text-primary); font:inherit; font-size:13.5px; font-weight:400; }
.es-sig-slot { display:grid; gap:6px; font-size:12.5px; font-weight:700; color: var(--text-secondary); }
.es-sig-preview { height:70px; border:1px dashed var(--border); border-radius:12px; display:grid; place-items:center; background:#fff; padding:6px; }
.es-sig-preview img { max-width:100%; max-height:58px; }
.es-sig-preview em { color:#94a3b8; font-weight:400; font-size:12.5px; }
.es-sm { padding:6px 12px; font-size:12.5px; }
.es-label { font-size:12px; color: var(--text-secondary); font-weight:700; grid-column:1 / -1; }
.es-place { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.es-place button { display:flex; align-items:center; gap:8px; padding:9px 10px; border-radius:10px; border:1px solid var(--border); background: var(--bg-sunken);
    color: var(--text-primary); font:inherit; font-size:13px; font-weight:600; cursor:pointer; text-align:left; }
.es-place button b { width:22px; text-align:center; font-size:12px; }
.es-place button:hover { border-color: var(--accent); }
.es-place button.active { border-color: var(--accent); background: var(--accent); color:#fff; }
.es-inks { display:flex; align-items:center; gap:8px; font-size:12.5px; font-weight:700; color: var(--text-secondary); }
.es-inks button { width:22px; height:22px; border-radius:50%; background: var(--ink); border:2px solid transparent; cursor:pointer; box-shadow: 0 0 0 1px var(--border); }
.es-inks button.active { border-color:#fff; box-shadow: 0 0 0 2px var(--ink); }
.es-check { display:flex; gap:8px; align-items:flex-start; font-size:12.5px; color: var(--text-secondary); }
.es-hint { margin:0; font-size:12.5px; color: var(--text-secondary); line-height:1.5; }
.es-hint.is-active { color: var(--text-primary); background: var(--warning-soft, #fef3c7); border-radius:10px; padding:8px 10px; font-weight:600; }
.es-link { border:none; background:none; color: var(--accent); font:inherit; font-weight:700; cursor:pointer; padding:0; }

.es-pages { display:grid; gap:18px; justify-items:center; padding:12px; border-radius:16px; background: var(--bg-sunken); min-height:300px; overflow:auto; }
.es-sheet-wrap { display:grid; gap:6px; justify-items:center; }
.es-sheet { position:relative; background:#fff; box-shadow: 0 4px 18px rgba(15,23,42,.18); }
.es-sheet canvas { position:absolute; inset:0; width:100%; height:100%; }
.es-layer { position:absolute; inset:0; }
.es-pages.is-placing .es-layer { cursor:crosshair; }
.es-pages.is-placing .es-sheet { outline:2px dashed var(--accent); outline-offset:3px; }
.es-pageno { font-size:12px; color: var(--text-secondary); }

.es-item { position:absolute; cursor:move; touch-action:none; border:1px dashed transparent; border-radius:3px; }
.es-item:hover, .es-item.is-selected { border-color: var(--accent); background: rgba(13,110,100,.05); }
.es-item img { width:100%; height:100%; display:block; pointer-events:none; user-select:none; }
/* Same font, size and inset as the text written into the PDF, so what is seen is what is signed. */
.es-text { display:block; height:100%; padding:0 .2em; line-height:1.3; white-space:nowrap; font-family: Helvetica, Arial, sans-serif; outline:none; cursor:text; }
.es-note { position:absolute; left:0; top:100%; white-space:nowrap; color:#595966; font-family: Helvetica, Arial, sans-serif; pointer-events:none; }
.es-del { position:absolute; top:-11px; right:-11px; width:22px; height:22px; border-radius:50%; border:none; background:#dc2626; color:#fff; font-size:15px; line-height:1;
    cursor:pointer; display:none; }
.es-grip { position:absolute; right:-6px; bottom:-6px; width:12px; height:12px; border-radius:3px; background: var(--accent); cursor:nwse-resize; display:none; }
.es-item:hover .es-del, .es-item.is-selected .es-del, .es-item:hover .es-grip, .es-item.is-selected .es-grip { display:block; }

.es-modal { position:fixed; inset:0; z-index:2000; background: rgba(15,23,42,.55); display:grid; place-items:center; padding:16px; }
.es-dialog { width:min(620px, 100%); max-height:92vh; overflow:auto; background: var(--bg-raised); border-radius:18px; padding:18px; display:grid; gap:14px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.es-dialog header { display:flex; justify-content:space-between; align-items:center; }
.es-dialog h3 { margin:0; }
.es-close { border:none; background:none; font-size:26px; line-height:1; cursor:pointer; color: var(--text-secondary); }
.es-tabs { display:flex; gap:4px; border-bottom:1px solid var(--border); }
.es-tabs button { border:none; background:none; padding:8px 12px; font:inherit; font-weight:600; color: var(--text-secondary); border-bottom:2px solid transparent; cursor:pointer; }
.es-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.es-pad { width:100%; aspect-ratio: 10 / 3; background:#fff; border:1px solid var(--border); border-radius:12px; touch-action:none; cursor:crosshair;
    background-image: linear-gradient(transparent calc(75% - 1px), #cbd5e1 calc(75% - 1px), #cbd5e1 75%, transparent 75%); }
.es-pad-foot { display:flex; justify-content:space-between; font-size:12.5px; color: var(--text-secondary); margin-top:6px; }
.es-dialog section input[type="text"], .es-dialog section input:not([type]) { width:100%; padding:10px 12px; border-radius:10px; border:1px solid var(--border); font:inherit; background: var(--bg-sunken); color: var(--text-primary); box-sizing:border-box; }
.es-fonts { display:grid; gap:8px; margin-top:10px; }
.es-fonts label { display:flex; align-items:center; gap:10px; padding:8px 12px; border:1px solid var(--border); border-radius:12px; background:#fff; cursor:pointer; }
.es-fonts span { font-size:34px; color:#1d3fbb; line-height:1.2; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.es-upload-preview { min-height:90px; display:grid; place-items:center; background:#fff; border:1px dashed var(--border); border-radius:12px; margin-top:8px; padding:8px; }
.es-upload-preview img { max-width:100%; max-height:120px; }
.es-dialog footer { display:flex; justify-content:flex-end; gap:8px; }

@media (max-width: 860px) {
    .es-work { grid-template-columns:1fr; }
    .es-tools { position:static; max-height:none; }
}

/* Page top like every other page, and the guide under the drop box. */
.es-page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 0; }
.es-lead { margin: -6px 0 0; color: var(--text-secondary); font-size: 13.5px; line-height: 1.6; max-width: 820px; }
.es-guide { padding: 20px 22px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg-raised); }
.es-guide h3 { margin: 0 0 14px; color: var(--text-primary); font-size: 16px; }
.es-guide-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.es-guide-steps li { display: flex; gap: 10px; align-items: flex-start; }
.es-step-no { flex: 0 0 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent); color: var(--text-inverse, #fff); font-size: 12.5px; font-weight: 700; }
.es-guide-steps strong { color: var(--text-primary); font-size: 13.5px; }
.es-guide-steps p { margin: 4px 0 0; color: var(--text-secondary); font-size: 12.5px; line-height: 1.6; }
.es-guide-notes { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.es-guide-notes p { margin: 0; color: var(--text-secondary); font-size: 12.5px; line-height: 1.6; }
#esBody { display: grid; gap: 16px; min-width: 0; }
