/* ============================================================
   Workflow Editor Styles
   ============================================================ */

.wf-details-drawer .dxbl-drawer-body {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
.wf-details-drawer .wf-node-editor,
.wf-details-drawer .wf-node-editor > *,
.wf-details-drawer .wf-node-editor .dxbl-fl {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}



/* App Layout */
.wf-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.wf-header {
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 16px;
    background: #1a1a2e;
    color: white;
    flex-shrink: 0;
}

.wf-header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}

.wf-header-brand i {
    font-size: 20px;
}

.wf-main {
    flex: 1;
    overflow: hidden;
}

/* Workflow Editor Container */
.wf-editor {
    display: flex;
    height: 100%;
}

.wf-editor-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}



.wf-trigger-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 0 2px;
    font-size: 14px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
}

.wf-trigger-item:hover .wf-trigger-delete {
    opacity: 1;
}

.wf-trigger-delete:hover {
    color: #dc3545;
}

.wf-drawer-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
    min-height: 30px;
    width: 100%;
    box-sizing: border-box;
}

.wf-drawer-header span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wf-drawer-header-icon {
    font-size: 16px;
    flex-shrink: 0;
}

/* Image-based variant for the AI Agent's IcloneU logomark — sized to match
   the font-icon variant above so headers render at a consistent height. */
.wf-drawer-header-icon-img {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    object-fit: contain;
}

.wf-drawer-name-display {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 3px;
    transition: background-color 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.wf-drawer-name-display:hover {
    background-color: #f0f0f0;
}

.wf-drawer-name-pencil {
    font-size: 14px;
    opacity: 0;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.wf-drawer-name-display:hover .wf-drawer-name-pencil {
    opacity: 0.4;
}

.wf-drawer-name-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid #ccc;
    outline: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    padding: 0 2px;
}

.wf-drawer-header-actions {
    display: flex;
    gap: 0.15rem;
    margin-left: auto;
    flex-shrink: 0;
}

.wf-drawer-body {
    overflow-y: auto;
    height: 100%;
    width: 100%;
    position: relative;
}

/* Automation Management Bar */
.wf-automation-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
    min-height: 38px;
}

.wf-bar-combo {
    font-size: 12px;
}

.wf-bar-separator {
    width: 1px;
    height: 20px;
    background: #dee2e6;
    margin: 0 2px;
}

.wf-bar-spacer {
    flex: 1;
}

.wf-bar-zoom {
    font-size: 11px;
    color: #999;
    margin-left: auto;
}

/* Canvas Toolbar */
.wf-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.wf-toolbar-separator {
    width: 1px;
    height: 24px;
    background: #dee2e6;
    margin: 0 4px;
}

/* Canvas Container */
.wf-canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
}

.wf-canvas-container.wf-panning,
.wf-canvas-container.wf-panning * {
    cursor: grabbing !important;
}

.wf-canvas-container.wf-ctrl-dragging,
.wf-canvas-container.wf-ctrl-dragging * {
    cursor: copy !important;
}

/* SVG Layer (connections) */
.wf-svg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    pointer-events: none;
    overflow: visible;
}

.wf-svg-layer svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Canvas grid background - the pannable surface */
.wf-canvas-bg {
    position: absolute;
    top: -5000px;
    left: -5000px;
    width: 10000px;
    height: 10000px;
    background-image:
        radial-gradient(circle, #d0d0d0 1px, transparent 1px);
    background-size: 20px 20px;
    transform-origin: 0 0;
    pointer-events: auto;
    cursor: default;
}

/* Nodes Layer */
.wf-nodes-layer {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
}

/* Node Card - dimensions used by connection calculations in WorkflowEditor.razor */
/* If you change these, update constants in WorkflowEditor.razor.cs */
.wf-node {
    position: absolute;
    width: 220px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    border: 2px solid transparent;
    cursor: grab;
    user-select: none;
    transition: box-shadow 0.15s;
    /* Stacking: each node creates its own context; z-index set inline for selected nodes */
    z-index: 1;
    isolation: isolate;
}

.wf-node:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.wf-node.wf-node-selected {
    border-color: #4A90D9;
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.3), 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.wf-node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px 6px 0 0;
    color: white;
    font-size: 13px;
    font-weight: 600;
    height: 36px;
    box-sizing: border-box;
    cursor: grab;
}

.wf-node-header:active {
    cursor: grabbing;
}

.wf-node-header i {
    font-size: 16px;
}

.wf-node-header span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wf-node-delete-btn {
    font-size: 11px !important;
    opacity: 0;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: opacity 0.15s, background-color 0.15s;
    flex-shrink: 0;
}

.wf-node:hover .wf-node-delete-btn {
    opacity: 0.5;
}

.wf-node-delete-btn:hover {
    opacity: 1 !important;
    background-color: rgba(255, 255, 255, 0.25);
}

.wf-node-body {
    padding: 8px 12px 10px;
    font-size: 12px;
    color: #666;
    border-top: none;
    height: 38px;
    box-sizing: border-box;
}

.wf-node-body-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Rich SendMessage Node */
.wf-node-rich .wf-node-rich-body {
    padding: 4px 0;
    font-size: 12px;
    cursor: grab;
}

.wf-node-rich .wf-node-rich-body:active {
    cursor: grabbing;
}

.wf-node-element {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    height: 22px;
    box-sizing: border-box;
    color: #555;
    overflow: hidden;
}

.wf-node-element i {
    font-size: 11px;
    color: #999;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.wf-node-element span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* Variable chips inside node element text */
.wf-var-chip {
    display: inline;
    background: #e0ecff;
    color: #2563eb;
    border-radius: 3px;
    padding: 0 3px;
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
}

/* Scope variants — match the editor chip colors so the canvas previews
   visually agree with the editor. Same color scheme as .var-chip-cf etc. in
   AutoSizeMemo.razor. Custom field = purple, bot field = grey, run var = amber. */
.wf-var-chip-cf {
    background: #f1e9fb;
    color: #6b21a8;
}
.wf-var-chip-bf {
    background: #eef0f3;
    color: #475569;
}
.wf-var-chip-rv {
    background: #fef4e2;
    color: #92400e;
}

.wf-node-element-delay {
    color: #8bc34a;
}

.wf-node-element-delay i {
    color: #8bc34a;
}

.wf-node-button-row {
    display: flex;
    align-items: center;
    height: 26px;
    box-sizing: border-box;
    padding: 0 6px 0 20px;
    position: relative;
}

.wf-node-button-label {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    padding: 3px 8px;
    background: #f0f4ff;
    border: 1px solid #d4dfef;
    border-radius: 4px;
    font-size: 11px;
    color: #4A90D9;
    overflow: hidden;
    position: relative;
}

.wf-node-button-label i {
    font-size: 10px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.wf-node-button-label span {
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 18px;
}

.wf-port-button {
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.wf-port-output.wf-port-button:hover {
    transform: translateY(-50%) scale(1.4);
}

.wf-port-output.wf-port-button.wf-port-occupied:hover {
    transform: translateY(-50%) scale(1.3);
}

/* Integration rich node — connector icon + display name + action */
.wf-node-integration-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
}

.wf-node-integration-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.wf-node-integration-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.wf-node-integration-connector {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wf-node-integration-action {
    font-size: 11px;
    color: #777;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Randomizer rich node — each path as its own row with port on the right */
.wf-node-path-row {
    display: flex;
    align-items: center;
    height: 26px;
    box-sizing: border-box;
    padding: 0 14px 0 10px;
    position: relative;
    font-size: 12px;
    color: #555;
    gap: 8px;
    border-top: 1px solid #f0f0f0;
}

.wf-node-path-row:first-child {
    border-top: none;
}

.wf-node-path-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.wf-node-path-pct {
    color: #888;
    font-size: 11px;
    flex-shrink: 0;
}

/* Ports */
.wf-port-input {
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #999;
    background: white;
    cursor: crosshair;
    z-index: 2;
    transition: transform 0.15s, border-color 0.15s;
}

/* Larger invisible hit area for dropping connections */
.wf-port-input::before {
    content: '';
    position: absolute;
    top: -13px;
    left: -13px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.wf-port-input:hover {
    transform: translateX(-50%) scale(1.4);
    border-color: #4A90D9;
    background: #e8f0fe;
}

.wf-port-output-container {
    display: flex;
    /* space-around distributes ports across the node's full width so multi-
       port nodes (Condition: Yes/No, External Request: Success/Error,
       AI Agent: Completed/Abandoned) get enough room for their labels
       without overlapping. Single-port nodes still center correctly because
       space-around with one child centers it. */
    justify-content: space-around;
    position: absolute;
    bottom: -7px;
    left: 0;
    right: 0;
    /* Small horizontal padding so the leftmost / rightmost ports don't
       hug the node edges when labels are long. */
    padding: 0 8px;
}

.wf-port-output {
    position: relative;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #999;
    background: white;
    cursor: crosshair;
    z-index: 2;
    transition: transform 0.15s, border-color 0.15s;
}

.wf-port-output:hover {
    transform: scale(1.4);
    border-color: #4A90D9;
    background: #e8f0fe;
}

/* Occupied ports: filled with their border color to indicate connected */
.wf-port-output.wf-port-occupied {
    /* background is set inline via style to match the port's color */
    cursor: pointer;
}

.wf-port-output.wf-port-occupied:hover {
    transform: scale(1.3);
}

.wf-port-label {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #999;
    white-space: nowrap;
    pointer-events: none;
}

/* Connection Paths */
.wf-connection {
    fill: none;
    stroke: #9B9B9B;
    stroke-width: 2;
    pointer-events: none;
}

.wf-connection-hit {
    fill: none;
    stroke: transparent;
    stroke-width: 14;
    pointer-events: stroke;
    cursor: pointer;
}

.wf-connection-hit:hover + .wf-connection {
    stroke: #6B6B6B;
    stroke-width: 2.5;
}

.wf-connection.wf-connection-selected {
    stroke: #4A90D9;
    stroke-width: 3;
}

.wf-connection-temp {
    fill: none;
    stroke: #4A90D9;
    stroke-width: 2;
    stroke-dasharray: 6, 4;
    pointer-events: none;
}

.wf-connection-label {
    font-size: 11px;
    fill: #666;
    text-anchor: middle;
    pointer-events: none;
}

/* Connection delete button */
.wf-connection-delete {
    cursor: pointer;
    pointer-events: auto;
}

.wf-connection-delete circle {
    fill: #fff;
    stroke: #dc3545;
    stroke-width: 1.5;
}

.wf-connection-delete text {
    fill: #dc3545;
    font-size: 12px;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.wf-connection-delete:hover circle {
    fill: #dc3545;
}

.wf-connection-delete:hover text {
    fill: #fff;
}

/* Trigger / Starting Step Node */
.wf-trigger-node {
    position: absolute;
    min-width: 180px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 2px dashed #ccc;
    padding: 10px 14px;
    font-size: 12px;
    color: #666;
    z-index: 1;
}

.wf-trigger-node.wf-node-selected {
    border-color: #F5A623;
    box-shadow: 0 0 0 2px rgba(245, 166, 35, 0.3), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.wf-trigger-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.wf-trigger-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #444;
    border: 1px solid transparent;
}

.wf-trigger-item:hover {
    background: #f5f5f5;
    border-color: #ddd;
}

.wf-trigger-item.active {
    background: #fff8ee;
    border-color: #F5A623;
}

.wf-trigger-item .wf-trigger-icon {
    color: #F5A623;
    font-size: 13px;
    margin-top: 2px;
    flex-shrink: 0;
}

.wf-trigger-item .wf-trigger-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.wf-trigger-item .wf-trigger-name-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wf-trigger-item .wf-trigger-name {
    font-size: 12px;
    color: #333;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wf-trigger-item .wf-trigger-type {
    font-size: 10px;
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wf-trigger-item .wf-trigger-disabled-icon {
    font-size: 11px;
    color: #b0b0b0;
    flex-shrink: 0;
}

/* Disabled trigger — muted visuals */
.wf-trigger-item.wf-trigger-disabled .wf-trigger-icon,
.wf-trigger-item.wf-trigger-disabled .wf-trigger-name {
    color: #aaa;
}

.wf-trigger-item.wf-trigger-disabled .wf-trigger-name {
    text-decoration: line-through;
    text-decoration-color: #ccc;
}

.wf-trigger-item.wf-trigger-disabled .wf-trigger-type {
    color: #bbb;
}

/* Node Editor Panel */
.wf-node-editor {
  padding: 0 12px;
  box-sizing: border-box;
  min-width: 0;
}

.wf-node-editor-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

.wf-node-editor-header i {
    font-size: 18px;
}

/* Connection drop context menu */
.wf-drop-menu-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 199;
}

.wf-drop-menu {
    position: absolute;
    z-index: 200;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 4px 0;
    min-width: 180px;
    max-height: 340px;
    overflow-y: auto;
    animation: mp-fadeIn 0.15s ease-out;
}

.wf-drop-menu-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.1s;
}

.wf-drop-menu-item:hover {
    background: #f0f4ff;
}

.wf-drop-menu-item i,
.wf-drop-menu-item img {
    font-size: 14px;
    width: 18px;
    height: 18px;
    text-align: center;
    flex-shrink: 0;
}

.wf-node-editor-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
    text-align: center;
}

.wf-editor-section {
    margin-bottom: 16px;
}

.wf-editor-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #999;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wf-tip-icon {
    font-size: 12px;
    color: #bbb;
    cursor: help;
    text-transform: none;
}

.wf-tip-icon:hover {
    color: #888;
}

/* ─── Multi-selection drawer panel ─────────────────────────── */
.wf-multi-selection {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 4px 0;
}

.wf-multi-summary {
    flex: 1 1 auto;
    overflow-y: auto;
}

.wf-multi-count {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.wf-multi-help {
    font-size: 12px;
    color: #888;
    margin-bottom: 14px;
    line-height: 1.4;
}

.wf-multi-types {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wf-multi-type-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 12px;
    color: #444;
}

.wf-multi-type-icon {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    font-size: 14px;
}

.wf-multi-type-icon-img {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    object-fit: contain;
}

.wf-multi-type-label {
    flex: 1 1 auto;
}

.wf-multi-type-count {
    color: #888;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.wf-multi-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0 4px;
    border-top: 1px solid #eee;
    margin-top: 12px;
    flex-shrink: 0;
}

/* ─── Marquee selection rectangle ──────────────────────────── */
.wf-marquee {
    position: absolute;
    border: 1px dashed #6366f1;
    background: rgba(99, 102, 241, 0.10);
    pointer-events: none;
    z-index: 50;
    border-radius: 2px;
}

/* IcloneU icon for AI Agent node */
.wf-icon-icloneu {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 154.1 154.1'%3E%3Cpath fill='%23fff' fill-rule='evenodd' d='M73.8.6l17.7,10.2,2.7,10.2-13.9,23.9-24.1-13.9L73.8.6ZM141.5,35.9v20.5l-7.5,7.5h-27.6v-27.8h35.1v-.2ZM144.9,112.5l-17.7,10.2-10.2-2.7-13.9-23.9,24.1-13.9,17.5,30.3h.2ZM80.3,153.5l-17.7-10.2-2.7-10.2,13.9-23.9,24.1,13.9-17.5,30.3h-.2l.1.1ZM12.6,118.2v-20.5l7.5-7.5h27.6v27.8H12.6v.2ZM9.2,41.6l17.7-10.2,10.2,2.7,13.9,23.9-24.1,13.9s-17.7-30.3-17.7-30.3ZM63,59.5h20.5l7.5,7.5v27.6h-27.8v-35.1h-.2Z'/%3E%3C/svg%3E") no-repeat center/contain;
}

/* Loading */
.wf-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
}

/* Empty state */
.wf-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    color: #999;
}

.wf-empty-state i {
    font-size: 48px;
}
