/* Canvas Page Styles */
* {
    box-sizing: border-box;
}

/* Main Layout */
.canvas-layout {
    display: flex;
    height: calc(100vh - 80px);
    margin-top: 80px;
    background: #f8fafc;
}

/* Sidebar Styles */
.sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
}

.sidebar-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Search Section */
.search-section {
    margin-bottom: 24px;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #8b7cf6;
    background: white;
    box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.1);
}

/* Models Section */
.models-section {
    margin-bottom: 24px;
}

.section-header {
    margin-bottom: 16px;
    padding: 16px;
    background: linear-gradient(135deg, #8b7cf6 0%, #7c3aed 100%);
    border-radius: 12px;
    color: white;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.models-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* Model Items */
.models-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.model-item {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    cursor: grab;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.model-item:hover {
    border-color: #8b7cf6;
    box-shadow: 0 8px 24px rgba(139, 124, 246, 0.2);
    transform: translateY(-2px);
    background: linear-gradient(135deg, #ffffff 0%, #faf5ff 100%);
}

.model-item:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.model-item.dragging {
    opacity: 0.7;
    transform: rotate(3deg) scale(1.05);
    z-index: 1000;
    box-shadow: 0 12px 32px rgba(139, 124, 246, 0.3);
}

.model-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}

.model-name {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
    max-width: 180px;
}

.model-type {
    padding: 2px 8px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-category {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 8px;
}

.model-tokens {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1px solid #a7f3d0;
    border-radius: 6px;
    font-size: 12px;
    color: #065f46;
    font-weight: 600;
}

.model-tokens svg {
    width: 12px;
    height: 12px;
    color: #10b981;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
}

/* Canvas Header */
.canvas-header {
    padding: 20px 24px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.canvas-title h2 {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px 0;
}

.canvas-subtitle {
    font-size: 14px;
    color: #64748b;
    margin: 0;
}

.canvas-controls {
    display: flex;
    gap: 12px;
}

.control-btn {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #64748b;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.control-btn:hover {
    border-color: #8b7cf6;
    color: #8b7cf6;
    background: #faf5ff;
}

.control-btn.primary {
    background: #8b7cf6;
    color: white;
    border-color: #8b7cf6;
}

.control-btn.primary:hover {
    background: #7c3aed;
    border-color: #7c3aed;
}

.control-btn.success {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.control-btn.success:hover {
    background: #059669;
    border-color: #059669;
}

.control-btn.save-run-btn {
    background: linear-gradient(135deg, #8b7cf6 0%, #10b981 100%);
    color: white;
    border-color: #8b7cf6;
    font-weight: 600;
    padding: 10px 16px;
}

.control-btn.save-run-btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #059669 100%);
    border-color: #7c3aed;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 124, 246, 0.3);
}

.control-btn.run-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-color: #10b981;
    font-weight: 600;
    padding: 10px 16px;
}

.control-btn.run-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    border-color: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Canvas Workspace - Gray Background with Dot Grid */
.canvas-workspace {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: 
        radial-gradient(circle at 1px 1px, #cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
    background-color: #f1f5f9;
}



/* Drop Zone */
.drop-zone {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 3px dashed rgba(139, 124, 246, 0.6);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    min-width: 300px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.drop-zone.active {
    border-color: #8b7cf6;
    background: rgba(139, 124, 246, 0.1);
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 20px 40px rgba(139, 124, 246, 0.2);
}

.drop-zone-content {
    color: #475569;
}

.drop-zone-content svg {
    color: #8b7cf6;
    margin-bottom: 16px;
    filter: drop-shadow(0 2px 4px rgba(139, 124, 246, 0.3));
}

.drop-zone-content h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #1e293b;
}

.drop-zone-content p {
    font-size: 14px;
    margin: 0;
    opacity: 0.8;
    color: #64748b;
}

/* Connections SVG */
.connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connection-line {
    stroke: #8b7cf6;
    stroke-width: 3;
    fill: none;
    marker-end: url(#arrowhead);
    filter: drop-shadow(0 2px 4px rgba(139, 124, 246, 0.3));
    transition: all 0.2s ease;
}

.connection-line:hover {
    stroke: #7c3aed;
    stroke-width: 4;
}

.connection-line.temporary {
    stroke: #10b981;
    stroke-width: 4;
    stroke-dasharray: 8,4;
    animation: dashMove 0.8s linear infinite;
    filter: drop-shadow(0 2px 4px rgba(16, 185, 129, 0.4));
}

@keyframes dashMove {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 10; }
}

/* Workflow Nodes */
.workflow-nodes {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.workflow-node {
    position: absolute;
    width: 280px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    cursor: move;
    transition: all 0.2s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.workflow-node:hover {
    border-color: #8b7cf6;
    box-shadow: 0 12px 32px rgba(139, 124, 246, 0.2);
    transform: translateY(-2px);
}

.workflow-node.dragging {
    transform: scale(1.05);
    z-index: 1000;
    box-shadow: 0 16px 40px rgba(139, 124, 246, 0.3);
}

.node-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.node-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.2;
}

.node-priority {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.priority-label {
    color: #475569;
    font-weight: 600;
}

.priority-input {
    width: 70px;
    height: 32px;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    background: white;
    padding: 0 10px;
    cursor: text;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.priority-input:hover {
    border-color: #8b7cf6;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(139, 124, 246, 0.15);
    transform: translateY(-1px);
}

.priority-input:focus {
    outline: none;
    border-color: #8b7cf6;
    box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.2), 0 2px 8px rgba(139, 124, 246, 0.1);
    background: white;
    transform: translateY(-1px);
}

.priority-percent {
    color: #475569;
    font-weight: 600;
    font-size: 13px;
}

/* Improve number input spinners sizing */
.priority-input::-webkit-outer-spin-button,
.priority-input::-webkit-inner-spin-button {
    height: 32px;
    opacity: 0.8;
}

.node-controls {
    display: flex;
    gap: 4px;
}

.node-control {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #64748b;
    border-radius: 4px;
    padding: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.node-control:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #475569;
}

.node-control.delete:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.node-category {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 8px;
}

.node-tokens {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 6px;
    font-size: 12px;
    color: #065f46;
    font-weight: 600;
    margin-bottom: 12px;
}

.node-tokens svg {
    width: 12px;
    height: 12px;
    color: #10b981;
}

/* Connection Points */
.connection-point {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid #8b7cf6;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
}

.connection-point:hover {
    transform: translateY(-50%) scale(1.3);
    border-color: #7c3aed;
    background: #8b7cf6;
    box-shadow: 0 0 0 4px rgba(139, 124, 246, 0.2);
}

.connection-point.left {
    left: -7px;
}

.connection-point.right {
    right: -7px;
}

.connection-point.connecting {
    border-color: #10b981;
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3);
    animation: pulse 1s ease-in-out infinite;
    transform: translateY(-50%) scale(1.2);
}

.connection-point.target {
    border-color: #f59e0b;
    background: #f59e0b;
    transform: translateY(-50%) scale(1.4);
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.3);
    animation: targetPulse 0.5s ease-in-out infinite;
}

@keyframes targetPulse {
    0%, 100% { 
        transform: translateY(-50%) scale(1.4);
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.3);
    }
    50% { 
        transform: translateY(-50%) scale(1.6);
        box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.5);
    }
}

@keyframes pulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); 
    }
    50% { 
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); 
    }
}

/* Selection Box */
.selection-box {
    position: absolute;
    border: 2px solid #3b82f6;
    background: rgba(59, 130, 246, 0.08);
    pointer-events: none;
    z-index: 1000;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2);
}

/* Selection States */
.workflow-node.selection-preview {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    transform: translateY(-2px);
}

.workflow-node.selected {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

.connection-line.selection-preview {
    stroke: #f59e0b;
    stroke-width: 4;
    filter: drop-shadow(0 2px 4px rgba(245, 158, 11, 0.3));
}

.connection-line.selected {
    stroke: #10b981;
    stroke-width: 4;
    filter: drop-shadow(0 2px 4px rgba(16, 185, 129, 0.3));
}

/* Connection Mode Indicator */
.connection-mode-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    z-index: 10000;
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

.indicator-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.indicator-icon {
    font-size: 16px;
}

.indicator-text {
    white-space: nowrap;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Workflow Guide */
.workflow-guide {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(139, 124, 246, 0.2);
}

.guide-step {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #475569;
    font-size: 14px;
}

.step-number {
    width: 20px;
    height: 20px;
    background: #8b7cf6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.guide-arrow {
    color: #94a3b8;
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
    
    .workflow-node {
        width: 200px;
        padding: 12px;
    }
}

@media (max-width: 768px) {
    .canvas-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .sidebar-content {
        padding: 16px;
    }
    
    .models-list {
        flex-direction: row;
        overflow-x: auto;
        gap: 8px;
    }
    
    .model-item {
        min-width: 200px;
        flex-shrink: 0;
    }
    
    .workflow-node {
        width: 180px;
        padding: 12px;
    }
    
    .canvas-header {
        padding: 16px;
    }
    
    .workflow-guide {
        position: relative;
        bottom: auto;
        left: auto;
        transform: none;
        margin: 16px;
        font-size: 12px;
    }
}

/* Animations */
@keyframes nodeAppear {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.workflow-node.appear {
    animation: nodeAppear 0.3s ease-out;
}

/* Selection styles */
.workflow-node.selected {
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.5);
}

.connection-line.selected {
    stroke: #f59e0b;
    stroke-width: 4;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: #f9fafb;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #8b7cf6;
    background: white;
    box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 8px;
}

.radio-group input[type="radio"] {
    margin-right: 8px;
}

.radio-group label {
    display: inline;
    margin-bottom: 0;
    cursor: pointer;
    font-weight: 400;
}

.modal-footer {
    padding: 16px 24px 24px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn.cancel-btn {
    background: #f1f5f9;
    color: #64748b;
}

.action-btn.cancel-btn:hover {
    background: #e2e8f0;
    color: #334155;
}

.action-btn.save-btn {
    background: linear-gradient(135deg, #8b7cf6 0%, #10b981 100%);
    color: white;
}

.action-btn.save-btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #059669 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 124, 246, 0.3);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;   /* 控制两个按钮之间的间距 */
}
