/* ===== Sign Documents V2 (DocuSign-style) ===== */

.sv2-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 2500;
    align-items: stretch;
    justify-content: stretch;
}
.sv2-overlay.show { display: flex; }

.sv2-modal {
    background: #f8fafc;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sv2-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.sv2-header h2 {
    margin: 0;
    font-size: 1rem;
    color: #1e293b;
    display: flex;
    gap: 8px;
    align-items: center;
}
.sv2-header .sv2-title-input {
    margin-left: 12px;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 320px;
}
.sv2-header .sv2-actions { display: flex; gap: 8px; align-items: center; }
.sv2-btn {
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 0.82rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.sv2-btn:hover { background: #f1f5f9; }
.sv2-btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.sv2-btn.primary:hover { background: #1d4ed8; }
.sv2-btn.danger { background: #ef4444; color: #fff; border-color: #ef4444; }
.sv2-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.sv2-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sv2-sidebar {
    width: 280px;
    min-width: 280px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sv2-sidebar-section {
    padding: 12px;
    border-bottom: 1px solid #f1f5f9;
}
.sv2-sidebar-section h3 {
    margin: 0 0 8px 0;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sv2-sidebar-section h3 .sv2-add-btn {
    background: #eff6ff;
    color: #2563eb;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.65rem;
    cursor: pointer;
    text-transform: none;
    letter-spacing: normal;
}
.sv2-sidebar-section h3 .sv2-add-btn:hover { background: #dbeafe; }

.sv2-signers { display: flex; flex-direction: column; gap: 6px; }
.sv2-signer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    background: #fff;
    border-left-width: 4px;
}
.sv2-signer:hover { background: #f8fafc; }
.sv2-signer.active {
    background: #eff6ff;
    box-shadow: 0 0 0 2px #93c5fd inset;
}
.sv2-signer-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}
.sv2-signer-info { flex: 1; min-width: 0; overflow: hidden; }
.sv2-signer-name { font-size: 0.82rem; font-weight: 600; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv2-signer-email { font-size: 0.7rem; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv2-signer-remove {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px;
    font-size: 0.75rem;
}
.sv2-signer-remove:hover { color: #ef4444; }
.sv2-signers-empty {
    color: #94a3b8;
    font-size: 0.75rem;
    text-align: center;
    padding: 12px 0;
}

.sv2-palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sv2-palette-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px 6px;
    text-align: center;
    cursor: grab;
    user-select: none;
    transition: all 0.15s;
    font-size: 0.72rem;
    color: #475569;
    font-weight: 500;
}
.sv2-palette-item:hover { background: #eff6ff; border-color: #93c5fd; color: #2563eb; }
.sv2-palette-item:active { cursor: grabbing; transform: scale(0.97); }
.sv2-palette-item.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.sv2-palette-item i { display: block; font-size: 1.1rem; margin-bottom: 4px; }

.sv2-palette-hint {
    margin-top: 8px;
    padding: 8px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 6px;
    font-size: 0.7rem;
    color: #92400e;
    line-height: 1.4;
}

.sv2-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #e5e7eb;
}

.sv2-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 8px 16px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.82rem;
    flex-shrink: 0;
}
.sv2-toolbar .sv2-tb-group { display: flex; align-items: center; gap: 8px; }
.sv2-toolbar button {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.8rem;
}
.sv2-toolbar button:hover { background: #e2e8f0; }
.sv2-toolbar button:disabled { opacity: 0.4; cursor: not-allowed; }

.sv2-viewer {
    flex: 1;
    overflow: auto;
    padding: 24px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.sv2-canvas-wrap {
    position: relative;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    margin: 0 auto;
}
.sv2-canvas-wrap canvas { display: block; }
.sv2-overlay-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.sv2-drop-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    background: #fff;
    margin: 24px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.sv2-drop-screen.drag-over {
    border-color: #2563eb;
    background: #eff6ff;
    color: #2563eb;
}
.sv2-drop-screen i { font-size: 3rem; margin-bottom: 12px; }
.sv2-drop-screen h3 { margin: 0 0 6px 0; font-size: 1rem; font-weight: 600; }
.sv2-drop-screen p { margin: 0; font-size: 0.85rem; }

.sv2-field {
    position: absolute;
    pointer-events: auto;
    border: 2px dashed #2563eb;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 4px;
    cursor: move;
    user-select: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #2563eb;
    font-size: 11px;
    font-family: Arial, sans-serif;
    padding: 4px;
    text-align: center;
    overflow: hidden;
}
.sv2-field:hover { box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3); }
.sv2-field.selected { box-shadow: 0 0 0 2px #2563eb; }
.sv2-field i { font-size: 14px; margin-bottom: 2px; }
.sv2-field .sv2-field-label { font-weight: 600; line-height: 1.1; }
.sv2-field .sv2-field-sub { font-size: 9px; opacity: 0.8; }
.sv2-field .sv2-field-delete {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.sv2-field:hover .sv2-field-delete,
.sv2-field.selected .sv2-field-delete { display: flex; }
.sv2-field .sv2-field-resize {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 10px;
    height: 10px;
    background: #2563eb;
    cursor: nwse-resize;
    border-radius: 2px;
    display: none;
}
.sv2-field:hover .sv2-field-resize,
.sv2-field.selected .sv2-field-resize { display: block; }

.sv2-ghost {
    position: absolute;
    pointer-events: none;
    opacity: 0.7;
    z-index: 10;
}

/* Reuse for picker sub-modal */
.sv2-picker {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2600;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.sv2-picker.show { display: flex; }
.sv2-picker-content {
    background: #fff;
    width: 560px;
    max-width: 95%;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sv2-picker-header {
    padding: 14px 18px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sv2-picker-header h3 {
    margin: 0;
    font-size: 0.95rem;
    color: #1e293b;
    display: flex;
    gap: 8px;
    align-items: center;
}
.sv2-picker-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
}
.sv2-picker-tab {
    flex: 1;
    padding: 10px;
    background: #f8fafc;
    border: none;
    cursor: pointer;
    font-size: 0.82rem;
    color: #64748b;
    border-bottom: 2px solid transparent;
}
.sv2-picker-tab.active {
    background: #fff;
    color: #2563eb;
    border-bottom-color: #2563eb;
    font-weight: 600;
}
.sv2-picker-body {
    padding: 16px;
    overflow: auto;
    flex: 1;
}
.sv2-picker-body input,
.sv2-picker-body select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 10px;
    box-sizing: border-box;
}
.sv2-picker-list {
    max-height: 280px;
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}
.sv2-picker-user {
    padding: 10px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    display: flex;
    gap: 10px;
    align-items: center;
}
.sv2-picker-user:hover { background: #f8fafc; }
.sv2-picker-user.selected { background: #eff6ff; }
.sv2-picker-user img,
.sv2-picker-user .sv2-avatar-fallback {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #cbd5e1;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}
.sv2-picker-user-info { flex: 1; min-width: 0; }
.sv2-picker-user-name { font-size: 0.85rem; font-weight: 600; color: #1e293b; }
.sv2-picker-user-meta { font-size: 0.7rem; color: #64748b; }
.sv2-picker-footer {
    padding: 12px 18px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
