/* sign.css */
body.editor-mode {
    background: #f3f4f6;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.editor-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.editor-header {
    height: 60px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
    flex-shrink: 0;
}

.editor-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
}

.editor-title {
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    /* needed for mobile absolute stacking */
}

/* MOBILE RESPONSIVENESS */
@media (max-width: 900px) {
    .editor-layout {
        /* allow native scrolling on mobile */
        height: auto;
        min-height: 100vh;
    }

    body.editor-mode {
        overflow: auto;
        height: auto;
    }

    .editor-body {
        flex-direction: column;
        overflow: visible;
    }

    .pdf-viewer-pane {
        /* let the viewer be as tall as it needs or set to a good static height */
        min-height: 50vh;
        overflow: visible;
    }

    .sidebar-pane {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        /* cancel fixed scrolling, let native scroll rule */
        flex-shrink: 0;
    }

    .tab-content-container {
        /* remove fixed scroll inside tab container on mobile */
        overflow-y: visible;
    }

    .editor-header {
        /* Allow links to scroll or wrap without breaking logo */
        flex-wrap: wrap;
        height: auto;
        padding: 12px 20px;
        gap: 12px;
    }

    .header-related-links {
        width: 100%;
        order: 3;
        text-align: center;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 8px;
    }

    .header-actions {
        order: 2;
    }
}

/* PDF VIEWER PANE */
.pdf-viewer-pane {
    flex: 1;
    position: relative;
    background: #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.full-uploader {
    position: absolute;
    inset: 20px;
    border: 3px dashed var(--border-hover);
    border-radius: var(--radius-lg);
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.full-uploader:hover,
.full-uploader.dragover {
    border-color: #16A34A;
    background: #F0FDF4;
}

.upload-content {
    text-align: center;
    pointer-events: none;
}

#pdf-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.pdf-workspace {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.pdf-toolbar {
    height: 48px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    flex-shrink: 0;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 12px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
}

.icon-btn:hover:not(:disabled) {
    background: #f3f4f6;
}

.icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.spacer {
    flex: 1;
}

.pdf-canvas-container {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
}

#pdf-render-canvas {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* DRAGGABLE SIGNATURE OVERLAY */
.draggable-signature {
    position: absolute;
    border: 2px dashed #3B82F6;
    background: rgba(59, 130, 246, 0.05);
    cursor: move;
    box-sizing: border-box;
    /* initial placement hidden/absolute */
}

.draggable-signature img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid #3B82F6;
    border-radius: 50%;
}

.resize-handle.nw {
    top: -6px;
    left: -6px;
    cursor: nwse-resize;
}

.resize-handle.ne {
    top: -6px;
    right: -6px;
    cursor: nesw-resize;
}

.resize-handle.sw {
    bottom: -6px;
    left: -6px;
    cursor: nesw-resize;
}

.resize-handle.se {
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;
}

.remove-sig-btn {
    position: absolute;
    top: -12px;
    right: -24px;
    background: #EF4444;
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* SIDEBAR PANE */
.sidebar-pane {
    width: 360px;
    background: #fff;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.02);
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    text-align: center;
    padding: 16px 0;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: #f9fafb;
}

.tab-btn.active {
    color: #16A34A;
    border-bottom-color: #16A34A;
    background: #F0FDF4;
}

.tab-content-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Draw Tab */
.canvas-wrapper {
    width: 100%;
    height: 200px;
    border: 2px dashed var(--border-hover);
    border-radius: var(--radius);
    background: #F9FAFB;
    margin-bottom: 16px;
    cursor: crosshair;
}

#sign-canvas {
    width: 100%;
    height: 100%;
    touch-action: none;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-picker label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-right: 4px;
}

.color-option {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.color-option.active {
    border-color: #3B82F6;
    transform: scale(1.1);
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.secondary-btn:hover {
    background: #f3f4f6;
}

/* Type Tab */
.type-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.font-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.font-option {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.8rem;
    text-align: center;
    background: #fff;
}

.font-option:hover {
    border-color: var(--border-hover);
    background: #F9FAFB;
}

.font-option.active {
    border-color: #16A34A;
    background: #F0FDF4;
}

/* Upload Tab */
.upload-stamp-zone {
    border: 2px dashed var(--border-hover);
    border-radius: var(--radius);
    padding: 32px 16px;
    text-align: center;
    background: #F9FAFB;
    cursor: pointer;
    position: relative;
}

.upload-stamp-zone:hover {
    border-color: var(--accent);
    background: #EFF6FF;
}

#stamp-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Footer */
.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    background: #F9FAFB;
}

.full-width {
    width: 100%;
    display: block;
}

.helper-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 10px;
}