/**
 * 流程图编辑器样式
 * 版本：20251210_v4 - 确保连线始终可见
 * 创建日期：2025-12-07
 */

/* ========== 主容器 ========== */
.flowchart-container {
    display: flex;
    height: calc(100vh - 120px);
    margin-top: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

/* ========== 侧边栏 ========== */
.flowchart-sidebar {
    width: 280px;
    background-color: #F8F9FA;
    border-right: 1px solid #DEE2E6;
    padding: 20px;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 30px;
}

.sidebar-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 模板列表 */
.template-item {
    border-radius: 6px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.template-item:hover {
    background-color: #E7F3FF !important;
    border-color: #4A90E2 !important;
}

.template-item h6 {
    font-size: 13px;
    font-weight: 500;
    color: #212529;
}

.template-item small {
    font-size: 11px;
}

/* 工具栏 */
.toolbar-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tool-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: calc(50% - 4px);
    padding: 12px 8px;
    border: 1px solid #DEE2E6;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.tool-button:hover {
    border-color: #4A90E2;
    background-color: #E7F3FF;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(74, 144, 226, 0.2);
}

.tool-button i {
    font-size: 18px;
    margin-right: 6px;
    color: #495057;
}

.tool-button:hover i {
    color: #4A90E2;
}

/* AI面板 */
.ai-panel {
    background: white;
    border: 1px solid #DEE2E6;
    border-radius: 6px;
    padding: 15px;
}

.ai-panel textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px;
    border: 1px solid #CED4DA;
    border-radius: 4px;
    font-size: 13px;
    resize: vertical;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ai-panel textarea:focus {
    border-color: #7C3AED;
    outline: none;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.btn-generate {
    width: 100%;
    margin-top: 10px;
    background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-generate:hover {
    background: linear-gradient(135deg, #6D28D9 0%, #5B21B6 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-generate:disabled {
    background: #9CA3AF;
    cursor: not-allowed;
    transform: none;
}

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

.flowchart-canvas {
    position: relative;
    width: 100%;
    min-height: 100%;
    background-color: #FFFFFF;
    background-image: 
        linear-gradient(#E5E5E5 1px, transparent 1px),
        linear-gradient(90deg, #E5E5E5 1px, transparent 1px);
    background-size: 20px 20px;
}

/* ========== 流程图节点 ========== */
.flowchart-node {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 20px;
    background-color: #4A90E2;
    color: white;
    border-radius: 6px;
    cursor: move;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s, transform 0.2s;
    user-select: none;
    min-width: 100px;
    min-height: 50px;
}

.flowchart-node:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
    z-index: 10;
}

.flowchart-node.selected {
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.5);
    z-index: 20;
}

.flowchart-node span {
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    word-break: break-word;
    outline: none;
}

.flowchart-node span:focus {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    padding: 2px 4px;
}

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

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

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

/* ========== 操作栏 ========== */
.flowchart-actions {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.flowchart-actions .btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.flowchart-actions .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.flowchart-actions .btn i {
    margin-right: 6px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .flowchart-container {
        flex-direction: column;
        height: auto;
    }
    
    .flowchart-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #DEE2E6;
        max-height: 300px;
    }
    
    .flowchart-canvas {
        min-height: 400px;
    }
    
    .flowchart-actions {
        position: fixed;
        bottom: 10px;
        right: 10px;
        flex-wrap: wrap;
    }
    
    .flowchart-actions .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* ========== 加载动画 ========== */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== 工具提示 ========== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background-color: #2D3748;
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 8px;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ========== PRISMA 模板样式 ========== */
.prisma-header {
    border-radius: 4px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 !important;
}

.prisma-box {
    background: white !important;
    border: 2px solid #34495e;
    color: #2c3e50 !important;
    border-radius: 4px;
    padding: 10px !important;
    align-items: flex-start !important;
    justify-content: center !important;
    flex-direction: column !important;
    font-size: 13px !important;
    box-shadow: none !important;
}

.prisma-box strong {
    display: block;
    font-size: 14px;
    margin-bottom: 5px;
    width: 100%;
    text-align: center;
}

.prisma-box ul {
    margin: 5px 0 0 15px;
    padding: 0;
    text-align: left;
    width: 100%;
}

.prisma-box li {
    margin: 2px 0;
    font-size: 12px;
    list-style-type: disc;
}

.prisma-excluded {
    background: #ffe6e6 !important;
    border-color: #e74c3c !important;
}

.prisma-side {
    background: #ecf0f1 !important;
}

.prisma-included {
    background: #f0e6ff !important;
    border-color: #9b59b6 !important;
}

/* ========== 拖拽连接视觉反馈 ========== */

/* 拖拽连接时，可连接的目标节点样式 */
.flowchart-node.connectable-target {
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.5), 0 0 12px rgba(102, 126, 234, 0.3) !important;
    transition: all 0.2s ease;
}

/* 鼠标悬停在可连接目标上时 */
.flowchart-node.connectable-target:hover {
    box-shadow: 0 0 0 3px #667eea, 0 0 20px rgba(102, 126, 234, 0.5) !important;
    transform: scale(1.02);
}

/* 连接成功时的闪烁效果 */
.flowchart-node.connection-success {
    animation: connection-success-pulse 0.6s ease;
}

@keyframes connection-success-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(67, 233, 123, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(67, 233, 123, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(67, 233, 123, 0);
    }
}

/* jsPlumb 端点样式增强 */
.jtk-endpoint {
    cursor: crosshair !important;
    transition: transform 0.15s ease;
    z-index: 100;
}

/* jsPlumb 端点悬停效果 */
.jtk-endpoint:hover {
    transform: scale(1.4) !important;
}

/* jsPlumb 连接线样式 - 确保始终可见 */
.jtk-connector {
    cursor: pointer;
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
    pointer-events: auto;
}

.jtk-connector:hover {
    z-index: 100;
}

/* 确保 jsPlumb 的 SVG 连接器始终显示 */
svg.jtk-connector {
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
}

/* 连接线的路径 */
.jtk-connector path {
    visibility: visible !important;
    opacity: 1 !important;
}

/* 箭头标记 */
.jtk-connector marker,
.jtk-overlay {
    visibility: visible !important;
    opacity: 1 !important;
}

/* 拖拽中的连接线样式 */
.jtk-drag-active .jtk-endpoint {
    opacity: 1 !important;
}

/* 选中节点时端点更明显 */
.flowchart-node.selected .jtk-endpoint {
    opacity: 1 !important;
}

