/* ==========================================================================
   PDF Sign Specific Components Styles
   (遵循全局架构规范：全局主题变量 → 页面使用变量 → 专属组件单独定义)
   ========================================================================== */

.pdf-sign-page {
    padding-bottom: 60px;
}

/* File Card Specifics for Sign Tool */
.pdf-sign-page .pdf-file-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--badge-red-bg);
    color: var(--danger, #ef4444);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.pdf-sign-page .pdf-file-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pdf-sign-page .pdf-file-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    word-break: break-all;
}

.pdf-sign-page .pdf-file-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-sub);
}

.pdf-sign-page .page-badge {
    background: var(--badge-red-bg);
    color: var(--badge-red-color);
    padding: 1px 8px;
    border-radius: 4px;
    font-weight: 600;
}

/* Page Thumbnail Cards Grid Section */
.pdf-sign-page .sign-options-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--border-main);
    border-radius: 10px;
    padding: 18px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.sign-options-pill {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.sign-option-item {
    flex: 1;
    cursor: pointer;
    border: 1px solid var(--border-main);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--card-bg);
    color: var(--text-main);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sign-option-item:hover {
    border-color: var(--border-strong);
    background: var(--card-muted-bg);
}

.sign-option-item.active {
    border-color: #ef4444;
    background: var(--badge-red-bg);
    color: var(--badge-red-color);
}

.sign-option-item input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

/* Page Thumbnail Cards Grid */
.pdf-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.pdf-page-card {
    background: var(--card-bg);
    border: 1px solid var(--border-main);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    box-shadow: var(--shadow-card, 0 2px 6px rgba(0, 0, 0, 0.03));
    transition: all 0.2s ease;
}

.pdf-page-card:hover {
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
}

.pdf-page-card .card-page-num {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(15, 23, 42, 0.75);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    z-index: 2;
}

.pdf-page-card .card-stamp-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--badge-green-bg);
    color: var(--badge-green-color);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pdf-page-card .card-canvas-wrap {
    width: 100%;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-muted-bg);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
    position: relative;
    cursor: pointer;
}

.pdf-page-card .card-canvas-wrap canvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.pdf-page-card .card-action-btn {
    width: 100%;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

/* Interactive Stamp Modal Editor */
.stamp-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.stamp-modal-dialog {
    background: var(--card-bg);
    border: 1px solid var(--border-main);
    border-radius: 14px;
    width: 96%;
    max-width: 1200px;
    height: 90vh;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.stamp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--panel-muted-bg);
    border-bottom: 1px solid var(--border-main);
    flex-shrink: 0;
}

.stamp-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.stamp-modal-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stamp-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #0b0f19;
}

.stamp-canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 44px 24px 30px 24px;
    overflow: auto;
    position: relative;
    user-select: none;
}

.stamp-canvas-stage {
    position: relative;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    background: #ffffff;
    margin: auto 0;
    flex-shrink: 0;
}

/* Interactive Floating Stamp Element */
.stamp-interact-elem {
    position: absolute;
    border: 2px dashed #dc2626;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8);
    cursor: move;
    user-select: none;
    touch-action: none;
    z-index: 10;
    transform-origin: center center;
    box-sizing: border-box;
}

.stamp-interact-elem canvas,
.stamp-interact-elem img {
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: block;
}

/* Handles */
.stamp-handle-rotate {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: #dc2626;
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: grab;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.stamp-handle-rotate::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 8px;
    background: #dc2626;
}

.stamp-handle-corner {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border: 2px solid #dc2626;
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.stamp-handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.stamp-handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.stamp-handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.stamp-handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* Modal Sidebar Controls - Compact & Neatly Formatted */
.stamp-modal-sidebar {
    width: 300px;
    background: var(--card-bg);
    border-left: 1px solid var(--border-main);
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stamp-modal-sidebar .sidebar-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-soft);
}

.stamp-modal-sidebar .sidebar-card {
    background: var(--card-muted-bg);
    border: 1px solid var(--border-main);
    border-radius: 8px;
    padding: 10px 12px;
}

.stamp-modal-sidebar .sidebar-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.stamp-modal-sidebar .card-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 5px;
}

.sign-options-pill-sidebar {
    display: flex;
    gap: 6px;
}

.sign-options-pill-sidebar .sign-option-item {
    flex: 1;
    cursor: pointer;
    border: 1px solid var(--border-main);
    border-radius: 6px;
    padding: 6px 8px;
    background: var(--card-bg);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-main);
}

.sign-options-pill-sidebar .sign-option-item.active {
    border-color: #ef4444;
    background: var(--badge-red-bg);
    color: var(--badge-red-color);
}

.sign-options-pill-sidebar .sign-option-item input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.stamp-modal-sidebar .sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--card-muted-bg);
    border: 1px solid var(--border-main);
    border-radius: 8px;
    padding: 10px 12px;
}

.stamp-modal-sidebar .sidebar-section-title {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stamp-modal-sidebar .sidebar-form-group {
    margin-bottom: 0;
}

.stamp-modal-sidebar .slider-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 3px;
}

.stamp-modal-sidebar .slider-val-badge {
    background: var(--card-bg);
    color: var(--text-main);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-main);
    font-family: Consolas, Monaco, monospace;
}

.stamp-modal-sidebar .sidebar-range {
    height: 22px;
    padding: 0;
    margin: 0;
    cursor: pointer;
    box-shadow: none;
}

/* Perforated Sidebar Card */
.stamp-modal-sidebar .perf-sidebar-card {
    border-color: var(--border-main);
    background: var(--card-muted-bg);
}

.stamp-modal-sidebar .perf-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stamp-modal-sidebar .perf-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.stamp-modal-sidebar .perf-checkbox-label input[type="checkbox"] {
    margin: 0;
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.stamp-modal-sidebar .perf-tag-badge {
    background: var(--badge-green-bg);
    color: var(--badge-green-color);
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
}

.stamp-modal-sidebar .sidebar-tip-box {
    font-size: 11px;
    color: var(--tip-box-text);
    background: var(--tip-box-bg);
    border: 1px solid var(--tip-box-border);
    padding: 8px 10px;
    border-radius: 6px;
    margin-top: auto;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.4;
}

.stamp-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--panel-muted-bg);
    border-top: 1px solid var(--border-main);
}

/* Result Card & Download Button */
.pdf-sign-page .wm-result-icon {
    width: 52px;
    height: 52px;
    background: var(--badge-red-bg);
    color: var(--badge-red-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 12px;
}

.pdf-sign-page .btn-download-pdf {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #ffffff !important;
    padding: 11px 26px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
    transition: all 0.2s ease;
}

.pdf-sign-page .btn-download-pdf:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.35);
    color: #ffffff !important;
    text-decoration: none;
}

/* Responsive */
.pdf-sign-page .sign-page-toolbar,
.pdf-sign-page .sign-page-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.pdf-sign-page .sign-page-toolbar {
    justify-content: space-between;
    margin-bottom: 14px;
}

.pdf-sign-page .sign-page-toolbar > div {
    min-width: 0;
}

.pdf-sign-page .sign-page-hint {
    color: var(--text-sub);
    font-size: 13px;
    line-height: 1.65;
}

.pdf-sign-page .sign-page-actions .btn {
    min-height: 44px;
    white-space: normal;
}

.pdf-stamp-modal--focused .stamp-modal-header {
    gap: 12px;
}

.pdf-stamp-modal--focused .stamp-modal-title {
    flex: 1;
    min-width: 0;
}

.pdf-stamp-modal--focused .stamp-modal-nav {
    flex-wrap: wrap;
}

.pdf-stamp-modal--focused #btnModalClose {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    font-size: 26px;
    color: var(--text-main);
}

.pdf-stamp-modal--focused .stamp-modal-body,
.pdf-stamp-modal--focused .stamp-canvas-container {
    min-width: 0;
    min-height: 0;
}

.pdf-stamp-modal--focused .stamp-canvas-container {
    scrollbar-gutter: stable;
}

.pdf-stamp-modal--focused #modalPageCanvas {
    display: block;
}

.pdf-stamp-modal--focused .stamp-modal-sidebar {
    flex-shrink: 0;
}

.pdf-stamp-modal--focused .stamp-canvas-status {
    position: absolute;
    top: 12px;
    left: 16px;
    right: 16px;
    color: #e2e8f0;
    font-size: 13px;
    text-align: center;
}

.pdf-stamp-modal--focused .stamp-modal-footer {
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 991px) {
    .stamp-modal-dialog {
        height: 95vh;
        max-height: 95vh;
        width: 98%;
    }

    .stamp-modal-body {
        flex-direction: column;
    }

    .stamp-modal-sidebar {
        width: 100%;
        max-height: 260px;
        border-left: none;
        border-top: 1px solid var(--border-main);
    }

    .pdf-stamp-modal--focused .stamp-modal-sidebar {
        max-height: 38vh;
    }
}

@media (max-width: 767px) {
    .pdf-sign-page.pdf-workspace-page .pdf-page-card {
        padding: 8px;
    }

    .pdf-sign-page.pdf-workspace-page .pdf-page-card .card-canvas-wrap {
        height: 160px;
    }

    .pdf-sign-page.pdf-workspace-page .pdf-page-card .card-action-btn {
        min-height: 44px;
        font-size: 13px;
        padding: 8px 4px;
    }

    .pdf-sign-page.pdf-workspace-page .card-stamp-badge {
        top: 31px;
        left: 8px;
        right: auto;
    }

    .pdf-stamp-modal--focused .stamp-modal-title {
        order: 0;
    }

    .pdf-stamp-modal--focused #btnModalClose {
        order: 1;
    }

    .pdf-stamp-modal--focused .stamp-modal-nav {
        order: 2;
        flex-basis: 100%;
    }

    .pdf-stamp-modal--focused .stamp-canvas-container {
        padding: 38px 12px 18px;
    }

    .pdf-stamp-modal--focused .stamp-modal-footer {
        padding: 10px 12px;
    }
}
