/* Éditeur visuel des workflows IA (IA > Workflows IA), par-dessus lib/drawflow/drawflow.min.css. */

.wf-visual {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr) 380px;
    gap: 12px;
    height: calc(100vh - 260px);
    min-height: 520px;
}

.wf-palette {
    overflow-y: auto;
}

.wf-palette-item {
    cursor: grab;
    user-select: none;
    padding: 8px 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    border-left: 4px solid #186EB6;
    background: var(--mud-palette-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
    font-size: .85rem;
}

.wf-palette-item.wf-interactive { border-left-color: #28AE73; }
.wf-palette-item.wf-end { border-left-color: #757575; }
.wf-palette-item.wf-alert { border-left-color: #F57C00; }
.wf-palette-item.wf-event { border-left-color: #7B1FA2; }

.wf-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    border: 1px solid var(--mud-palette-lines-default);
    background-color: var(--mud-palette-background);
    background-image: radial-gradient(rgba(127, 127, 127, .25) 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: hidden;
}

.wf-side {
    overflow-y: auto;
}

/* ---- Ascenseurs (workflowCanvas.js : Drawflow n'en a pas) ---- */

.wf-scroll {
    position: absolute;
    z-index: 5;
    background: rgba(127, 127, 127, .10);
}

.wf-scroll-x { left: 0; right: 12px; bottom: 0; height: 12px; }
.wf-scroll-y { top: 0; bottom: 12px; right: 0; width: 12px; }
.wf-scroll-hidden { display: none; }

.wf-scroll-thumb {
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 6px;
    background: rgba(127, 127, 127, .45);
    cursor: pointer;
}

.wf-scroll-x .wf-scroll-thumb { height: 8px; margin-top: 2px; }
.wf-scroll-y .wf-scroll-thumb { width: 8px; margin-left: 2px; }
.wf-scroll-thumb:hover,
.wf-scrolling .wf-scroll-thumb { background: rgba(24, 110, 182, .75); }
.wf-scrolling { user-select: none; }

/* ---- Blocs ---- */

.wf-canvas .drawflow .drawflow-node {
    width: 220px;
    min-height: 0;
    padding: 0;
    border: 2px solid #186EB6;
    border-radius: 8px;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}

.wf-canvas .drawflow .drawflow-node.selected {
    background: var(--mud-palette-surface);
    box-shadow: 0 0 0 3px rgba(24, 110, 182, .35);
}

.wf-canvas .drawflow .drawflow-node.wf-interactive { border-color: #28AE73; }
.wf-canvas .drawflow .drawflow-node.wf-end { border-color: #757575; border-style: dashed; }
.wf-canvas .drawflow .drawflow-node.wf-end-alert { border-color: #D32F2F; }
.wf-canvas .drawflow .drawflow-node.wf-alert { border-color: #F57C00; }
.wf-canvas .drawflow .drawflow-node.wf-event { border-color: #7B1FA2; }
.wf-canvas .drawflow .drawflow-node.wf-start { box-shadow: 0 0 0 3px rgba(40, 174, 115, .35); }
.wf-canvas .drawflow .drawflow-node.wf-startblock {
    width: 180px;
    border-color: #28AE73;
    border-width: 3px;
    border-radius: 24px;
    background: rgba(40, 174, 115, .08);
}

.wf-canvas .drawflow .drawflow-node .drawflow_content_node {
    width: 100%;
    padding: 8px 10px;
}

.wf-node-title { font-weight: 600; font-size: .85rem; line-height: 1.2; }
.wf-node-key { font-size: .72rem; opacity: .65; margin-bottom: 4px; }
.wf-node-mapping { font-size: .72rem; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-node-badges { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }

.wf-badge {
    font-size: .65rem;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(24, 110, 182, .12);
    color: #186EB6;
}

.wf-badge.wf-badge-start { background: rgba(40, 174, 115, .15); color: #1d7f54; }
.wf-badge.wf-badge-warning { background: rgba(245, 124, 0, .15); color: #b45a00; }

.wf-canvas .drawflow .drawflow-node .input,
.wf-canvas .drawflow .drawflow-node .output {
    width: 14px;
    height: 14px;
    border: 2px solid #186EB6;
    background: var(--mud-palette-surface);
}

.wf-canvas .drawflow .drawflow-node .output { background: #186EB6; }

/* ---- Liens ---- */

.wf-canvas .drawflow .connection .main-path {
    stroke: #186EB6;
    stroke-width: 3px;
}

.wf-canvas .drawflow .connection .main-path:hover { stroke: #28AE73; }
.wf-canvas .drawflow .connection .main-path.selected { stroke: #F57C00; }

.wf-canvas .drawflow .connection.wf-edge-conditional .main-path { stroke-dasharray: 8 5; }
.wf-canvas .drawflow .connection.wf-edge-failed .main-path { stroke: #D32F2F; }
.wf-canvas .drawflow .connection.wf-edge-parallel .main-path { stroke: #28AE73; }

/* Liens de données (variables d'un agent, brique de données) : pointillés verts, sous les blocs, non cliquables. */
.wf-data-links {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    overflow: visible;
    pointer-events: none;
}

.wf-data-link {
    fill: none;
    stroke: #28AE73;
    stroke-width: 2px;
    stroke-dasharray: 4 4;
}

.wf-data-link-label {
    font-size: 11px;
    fill: #1B7A51;
    text-anchor: middle;
}

.wf-edge-labels {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.wf-edge-label {
    position: absolute;
    transform: translate(-50%, -50%);
    max-width: 220px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: .7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    pointer-events: auto;
    background: var(--mud-palette-surface);
    border: 1px solid #186EB6;
    color: var(--mud-palette-text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}

.wf-edge-label.wf-edge-failed { border-color: #D32F2F; }
.wf-edge-label.wf-edge-parallel { border-color: #28AE73; }
