* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft JhengHei', '微軟正黑體', 'PMingLiU', '新細明體', Arial, sans-serif;
    background: #f5f5f5;
    padding: 10px;
    -webkit-font-smoothing: antialiased;
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 浮水印效果 - 使用实际元素 */
#watermark-logo {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh; /* 确保覆盖整个视口 */
    background-image: url('LOGO.jpg');
    background-size: 50%; /* LOGO 大小：50% */
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    opacity: 0.12; /* 浮水印效果：淡淡的，12% 不透明度 */
    z-index: 0; /* 在背景层 */
    pointer-events: none; /* 不阻挡鼠标事件 */
    /* 确保背景图片显示 */
    background-color: transparent;
}

.contract-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.75); /* 更透明，让浮水印能透过来 */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: visible;
    position: relative;
    z-index: 1; /* 确保内容在背景 LOGO 之上 */
}

/* 翻页控制 */
.page-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #667eea;
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-controls-bottom {
    position: sticky;
    bottom: 0;
    top: auto;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.page-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    pointer-events: auto;
    position: relative;
    z-index: 101;
    transition: all 0.3s;
}

.page-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#pageInfo {
    font-size: 14px;
    font-weight: 500;
}

/* 契约书容器 */
.contract-container {
    position: relative;
    min-height: calc(100vh - 200px);
    overflow: visible;
}

.contract-page {
    display: none;
    padding: 40px;
    min-height: calc(100vh - 200px);
    page-break-after: always;
    position: relative;
    z-index: 1;
}

.contract-page.active {
    display: block !important;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.page-content {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
    color: #333;
}

.contract-title {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 30px;
    color: #333;
    padding-bottom: 15px;
    border-bottom: 2px solid #667eea;
}

.section-title {
    font-size: 18px;
    font-weight: bold;
    margin: 25px 0 15px 0;
    color: #667eea;
    padding-left: 10px;
    border-left: 4px solid #667eea;
}

.contract-text {
    margin-bottom: 15px;
    text-align: justify;
    font-size: 14px;
    line-height: 1.8;
}

.form-list {
    margin: 15px 0;
    padding-left: 20px;
}

.form-list p {
    margin-bottom: 10px;
    line-height: 2;
}

/* 输入框样式 */
.inline-input {
    border: none;
    border-bottom: 1px solid #667eea;
    background: transparent;
    padding: 2px 5px;
    font-size: inherit;
    font-family: inherit;
    color: #333;
    text-align: center;
}

.inline-input:focus {
    outline: none;
    border-bottom: 2px solid #764ba2;
    background: rgba(102, 126, 234, 0.05);
}

.underline-input {
    border: none;
    border-bottom: 1px solid #333;
    background: transparent;
    padding: 2px 5px;
    font-size: inherit;
    font-family: inherit;
    color: #333;
    min-width: 150px;
}

.underline-input:focus {
    outline: none;
    border-bottom: 2px solid #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.date-input {
    border: none;
    border-bottom: 1px solid #333;
    background: transparent;
    display: inline-block;
    visibility: visible;
    padding: 2px 5px;
    font-size: inherit;
    font-family: inherit;
    color: #333;
    text-align: center;
}

.date-input:focus {
    outline: none;
    border-bottom: 2px solid #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.textarea-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.textarea-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 签名区域 */
.signature-section {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
}

.party-info {
    margin: 15px 0;
    padding: 10px;
}

.signature-form {
    margin-top: 30px;
}

.signature-party {
    margin: 25px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
}

.signature-party h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #667eea;
}

.signature-party p {
    margin: 8px 0;
    line-height: 2;
}

.signature-box {
    margin-top: 20px;
    padding: 15px;
    background: white;
    border-radius: 4px;
}

.signature-area {
    margin-top: 10px;
}

#signatureCanvas {
    border: 2px dashed #667eea;
    border-radius: 6px;
    background: white;
    cursor: crosshair;
    display: block;
    width: 100%;
    max-width: 500px;
    height: 150px;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.signature-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.signature-box-inline {
    margin: 15px 0;
    padding: 15px;
    background: white;
    border-radius: 4px;
}

#customerSignatureCanvas {
    border: 2px dashed #667eea;
    border-radius: 6px;
    background: white;
    cursor: crosshair;
    display: block;
    width: 100%;
    max-width: 400px;
    height: 120px;
    touch-action: none;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.signature-controls-inline {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* 复选框和单选框 */
.checkbox-group {
    margin: 15px 0;
    padding-left: 20px;
}

.checkbox-group label {
    display: block;
    margin: 8px 0;
    cursor: pointer;
    line-height: 1.8;
}

.checkbox-group input[type="checkbox"],
.checkbox-group input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

/* 按钮 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.form-actions {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
}

.form-actions .btn {
    min-width: 200px;
    font-size: 16px;
}

/* 消息提示 */
.message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    border-radius: 6px;
    display: none;
    z-index: 1000;
    max-width: 90%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* 表单表格样式 */
.form-table {
    margin-top: 20px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.form-col {
    flex: 1;
    min-width: 300px;
}

.form-section-inline {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.form-section-inline h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #667eea;
    border-bottom: 1px solid #ddd;
    padding-bottom: 8px;
}

.form-section-inline h4 {
    font-size: 14px;
    margin: 10px 0 5px 0;
    color: #333;
}

.form-item {
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.form-item span {
    min-width: 120px;
    font-size: 14px;
}

.checkbox-group-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin: 10px 0;
    align-items: center;
}

.checkbox-group-inline label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 14px;
}

.service-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 14px;
}

.service-table th,
.service-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.service-table th {
    background: #667eea;
    color: white;
    font-weight: 500;
}

.service-table td {
    background: white;
}

.table-input {
    border: none;
    border-bottom: 1px solid #667eea;
    background: transparent;
    padding: 4px;
    font-size: 14px;
    width: 100%;
    text-align: center;
}

.table-input:focus {
    outline: none;
    border-bottom: 2px solid #764ba2;
    background: rgba(102, 126, 234, 0.05);
}

/* 移动端优化 */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .contract-page {
        padding: 20px 15px;
    }
    
    .contract-title {
        font-size: 20px;
    }
    
    .section-title {
        font-size: 16px;
    }
    
    .contract-text {
        font-size: 13px;
    }
    
    .page-controls {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .page-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    #pageInfo {
        font-size: 12px;
        width: 100%;
        text-align: center;
        order: 3;
    }
    
    .underline-input {
        width: 100% !important;
        min-width: auto;
    }
    
    .inline-input {
        width: 60px !important;
    }
    
    #signatureCanvas {
        height: 120px;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-col {
        min-width: 100%;
    }
    
    .service-table {
        font-size: 12px;
    }
    
    .service-table th,
    .service-table td {
        padding: 4px;
    }
    
    .checkbox-group-inline {
        flex-direction: column;
        align-items: flex-start;
    }
}

