/* 整合原本介面與字帖模式所需的全部樣式 */
@font-face {
    font-family: 'StarfruitCelesSerif-Bold';
    src: url('../fonts/StarfruitCelesSerif-Bold.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
}
@font-face {
    font-family: '1a8a2423bb5924f5';
    src: url('../../upload/1a8a2423bb5924f5.ttf') format('truetype');
}

svg text {
    text-rendering: optimizeLegibility;
}
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f0f2f5; margin: 0; color: #333; height: 100vh; overflow: hidden; }
.main-container { display: flex; gap: 20px; padding: 20px; box-sizing: border-box; height: 100%; }

.control-panel { width: 360px; flex-shrink: 0; background: white; padding: 20px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); display: flex; flex-direction: column; box-sizing: border-box; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid #eaeaea; }
.panel-header h2 { margin: 0; font-size: 18px; color: #1a202c; font-weight: 700; }
.panel-header select { padding: 4px 8px; border-radius: 6px; border: 1px solid #cbd5e1; background: #f8fafc; outline: none; cursor: pointer; font-size: 12px; color: #475569; }

#pdfForm { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.form-scroll-area { flex: 1; overflow-y: auto; padding-right: 5px; margin-bottom: 10px; }
.action-area { flex-shrink: 0; padding-top: 10px; border-top: 1px solid #eee; }

.preview-panel { flex: 1; background: #e0e4e8; border-radius: 12px; display: flex; justify-content: center; align-items: center; padding: 20px; box-sizing: border-box; overflow: hidden; }
canvas, svg { background: white; box-shadow: 0 10px 40px rgba(0,0,0,0.15); max-width: 100%; max-height: 100%; object-fit: contain; }

.form-group { margin-bottom: 12px; }
.row { display: flex; gap: 10px; }
.col { flex: 1; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #555; }
select, input[type="number"], input[type="color"], textarea { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 6px; box-sizing: border-box; font-size: 14px; outline: none; }
select:focus, input:focus, textarea:focus { border-color: #2b6cb0; }
button { width: 100%; background: #2b6cb0; color: white; border: none; padding: 14px; border-radius: 8px; font-size: 16px; font-weight: bold; cursor: pointer; transition: 0.2s; }
button:hover { background: #2c5282; }

.stats { background: #edf2f7; padding: 12px; border-radius: 8px; font-size: 13px; color: #4a5568; line-height: 1.6; border: 1px solid #e2e8f0; margin-bottom: 15px;}
.hidden { display: none !important; }
hr { border: none; border-top: 1px solid #eee; margin: 15px 0; }

/* 字帖模式新增樣式 */
.mode-switch { display: flex; background: #e2e8f0; border-radius: 8px; padding: 4px; margin-bottom: 15px; }
.mode-btn { flex: 1; text-align: center; padding: 8px; font-size: 14px; font-weight: bold; cursor: pointer; border-radius: 6px; color: #4a5568; transition: 0.3s; }
.mode-btn.active { background: #fff; color: #2b6cb0; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.pagination-control { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,0.9); padding: 10px 20px; border-radius: 30px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 15px; z-index: 10; }
.pagination-control input[type="range"] { width: 200px; cursor: pointer; }
.pagination-control span { font-weight: bold; font-family: monospace; color: #2d3748; }

.wysiwyg-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.wysiwyg-element { position: absolute; pointer-events: auto; cursor: grab; border: 1px dashed transparent; transition: border 0.2s; }
.wysiwyg-element:hover { border-color: #3182ce; }
.wysiwyg-element.active { border: 2px solid #3182ce; background: rgba(49,130,206,0.1); }

.loading-modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.7); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 9999; color: white; }
.spinner { border: 5px solid rgba(255,255,255,0.3); border-top: 5px solid #fff; border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin-bottom: 20px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.warning-box { background: #fed7d7; color: #c53030; padding: 10px; border-radius: 6px; font-size: 13px; margin-bottom: 10px; border: 1px solid #feb2b2; display: none; }

.popup-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: flex-start; padding-top: 60px; z-index: 99990; }
.popup-dialog { background: white; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); max-width: 520px; width: 90%; max-height: 70vh; overflow-y: auto; animation: popupIn 0.25s ease; }
@keyframes popupIn { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: translateY(0); } }
.popup-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e2e8f0; }
.popup-header h3 { margin: 0; font-size: 16px; }
.popup-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #a0aec0; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; padding: 0; }
.popup-close:hover { background: #edf2f7; color: #4a5568; }
.popup-body { padding: 16px 20px; font-size: 14px; color: #4a5568; line-height: 1.8; white-space: pre-wrap; word-break: break-all; }
.popup-body.warn { color: #c05621; background: #fffaf0; }
.popup-body.error { color: #c53030; background: #fff5f5; }
.popup-body.info { color: #2b6cb0; background: #ebf8ff; }
.popup-footer { padding: 12px 20px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 8px; }
.popup-btn { width: auto; padding: 8px 24px; font-size: 14px; }

@media (max-width: 768px) {
    body { height: auto; overflow: auto; }
    .main-container { flex-direction: column; padding: 10px; height: auto; }
    .control-panel { width: 100%; height: auto; }
    .form-scroll-area { overflow-y: visible; }
    .preview-panel { width: 100%; min-height: 400px; order: -1; }
}