/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* 主容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.btn-secondary {
    background: #f0f2f5;
    color: #333;
}

.btn-secondary:hover {
    background: #e4e6eb;
}

.btn-small {
    padding: 4px 8px;
    font-size: 0.8rem;
}

/* 内容区域 */
.content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* 模块列表 */
.module-section,
.template-section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
}

.section-title {
    font-size: 1.3rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 模块列表 */
.module-list,
.template-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 模块项 */
.module-item,
.template-item {
    padding: 15px;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.module-item:hover,
.template-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.module-header,
.template-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.module-name,
.template-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.module-description,
.template-description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.module-actions,
.template-actions {
    display: flex;
    gap: 5px;
}

/* 配置面板 */
.config-panel {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
    margin-top: 20px;
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.config-title {
    font-size: 1.2rem;
    font-weight: 600;
}

/* 配置表单 */
.config-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.form-input,
.form-textarea,
.form-select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-color {
    width: 100%;
    height: 40px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.3rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.close-btn:hover {
    color: #333;
}

/* 表单底部 */
.form-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
}

/* 加载状态 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #667eea;
    font-size: 1.1rem;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .content {
        grid-template-columns: 1fr;
    }
    
    .config-form {
        grid-template-columns: 1fr;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}
/* Desktop template editor: presentation only; field names and canvas rendering stay intact. */
.template-workbench { min-width: 1000px; }
.template-workbench .container { padding: 0; }
.template-page-heading { margin: 26px 0 22px; }
.template-page-heading h1 { font-size: 26px; margin-bottom: 5px; }
.template-page-heading p { font-size: 13px; color: var(--muted); }
.template-workbench .template-section { border: 1px solid var(--line); box-shadow: none; }
.template-workbench .template-list { gap: 10px; }
.template-workbench .template-item { padding: 16px; background: #fff; border-color: var(--line); }
.template-workbench .template-item:hover { transform: none; box-shadow: none; border-color: #c9c2e4; }
.template-workbench .template-name { font-size: 15px; }
.template-workbench .module-description { font-size: 12px; margin: 0; color: var(--muted); }
.template-workbench .template-actions button:nth-child(2) { color: #ab474d; }
.template-editing .container > .content, .template-editing .template-page-heading { display: none; }
.template-workbench .config-panel { margin: 0 0 24px; border: 1px solid var(--line); border-radius: 10px; padding: 0; box-shadow: none; scroll-margin-top: 16px; }
.template-workbench .config-header { padding: 16px 22px; margin: 0; border-bottom: 1px solid var(--line); }
.template-workbench .config-title { font-size: 17px; }
.template-workbench .config-form { grid-template-columns: minmax(0,1fr) minmax(320px,.8fr); gap: 0; }
.template-workbench .config-left { padding: 18px; max-height: calc(100vh - 260px); min-height: 350px; overflow-y: auto; border-right: 1px solid var(--line); }
.template-config-group { margin-bottom: 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.template-config-group:last-child { margin-bottom: 0; }
.template-config-group > summary { padding: 12px 14px; cursor: pointer; color: #4b5264; font-size: 13px; font-weight: 600; }
.template-config-group[open] > summary { color: var(--accent); border-bottom: 1px solid #efedf6; }
.template-config-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; padding: 14px; }
.template-config-fields .form-group { min-width: 0; gap: 5px; }
.template-config-fields .form-group[hidden] { display: none !important; }
.template-config-fields .wide-field, .template-config-fields .effect-switch { grid-column: 1 / -1; }
.template-config-fields .effect-switch { padding-top: 5px; }
.template-config-fields .form-label { font-size: 12px; margin: 0; color: #62697a; }
.template-config-fields input, .template-config-fields select, .template-config-fields textarea { min-width: 0; max-width: 100%; font-size: 13px; }
.template-config-fields input:not([type=checkbox]):not([type=range]), .template-config-fields select { height: 34px; padding: 5px 8px; }
.template-config-fields input[type=color] { width: 100%; cursor: pointer; }
.template-config-fields input[type=range] { accent-color: var(--accent); padding: 0; width: 100%; }
.template-config-fields input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); }
.template-workbench .config-right { padding: 18px 24px; background: #fafbfc; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.template-workbench .config-right h3 { font-size: 13px; font-weight: 600; align-self: flex-start; color: #62697a; }
.template-preview-stage { width: 100%; display: flex; align-items: center; justify-content: center; }
.template-workbench #template-preview { display: block; height: min(440px, calc(100vh - 320px)) !important; width: auto !important; max-width: 100%; border: 1px solid #e0dfe6 !important; border-radius: 4px !important; box-shadow: 0 4px 18px #25293612 !important; }
.template-preview-spec { font-size: 11px; color: var(--muted); }
.template-workbench .config-form > .form-footer { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin: 0; padding: 14px 22px; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 10px 10px; }
.template-save-status { margin-right: auto; font-size: 12px; color: var(--muted); }
.template-save-status[data-dirty=true] { color: #956c24; }
