/* SignFlow 页面层 | 编辑器、签署页等页面专属分区
   依赖：tokens.css → base.css → components.css */
/* === 编辑器 === */
.editor-layout {
    display: flex;
    gap: 20px;
    height: calc(100vh - 120px);
    min-height: 600px;
}
.editor-sidebar {
    width: 300px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
}
.editor-main {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: auto;
    position: relative;
    box-shadow: var(--shadow-sm);
}
.sidebar-section {
    margin-bottom: 24px;
}
.sidebar-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

/* 字段类型面板 */
.field-palette {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.field-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    cursor: grab;
    transition: all var(--transition);
    text-align: center;
}
.field-type-btn:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
    transform: translateY(-2px);
}
.field-type-btn:active {
    cursor: grabbing;
}
.field-type-icon {
    font-size: 22px;
}
.field-type-name {
    font-size: 12px;
    font-weight: 600;
}

/* PDF渲染区域 */
.pdf-canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    min-height: 100%;
}
.pdf-page-wrapper {
    position: relative;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    border-radius: 4px;
    overflow: visible;
}
.pdf-page-canvas {
    display: block;
    border-radius: 4px;
}
.field-overlay {
    position: absolute;
    border: 2px solid;
    border-radius: 6px;
    cursor: move;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    transition: box-shadow var(--transition);
    user-select: none;
}
.field-overlay:hover {
    box-shadow: 0 0 0 3px var(--accent-ring);
}
.field-overlay.selected {
    box-shadow: 0 0 0 3px var(--accent);
    z-index: 10;
}
.field-overlay.field-grouped {
    border-style: dashed;
    border-width: 2.5px;
}

/* 静态文本字段: 透明背景+虚线边框，让编辑器预览效果与签署页一致 */
.field-overlay.is-static-text {
    border: 1px dashed var(--border-dashed) !important;
    background: transparent !important;
    border-radius: 4px;
}
.field-overlay.is-static-text:hover {
    border-color: var(--border-strong) !important;
}
.field-overlay.is-static-text.selected {
    border-color: var(--accent) !important;
}

/* 签名贴图：图片预览 */
.field-overlay img.signature-stamp-content {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}
.field-overlay-label {
    position: absolute;
    top: -22px;
    left: 0;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
}
.field-resize-handle {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--accent);
    border-radius: 50%;
    cursor: nwse-resize;
}

/* 页面导航 */
.page-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: var(--shadow-sm);
}
.page-nav-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all var(--transition);
    font-size: 18px;
}
.page-nav-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.page-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.page-nav-action {
    width: auto !important;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}
.page-nav-action:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.page-nav-action.danger {
    color: var(--danger);
}
.page-nav-action.danger:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.page-nav-info {
    font-size: 14px;
    font-weight: 600;
    min-width: 80px;
    text-align: center;
}

/* === 签署页面 === */
.signing-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 20px;
}
.signing-header {
    text-align: center;
    margin-bottom: 32px;
}
.signing-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}
.signing-progress-bar {
    width: 200px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.signing-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--success-light));
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* 签署字段输入 */
.sign-field {
    position: absolute;
    border: 2px dashed;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.3s ease, background 0.3s ease;
}
.sign-field:hover {
    border-color: var(--accent);
}

/* 填写后边框消失，内容直接显示在PDF上 */
.sign-field.filled {
    border: none;
    background: transparent;
    opacity: 1;
}

/* 未完成的必填字段：脉冲提示 */
.sign-field.required-pending {
    animation: pulse-required 2s ease-in-out infinite;
}
@keyframes pulse-required {
    0%, 100% {
        box-shadow: 0 0 0 0 var(--danger-ring);
    }
    50% {
        box-shadow: 0 0 0 8px var(--danger-ring-fade);
    }
}

/* 提交时定位高亮 */
.sign-field.field-highlight {
    animation: highlight-field 0.4s ease 3;
    z-index: 100;
}
@keyframes highlight-field {
    0%, 100% {
        box-shadow: 0 0 0 2px var(--accent);
    }
    50% {
        box-shadow: 0 0 0 8px var(--accent), 0 0 20px var(--accent);
    }
}

/* 提交按钮未完成状态 */
.btn-pending {
    opacity: 0.65;
    animation: pulse-btn 2.5s ease-in-out infinite;
}
@keyframes pulse-btn {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 0.9; }
}
.sign-field-input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 14px;
    outline: none;
    color: var(--text-primary);
}
.sign-field-label {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
    max-width: calc(100% - 4px);
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease;
}

/* 填写后隐藏标签，避免遮挡内容 */
.sign-field.filled .sign-field-label {
    opacity: 0;
}
.sign-field-required {
    color: var(--danger);
}

/* 签名弹窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--scrim);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

/* === 签名画布水印提示（非阻塞，引导横屏） === */
.sig-watermark {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.4s ease;
}
.sig-watermark.show {
    display: flex;
}
.sig-watermark.faded {
    opacity: 0;
}
.sig-watermark-rotate {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    white-space: nowrap;
}
.sig-watermark-icon {
    font-size: 84px;
    opacity: 0.35;
    animation: rotateNudge 2.5s ease-in-out infinite;
}
.sig-watermark-text {
    font-size: 54px;
    font-weight: 700;
    color: var(--watermark-fg);
    letter-spacing: 4px;
    opacity: 0.35;
}
@keyframes rotateNudge {
    0%, 100% { transform: rotate(0deg); opacity: 0.35; }
    50% { transform: rotate(-15deg); opacity: 0.5; }
}

/* === 文档列表（dashboard 列表视图；原 dashboard.html 内联样式，整体迁出） === */
/* 主界面工具栏 */
.doc-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: center;
}
.doc-toolbar .doc-search { flex: 1; min-width: 160px; }
.doc-toolbar .doc-filter { width: auto; min-width: 120px; }

/* 列表视图 */
.doc-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.doc-grid.list-view .doc-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
}
.doc-grid.list-view .doc-card-header { flex: 0 0 240px; }
.doc-grid.list-view .doc-card-body {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
}
.doc-grid.list-view .doc-card-body .progress-bar {
    flex: 1;
    max-width: 200px;
}
.doc-grid.list-view .doc-card-footer { flex-shrink: 0; }

/* === progress 页 Tab 分区（T10） === */
.tab-btn.tab-active {
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 700;
    box-shadow: inset 0 -2px 0 var(--accent);
}
.round-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* === 签署页底部操作条（T12） === */
.signing-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}
.signing-container {
    padding-bottom: 8px;
}
