html, body {
    height: 100%;
    margin: 0;
    overflow: hidden; /* 防止整个页面滚动 */
    font-family: Arial, sans-serif;
}

body {
    display: flex;
    height: 100%;
}

/* 模块区域样式 */
#module-area {
    width: 20%;
    border-right: 1px solid #ccc;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 防止整体滚动 */
}

/* 分类选项卡容器 */
.category-tabs {
    display: flex;
    flex-wrap: wrap;
    background-color: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    padding: 5px 5px 0 5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* 分类选项卡 */
.category-tab {
    padding: 8px 12px;
    margin: 0 3px 5px 0;
    border-radius: 4px 4px 0 0;
    background-color: #e0e0e0;
    color: #555;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    user-select: none;
}

.category-tab:hover {
    background-color: #d0d0d0;
}

.category-tab.active {
    background-color: #4dabf7;
    color: white;
}

/* 模块容器 */
.blocks-container {
    padding: 10px;
    overflow-y: auto; /* 允许纵向滚动 */
    flex-grow: 1;
}

/* 编辑区域样式 */
#edit-area {
    width: 60%;
    border-right: 1px solid #ccc;
    padding: 10px;
    overflow-y: auto; /* 允许纵向滚动 */
}

/* 代码区域样式 - 重点优化 */
#code-area {
    width: 20%;
    min-width: 200px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    height: 100%; /* 确保高度填满 */
    overflow: hidden; /* 隐藏超出部分 */
}

/* 代码头部区域 */
.code-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 2px solid #e0e0e0;
    flex-shrink: 0; /* 防止被压缩 */
    flex-wrap: nowrap; /* 防止按钮换行 */
    gap: 8px; /* 添加间距 */
}

.code-header span {
    font-weight: 600;
    font-size: 16px;
    color: #333;
    margin-right: 10px;
    margin-bottom: 0;
    display: inline-block;
    vertical-align: middle;
    white-space: nowrap;
}

/* 代码内容区域 - 添加横向滚动 */
#generated-code {
    white-space: pre; /* 防止代码自动换行 */
    overflow-x: auto; /* 允许横向滚动 */
    overflow-y: auto; /* 允许纵向滚动 */
    flex-grow: 1; /* 填充剩余空间 */
    min-height: 0; /* 修复flex滚动问题 */
    background-color: #f8f8f8;
    padding: 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
}

/* 代码区按钮通用样式 */
.copy-btn, .info-btn, .save-btn, .load-btn, .lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    margin: 4px 4px 4px 0;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    height: 32px;
}

/* 复制按钮样式 */
.copy-btn {
    background-color: #4dabf7;
}

.copy-btn:hover {
    background-color: #339af0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 保存按钮样式 */
.save-btn {
    background-color: #40c057;
}

.save-btn:hover {
    background-color: #2f9e44;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 加载按钮样式 */
.load-btn {
    background-color: #7950f2;
}

.load-btn:hover {
    background-color: #6741d9;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 关于按钮样式 */
.info-btn {
    background-color: #fa5252;
}

.info-btn:hover {
    background-color: #e03131;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 语言切换按钮样式 */
.lang-btn {
    background-color: #4dabf7;
}

.lang-btn:hover {
    background-color: #339af0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 按钮图标通用样式 */
.copy-icon, .info-icon, .save-icon, .load-icon, .lang-icon {
    width: 16px;
    height: 16px;
    fill: white;
    margin-right: 8px;
    vertical-align: middle;
    display: inline-block;
}

/* 按钮文本 */
.btn-text {
    display: inline-block;
    color: white !important; /* 强制使用白色 */
    line-height: 16px;
    vertical-align: middle;
}

/* 按钮提示框 */
.tooltip {
    position: absolute;
    top: 40px; /* 改为顶部偏移，显示在按钮下方 */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100;
    pointer-events: none; /* 防止tooltip阻挡点击 */
}

.copy-btn:hover .tooltip,
.save-btn:hover .tooltip,
.load-btn:hover .tooltip,
.info-btn:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* 响应式设计 - 当宽度小于特定值时，隐藏按钮文本，只显示图标 */
@media (max-width: 600px) {
    .code-header {
        justify-content: space-between;
    }
    
    .copy-btn, .info-btn, .save-btn, .load-btn {
        padding: 6px;
        border-radius: 4px;
        min-width: 32px;
        width: 32px;
        height: 32px;
        margin: 0 2px;
    }
    
    .btn-text {
        display: none;
    }
    
    .copy-icon, .info-icon, .save-icon, .load-icon {
        margin-right: 0;
    }
}

/* 当代码区域宽度不足时，强制使用图标模式 */
.code-header.icon-mode {
    display: flex;
    gap: 6px;
}

.code-header.icon-mode span {
    margin-right: auto;
    text-align: left;
}

.code-header.icon-mode .copy-btn,
.code-header.icon-mode .info-btn,
.code-header.icon-mode .save-btn,
.code-header.icon-mode .load-btn {
    padding: 6px;
    border-radius: 4px;
    min-width: 32px;
    width: 32px;
    height: 32px;
    margin: 2px;
}

.code-header.icon-mode .btn-text {
    display: none;
}

.code-header.icon-mode .copy-icon,
.code-header.icon-mode .info-icon,
.code-header.icon-mode .save-icon,
.code-header.icon-mode .load-icon {
    margin-right: 0;
}

/* 当代码头部区域宽度不足以容纳所有按钮时自动切换为图标模式 */
@media (max-width: 450px) {
    .code-header {
        justify-content: space-between;
    }
    
    .code-header span {
        flex-shrink: 0;
        margin-right: 4px;
    }
    
    .code-header button {
        flex-shrink: 0;
    }
}

/* 代码块基本样式 */
.block {
    padding: 10px;
    margin: 5px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    cursor: move;
    position: relative;
    border-radius: 5px;
    transition: all 0.2s ease;
    overflow: hidden;
}

/* 不同类型块的样式 */
.math-block {
    border-left: 4px solid #4dabf7;
}

.text-block {
    border-left: 4px solid #40c057;
}

.control-block {
    border-left: 4px solid #f76707;
}

.variables-block {
    border-left: 4px solid #ae3ec9;
}

.functions-block {
    border-left: 4px solid #1098ad;
}

.logic-block {
    border-left: 4px solid #f59f00;
}

.array-block {
    border-left: 4px solid #7950f2;
}

.json-block {
    border-left: 4px solid #e64980;
}

.storage-block {
    border-left: 4px solid #15aabf;
}

.dom-block {
    border-left: 4px solid #fd7e14;
}

.async-block {
    border-left: 4px solid #20c997;
}

.block.dragging {
    opacity: 0.5;
}

.block.drag-over {
    background-color: #e0e0e0;
}

/* 触屏拖动图像 */
.touch-drag-image {
    pointer-events: none;
    position: fixed;
    z-index: 1000;
    opacity: 0.8;
    transform: translate(-50%, -50%);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    max-width: 300px;
    max-height: 200px;
    overflow: hidden;
    will-change: transform, left, top; /* 优化性能 */
    transition: transform 0.05s linear; /* 添加微小的过渡效果，使移动更平滑 */
    border-radius: 4px; /* 圆角边框 */
    background-color: #fff; /* 确保背景色 */
}

/* 输入容器 */
.input-container {
    margin: 8px 0;
    padding: 8px;
    border: 1px dashed #ccc;
    border-radius: 4px;
    min-height: 30px;
    background-color: rgba(0, 0, 0, 0.02);
    transition: all 0.2s ease;
}

.input-container:hover {
    border-color: #4dabf7;
    background-color: rgba(77, 171, 247, 0.05);
}

.input-container.drag-over {
    background-color: #e0e0e0;
}

/* 输入框样式 */
input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s ease;
    box-sizing: border-box; /* 确保padding不会增加宽度 */
}

input:focus {
    border-color: #4dabf7;
    box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.2);
    outline: none;
}

/* 删除按钮 */
.delete-button {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px; /* 增加按钮大小，提高可点击性 */
    height: 24px; /* 增加按钮大小，提高可点击性 */
    background-color: #ff4d4f;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0.8;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    z-index: 10; /* 确保删除按钮在最上层 */
    touch-action: none; /* 防止触摸事件引起页面滚动 */
}

.delete-button:hover {
    opacity: 1;
    background-color: #e03131;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* 快速选择按钮样式 */
.quick-select-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background-color: #4dabf7;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    z-index: 10;
    height: 24px;
}

.quick-select-btn:hover {
    background-color: #339af0;
}

/* 输入框包裹容器 */
.input-with-quickselect {
    position: relative;
}

.input-with-quickselect input {
    padding-right: 30px; /* 为按钮留出空间 */
}

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

/* 复制成功提示 */
.copy-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background-color: #40c057;
    color: white;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: fadeInOut 2s ease-in-out;
    z-index: 1000;
}

.type-label{
    color: #8f8e8e;
}
@keyframes fadeInOut {
    0% { opacity: 0; bottom: 10px; }
    20% { opacity: 1; bottom: 20px; }
    80% { opacity: 1; bottom: 20px; }
    100% { opacity: 0; bottom: 10px; }
}
/* 在文档2的CSS中添加以下样式 */
.vertical-resizer {
    width: 5px;
    background-color: #ccc;
    cursor: col-resize;
    position: relative;
    z-index: 10;
}

#module-area .delete-button{
    display: none;
}

.vertical-resizer:hover {
    background-color: #3b82f6;
}
/* 可嵌套区域样式 */
/* 可嵌套区域 */
.nested-container {
    min-height: 50px;
    border: 2px dashed #ddd;
    border-radius: 4px;
    padding: 8px;
    margin: 8px 0;
    transition: all 0.3s;
    background-color: #f8f9fa;
}

.nested-container:hover {
    border-color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.05);
}

/* 嵌套块 */
.nested-block {
    margin: 8px 0;
    padding: 10px;
    background-color: #e9ecef;
    border-left: 3px solid #3b82f6;
    position: relative;
    z-index: 1; /* 确保正确的层叠顺序 */
    touch-action: pan-x pan-y; /* 允许滚动但优化触摸体验 */
}

/* 深度指示器 */
.nest-indicator {
    color: #6c757d;
    font-size: 0.85em;
    margin-bottom: 5px;
}

/* 最大深度限制 */
.max-depth {
    background-color: #fff8f8;
    border-left-color: #ff6b6b;
}

.max-depth .nested-container {
    background-color: #ffebee;
    border-color: #ff6b6b;
    opacity: 0.6;
    cursor: not-allowed;
}

/* 嵌套层级视觉提示 */
.nested-block[data-nest-depth="1"] {
    border-left-width: 3px;
    padding-left: 12px;
}

.nested-block[data-nest-depth="2"] {
    border-left-width: 6px;
    padding-left: 15px;
}

.nested-block[data-nest-depth="3"] {
    border-left-width: 9px;
    padding-left: 18px;
}

.save-btn, .load-btn {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-right: 8px;
}

.save-btn {
    background-color: #10b981;
}

.save-btn:hover {
    background-color: #0da271;
}

.load-btn {
    background-color: #3b82f6;
}

.load-btn:hover {
    background-color: #2563eb;
}

.save-icon, .load-icon {
    width: 16px;
    height: 16px;
    fill: white;
    margin-right: 6px;
}

/* 通知样式 */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-width: 350px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.notification.success {
    background-color: #10b981;
    color: white;
}

.notification.error {
    background-color: #ef4444;
    color: white;
}

.notification.fade-out {
    opacity: 0;
}

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

.hidden {
    display: none !important;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

/* 本地操作按钮 */
.local-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    margin-right: 8px;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: 32px;
}

#localSaveButton {
    background-color: #10b981;
}

#localSaveButton:hover {
    background-color: #0da271;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

#localLoadButton {
    background-color: #3b82f6;
}

#localLoadButton:hover {
    background-color: #2563eb;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.local-action-button i {
    margin-right: 5px;
}

.close-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 130px);
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

/* 表单样式 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-input:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* 按钮样式 */
.modal-button {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.primary-button {
    background-color: #3b82f6;
    color: white;
}

.primary-button:hover {
    background-color: #2563eb;
}

.secondary-button {
    background-color: #e5e7eb;
    color: #374151;
}

.secondary-button:hover {
    background-color: #d1d5db;
}

/* 文件列表样式 */
.file-list {
    margin-top: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
}

.file-item {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.file-item:last-child {
    border-bottom: none;
}

.file-item:hover {
    background-color: #f9fafb;
}

.file-info {
    display: flex;
    align-items: center;
}

.file-icon {
    color: #3b82f6;
    margin-right: 10px;
    font-size: 18px;
}

.file-name {
    font-weight: 500;
    color: #333;
}

.file-date {
    font-size: 12px;
    color: #6b7280;
    margin-top: 3px;
}

.file-actions {
    display: flex;
}

.file-action-button {
    background: none;
    border: none;
    color: #3b82f6;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.file-action-button:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #6b7280;
}

/* 通知样式 */
#notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(0);
}

#notification.success {
    background-color: #10b981;
}

#notification.error {
    background-color: #ef4444;
}

#notification.hidden {
    opacity: 0;
    transform: translateY(20px);
}