/**
 * 流程图编辑器主题样式
 * 版本：20251211_v1 - 修复科幻/黑夜模式下节点文字颜色被全局样式覆盖的问题
 * 完善三种主题模式适配（白天、黑夜、科幻）
 */

/* ========== 页面头部 ========== */
.flowchart-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 0;
    border-radius: 0 0 15px 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.flowchart-header h2 {
    color: white !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 0.5rem;
    font-size: 1.75rem;
    font-weight: 600;
}

.flowchart-header .subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    margin-bottom: 0;
}

/* 科幻模式 - 页面头部 */
body.scifi-mode .flowchart-header,
body.mode-scifi .flowchart-header {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.3) 0%, rgba(0, 136, 170, 0.3) 100%);
    border-bottom: 2px solid rgba(100, 200, 255, 0.3);
    box-shadow: 0 4px 20px rgba(100, 200, 255, 0.2);
}

body.scifi-mode .flowchart-header h2,
body.mode-scifi .flowchart-header h2 {
    text-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
}

/* 黑夜模式 - 页面头部 */
body.dark-mode .flowchart-header,
body.mode-dark .flowchart-header {
    background: linear-gradient(135deg, #343a40 0%, #2c3138 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ========== 主容器 ========== */
.flowchart-main-container {
    padding: 2rem 0;
    background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
    min-height: calc(100vh - 200px);
}

/* 移除容器内边距，实现全宽布局 */
.flowchart-main-container .container-fluid {
    padding-left: 0;
    padding-right: 0;
}

body.dark-mode .flowchart-main-container,
body.mode-dark .flowchart-main-container {
    background: linear-gradient(180deg, #2c3138 0%, #1a1d23 100%);
}

.flowchart-container {
    display: flex;
    gap: 0;
    height: calc(75vh * 1.5);
    /* 增加50%高度 */
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

body.dark-mode .flowchart-container,
body.mode-dark .flowchart-container {
    background: #343a40;
    box-shadow: 0 8px 32px rgba(255, 255, 255, 0.05);
}

/* ========== 侧边栏 ========== */
.flowchart-sidebar {
    width: 300px;
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 1.5rem;
    overflow-y: auto;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
}

/* 侧边栏收起状态 - 使用width变化而非负margin，避免内容移位 */
.flowchart-sidebar.collapsed-menu {
    width: 0;
    padding: 0;
    overflow: hidden;
    border-right: none;
}

body.dark-mode .flowchart-sidebar,
body.mode-dark .flowchart-sidebar {
    background: linear-gradient(180deg, #2c3138 0%, #1f2429 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

/* 全屏模式 */
.flowchart-container.fullscreen-mode .flowchart-sidebar {
    margin-left: -300px;
    width: 0;
}

.flowchart-container.fullscreen-mode .templates-bar {
    display: none;
}

.flowchart-container.fullscreen-mode .flowchart-canvas {
    margin-top: 100px;
    /* 全屏时减少上边距 */
}

/* 侧边栏收起按钮 */
.sidebar-toggle-btn {
    position: absolute;
    top: 50%;
    right: -15px;
    transform: translateY(-50%);
    width: 30px;
    height: 60px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    transition: all 0.3s ease;
}

.sidebar-toggle-btn:hover {
    background: #764ba2;
    width: 35px;
}

.sidebar-toggle-btn i {
    transition: transform 0.3s ease;
}

/* 展开按钮（侧边栏收起时显示） */
#sidebarExpandBtn {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 0 8px 8px 0;
    z-index: 1001;
}

#sidebarExpandBtn i {
    transform: rotate(0deg);
}

/* 顶部工具栏区域 - 固定在canvas-wrapper内，不受侧边栏影响 */
.top-toolbar-area {
    position: absolute;
    top: 0;
    left: 0;
    right: 80px;
    /* 为右侧按钮留空间 */
    background: white;
    border-bottom: 2px solid #e9ecef;
    padding: 0.75rem 1rem;
    z-index: 100;
    width: calc(100% - 80px);
    /* 明确设置宽度，确保不超出 */
    box-sizing: border-box;
    /* 包含padding和border */
}

/* 确保工具栏始终在wrapper内可见 */
.flowchart-canvas-wrapper {
    position: relative;
    /* 确保top-toolbar-area相对于wrapper定位 */
    overflow: visible;
    /* 允许工具栏显示 */
}

body.dark-mode .top-toolbar-area,
body.mode-dark .top-toolbar-area {
    background: #343a40;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* 主工具行：图形工具 + 模板TAB同行显示 */
.toolbar-main-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #e9ecef;
    flex-wrap: wrap;
}

/* 工具栏标签 */
.toolbar-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

body.dark-mode .toolbar-label,
body.mode-dark .toolbar-label {
    color: #a8b3cf;
}

body.scifi-mode .toolbar-label,
body.mode-scifi .toolbar-label {
    color: #00d9ff;
}

/* 图形工具栏（一行） */
.shape-tools-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* 模板TAB容器 */
.template-tabs-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

/* 模板TAB组 */
.template-tabs {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

/* 单个TAB按钮 */
.template-tab {
    padding: 0.4rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    background: #f8f9fa;
    color: #495057;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.template-tab:hover {
    border-color: #667eea;
    background: #e7f0ff;
    color: #667eea;
    transform: translateY(-1px);
}

.template-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.template-tab i {
    font-size: 0.7rem;
}

/* 黑夜模式 - TAB */
body.dark-mode .template-tab,
body.mode-dark .template-tab {
    background: #2c3138;
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8f9fa;
}

body.dark-mode .template-tab:hover,
body.mode-dark .template-tab:hover {
    background: #3a3f47;
    border-color: #667eea;
    color: #a8b3cf;
}

body.dark-mode .template-tab.active,
body.mode-dark .template-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

body.dark-mode .toolbar-main-row,
body.mode-dark .toolbar-main-row {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* 科幻模式 - TAB */
body.scifi-mode .template-tab,
body.mode-scifi .template-tab {
    background: rgba(13, 13, 26, 0.8);
    border-color: rgba(100, 200, 255, 0.2);
    color: #66b3ff;
}

body.scifi-mode .template-tab:hover,
body.mode-scifi .template-tab:hover {
    background: rgba(0, 217, 255, 0.15);
    border-color: rgba(100, 200, 255, 0.5);
    color: #78c5ff;
    box-shadow: 0 0 10px rgba(100, 200, 255, 0.2);
}

body.scifi-mode .template-tab.active,
body.mode-scifi .template-tab.active {
    background: linear-gradient(135deg, #00d9ff 0%, #0088aa 100%);
    color: #0a1929;
    border-color: transparent;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.4);
}

body.scifi-mode .toolbar-main-row,
body.mode-scifi .toolbar-main-row {
    border-bottom-color: rgba(100, 200, 255, 0.3);
}

.shape-tool-btn {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.shape-tool-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.shape-tool-btn i {
    font-size: 1.3rem;
}

/* 模板库网格 */
.templates-bar {
    max-height: 120px;
    /* 减小高度，TAB已在上方，只需显示当前分类模板 */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
    /* 为滚动条留出空间 */
    /* 美化滚动条 */
    scrollbar-width: thin;
    scrollbar-color: #667eea #f1f1f1;
}

.templates-bar::-webkit-scrollbar {
    width: 8px;
}

.templates-bar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.templates-bar::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.templates-bar::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

body.dark-mode .templates-bar::-webkit-scrollbar-track,
body.mode-dark .templates-bar::-webkit-scrollbar-track {
    background: #2c3138;
}

body.dark-mode .templates-bar::-webkit-scrollbar-thumb,
body.mode-dark .templates-bar::-webkit-scrollbar-thumb {
    background: #667eea;
}

.templates-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.template-card-mini {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
    white-space: nowrap;
}

.template-card-mini:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.template-card-mini .badge {
    font-size: 0.65rem;
    margin-left: 0.25rem;
}

/* 内联属性面板 */
.properties-panel-inline {
    padding: 0;
}

.properties-panel-inline .form-label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.properties-panel-inline .form-control,
.properties-panel-inline .form-select {
    font-size: 0.8rem;
}

.form-control-color {
    width: 60px;
    height: 32px;
    padding: 0.2rem;
}

.sidebar-section {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.sidebar-section:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

body.dark-mode .sidebar-section,
body.mode-dark .sidebar-section {
    background: #3a3f47;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
}

.sidebar-section h4:hover {
    color: #667eea;
}

body.dark-mode .sidebar-section h4,
body.mode-dark .sidebar-section h4 {
    color: #f8f9fa;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.sidebar-section h4 .title-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-section h4 .title-left i {
    color: #667eea;
    font-size: 1.1rem;
}

.sidebar-section h4 .toggle-icon {
    font-size: 0.8rem;
    color: #6c757d;
    transition: transform 0.3s ease;
}

.sidebar-section.collapsed h4 .toggle-icon {
    transform: rotate(-90deg);
}

.sidebar-section .section-content {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.sidebar-section.collapsed .section-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

/* 滚动条美化 */
.sidebar-section .section-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-section .section-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.sidebar-section .section-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.sidebar-section .section-content::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* 黑夜模式 - 滚动条 */
body.dark-mode .sidebar-section .section-content::-webkit-scrollbar-track,
body.mode-dark .sidebar-section .section-content::-webkit-scrollbar-track {
    background: #1f2429;
}

body.dark-mode .sidebar-section .section-content::-webkit-scrollbar-thumb,
body.mode-dark .sidebar-section .section-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

body.dark-mode .sidebar-section .section-content::-webkit-scrollbar-thumb:hover,
body.mode-dark .sidebar-section .section-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 科幻模式 - 滚动条 */
body.scifi-mode .sidebar-section .section-content::-webkit-scrollbar-track,
body.mode-scifi .sidebar-section .section-content::-webkit-scrollbar-track {
    background: rgba(13, 13, 26, 0.5);
}

body.scifi-mode .sidebar-section .section-content::-webkit-scrollbar-thumb,
body.mode-scifi .sidebar-section .section-content::-webkit-scrollbar-thumb {
    background: rgba(100, 200, 255, 0.3);
}

body.scifi-mode .sidebar-section .section-content::-webkit-scrollbar-thumb:hover,
body.mode-scifi .sidebar-section .section-content::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 200, 255, 0.5);
}

/* ========== 模板库 ========== */
.template-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.template-item {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.template-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.5s;
}

.template-item:hover::before {
    left: 100%;
}

.template-item:hover {
    border-color: #667eea;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
    transform: translateX(5px);
}

body.dark-mode .template-item,
body.mode-dark .template-item {
    background: linear-gradient(135deg, #2c3138 0%, #1f2429 100%);
    border-color: rgba(255, 255, 255, 0.1);
}

.template-item h6 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.25rem;
}

body.dark-mode .template-item h6,
body.mode-dark .template-item h6 {
    color: #f8f9fa;
}

.template-item small {
    font-size: 0.75rem;
    color: #6c757d;
}

.template-item .badge {
    font-size: 0.7rem;
}

/* ========== 工具栏 ========== */
.toolbar-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.tool-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.875rem 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.tool-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.tool-button:active {
    transform: translateY(-1px) scale(0.98);
}

.tool-button i {
    font-size: 1.5rem;
}

/* ========== AI面板 ========== */
.ai-panel {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    padding: 1.25rem;
    color: white;
}

.ai-panel label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
    color: rgba(255, 255, 255, 0.95);
}

.ai-panel textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.75rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 0.85rem;
    resize: vertical;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    backdrop-filter: blur(10px);
}

.ai-panel textarea::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.ai-panel textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.15);
}

.btn-ai-generate {
    width: 100%;
    margin-top: 0.75rem;
    background: white;
    color: #667eea;
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-ai-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.btn-ai-generate i {
    margin-right: 0.5rem;
}

/* ========== 画布区域 ========== */
.flowchart-canvas-wrapper {
    flex: 1;
    position: relative;
    background: #ffffff;
    overflow: auto;
}

body.dark-mode .flowchart-canvas-wrapper,
body.mode-dark .flowchart-canvas-wrapper {
    background: #2c3138;
}

.canvas-toolbar {
    position: fixed;
    top: 50%;
    right: 1.5rem;
    transform: translateY(-50%);
    background: white;
    border-radius: 8px;
    padding: 0.6rem 0.4rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    /* 纵向排列 */
    align-items: center;
    gap: 0.5rem;
    z-index: 1000;
}

body.dark-mode .canvas-toolbar,
body.mode-dark .canvas-toolbar {
    background: #3a3f47;
}

.canvas-toolbar .btn {
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 42px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-toolbar .btn i {
    font-size: 1rem;
}

/* 工具栏分隔线（横向） */
.canvas-toolbar>div {
    width: 32px;
    height: 1px;
    background: #dee2e6;
    margin: 0.25rem 0;
}

/* 整体移动按钮组 */
.move-all-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.3rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 6px;
    margin-top: 1rem;
    /* 向下移动，避免重叠 */
}

.move-all-row {
    display: flex;
    gap: 0.2rem;
}

.move-all-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0.25rem !important;
    font-size: 0.75rem !important;
}

.move-all-btn i {
    font-size: 0.85rem !important;
}

/* 向上和向下箭头更明显 */
.move-all-btn#btnMoveAllUp i,
.move-all-btn#btnMoveAllDown i {
    font-size: 1rem !important;
    font-weight: 600;
}

.flowchart-canvas {
    position: relative;
    width: 100%;
    min-height: calc((100% - 220px) * 1.5);
    /* TAB布局后工具栏更紧凑 */
    margin-top: 220px;
    /* 减小到220px，TAB布局节省了空间 */
    background-image:
        radial-gradient(circle, #e9ecef 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0;
    padding: 2rem;
    /* 添加内边距，避免节点贴边 */
}

body.dark-mode .flowchart-canvas,
body.mode-dark .flowchart-canvas {
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
}

/* ========== 节点样式 ========== */
.flowchart-node {
    position: absolute;
    min-width: 120px;
    min-height: 60px;
    padding: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    cursor: move;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    user-select: none;
    font-weight: 500;
}

/* 文字节点 - 透明背景 */
.flowchart-node.node-text {
    background: transparent;
    box-shadow: none;
    color: #212529;
    border: 2px dashed #dee2e6;
    padding: 0.5rem 1rem;
    min-width: 80px;
    min-height: 40px;
}

.flowchart-node.node-text:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.flowchart-node.node-text.selected {
    border-color: #667eea;
    border-style: solid;
}

body.dark-mode .flowchart-node.node-text,
body.mode-dark .flowchart-node.node-text {
    color: #f8f9fa;
    border-color: rgba(255, 255, 255, 0.3);
}

body.dark-mode .flowchart-node.node-text:hover,
body.mode-dark .flowchart-node.node-text:hover {
    border-color: #667eea;
}

.flowchart-node:hover {
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.4);
    transform: translateY(-2px);
}

.flowchart-node.selected {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.5);
}

.flowchart-node [contenteditable] {
    outline: none;
    min-width: 50px;
}

.flowchart-node [contenteditable]:focus {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 2px 4px;
}

/* 节点类型变体 */
.flowchart-node.node-circle {
    border-radius: 50%;
    width: 120px;
    height: 120px;
}

.flowchart-node.node-diamond {
    transform: rotate(45deg);
    /* 确保菱形是正方形，四条边相等 */
    aspect-ratio: 1 / 1;
}

.flowchart-node.node-diamond span {
    transform: rotate(-45deg);
}

/* 节点删除按钮 */
.node-delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #dc3545;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.flowchart-node:hover .node-delete-btn {
    display: flex;
}

.node-delete-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* ========== 操作按钮栏 ========== */
/* 移除独立的操作按钮组CSS（已合并到工具栏） */

/* ========== 空状态 ========== */
.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #6c757d;
    max-width: 400px;
}

body.dark-mode .empty-state,
body.mode-dark .empty-state {
    color: rgba(255, 255, 255, 0.5);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h5 {
    color: #495057;
    margin-bottom: 0.75rem;
}

body.dark-mode .empty-state h5,
body.mode-dark .empty-state h5 {
    color: rgba(255, 255, 255, 0.7);
}

.empty-state p {
    font-size: 0.9rem;
    color: #6c757d;
}

/* ========== 多选功能样式 ========== */
/* 选择框 */
.selection-box {
    position: absolute;
    border: 2px dashed #667eea;
    background: rgba(102, 126, 234, 0.1);
    pointer-events: none;
    z-index: 9999;
    display: none;
}

/* 多选节点高亮 */
.flowchart-node.multi-selected {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.7) !important;
    outline: 2px solid #667eea !important;
    outline-offset: 2px;
}

body.dark-mode .empty-state p,
body.mode-dark .empty-state p {
    color: rgba(255, 255, 255, 0.5);
}

/* ========== 科幻模式样式适配 ========== */
/* 科幻模式 - 主容器 */
body.scifi-mode .flowchart-main-container,
body.mode-scifi .flowchart-main-container {
    background: linear-gradient(180deg, #0a1929 0%, #001e3c 50%, #0a1929 100%);
}

/* 科幻模式 - 流程图容器 */
body.scifi-mode .flowchart-container,
body.mode-scifi .flowchart-container {
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid rgba(100, 200, 255, 0.3);
    box-shadow: 0 0 30px rgba(100, 200, 255, 0.2);
}

/* 科幻模式 - 侧边栏 */
body.scifi-mode .flowchart-sidebar,
body.mode-scifi .flowchart-sidebar {
    background: rgba(13, 13, 26, 0.9);
    border-right: 1px solid rgba(100, 200, 255, 0.3);
}

/* 科幻模式 - 顶部工具栏 */
body.scifi-mode .top-toolbar-area,
body.mode-scifi .top-toolbar-area {
    background: rgba(13, 13, 26, 0.9);
    border-bottom: 2px solid rgba(100, 200, 255, 0.3);
    box-shadow: 0 2px 10px rgba(100, 200, 255, 0.1);
}

/* 科幻模式 - 侧边栏区块 */
body.scifi-mode .sidebar-section,
body.mode-scifi .sidebar-section {
    background: rgba(13, 13, 26, 0.8);
    border: 1px solid rgba(100, 200, 255, 0.2);
    box-shadow: 0 0 15px rgba(100, 200, 255, 0.1);
    color: #66b3ff;
}

body.scifi-mode .sidebar-section:hover,
body.mode-scifi .sidebar-section:hover {
    border-color: rgba(100, 200, 255, 0.4);
    box-shadow: 0 0 20px rgba(100, 200, 255, 0.2);
}

body.scifi-mode .sidebar-section h4,
body.mode-scifi .sidebar-section h4 {
    color: #66b3ff;
    border-bottom-color: rgba(100, 200, 255, 0.3);
}

body.scifi-mode .sidebar-section h4:hover,
body.mode-scifi .sidebar-section h4:hover {
    color: #78c5ff;
}

body.scifi-mode .sidebar-section h4 .title-left i,
body.mode-scifi .sidebar-section h4 .title-left i {
    color: #00d9ff;
}

/* 科幻模式 - 模板项 */
body.scifi-mode .template-item,
body.mode-scifi .template-item {
    background: rgba(13, 13, 26, 0.8);
    border: 1px solid rgba(100, 200, 255, 0.2);
    color: #66b3ff;
}

body.scifi-mode .template-item:hover,
body.mode-scifi .template-item:hover {
    border-color: rgba(100, 200, 255, 0.4);
    box-shadow: 0 0 15px rgba(100, 200, 255, 0.3);
    background: rgba(26, 26, 46, 0.9);
}

body.scifi-mode .template-item h6,
body.mode-scifi .template-item h6 {
    color: #66b3ff;
}

body.scifi-mode .template-item small,
body.mode-scifi .template-item small {
    color: #78c5ff;
}

body.scifi-mode .template-card-mini,
body.mode-scifi .template-card-mini {
    background: rgba(13, 13, 26, 0.8);
    border: 1px solid rgba(100, 200, 255, 0.2);
    color: #66b3ff;
}

body.scifi-mode .template-card-mini:hover,
body.mode-scifi .template-card-mini:hover {
    border-color: rgba(100, 200, 255, 0.4);
    box-shadow: 0 0 10px rgba(100, 200, 255, 0.3);
}

/* 科幻模式 - 画布包装器 */
body.scifi-mode .flowchart-canvas-wrapper,
body.mode-scifi .flowchart-canvas-wrapper {
    background: rgba(13, 13, 26, 0.8);
}

/* 科幻模式 - 画布 */
body.scifi-mode .flowchart-canvas,
body.mode-scifi .flowchart-canvas {
    background-image:
        radial-gradient(circle, rgba(100, 200, 255, 0.1) 1px, transparent 1px);
}

/* 科幻模式 - 文字节点 */
body.scifi-mode .flowchart-node.node-text,
body.mode-scifi .flowchart-node.node-text {
    color: #66b3ff;
    border-color: rgba(100, 200, 255, 0.3);
    background: rgba(13, 13, 26, 0.5);
}

body.scifi-mode .flowchart-node.node-text:hover,
body.mode-scifi .flowchart-node.node-text:hover {
    border-color: rgba(100, 200, 255, 0.6);
    box-shadow: 0 0 15px rgba(100, 200, 255, 0.3);
}

body.scifi-mode .flowchart-node.node-text.selected,
body.mode-scifi .flowchart-node.node-text.selected {
    border-color: #00d9ff;
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.4);
}

/* 科幻模式 - 普通节点 */
body.scifi-mode .flowchart-node:not(.node-text),
body.mode-scifi .flowchart-node:not(.node-text) {
    box-shadow: 0 0 20px rgba(100, 200, 255, 0.3);
}

body.scifi-mode .flowchart-node:not(.node-text):hover,
body.mode-scifi .flowchart-node:not(.node-text):hover {
    box-shadow: 0 0 30px rgba(100, 200, 255, 0.5);
}

body.scifi-mode .flowchart-node:not(.node-text).selected,
body.mode-scifi .flowchart-node:not(.node-text).selected {
    box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.6), 0 0 25px rgba(100, 200, 255, 0.4);
}

/* ⭐ 科幻模式/黑夜模式 - 保护流程图节点内span的文字颜色 */
/* 防止全局主题样式覆盖节点的内联文字颜色设置 */
body.scifi-mode .flowchart-node:not(.node-text) span,
body.mode-scifi .flowchart-node:not(.node-text) span,
html.mode-scifi .flowchart-node:not(.node-text) span,
body.dark-mode .flowchart-node:not(.node-text) span,
body.mode-dark .flowchart-node:not(.node-text) span {
    color: inherit !important;
}

/* 科幻模式 - 文字节点的span也需要继承颜色 */
body.scifi-mode .flowchart-node.node-text span,
body.mode-scifi .flowchart-node.node-text span,
html.mode-scifi .flowchart-node.node-text span {
    color: inherit !important;
}

/* 黑夜模式 - 文字节点的span继承颜色 */
body.dark-mode .flowchart-node.node-text span,
body.mode-dark .flowchart-node.node-text span {
    color: inherit !important;
}

/* 科幻模式 - 工具栏 */
body.scifi-mode .canvas-toolbar,
body.mode-scifi .canvas-toolbar {
    background: rgba(13, 13, 26, 0.9);
    border: 1px solid rgba(100, 200, 255, 0.3);
    box-shadow: 0 0 20px rgba(100, 200, 255, 0.2);
}

body.scifi-mode .canvas-toolbar>div,
body.mode-scifi .canvas-toolbar>div {
    background: rgba(100, 200, 255, 0.3);
}

/* 科幻模式 - 图形工具按钮 */
body.scifi-mode .shape-tool-btn,
body.mode-scifi .shape-tool-btn {
    background: linear-gradient(135deg, #00d9ff 0%, #0088aa 100%);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

body.scifi-mode .shape-tool-btn:hover,
body.mode-scifi .shape-tool-btn:hover {
    box-shadow: 0 0 25px rgba(0, 217, 255, 0.5);
    background: linear-gradient(135deg, #00ff88 0%, #00d9ff 100%);
}

/* 科幻模式 - AI面板 */
body.scifi-mode .ai-panel,
body.mode-scifi .ai-panel {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.2) 0%, rgba(0, 136, 170, 0.2) 100%);
    border: 1px solid rgba(100, 200, 255, 0.3);
    box-shadow: 0 0 20px rgba(100, 200, 255, 0.2);
}

body.scifi-mode .ai-panel textarea,
body.mode-scifi .ai-panel textarea {
    background: rgba(13, 13, 26, 0.8);
    border-color: rgba(100, 200, 255, 0.3);
    color: #66b3ff;
}

body.scifi-mode .ai-panel textarea:focus,
body.mode-scifi .ai-panel textarea:focus {
    border-color: rgba(100, 200, 255, 0.6);
    box-shadow: 0 0 15px rgba(100, 200, 255, 0.3);
}

body.scifi-mode .btn-ai-generate,
body.mode-scifi .btn-ai-generate {
    background: linear-gradient(135deg, #00d9ff 0%, #0088aa 100%);
    color: #0a1929;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

body.scifi-mode .btn-ai-generate:hover,
body.mode-scifi .btn-ai-generate:hover {
    background: linear-gradient(135deg, #00ff88 0%, #00d9ff 100%);
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.5);
}

/* 科幻模式 - 表单控件 */
body.scifi-mode .form-control,
body.scifi-mode .form-select,
body.mode-scifi .form-control,
body.mode-scifi .form-select {
    background: rgba(13, 13, 26, 0.8);
    border: 1px solid rgba(100, 200, 255, 0.3);
    color: #66b3ff;
}

body.scifi-mode .form-control:focus,
body.scifi-mode .form-select:focus,
body.mode-scifi .form-control:focus,
body.mode-scifi .form-select:focus {
    background: rgba(13, 13, 26, 0.9);
    border-color: rgba(100, 200, 255, 0.6);
    box-shadow: 0 0 10px rgba(100, 200, 255, 0.3);
    color: #66b3ff;
}

body.scifi-mode .form-control::placeholder,
body.mode-scifi .form-control::placeholder {
    color: rgba(102, 179, 255, 0.5);
}

body.scifi-mode .form-label,
body.mode-scifi .form-label {
    color: #78c5ff;
}

/* 科幻模式 - 按钮 */
body.scifi-mode .btn-primary,
body.mode-scifi .btn-primary {
    background: linear-gradient(135deg, #00d9ff 0%, #0088aa 100%);
    border-color: rgba(100, 200, 255, 0.3);
    color: #0a1929;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

body.scifi-mode .btn-primary:hover,
body.mode-scifi .btn-primary:hover {
    background: linear-gradient(135deg, #00ff88 0%, #00d9ff 100%);
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.5);
}

body.scifi-mode .btn-outline-primary,
body.scifi-mode .btn-outline-info,
body.scifi-mode .btn-outline-secondary,
body.mode-scifi .btn-outline-primary,
body.mode-scifi .btn-outline-info,
body.mode-scifi .btn-outline-secondary {
    border-color: rgba(100, 200, 255, 0.3);
    color: #66b3ff;
}

body.scifi-mode .btn-outline-primary:hover,
body.scifi-mode .btn-outline-info:hover,
body.scifi-mode .btn-outline-secondary:hover,
body.mode-scifi .btn-outline-primary:hover,
body.mode-scifi .btn-outline-info:hover,
body.mode-scifi .btn-outline-secondary:hover {
    background: rgba(100, 200, 255, 0.2);
    border-color: rgba(100, 200, 255, 0.6);
    color: #78c5ff;
    box-shadow: 0 0 15px rgba(100, 200, 255, 0.3);
}

body.scifi-mode .btn-success,
body.mode-scifi .btn-success {
    background: linear-gradient(135deg, #00ff88 0%, #00d9ff 100%);
    border-color: rgba(0, 255, 136, 0.3);
    color: #0a1929;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

body.scifi-mode .btn-success:hover,
body.mode-scifi .btn-success:hover {
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.5);
}

body.scifi-mode .btn-outline-danger,
body.mode-scifi .btn-outline-danger {
    border-color: rgba(255, 71, 87, 0.3);
    color: #ff4757;
}

body.scifi-mode .btn-outline-danger:hover,
body.mode-scifi .btn-outline-danger:hover {
    background: rgba(255, 71, 87, 0.2);
    border-color: rgba(255, 71, 87, 0.6);
    box-shadow: 0 0 15px rgba(255, 71, 87, 0.3);
}

/* 科幻模式 - 空状态 */
body.scifi-mode .empty-state,
body.mode-scifi .empty-state {
    color: rgba(102, 179, 255, 0.6);
}

body.scifi-mode .empty-state h5,
body.mode-scifi .empty-state h5 {
    color: #66b3ff;
}

body.scifi-mode .empty-state p,
body.mode-scifi .empty-state p {
    color: rgba(102, 179, 255, 0.5);
}

/* 科幻模式 - 侧边栏收起按钮 */
body.scifi-mode .sidebar-toggle-btn,
body.mode-scifi .sidebar-toggle-btn {
    background: linear-gradient(135deg, #00d9ff 0%, #0088aa 100%);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

body.scifi-mode .sidebar-toggle-btn:hover,
body.mode-scifi .sidebar-toggle-btn:hover {
    background: linear-gradient(135deg, #00ff88 0%, #00d9ff 100%);
    box-shadow: 0 0 25px rgba(0, 255, 136, 0.5);
}

/* 科幻模式 - 工具按钮 */
body.scifi-mode .tool-button,
body.mode-scifi .tool-button {
    background: linear-gradient(135deg, #00d9ff 0%, #0088aa 100%);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

body.scifi-mode .tool-button:hover,
body.mode-scifi .tool-button:hover {
    box-shadow: 0 0 25px rgba(0, 217, 255, 0.5);
    background: linear-gradient(135deg, #00ff88 0%, #00d9ff 100%);
}

/* 科幻模式 - 文字颜色 */
body.scifi-mode .text-muted,
body.mode-scifi .text-muted {
    color: rgba(102, 179, 255, 0.6) !important;
}

/* 科幻模式 - 整体移动按钮组 */
body.scifi-mode .move-all-buttons,
body.mode-scifi .move-all-buttons {
    background: rgba(0, 217, 255, 0.1);
    border: 1px solid rgba(100, 200, 255, 0.2);
}

/* ========== 完善黑夜模式样式 ========== */
/* 黑夜模式 - 表单控件 */
body.dark-mode .form-control,
body.dark-mode .form-select,
body.mode-dark .form-control,
body.mode-dark .form-select {
    background: #2c3138;
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8f9fa;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus,
body.mode-dark .form-control:focus,
body.mode-dark .form-select:focus {
    background: #343a40;
    border-color: rgba(255, 255, 255, 0.2);
    color: #f8f9fa;
}

body.dark-mode .form-control::placeholder,
body.mode-dark .form-control::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .form-label,
body.mode-dark .form-label {
    color: #f8f9fa;
}

/* 黑夜模式 - 按钮文字颜色 */
body.dark-mode .btn-outline-primary,
body.dark-mode .btn-outline-info,
body.dark-mode .btn-outline-secondary,
body.mode-dark .btn-outline-primary,
body.mode-dark .btn-outline-info,
body.mode-dark .btn-outline-secondary {
    color: #f8f9fa;
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .btn-outline-primary:hover,
body.dark-mode .btn-outline-info:hover,
body.dark-mode .btn-outline-secondary:hover,
body.mode-dark .btn-outline-primary:hover,
body.mode-dark .btn-outline-info:hover,
body.mode-dark .btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #f8f9fa;
}

/* 黑夜模式 - 工具栏分隔线 */
body.dark-mode .canvas-toolbar>div,
body.mode-dark .canvas-toolbar>div {
    background: rgba(255, 255, 255, 0.2);
}

/* 黑夜模式 - 模板卡片 */
body.dark-mode .template-card-mini,
body.mode-dark .template-card-mini {
    background: #2c3138;
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8f9fa;
}

body.dark-mode .template-card-mini:hover,
body.mode-dark .template-card-mini:hover {
    background: #3a3f47;
    border-color: rgba(255, 255, 255, 0.2);
}

/* 黑夜模式 - AI面板 */
body.dark-mode .ai-panel textarea,
body.mode-dark .ai-panel textarea {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    color: #f8f9fa;
}

body.dark-mode .ai-panel textarea:focus,
body.mode-dark .ai-panel textarea:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
}

/* 黑夜模式 - 整体移动按钮组 */
body.dark-mode .move-all-buttons,
body.mode-dark .move-all-buttons {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .flowchart-container {
        flex-direction: column;
        height: auto;
    }

    .flowchart-sidebar {
        width: 100%;
        max-height: 300px;
    }

    .flowchart-canvas-wrapper {
        min-height: 400px;
    }

    .flowchart-actions {
        bottom: 1rem;
        right: 1rem;
        flex-wrap: wrap;
    }
}

