/* ── Sign PDF specific styles ── */
.editor-wrap {
    display: grid;
    grid-template-columns: 200px 1fr 270px;
    gap: 0;
    height: 620px;
    background: #f8f9fa;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    margin-bottom: 20px;
}

/* Left: Thumbnails */
.panel-left {
    background: #f0f2f5;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    background: white;
}

.thumb-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.thumb-item {
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    background: white;
    position: relative;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.thumb-item:hover {
    border-color: #667eea;
}

.thumb-item.active {
    border-color: #667eea;
}

.thumb-canvas {
    width: 100%;
    display: block;
}

.thumb-num {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

/* Center: Canvas */
.panel-center {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #e9ecef;
}

.toolbar-top {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
}

.tb-group {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 0 6px;
    border-right: 1px solid #e0e0e0;
}

.tb-group:last-child {
    border-right: none;
    margin-left: auto;
}

.tb-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid transparent;
    color: #666;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tb-btn:hover {
    background: #f0f2f5;
    color: #333;
    border-color: #ddd;
}

.tb-btn.active {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border-color: rgba(102, 126, 234, 0.3);
}

.tb-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.zoom-display {
    font-size: 12px;
    color: #666;
    min-width: 40px;
    text-align: center;
}

.tb-input-num {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    color: #333;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 12px;
    width: 48px;
    text-align: center;
}

.canvas-wrap {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

.canvas-page-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
}

.page-wrapper {
    position: relative;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    overflow: visible;
    cursor: crosshair;
}

.page-wrapper.select-mode {
    cursor: default;
}

.page-pdf-canvas {
    display: block;
    border-radius: 3px;
}

.page-fabric-canvas {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 3px;
    z-index: 2;
}

.page-label {
    text-align: center;
    font-size: 11px;
    color: #999;
    margin-top: 5px;
}

/* Right: Tool Panel */
.panel-right {
    background: white;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tool-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.tool-tab {
    flex: 1;
    padding: 10px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    color: #999;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.tool-tab.active {
    color: #667eea;
    border-color: #667eea;
    background: white;
}

.tool-panel {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.tool-panel-section {
    display: none;
}

.tool-panel-section.active {
    display: block;
}

/* Signature method tabs */
.sig-method-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 12px;
}

.sig-tab {
    flex: 1;
    padding: 6px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}

.sig-tab.active {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
    color: #667eea;
}

.sig-panel {
    display: none;
}

.sig-panel.active {
    display: block;
}

/* Draw canvas */
.draw-area {
    position: relative;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    margin-bottom: 8px;
}

#sigCanvas,
#initCanvas {
    display: block;
    width: 100%;
    touch-action: none;
}

.draw-controls {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
}

/* Color row */
.color-row {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.color-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-dot.selected {
    border-color: #667eea;
    transform: scale(1.15);
}

.stroke-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 11px;
    color: #666;
}

.stroke-row input[type=range] {
    flex: 1;
    accent-color: #667eea;
}

/* Type sig */
.type-input {
    width: 100%;
    background: white;
    border: 2px solid #e0e0e0;
    color: #333;
    padding: 9px 10px;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    margin-bottom: 8px;
    font-family: 'Dancing Script', cursive;
}

.type-input:focus {
    border-color: #667eea;
}

.font-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 8px;
}

.font-option {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 8px 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    color: #111;
    font-size: 16px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.font-option:hover {
    border-color: #aaa;
}

.font-option.selected {
    border-color: #667eea;
}

/* Upload zone */
.upload-sig-zone {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9fa;
    margin-bottom: 8px;
}

.upload-sig-zone:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

#sigUploadPreview,
#initUploadPreview {
    max-width: 100%;
    max-height: 70px;
    display: none;
    margin: 8px auto 0;
    border-radius: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: 'Segoe UI', sans-serif;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #ccc;
}

.btn-danger {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #dc3545;
}

.btn-danger:hover {
    background: rgba(220, 53, 69, 0.2);
}

.btn-sm {
    padding: 4px 9px;
    font-size: 11px;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-1px);
}

/* Section labels */
.section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    margin-bottom: 6px;
    margin-top: 12px;
}

.section-label:first-child {
    margin-top: 0;
}

/* Text tool */
.text-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.form-label {
    font-size: 10px;
    color: #888;
    font-weight: 600;
}

.form-input,
.form-select {
    background: white;
    border: 1px solid #e0e0e0;
    color: #333;
    padding: 5px 7px;
    border-radius: 5px;
    font-size: 11px;
    outline: none;
    width: 100%;
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus {
    border-color: #667eea;
}

.toggle-row {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
}

.toggle-btn {
    flex: 1;
    padding: 5px;
    text-align: center;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
    color: #667eea;
}

/* Props panel */
.props-panel {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px;
    margin-top: 8px;
}

.props-title {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.prop-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 11px;
    color: #666;
}

.prop-row input[type=range] {
    flex: 1;
    accent-color: #667eea;
}

.prop-row .val {
    min-width: 28px;
    text-align: right;
    color: #333;
    font-weight: 600;
}

/* Download bar */
.download-bar {
    padding: 10px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.download-bar .btn-success {
    width: 100%;
    justify-content: center;
    margin-bottom: 6px;
}

.undo-redo {
    display: flex;
    gap: 5px;
}

.undo-redo .btn {
    flex: 1;
    justify-content: center;
}

/* Progress overlay */
.progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    display: none;
    place-items: center;
}

.progress-overlay.show {
    display: grid;
}

.progress-box {
    background: white;
    border-radius: 12px;
    padding: 28px 36px;
    text-align: center;
    min-width: 260px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.progress-box h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #333;
}

.progress-box p {
    font-size: 13px;
    color: #666;
    margin-bottom: 16px;
}

.progress-bar-wrap {
    background: #e9ecef;
    border-radius: 99px;
    height: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 99px;
    transition: width 0.3s ease;
    width: 0;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sign-toast {
    background: #333;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    animation: toastIn 0.2s ease;
    max-width: 300px;
    color: white;
}

.sign-toast.success {
    background: #28a745;
}

.sign-toast.error {
    background: #dc3545;
}

.sign-toast.info {
    background: #17a2b8;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

input[type=color] {
    -webkit-appearance: none;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: none;
}

input[type=color]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type=color]::-webkit-color-swatch {
    border: 1px solid #ddd;
    border-radius: 4px;
}

@media (max-width: 900px) {
    .editor-wrap {
        grid-template-columns: 1fr 260px;
        height: auto;
        min-height: 500px;
    }

    .panel-left {
        display: none;
    }
}

@media (max-width: 600px) {
    .editor-wrap {
        grid-template-columns: 1fr;
        height: auto;
    }

    .panel-right {
        max-height: 340px;
    }

    .toolbar-top {
        gap: 3px;
        padding: 6px 8px;
    }
}