/* 全局签名功能样式 */

/* 签名弹窗样式 */
.signature-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.signature-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.signature-modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.signature-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.signature-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.signature-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.signature-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.signature-modal-body {
    padding: 24px;
    text-align: center;
}

.signature-instructions {
    color: #6c757d;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.signature-pad-container {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
    margin: 0 auto 20px;
    position: relative;
    overflow: hidden;
}

.signature-pad-container:hover {
    border-color: #007bff;
}

#signaturePadCanvas {
    display: block;
    cursor: crosshair;
    background: white;
    border-radius: 6px;
    touch-action: none;
}

.signature-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.signature-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
}

.signature-btn-clear {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.signature-btn-clear:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.signature-btn-confirm {
    background: #28a745;
    color: white;
}

.signature-btn-confirm:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.signature-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* 移动端提示 */
.mobile-signature-hint {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 6px;
    padding: 12px;
    margin-top: 16px;
    font-size: 0.9rem;
    color: #1976d2;
    display: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .signature-modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .signature-modal-header {
        padding: 16px 20px;
    }
    
    .signature-modal-body {
        padding: 20px;
    }
    
    .signature-buttons {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        width: 100%;
    }
    
    .signature-btn {
        flex: 1;
        min-width: 120px;
        max-width: none;
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    .mobile-signature-hint {
        display: block;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    .signature-modal-content {
        width: 98%;
        margin: 10px;
    }
    
    .signature-modal-body {
        padding: 16px;
    }
    
    .signature-buttons {
        gap: 6px;
    }
    
    .signature-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
        min-width: 100px;
    }
}

/* 签名区域样式增强 */
.signature-area {
    border: 2px dashed #dee2e6 !important;
    border-radius: 8px !important;
    padding: 24px !important;
    text-align: center !important;
    background: #f8f9fa !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    min-height: 120px !important;
    /* 移除 display: flex !important，让HTML内联样式控制显示状态 */
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
}

/* 当签名区域需要显示时，通过JavaScript添加这个类 */
.signature-area.show {
    display: flex !important;
}

.signature-area:hover {
    border-color: #007bff !important;
    background: #f0f8ff !important;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15) !important;
}

.signature-area.signed {
    border-color: #28a745 !important;
    background: #f8fff9 !important;
    cursor: default !important;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.15) !important;
}

.signature-area:before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid transparent;
    border-radius: 10px;
    background: linear-gradient(45deg, #007bff, #28a745) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: destination-out;
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.signature-area:hover:before {
    opacity: 0.3;
}

.signature-area.signed:before {
    opacity: 0.5;
}

/* 签名占位符样式 */
.signature-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    position: relative;
}

.signature-placeholder i {
    font-size: 2rem;
    color: #6c757d;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

.signature-area:hover .signature-placeholder i {
    color: #007bff;
}

.signature-area.signed .signature-placeholder i {
    color: #28a745;
}

/* 签名预览样式 */
.signature-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    position: relative;
}

.signature-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: white;
    border: none;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 公章上传区域样式增强 */
.seal-upload-area {
    border: 2px dashed #dee2e6 !important;
    border-radius: 8px !important;
    padding: 24px !important;
    text-align: center !important;
    background: #f8f9fa !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    width: 200px !important;
    height: 200px !important;
    /* 移除 display: flex !important，让HTML内联样式控制显示状态 */
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 auto !important;
    position: relative !important;
}

/* 当公章区域需要显示时，通过JavaScript添加这个类 */
.seal-upload-area.show {
    display: flex !important;
}

.seal-upload-area:hover {
    border-color: #28a745 !important;
    background: #f0f8f0 !important;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.15) !important;
}

.seal-upload-area.uploaded {
    border-color: #28a745 !important;
    background: #f8fff9 !important;
    cursor: default !important;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.15) !important;
}

/* 加载动画 */
.signature-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误状态样式 */
.signature-error {
    border-color: #dc3545 !important;
    background: #fff5f5 !important;
}

.signature-error .signature-placeholder i {
    color: #dc3545 !important;
}

/* 成功状态样式 */
.signature-success {
    border-color: #28a745 !important;
    background: #f8fff9 !important;
}

.signature-success .signature-placeholder i {
    color: #28a745 !important;
}
