﻿/* CSS Variables for consistent theming */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --border-primary: #e0e0e0;
    --border-secondary: #cccccc;
    --border-tertiary: #888888;
    --diagram-link: #888888;
    --text-primary: #000000;
    --text-secondary: #888888;
    --accent-blue: #6e9fd4;
    --accent-blue-alpha: rgba(110, 159, 212, 0.3);
    --accent-blue-bright: #8bb3e8;
    --accent-green: #2ecc71;
    --accent-green-alpha: rgba(46, 204, 113, 0.3);
    --accent-red: #e74c3c;
    --accent-red-alpha: rgba(231, 76, 60, 0.3);
    --shadow-primary: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.15);
    --shadow-selected: 0 8px 25px rgba(110, 159, 212, 0.4);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease-out;
    --node-hover: #E5E6E8;
    --diagram-canvas-color: rgb(240, 240, 240);
    --node-selected: rgb(210, 210, 210);
    --bg-primary: #58151c;
    --bs-primary-rgb: 88, 21, 28;
}

[data-bs-theme=dark] {
    --bg-primary: #2d2f2e;
    --bg-secondary: #414244;
    --border-primary: #d0d0d0;
    --border-secondary: #404040;
    --border-tertiary: #888888;
    --diagram-link: #666666;
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --accent-blue: #6e9fd4;
    --accent-blue-alpha: rgba(110, 159, 212, 0.3);
    --accent-blue-bright: #8bb3e8;
    --accent-green: #2ecc71;
    --accent-green-alpha: rgba(46, 204, 113, 0.3);
    --accent-red: #e74c3c;
    --accent-red-alpha: rgba(231, 76, 60, 0.3);
    --shadow-primary: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.4);
    --shadow-selected: 0 8px 25px rgba(110, 159, 212, 0.4);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease-out;
    --node-hover: #505153;
    --diagram-canvas-color: rgb(45, 47, 46);
    --node-selected: #353535;
    --bg-primary: #58151c;
    --bs-primary-rgb: 88, 21, 28;
}


.card-image, .menu-image {
    margin-left:4px;
    margin-right:4px;
    color: var(--text-primary);
    pointer-events: none;
}
/* Canvas Styling */
/*.diagram-canvas,
.diagram-canvas.grid {
    background-color: var(--bg-primary);
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.2) 1px, transparent 1px);
    background-size: 20px 20px;
}*/

    /* Scrollbar Styling */
    .diagram-canvas::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    .diagram-canvas::-webkit-scrollbar-track {
        background: var(--bg-primary);
    }

    .diagram-canvas::-webkit-scrollbar-thumb {
        background: var(--border-secondary);
        border-radius: 4px;
    }

        .diagram-canvas::-webkit-scrollbar-thumb:hover {
            background: #555555;
        }

/* Default Node Dark Theme Overrides */
.default-node {
    background-color: var(--bg-secondary) !important;
    border: 2px solid var(--border-primary);
    border-radius: var(--border-radius);
    color: var(--text-primary) !important;
    font-weight: 600;
    box-shadow: var(--shadow-primary);
    font-size: 14px;
    min-width: 120px;
    padding: 16px 20px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

    .default-node:hover {
        border-color: var(--accent-blue-bright);
        box-shadow: var(--shadow-hover), 0 0 0 3px var(--accent-blue-alpha);
        background-color: var(--node-hover) !important;
    }

    .default-node.selected {
        border-color: var(--accent-blue) !important;
        box-shadow: var(--shadow-selected), 0 0 0 4px var(--accent-blue-alpha) !important;
        background-color: var(--node-selected) !important;
    }

    .default-node .diagram-port {
        width: 16px !important;
        height: 16px !important;
        background-color: #f5f5f5 !important;
        border: 2px solid var(--border-tertiary) !important;
        transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
        transform: scale(1);
    }

    .default-node:hover .diagram-port {
        transform: scale(1.1);
        border-color: var(--accent-blue-bright) !important;
        box-shadow: 0 0 8px var(--accent-blue-alpha) !important;
    }

    .default-node .diagram-port:hover {
        background-color: #ffffff !important;
        border-color: var(--accent-blue) !important;
        box-shadow: 0 0 12px var(--accent-blue-alpha), 0 0 0 2px rgba(255, 255, 255, 0.3) !important;
        transform: scale(1.3);
    }

    /* Default node connected ports - keep green for backward compatibility */
    .default-node .diagram-port.has-links {
        background-color: var(--accent-green) !important;
        border-color: #27ae60 !important;
        box-shadow: 0 0 8px var(--accent-green-alpha) !important;
        transform: scale(1.15);
        animation: pulse-green 2s infinite;
    }

    .default-node.selected .diagram-port {
        border-color: var(--accent-blue) !important;
        box-shadow: 0 0 6px var(--accent-blue-alpha) !important;
        transform: scale(1.1);
    }

/* Custom Node Styling */
.custom-node {
    border-radius: var(--border-radius);
    overflow: visible;
    box-shadow: var(--shadow-primary);
    transition: box-shadow 0.2s ease;
}

    .custom-node:hover {
        box-shadow: var(--shadow-hover), 0 0 0 3px var(--accent-blue-alpha);
    }

    .custom-node.selected {
        box-shadow: var(--shadow-selected), 0 0 0 4px var(--accent-blue-alpha);
    }

    .custom-node .card {
        background-color: var(--bg-secondary);
        border: 2px solid var(--border-primary);
        border-radius: var(--border-radius);
        color: var(--text-primary);
        transition: border-color 0.2s ease, background-color 0.2s ease;
        height: 80px;
        width: 80px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .custom-node:hover .card {
        border-color: var(--accent-blue-bright);
        background-color: var(--node-hover);
    }

    .custom-node.selected .card {
        border-color: var(--accent-blue);
        background-color: var(--node-selected);
    }

    .custom-node .card-body {
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .custom-node .card-title {
        color: var(--text-primary);
        font-weight: 600;
        margin-bottom: 12px;
        font-size: 14px;
    }

    .custom-node .form-control {
        background-color: var(--bg-primary);
        border: 1px solid var(--border-secondary);
        color: var(--text-primary);
        border-radius: 6px;
        padding: 8px 12px;
        font-size: 12px;
        transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

        .custom-node .form-control:focus {
            border-color: var(--accent-blue);
            box-shadow: 0 0 0 2px var(--accent-blue-alpha);
            outline: none;
        }

        .custom-node .form-control::placeholder {
            color: var(--text-secondary);
        }

    .custom-node .diagram-port {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background-color: #f5f5f5;
        border: 2px solid var(--border-tertiary);
        cursor: pointer;
        transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
        transform: scale(1);
    }

        .custom-node .diagram-port.bottom {
            position: absolute;
            bottom: -8px;
            left: 50%;
            transform: translateX(-50%) scale(1);
        }

        .custom-node .diagram-port.top {
            position: absolute;
            top: -8px;
            left: 50%;
            transform: translateX(-50%) scale(1);
        }

    .custom-node:hover .diagram-port {
        border-color: var(--accent-blue-bright);
        box-shadow: 0 0 8px var(--accent-blue-alpha);
    }

        .custom-node:hover .diagram-port.bottom {
            transform: translateX(-50%) scale(1.1);
        }

        .custom-node:hover .diagram-port.top {
            transform: translateX(-50%) scale(1.1);
        }

    .custom-node .diagram-port:hover {
        background-color: #ffffff;
        border-color: var(--accent-blue);
        box-shadow: 0 0 12px var(--accent-blue-alpha), 0 0 0 2px rgba(255, 255, 255, 0.3);
    }

        .custom-node .diagram-port:hover.bottom {
            transform: translateX(-50%) scale(1.3);
        }

        .custom-node .diagram-port:hover.top {
            transform: translateX(-50%) scale(1.3);
        }

    /* Generic connected ports - keep for top/bottom ports */
    .custom-node .diagram-port.has-links {
        background-color: var(--accent-green);
        border-color: #27ae60;
        box-shadow: 0 0 8px var(--accent-green-alpha);
        animation: pulse-green 2s infinite;
    }

        .custom-node .diagram-port.has-links.bottom {
            transform: translateX(-50%) scale(1.15);
        }

        .custom-node .diagram-port.has-links.top {
            transform: translateX(-50%) scale(1.15);
        }

    /* LEFT PORTS - GREEN when connected */
    .custom-node .diagram-port.left.has-links {
        background-color: var(--accent-green);
        border-color: #27ae60;
        box-shadow: 0 0 8px var(--accent-green-alpha);
        transform: translateY(-50%) scale(1.15);
        animation: pulse-green 2s infinite;
    }

    /* RIGHT PORTS - RED when connected */
    .custom-node .diagram-port.right.has-links {
        background-color: var(--accent-red);
        border-color: #c0392b;
        box-shadow: 0 0 8px var(--accent-red-alpha);
        transform: translateY(-50%) scale(1.15);
        animation: pulse-red 2s infinite;
    }

    .custom-node.selected .diagram-port {
        border-color: var(--accent-blue);
        box-shadow: 0 0 6px var(--accent-blue-alpha);
    }

        .custom-node.selected .diagram-port.bottom {
            transform: translateX(-50%) scale(1.1);
        }

        .custom-node.selected .diagram-port.top {
            transform: translateX(-50%) scale(1.1);
        }

/* Colored Node Styling */
.colored-node {
    border: 2px solid var(--border-secondary);
    text-align: center;
    border-radius: var(--border-radius);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 16px;
    box-shadow: var(--shadow-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

    .colored-node:hover {
        border-color: var(--accent-blue-bright);
        box-shadow: var(--shadow-hover), 0 0 0 3px var(--accent-blue-alpha);
        background-color: #505153;
    }

    .colored-node.selected {
        border-color: var(--accent-blue);
        box-shadow: var(--shadow-selected), 0 0 0 4px var(--accent-blue-alpha);
        background-color: #353535;
    }

    .colored-node .diagram-port {
        width: 20px;
        height: 20px;
        border-radius: 50%;
        border: 2px solid var(--border-secondary);
        transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
        transform: scale(1);
    }

    .colored-node:hover .diagram-port {
        border-color: var(--accent-blue-bright);
        box-shadow: 0 0 8px var(--accent-blue-alpha);
        transform: scale(1.1);
    }

    .colored-node .diagram-port:hover {
        border-color: var(--accent-blue);
        box-shadow: 0 0 12px var(--accent-blue-alpha), 0 0 0 2px rgba(255, 255, 255, 0.3);
        transform: scale(1.25);
    }

    /* Colored node connected ports - keep green for backward compatibility */
    .colored-node .diagram-port.has-links {
        border-color: #27ae60;
        box-shadow: 0 0 8px var(--accent-green-alpha);
        transform: scale(1.15);
        animation: pulse-green 2s infinite;
    }

    .colored-node.selected .diagram-port {
        border-color: var(--accent-blue);
        box-shadow: 0 0 6px var(--accent-blue-alpha);
        transform: scale(1.1);
    }

    .colored-node .diagram-port.blue {
        background-color: #4a90e2;
    }

    .colored-node .diagram-port.red {
        background-color: #e74c3c;
    }

    .colored-node .diagram-port.green {
        background-color: #2ecc71;
    }

    .colored-node .diagram-port.orange {
        background-color: #f39c12;
    }

/* Animations */
@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 8px var(--accent-green-alpha);
    }

    50% {
        box-shadow: 0 0 16px var(--accent-green-alpha), 0 0 0 3px rgba(46, 204, 113, 0.2);
    }
}

@keyframes pulse-red {
    0%, 100% {
        box-shadow: 0 0 8px var(--accent-red-alpha);
    }

    50% {
        box-shadow: 0 0 16px var(--accent-red-alpha), 0 0 0 3px rgba(231, 76, 60, 0.2);
    }
}

@keyframes glow-blue {
    0%, 100% {
        box-shadow: 0 0 8px var(--accent-blue-alpha);
    }

    50% {
        box-shadow: 0 0 20px var(--accent-blue-alpha), 0 0 0 4px rgba(110, 159, 212, 0.2);
    }
}

/* Node Type Gradients */
.node-trigger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border-color: #e74c3c;
}

.node-ai {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    border-color: #9b59b6;
}

.node-decision {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    border-color: #2ecc71;
}

.node-action {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-color: #3498db;
}

.node-integration {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    border-color: #f39c12;
}

/* Group Styling */
div.diagram-group:not(.default) {
    outline: 2px solid var(--border-secondary);
    background-color: rgba(46, 204, 113, 0.1);
    border-radius: var(--border-radius);
    transition: outline-color 0.2s ease, background-color 0.2s ease;
}

    div.diagram-group:not(.default):hover {
        outline-color: var(--accent-blue-bright);
        background-color: rgba(46, 204, 113, 0.15);
    }

    div.diagram-group:not(.default) > span.title {
        padding: 12px 20px;
        position: absolute;
        left: 50%;
        transform: translate(-50%, -50%);
        background: var(--bg-secondary);
        border: 2px solid var(--border-secondary);
        border-radius: 20px;
        color: var(--text-primary);
        font-weight: bold;
        text-transform: uppercase;
        font-size: 12px;
        transition: border-color 0.2s ease;
    }

g.diagram-group:not(.default) rect {
    outline: 2px solid var(--border-secondary);
    fill: rgba(46, 204, 113, 0.1);
}

g.diagram-group:not(.default) text {
    text-anchor: middle;
    dominant-baseline: middle;
    fill: var(--text-primary);
}

/* Link/Connection Styling - NO TRANSITIONS for smooth dragging */
.diagram-link path {
    stroke: var(--diagram-link);
    stroke-width: 2;
}

.diagram-link:hover path {
    stroke: var(--accent-blue-bright);
    stroke-width: 3;
    filter: drop-shadow(0 0 4px var(--accent-blue-alpha));
}

.diagram-link.selected path {
    stroke: var(--accent-blue);
    stroke-width: 4;
    filter: drop-shadow(0 0 6px var(--accent-blue-alpha));
    animation: glow-blue 3s infinite;
}

/* Left and Right Custom Port Styling */
.custom-node .diagram-port.left {
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%) scale(1);
}

.custom-node .diagram-port.right {
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%) scale(1);
}

/* Hover states for left and right ports */
.custom-node:hover .diagram-port.left {
    transform: translateY(-50%) scale(1.1);
}

.custom-node:hover .diagram-port.right {
    transform: translateY(-50%) scale(1.1);
}

.custom-node .diagram-port:hover.left {
    transform: translateY(-50%) scale(1.3);
}

.custom-node .diagram-port:hover.right {
    transform: translateY(-50%) scale(1.3);
}

/* Selected state for left and right ports */
.custom-node.selected .diagram-port.left {
    transform: translateY(-50%) scale(1.1);
}

.custom-node.selected .diagram-port.right {
    transform: translateY(-50%) scale(1.1);
}



.diamond-node {
    transform: rotate(45deg);
    border-radius:0;
}

.diamond-node .card {
    border-radius: 0;
}

    .diamond-node .card .card-body {
        transform: rotate(-45deg);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        width: 80px;
        height: 80px;
    }

    .diamond-node .diagram-port.topleft {
        position: absolute;
        left: -6px;
        top: -6px;
        transform: scale(1);
    }

    .diamond-node .diagram-port.topright {
        position: absolute;
        right: -6px;
        top: -6px;
        transform: scale(1);
    }

    .diamond-node .diagram-port.bottomleft {
        position: absolute;
        left: -6px;
        bottom: -6px;
        transform: scale(1);
    }

    .diamond-node .diagram-port.bottomright {
        position: absolute;
        right: -6px;
        bottom: -6px;
        transform: scale(1);
    }


.category-item {
    border: 1px solid var(--text-primary);
    border-left: 4px solid var(--bs-primary);
}

    .category-item:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
    }

.category-header {
    user-select: none;
}

.draggable-item {
    border: 1px solid var(--text-primary);
    transition: all 0.2s ease;
}

    .draggable-item:hover {
        border-color: var(--bs-primary);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    }

.menu-image {
    filter: brightness(0) saturate(100%) invert(27%) sepia(51%) saturate(2878%) hue-rotate(346deg) brightness(104%) contrast(97%);
}