/**
 * 统一脚本编辑器样式
 * ===========================================
 * 恢复使用原始对象脚本编辑器的样式设计
 */

/* 统一脚本编辑模态框 - 弹窗样式 */
#script-editor-modal {
    z-index: 16000;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0; /* 移除外围留白，避免出现厚边框效果 */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
}

/* 移除模糊效果 - 覆盖全局.modal样式 */
#script-editor-modal.modal {
    background-color: rgba(0, 0, 0, 0.5);
}

/* 默认隐藏并启用淡入淡出效果 */
#script-editor-modal {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

#script-editor-modal.modal-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* 脚本编辑模态框弹窗样式 */
#script-editor-modal .modal-content {
    width: 92vw;
    max-width: 1440px;
    min-width: 960px;
    height: 85vh;
    max-height: 85vh;
    min-height: 460px;
    display: flex;
    flex-direction: column;
    margin: auto;
    align-self: center;
    border-radius: 12px;
    overflow: hidden;
    background: var(--background-color, #ffffff);
    padding: 0; /* 覆盖全局 .modal-content 的 30px 内边距，避免形成宽边框视觉 */
    /* 仅保留细边框，去除厚重阴影 */
    border: 1px solid var(--border-color, #ddd);
    box-shadow: none !important; /* 覆盖全局 .modal-content 阴影 */
    transform: none; /* 覆盖全局 translateY(-20px) */
    outline: none; /* 取消聚焦时的外轮廓 */
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* 防止聚焦时出现额外外框（与 API 配置窗体一致） */
#script-editor-modal .modal-content:focus,
#script-editor-modal .modal-content:focus-within {
    outline: none;
    box-shadow: none;
}

#script-editor-modal.modal-visible .modal-content {
    opacity: 1;
}

#script-editor-modal .modal-header {
    background: var(--header-background, #f8f9fa);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #eee);
    margin: 0;
    border-radius: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
}

#script-editor-modal .script-language-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 24px;
    font-size: 12px;
    color: var(--text-light, #666);
}

#script-editor-modal .script-language-control label {
    font-weight: 600;
}

#script-editor-modal .script-language-control select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color, #ddd);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-color, #333);
    font-size: 12px;
}

#script-editor-modal .modal-header h3 {
    color: var(--text-color, #333);
    margin: 0;
    font-weight: 600;
    font-size: 18px;
}

#script-editor-modal .modal-header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

#script-editor-modal .modal-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-light, #666);
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    padding: 0;
}

#script-editor-modal .modal-btn:hover {
    background-color: var(--hover-background, #f0f0f0);
    border-color: var(--border-color, #ddd);
    color: var(--text-color, #333);
}

#script-editor-modal .modal-body {
    background: var(--background-color, #ffffff);
    flex: 1;
    display: flex;
    flex-direction: row;
    padding: 20px;
    height: 100%;
    min-height: 0;
    gap: 20px;
    overflow: hidden;
}

/* 编辑器容器背景 */
#script-editor-modal #script-content-editor {
    background: var(--input-background, #ffffff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    flex: 1;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    box-shadow: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#script-editor-modal #script-content-editor:focus-within {
    border-color: var(--primary-color, #007bff);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15);
}

#script-content-editor.cpp-mode .ace_error,
#script-content-editor.cpp-mode .ace_gutter-cell.ace_error,
#script-content-editor.cpp-mode .ace_warning,
#script-content-editor.cpp-mode .ace_gutter-cell.ace_warning {
    background-color: transparent !important;
    color: inherit !important;
    border-bottom: none !important;
    background-image: none !important;
    text-decoration: none !important;
}

#script-editor-modal .modal-close {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-light, #666);
    font-size: 18px;
    font-weight: 600;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    padding: 0;
}

#script-editor-modal .modal-close:hover {
    background-color: rgba(220, 53, 69, 0.12);
    color: #dc3545;
}

/* 元素信息样式 */
#script-editor-modal .script-info {
    padding: 10px;
    background-color: var(--color-bg-light);
    border-radius: 4px;
    margin-bottom: 15px;
    border: 1px solid var(--color-border-medium);
}

#script-editor-modal .element-info {
    color: var(--color-text-secondary);
    font-size: 14px;
}

#script-editor-modal .element-type-label {
    font-weight: bold;
    color: var(--color-text-primary);
}

/* 编辑区域容器（左侧） */
#script-editor-modal .editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* 编辑器区域 */
#script-editor-modal .editor-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin: 0;
    min-width: 0;
    overflow: hidden;
}

/* 输出区域 */
#script-editor-modal .output-section {
    display: flex;
    flex-direction: column;
    margin-top: 20px;
    flex-shrink: 0;
}

/* 区域标题头部 */
#script-editor-modal .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 0 4px;
}

#script-editor-modal .section-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 清空按钮样式 */
#script-editor-modal .clear-btn {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 4px 6px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

#script-editor-modal .clear-btn:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
    color: #ef4444;
    transform: scale(1.05);
}

#script-editor-modal .clear-btn svg {
    width: 14px;
    height: 14px;
}

/* 按钮组（右侧垂直布局） */
#script-editor-modal .button-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
    width: max-content;
    flex-shrink: 0;
    align-items: stretch;
}

#script-editor-modal .btn {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 6px 6px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--app-font-family);
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    font-size: 13px;
    font-weight: 500;
    width: auto;
    min-width: 0;
    text-align: left;
    min-height: 38px;
    text-transform: none;
    letter-spacing: normal;
    background: var(--input-background, #ffffff);
    color: var(--text-color, #333);
    box-shadow: none;
}

#script-editor-modal .btn:hover {
    background: var(--hover-background, #f0f0f0);
    border-color: var(--border-color, #ccc);
    color: var(--text-color, #222);
}

#script-editor-modal .btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

/* 统一的按钮色系（与 API 配置窗体一致） */
#script-editor-modal .btn-primary {
    background: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
    color: #ffffff;
}
#script-editor-modal .btn-primary:hover {
    background: #0056b3;
    border-color: #0056b3;
    color: #ffffff;
}

#script-editor-modal .btn-secondary {
    background: var(--secondary-color, #6c757d);
    border-color: var(--secondary-color, #6c757d);
    color: #ffffff;
}
#script-editor-modal .btn-secondary:hover {
    background: #545b62;
    border-color: #545b62;
}

#script-editor-modal .btn-danger {
    background: #dc3545;
    border-color: #dc3545;
    color: #ffffff;
}
#script-editor-modal .btn-danger:hover {
    background: #c82333;
    border-color: #c82333;
}

#script-editor-modal .btn-outline-primary {
    background: transparent;
    color: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
}
#script-editor-modal .btn-outline-primary:hover {
    background: rgba(0, 123, 255, 0.08);
    color: #0056b3;
    border-color: #0056b3;
}

/* 新增：无填充的灰色与红色轮廓按钮 */
#script-editor-modal .btn-outline-secondary {
    background: transparent;
    color: var(--secondary-color, #6c757d);
    border-color: var(--secondary-color, #6c757d);
}
#script-editor-modal .btn-outline-secondary:hover {
    background: rgba(108, 117, 125, 0.08);
    color: #545b62;
    border-color: #545b62;
}

#script-editor-modal .btn-outline-danger {
    background: transparent;
    color: #dc3545;
    border-color: #dc3545;
}
#script-editor-modal .btn-outline-danger:hover {
    background: rgba(220, 53, 69, 0.08);
    color: #c82333;
    border-color: #c82333;
}

/* SVG图标样式 */
#script-editor-modal .btn-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* 按钮文本样式 */
#script-editor-modal .btn-text {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    text-align: left;
}

#script-editor-modal #script-import-btn,
#script-editor-modal #script-clear-btn,
#script-editor-modal #script-example-btn {
    /* 使用无填充的灰色轮廓样式 */
    background: transparent;
    color: var(--secondary-color, #6c757d);
    border-color: var(--secondary-color, #6c757d);
}

#script-editor-modal #script-test-btn {
    /* 与 .btn-outline-primary 一致 */
    background: transparent;
    border-color: var(--primary-color, #007bff);
    color: var(--primary-color, #007bff);
}
#script-editor-modal #script-test-btn:hover {
    background: rgba(0, 123, 255, 0.08);
    border-color: #0056b3;
    color: #0056b3;
}

#script-editor-modal #script-save-btn {
    /* 使用无填充的主色轮廓 */
    background: transparent;
    border-color: var(--primary-color, #007bff);
    color: var(--primary-color, #007bff);
}

#script-editor-modal #script-save-btn:hover {
    background: rgba(0, 123, 255, 0.08);
    border-color: #0056b3;
    color: #0056b3;
}

#script-editor-modal #script-remove-btn {
    /* 使用无填充的危险色轮廓 */
    background: transparent;
    border-color: #dc3545;
    color: #dc3545;
}

#script-editor-modal #script-remove-btn:hover {
    background: rgba(220, 53, 69, 0.08);
    border-color: #c82333;
    color: #c82333;
}

/* 脚本输出区域 */
#script-editor-modal .script-output {
    background: var(--input-background, #ffffff) !important;
    border: 1px solid var(--border-color, #ddd) !important;
    border-radius: 8px !important;
    padding: 12px;
    height: 160px;
    overflow-y: auto;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    flex: 1;
    box-shadow: none;
    color: var(--text-color, #1e293b);
}

#script-editor-modal .script-output .output-message {
    margin: 3px 0;
    padding: 2px 0;
    line-height: 1.4;
}

#script-editor-modal .script-output .output-message.success {
    color: #059669;
    background: rgba(16, 185, 129, 0.08);
    border-left: 3px solid #10b981;
    padding: 6px 10px;
    border-radius: 6px;
    margin: 4px 0;
    font-weight: 500;
}

#script-editor-modal .script-output .output-message.error {
    color: #dc2626;
    background: rgba(239, 68, 68, 0.08);
    border-left: 3px solid #ef4444;
    padding: 6px 10px;
    border-radius: 6px;
    margin: 4px 0;
    font-weight: 500;
}

#script-editor-modal .script-output .output-message.warning {
    color: #d97706;
    background: rgba(245, 158, 11, 0.08);
    border-left: 3px solid #f59e0b;
    padding: 6px 10px;
    border-radius: 6px;
    margin: 4px 0;
    font-weight: 500;
}

#script-editor-modal .script-output .output-message.info {
    color: var(--primary-color, #007bff);
    background: rgba(0, 123, 255, 0.1);
    border-left: 3px solid var(--primary-color, #007bff);
    padding: 6px 10px;
    border-radius: 6px;
    margin: 4px 0;
    font-weight: 500;
}

/* 脚本编辑器容器 */
#script-editor-modal .script-editor-container {
    position: relative;
    display: flex;
    flex-direction: row;
    flex: 1;
    height: 100%;
    padding: 0;
    gap: 20px;
    min-width: 0;
    overflow: hidden;
}

/* 文本区域样式（作为Ace编辑器的后备） */
#script-editor-modal textarea {
    background-color: #ffffff !important;
    color: #1e293b !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
    padding: 8px !important;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 16px !important;
    font-weight: 500 !important;
    resize: vertical;
    line-height: 1.6 !important;
}

/* Ace编辑器特定样式 */
#script-editor-modal .ace_editor {
    background-color: #ffffff !important;
    color: #1e293b !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    font-family: 'Fira Code', 'Courier New', monospace !important;
    line-height: 1.6 !important;
}

/* Ace编辑器整体容器 - 设置内边距 */
#script-editor-modal .ace_editor {
    padding: 8px !important;
    box-sizing: border-box !important;
    border-radius: 10px !important;
}

/* 文本层 - 字体样式 */
#script-editor-modal .ace_editor .ace_text-layer {
    font-size: 16px !important;
    font-weight: 600 !important;
    font-family: 'Fira Code', 'Courier New', monospace !important;
    line-height: 1.6 !important;
}

#script-editor-modal .ace_editor .ace_line {
    font-size: 16px !important;
    font-weight: 600 !important;
    font-family: 'Fira Code', 'Courier New', monospace !important;
    line-height: 1.6 !important;
}

/* 覆盖Ace编辑器的所有token样式 */
#script-editor-modal .ace_editor .ace_keyword,
#script-editor-modal .ace_editor .ace_string,
#script-editor-modal .ace_editor .ace_comment,
#script-editor-modal .ace_editor .ace_constant,
#script-editor-modal .ace_editor .ace_numeric,
#script-editor-modal .ace_editor .ace_variable,
#script-editor-modal .ace_editor .ace_identifier,
#script-editor-modal .ace_editor .ace_operator,
#script-editor-modal .ace_editor .ace_punctuation,
#script-editor-modal .ace_editor .ace_paren {
    font-weight: 600 !important;
    font-size: 16px !important;
    font-family: 'Fira Code', 'Courier New', monospace !important;
    line-height: 1.6 !important;
}

/* 强制覆盖Ace编辑器的所有文本样式 */
#script-editor-modal .ace_editor,
#script-editor-modal .ace_editor *,
#script-editor-modal .ace_editor .ace_scroller,
#script-editor-modal .ace_editor .ace_content,
#script-editor-modal .ace_editor .ace_text-layer,
#script-editor-modal .ace_editor .ace_line,
#script-editor-modal .ace_editor .ace_line span {
    font-weight: 600 !important;
    font-size: 16px !important;
    font-family: 'Fira Code', 'Courier New', monospace !important;
    line-height: 1.6 !important;
}

/* 确保Ace编辑器可以正常交互 */
#script-editor-modal .ace_editor,
#script-editor-modal .ace_editor *,
#script-editor-modal .ace_scroller,
#script-editor-modal .ace_content,
#script-editor-modal .ace_text-layer {
    pointer-events: auto !important;
    user-select: auto !important;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    #script-editor-modal .modal-content {
        width: 95vw;
        height: 90vh;
        min-width: 600px;
        min-height: 500px;
    }
    
    #script-editor-modal .script-editor-container {
        flex-direction: column;
        gap: 15px;
    }
    
    #script-editor-modal .button-group {
        flex-direction: row;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    #script-editor-modal .btn {
        flex: 1;
        min-width: 70px;
        max-width: 90px;
        flex-direction: row;
        gap: 6px;
        min-height: 36px;
    }
}

@media (max-width: 768px) {
    #script-editor-modal .modal-content {
        width: 98vw;
        height: 95vh;
        min-width: 400px;
        min-height: 400px;
        border-radius: 12px !important;
    }
    
    #script-editor-modal .modal-header {
        padding: 8px 10px !important;
    }
    
    #script-editor-modal .modal-body {
        padding: 8px 10px !important;
    }
    
    #script-editor-modal .button-group {
        flex-direction: column;
        gap: 8px;
    }
    
    #script-editor-modal .btn {
        width: 100%;
        max-width: none;
        flex-direction: row;
        gap: 8px;
        min-height: 40px;
    }
    
    #script-editor-modal .script-output {
        height: 120px;
    }
}

@media (max-width: 480px) {
    #script-editor-modal {
        padding: 0;
    }

    #script-editor-modal .modal-content {
        width: 100vw;
        height: 100vh;
        min-width: unset;
        min-height: unset;
        border-radius: 0 !important;
    }
}

/* ========================================
 * 词同选中高亮（Ace）
 * 让与当前选中单词相同的词更加醒目（由灰色改为彩色）
 * - .ace_selection        当前实际选区
 * - .ace_selected-word    同词高亮（当光标选中单词时出现）
 * ======================================== */

/* 通用基础样式（两种主题共享的轮廓/圆角设定） */
#script-editor-modal .ace_editor .ace_marker-layer .ace_selection,
#script-editor-modal .ace_editor .ace_marker-layer .ace_selected-word {
    border-radius: 3px !important;
}

/* 亮色主题下的高亮色（更鲜明） */
[data-theme="light"] #script-editor-modal .ace_editor .ace_marker-layer .ace_selection {
    background: rgba(59, 130, 246, 0.35) !important; /* 蓝色：当前选区 */
}

[data-theme="light"] #script-editor-modal .ace_editor .ace_marker-layer .ace_selected-word {
    background: rgba(251, 191, 36, 0.35) !important; /* 琥珀色：同词高亮 */
    box-shadow: inset 0 0 0 2px rgba(245, 158, 11, 0.75) !important; /* 增加边缘对比 */
}

/* 暗色主题下的高亮色（在深背景上保持对比） */
[data-theme="dark"] #script-editor-modal .ace_editor .ace_marker-layer .ace_selection {
    background: rgba(99, 102, 241, 0.40) !important; /* 靛蓝：当前选区 */
}

[data-theme="dark"] #script-editor-modal .ace_editor .ace_marker-layer .ace_selected-word {
    background: rgba(34, 197, 94, 0.35) !important;  /* 绿色：同词高亮 */
    box-shadow: inset 0 0 0 2px rgba(16, 185, 129, 0.8) !important;  /* 边缘描边 */
}

/* 高对比主题（如启用）时进一步增强可见性） */
[data-theme="high-contrast"] #script-editor-modal .ace_editor .ace_marker-layer .ace_selection {
    background: rgba(59, 130, 246, 0.55) !important;
}

[data-theme="high-contrast"] #script-editor-modal .ace_editor .ace_marker-layer .ace_selected-word {
    background: rgba(255, 99, 132, 0.45) !important; /* 粉红/红：同词高亮更醒目 */
    box-shadow: inset 0 0 0 2px rgba(255, 99, 132, 0.95) !important;
}

/* 光标颜色稍作强化，便于在彩色高亮中定位 */
#script-editor-modal .ace_editor .ace_cursor {
    border-left: 2px solid var(--primary-color, #007bff) !important;
}

/* ========================================
 * 黑板面板样式
 * ======================================== */

/* 按钮间隔样式 */
.modal-btn-gap {
    margin-right: 8px;
}

#script-blackboard-toggle:hover,
#script-editor-modal .modal-btn:hover {
    background-color: var(--hover-background, #f0f0f0);
    border-color: var(--border-color, #ddd);
    color: var(--text-color, #333);
}

#script-editor-modal .modal-btn svg {
    width: 16px;
    height: 16px;
}

/* 黑板面板主容器 */
.script-blackboard-panel,
.script-message-panel,
.script-ai-panel {
    width: 320px;
    background: var(--background-color, #ffffff);
    border: none;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    margin-left: 16px;
    flex-shrink: 0;
    /* Ensure the inner content area can calculate height and scroll within the modal */
    height: 100%;
    min-height: 0; /* critical for flex children with overflow to work in some browsers */
    box-shadow: none;
    transition: all 0.3s ease;
    overflow: hidden;
}

.script-blackboard-panel.collapsed,
.script-message-panel.collapsed,
.script-ai-panel.collapsed {
    width: 0;
    margin-left: 0;
    padding: 0;
    border: none;
    opacity: 0;
}

/* 黑板面板头部 */
.blackboard-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--header-background, #f8f9fa);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.blackboard-panel-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.blackboard-panel-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 6px;
}

.blackboard-panel-header h4 svg {
    width: 16px;
    height: 16px;
    color: var(--primary-color, #007bff);
}

/* 内联统计信息样式 */
.blackboard-panel-stats-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
}

#script-editor-modal .blackboard-panel-stats-inline .stat-badge {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
}

#script-editor-modal .blackboard-panel-stats-inline .stat-badge .stat-label {
    font-weight: 500;
    color: #6b7280;
}

#script-editor-modal .blackboard-panel-stats-inline .stat-badge .stat-value {
    font-weight: 700;
    font-family: 'Fira Code', monospace;
    color: #1f2937;
}

[data-theme="light"] #script-editor-modal .blackboard-panel-stats-inline .stat-badge {
    background: #f3f4f6;
    border-color: #d1d5db;
}

[data-theme="light"] #script-editor-modal .blackboard-panel-stats-inline .stat-badge .stat-label {
    color: #6b7280;
}

[data-theme="light"] #script-editor-modal .blackboard-panel-stats-inline .stat-badge .stat-value {
    color: #1f2937;
}

[data-theme="dark"] #script-editor-modal .blackboard-panel-stats-inline .stat-badge {
    background: #2a2a2a;
    border: 1px solid #444;
}
[data-theme="dark"] #script-editor-modal .blackboard-panel-stats-inline .stat-badge .stat-label {
    color: #9ca3af;
}
[data-theme="dark"] #script-editor-modal .blackboard-panel-stats-inline .stat-badge .stat-value {
    color: #e5e7eb;
}

.blackboard-panel-collapse {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    color: #6b7280;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.blackboard-panel-collapse:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

.blackboard-panel-collapse svg {
    width: 14px;
    height: 14px;
}

.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--header-background, #f8f9fa);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.ai-panel-header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.ai-panel-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.ai-panel-context {
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-panel-collapse {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    color: #6b7280;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.ai-panel-collapse:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

.ai-panel-toolbar {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color, #eef2f7);
    background: rgba(59, 130, 246, 0.03);
}

.ai-panel-status {
    font-size: 12px;
    line-height: 1.5;
    color: #475569;
}

.ai-panel-status[data-state="running"] {
    color: #2563eb;
}

.ai-panel-status[data-state="success"] {
    color: #059669;
}

.ai-panel-status[data-state="warning"] {
    color: #d97706;
}

.ai-panel-status[data-state="error"] {
    color: #dc2626;
}

.ai-panel-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-panel-empty-state {
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #64748b;
    gap: 10px;
}

.ai-message {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-message-user {
    background: rgba(59, 130, 246, 0.05);
    border-color: rgba(59, 130, 246, 0.18);
}

.ai-message-assistant {
    background: rgba(15, 23, 42, 0.02);
}

#script-editor-modal .ai-message-role {
    font-size: 11px !important;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #64748b;
}

#script-editor-modal .ai-message-body,
#script-editor-modal .ai-message-meta,
#script-editor-modal .ai-message-note {
    font-size: 12px !important;
    line-height: 1.6;
    color: #334155;
}

#script-editor-modal .ai-message-meta {
    color: #64748b;
}

.ai-message-notes {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-message-note::before {
    content: "• ";
}

#script-editor-modal .ai-message-script {
    margin: 0;
    padding: 10px;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 12px !important;
    line-height: 1.5;
    overflow-x: auto;
}

.ai-panel-input {
    border-top: 1px solid var(--border-color, #e2e8f0);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#script-editor-modal #script-ai-prompt {
    width: 100%;
    min-height: 84px;
    resize: vertical;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 10px;
    font-family: var(--app-font-family);
    font-size: 13px !important;
    line-height: 1.5;
    color: #1f2937;
    background: #fff;
    box-sizing: border-box;
}

#script-editor-modal #script-ai-prompt:focus {
    outline: none;
    border-color: var(--primary-color, #007bff);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.12);
}

#script-editor-modal .ai-panel-empty-state,
#script-editor-modal .ai-panel-empty-state p,
#script-editor-modal .ai-panel-status,
#script-editor-modal .ai-panel-context {
    font-size: 12px !important;
}

.ai-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-panel-actions .btn {
    min-height: 34px;
}

/* 黑板统计信息 - 已废弃，统计信息已移至标题栏 */
/*
.blackboard-panel-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px 16px;
    background: #fafafa;
    border-bottom: 1px solid #e5e7eb;
}

.script-stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.script-stat-label {
    font-size: 10px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.script-stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color, #007bff);
    font-family: 'Fira Code', monospace;
}
*/

/* 黑板工具栏 */
.blackboard-panel-toolbar {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    background: var(--background-color, #ffffff);
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.blackboard-filter {
    flex: 1;
    padding: 4px 8px;
    background: var(--input-background, #f9fafb);
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    color: #374151;
    font-size: 12px;
    line-height: 1.4;
    outline: none;
    transition: all 0.2s;
}

#script-message-filter.blackboard-filter,
#script-blackboard-filter.blackboard-filter {
    font-size: 12px;
    line-height: 1.4;
}

.blackboard-filter::placeholder {
    color: #9ca3af;
}

.blackboard-filter:focus {
    border-color: var(--primary-color, #007bff);
    background: var(--background-color, #ffffff);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.12);
}

.blackboard-panel-btn {
    padding: 4px;
    min-width: 28px;
    height: 28px;
    background: var(--input-background, #f9fafb);
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.blackboard-panel-btn svg {
    width: 14px;
    height: 14px;
}

.blackboard-panel-btn:hover {
    background: var(--hover-background, #f0f0f0);
    border-color: var(--primary-color, #007bff);
    color: var(--primary-color, #007bff);
}

#script-message-clear {
    color: #dc2626;
    border-color: #fca5a5;
}

#script-message-clear:hover {
    background: rgba(220, 38, 38, 0.08);
    border-color: #dc2626;
    color: #b91c1c;
}

[data-theme="dark"] .blackboard-filter {
    background: #1f2937;
    border-color: #374151;
    color: #f3f4f6;
    font-size: 12px;
}

[data-theme="dark"] .blackboard-filter::placeholder {
    color: #6b7280;
}

[data-theme="dark"] .blackboard-panel-btn {
    background: #1f2937;
    border-color: #374151;
    color: #d1d5db;
}

[data-theme="dark"] .blackboard-panel-btn:hover {
    background: #2d3748;
    border-color: var(--primary-color, #3b82f6);
    color: var(--primary-color, #3b82f6);
}

[data-theme="dark"] #script-message-clear {
    color: #f87171;
    border-color: #b91c1c;
}

[data-theme="dark"] #script-message-clear:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: #ef4444;
    color: #fca5a5;
}

/* 黑板内容区 */
.blackboard-panel-content {
    flex: 1;
    overflow-y: auto; /* enable vertical scrolling for long content */
    min-height: 0;    /* avoid flex min-content sizing from preventing scroll */
    padding: 12px 16px;
    font-size: 12px;
    line-height: 1.5;
    background: #ffffff;
}

/* 空状态 */
.blackboard-panel-content .blackboard-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    text-align: center;
    gap: 8px;
}

.blackboard-panel-content .blackboard-empty-state svg {
    opacity: 0.3;
}

.blackboard-panel-content .blackboard-empty-state p {
    font-size: 13px;
    margin: 0;
}

/* JSON树样式（复用主黑板查看器样式） */
.blackboard-panel-content .json-tree {
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 11px;
}

.blackboard-panel-content .json-node {
    margin: 2px 0;
}

.blackboard-panel-content .json-node-header {
    display: flex;
    align-items: center;
    padding: 3px 0;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s;
}

.blackboard-panel-content .json-node-header:hover {
    background: rgba(59, 130, 246, 0.05);
}

.blackboard-panel-content .json-indent {
    display: inline-block;
    flex-shrink: 0;
}

.blackboard-panel-content .json-toggle {
    width: 14px;
    text-align: center;
    color: #9ca3af;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.blackboard-panel-content .json-toggle.collapsed {
    transform: rotate(-90deg);
}

.blackboard-panel-content .json-toggle-placeholder {
    width: 14px;
    flex-shrink: 0;
}

.blackboard-panel-content .json-key {
    color: #0451a5;
    margin-right: 4px;
    font-weight: 500;
}

.blackboard-panel-content .json-colon {
    color: #6b7280;
    margin-right: 6px;
}

.blackboard-panel-content .json-value {
    word-break: break-all;
}

.blackboard-panel-content .json-string {
    color: #a31515;
}

.blackboard-panel-content .json-number {
    color: #098658;
}

.blackboard-panel-content .json-boolean {
    color: #0000ff;
    font-weight: 600;
}

.blackboard-panel-content .json-null {
    color: #808080;
    font-style: italic;
}

.blackboard-panel-content .json-collapsed-hint {
    color: #9ca3af;
    font-style: italic;
    opacity: 0.7;
}

.blackboard-panel-content .json-empty {
    color: #9ca3af;
    opacity: 0.5;
}

/* 滚动条样式 */
.blackboard-panel-content::-webkit-scrollbar {
    width: 6px;
}

.blackboard-panel-content::-webkit-scrollbar-track {
    background: #f9fafb;
}

.blackboard-panel-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.blackboard-panel-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.message-panel-channel {
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 14px;
}

.message-panel-channel:last-child {
    border-bottom: none;
}

.message-panel-channel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.message-panel-channel-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
}

.message-panel-channel-count {
    font-size: 12px;
    color: #2563eb;
    background: rgba(37, 99, 235, 0.1);
    padding: 2px 8px;
    border-radius: 999px;
}

.message-panel-channel-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}

.message-panel-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 10px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.message-panel-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message-panel-item-type {
    font-size: 12px;
    font-weight: 600;
    color: #047857;
    background: rgba(16, 185, 129, 0.12);
    padding: 2px 6px;
    border-radius: 6px;
}

.message-panel-item-time {
    font-size: 12px;
    color: #6b7280;
}

.message-panel-item-meta-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
    color: #4b5563;
}

.message-panel-item-tags {
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
    padding: 2px 6px;
    border-radius: 6px;
}

.message-panel-item-meta {
    color: #6b7280;
}

.message-panel-item-body {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 6px;
    padding: 8px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
    color: #1f2937;
    border: 1px solid #e5e7eb;
}

.message-panel-item-empty {
    text-align: center;
    color: #6b7280;
    padding: 12px 0;
    font-size: 12px;
}

/* 响应式调整 */
@media (max-width: 1024px) {
    .script-blackboard-panel,
    .script-message-panel,
    .script-ai-panel {
        width: 280px;
    }
}

/* 亮色主题 */
[data-theme="light"] .message-panel-channel {
    border-color: #e5e7eb;
    background: #ffffff;
}

[data-theme="light"] .message-panel-channel-body {
    background: #f8fafc;
}

[data-theme="light"] .message-panel-item {
    border-color: #e2e8f0;
    background: #f8fafc;
    color: #1f2937;
}

[data-theme="light"] .message-panel-item-time {
    color: #64748b;
}

[data-theme="light"] .message-panel-item-body {
    background: #ffffff;
    border-color: #cbd5f5;
    color: #1f2937;
}

[data-theme="light"] .message-panel-item-meta-group {
    color: #475569;
}

[data-theme="light"] .message-panel-item-tags {
    background: rgba(59, 130, 246, 0.12);
    color: #1d4ed8;
}

/* 深色主题 */
[data-theme="dark"] .message-panel-channel {
    border-color: rgba(148, 163, 184, 0.18);
    background: rgba(17, 24, 39, 0.6);
}

[data-theme="dark"] .message-panel-channel-body {
    background: rgba(15, 23, 42, 0.55);
}

[data-theme="dark"] .message-panel-item {
    border-color: rgba(148, 163, 184, 0.18);
    background: rgba(30, 41, 59, 0.7);
    color: #e2e8f0;
}

[data-theme="dark"] .message-panel-item-time {
    color: #cbd5f5;
}

[data-theme="dark"] .message-panel-item-body {
    background: rgba(17, 24, 39, 0.8);
    border-color: rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
}

[data-theme="dark"] .message-panel-item-meta-group {
    color: #a5b4fc;
}

[data-theme="dark"] .message-panel-item-tags {
    background: rgba(96, 165, 250, 0.2);
    color: #bfdbfe;
}
/* ========================================
   测试输出侧边栏样式
   ======================================== */

/* 输出面板容器 */
.script-output-panel {
    width: 320px;
    background: var(--background-color, #ffffff);
    border: none;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    margin-left: 16px;
    flex-shrink: 0;
    box-shadow: none;
    transition: all 0.3s ease;
    overflow: hidden;
}

.script-output-panel.collapsed {
    width: 0;
    margin-left: 0;
    padding: 0;
    border: none;
    opacity: 0;
}

/* 输出面板头部 */
.output-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--header-background, #f8f9fa);
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}

.output-panel-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color, #333);
    display: flex;
    align-items: center;
    gap: 8px;
}

.output-panel-header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.output-panel-collapse {
    background: none;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    color: var(--text-light, #666);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    padding: 0;
}

.output-panel-collapse:hover {
    background-color: var(--hover-background, #f0f0f0);
    border-color: var(--border-color, #ccc);
    color: var(--text-color, #333);
}

.output-panel-btn {
    background: none;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    color: var(--text-light, #666);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.output-panel-btn:hover {
    background-color: var(--hover-background, #f0f0f0);
    border-color: var(--border-color, #ccc);
    color: var(--text-color, #333);
}

.output-panel-btn:active {
    transform: scale(0.95);
}

/* 输出内容区域 */
.output-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--background-color, #ffffff);
}

/* 空状态样式 */
.output-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    text-align: center;
}

.output-empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.output-empty-state p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
}

/* 输出消息样式 */
.output-panel-content .output-message {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    border-left: 3px solid;
}

.output-panel-content .output-message.success {
    background: #f0fdf4;
    border-left-color: #22c55e;
    color: #166534;
}

.output-panel-content .output-message.error {
    background: #fef2f2;
    border-left-color: #ef4444;
    color: #991b1b;
}

.output-panel-content .output-message.warning {
    background: #fef3c7;
    border-left-color: #f59e0b;
    color: #92400e;
}

.output-panel-content .output-message.info {
    background: #eff6ff;
    border-left-color: var(--primary-color, #007bff);
    color: #1e40af;
}

/* 滚动条样式 */
.output-panel-content::-webkit-scrollbar {
    width: 8px;
}

.output-panel-content::-webkit-scrollbar-track {
    background: #f9fafb;
}

.output-panel-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.output-panel-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 响应式调整 */
@media (max-width: 1024px) {
    .script-output-panel {
        width: 320px;
    }
}
