* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 800px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

h1 {
    text-align: center;
    color: #333;
    font-size: 28px;
    margin-bottom: 10px;
}

.signature-container {
    position: relative;
    width: 100%;
    border: 2px dashed #ddd;
    border-radius: 10px;
    background: #fafafa;
    overflow: hidden;
}

#signatureCanvas {
    display: block;
    width: 100%;
    height: 400px;
    cursor: crosshair;
    touch-action: none;
}

.placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 18px;
    pointer-events: none;
    z-index: 0;
}

.placeholder.hidden {
    display: none;
}

.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

button {
    flex: 1;
    min-width: 120px;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(0);
}

.btn-clear {
    background: #ff6b6b;
    color: white;
}

.btn-clear:hover {
    background: #ff5252;
}

.btn-download {
    background: #4ecdc4;
    color: white;
}

.btn-download:hover {
    background: #45b7aa;
}

.btn-save {
    background: #95e1d3;
    color: white;
}

.btn-save:hover {
    background: #7dd3c0;
}

.btn-undo {
    background: #ffe66d;
    color: #333;
}

.btn-undo:hover {
    background: #ffd93d;
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.preview-container {
    margin-top: 20px;
    text-align: center;
    display: none;
}

.preview-container.show {
    display: block;
}

.preview-image {
    max-width: 100%;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-top: 10px;
}

.tips {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-top: 10px;
}

/* 成功提示模态框 */
.success-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.success-modal.show {
    display: flex;
}

.success-content {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s ease;
}

.success-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    color: white;
    font-size: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    animation: scaleIn 0.5s ease;
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

.success-content h2 {
    color: #333;
    font-size: 24px;
    margin-bottom: 10px;
    font-weight: 600;
}

.success-content p {
    color: #666;
    font-size: 16px;
    margin-bottom: 30px;
}

.btn-close {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 40px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-close:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-close:active {
    transform: translateY(0);
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes scaleIn {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* 通用提示模态框 */
.alert-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.alert-modal.show {
    display: flex;
}

.alert-content {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s ease;
}

.alert-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    font-size: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    animation: scaleIn 0.5s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.alert-icon.warning {
    background: linear-gradient(135deg, #ffe66d 0%, #ffd93d 100%);
    box-shadow: 0 4px 15px rgba(255, 230, 109, 0.4);
}

.alert-icon.info {
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

.alert-content h2 {
    color: #333;
    font-size: 24px;
    margin-bottom: 10px;
    font-weight: 600;
}

.alert-content p {
    color: #666;
    font-size: 16px;
    margin-bottom: 30px;
    line-height: 1.6;
    word-wrap: break-word;
}

/* Toast 提示 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s;
    pointer-events: auto;
    position: relative;
}

.toast::before {
    content: '';
    width: 4px;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 10px 0 0 10px;
    background: #4ecdc4;
}

.toast.warning::before {
    background: #ffe66d;
}

.toast.error::before {
    background: #ff6b6b;
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
        border-radius: 15px;
    }

    h1 {
        font-size: 24px;
    }

    #signatureCanvas {
        height: 300px;
    }

    button {
        min-width: 100%;
        padding: 12px 20px;
    }

    .button-group {
        flex-direction: column;
    }

    .success-content {
        padding: 30px 20px;
    }

    .success-icon {
        width: 60px;
        height: 60px;
        font-size: 40px;
    }

    .success-content h2 {
        font-size: 20px;
    }

    .success-content p {
        font-size: 14px;
    }

    .alert-content {
        padding: 30px 20px;
    }

    .alert-icon {
        width: 60px;
        height: 60px;
        font-size: 40px;
    }

    .alert-content h2 {
        font-size: 20px;
    }

    .alert-content p {
        font-size: 14px;
    }

    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}
