/* ==========================================================================
   Gardener Workflow Designer - canvas, nodes, links, palette
   Uses Radzen CSS variables so light/dark themes both work.
   Node geometry here MUST stay in sync with Gardener.Models.Workflow.CanvasGeometry.
   ========================================================================== */

.gd-shell {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 6rem);
    min-height: 520px;
    gap: .5rem;
}

.gd-main {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    gap: .5rem;
}

.gd-canvas-wrap {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ------------------------------------------------------------------ canvas */
.gd-canvas {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: var(--rz-base-background-color, #fafafa);
    border: 1px solid var(--rz-border-color, #e0e0e0);
    border-radius: var(--rz-border-radius, 4px);
    touch-action: none;
    outline: none;
    cursor: default;
}

.gd-canvas.gd-panning { cursor: grabbing; }

.gd-world {
    position: absolute;
    top: 0;
    left: 0;
    width: 8000px;
    height: 6000px;
    transform-origin: 0 0;
    background-image:
        linear-gradient(to right, rgba(128,128,128,.16) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(128,128,128,.16) 1px, transparent 1px);
    background-size: 20px 20px;
}

.gd-links {
    position: absolute;
    top: 0;
    left: 0;
    width: 8000px;
    height: 6000px;
    pointer-events: none;
    overflow: visible;
}

.gd-link {
    fill: none;
    stroke-width: 2;
    stroke: var(--rz-text-secondary-color, #78909c);
}

.gd-link-hit {
    fill: none;
    stroke: transparent;
    stroke-width: 14;
    pointer-events: stroke;
    cursor: pointer;
}

.gd-canvas.gd-linking .gd-link-hit { pointer-events: none; }

.gd-link.sel { stroke-width: 3.5; stroke-dasharray: none; filter: drop-shadow(0 0 3px currentColor); }

.gd-link.t-success { stroke: #2e7d32; }
.gd-link.t-fail    { stroke: #c62828; }
.gd-link.t-timeout { stroke: #ef6c00; }
.gd-link.t-alarm   { stroke: #b71c1c; stroke-dasharray: 6 4; }
.gd-link.t-true    { stroke: #2e7d32; }
.gd-link.t-false   { stroke: #6a1b9a; }
.gd-link.t-next    { stroke: #1565c0; }
.gd-link.t-dependency { stroke: #757575; stroke-dasharray: 4 4; }
.gd-link.t-data       { stroke: #00838f; stroke-dasharray: 2 4; }
.gd-link.t-manual_confirmed { stroke: #00695c; }
.gd-link.t-manual_rejected  { stroke: #ad1457; stroke-dasharray: 6 4; }
.gd-link.inactive { opacity: .35; stroke-dasharray: 3 5; }

.gd-temp-link {
    fill: none;
    stroke: var(--rz-primary, #1565c0);
    stroke-width: 2;
    stroke-dasharray: 5 4;
    pointer-events: none;
}

/* HTML label positioned in the world layer (SVG <text> is unusable from Razor) */
.gd-link-label {
    position: absolute;
    transform: translate(-50%, -100%);
    padding: 0 4px;
    border-radius: 3px;
    font-size: 10px;
    line-height: 14px;
    color: var(--rz-text-secondary-color, #607d8b);
    background: var(--rz-base-background-color, #fafafa);
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
}

/* -------------------------------------------------------------------- node */
.gd-node {
    position: absolute;
    width: 210px;
    background: var(--rz-base-100, #fff);
    border: 1px solid var(--rz-border-color, #cfd8dc);
    border-left: 6px solid var(--gd-accent, #546e7a);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,.10);
    font-size: 12px;
    user-select: none;
    cursor: move;
}

.gd-node.sel {
    border-color: var(--rz-primary, #1565c0);
    box-shadow: 0 0 0 2px var(--rz-primary, #1565c0), 0 2px 6px rgba(0,0,0,.25);
}

.gd-node.inactive { opacity: .5; }

.gd-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 8px 10px 0;
    font-weight: 700;
    color: var(--rz-text-title-color, #263238);
    overflow: hidden;
}

.gd-node-header .rz-icon,
.gd-node-header .material-icons {
    font-size: 16px;
    color: var(--gd-accent, #546e7a);
}

.gd-node-title {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gd-node-badges { display: flex; gap: 3px; }

.gd-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
}

.gd-badge.err  { background: #c62828; }
.gd-badge.warn { background: #ef6c00; }

.gd-node-body {
    position: relative;
    padding: 2px 10px 10px;
    min-height: 28px;
    color: var(--rz-text-secondary-color, #607d8b);
    line-height: 1.35;
}

.gd-node-cat {
    display: inline-block;
    padding: 0 5px;
    border-radius: 3px;
    background: var(--gd-accent, #546e7a);
    color: #fff;
    font-size: 9px;
    letter-spacing: .4px;
    text-transform: uppercase;
}

.gd-node-meta {
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ------------------------------------------------------------------- ports */
.gd-port {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--rz-base-100, #fff);
    border: 2px solid var(--rz-text-secondary-color, #78909c);
    cursor: crosshair;
    z-index: 2;
}

.gd-port.in  { left: -7px; }
.gd-port.out { right: -7px; }
.gd-port:hover { background: var(--rz-primary, #1565c0); border-color: var(--rz-primary, #1565c0); }
.gd-port.drop-ok { background: #2e7d32; border-color: #2e7d32; }

.gd-port-label {
    position: absolute;
    font-size: 9px;
    color: var(--rz-text-secondary-color, #90a4ae);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .12s;
}

/* revealed on hover, so the resting node looks like the mockup */
.gd-node:hover .gd-port-label { opacity: 1; }

.gd-port-label.in  { left: 10px; }
.gd-port-label.out { right: 10px; }

/* ----------------------------------------------------------------- palette */
.gd-side {
    width: 300px;
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.gd-palette {
    overflow-y: auto;
    padding-right: 4px;
}

.gd-palette-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    border: 1px solid var(--rz-border-color, #e0e0e0);
    border-left: 4px solid var(--gd-accent, #546e7a);
    border-radius: 4px;
    background: var(--rz-base-100, #fff);
    cursor: grab;
    font-size: 12px;
}

.gd-palette-item:hover { border-color: var(--rz-primary, #1565c0); }
.gd-palette-item:active { cursor: grabbing; }

.gd-palette-group {
    margin: 8px 0 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--rz-text-secondary-color, #90a4ae);
}

/* ------------------------------------------------------------ bottom panel */
.gd-bottom {
    height: 210px;
    flex: 0 0 auto;
    overflow: hidden;
}

.gd-bottom .rz-tabview-panel { overflow: auto; max-height: 150px; }

.gd-json {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 11px;
    white-space: pre;
    margin: 0;
}

.gd-empty {
    padding: 1rem;
    color: var(--rz-text-secondary-color, #90a4ae);
    font-size: 12px;
}

/* ==========================================================================
   Workflow Designer shell — toolbar, panels, node chrome
   ========================================================================== */

.ed-shell { display: flex; flex-direction: column; gap: .5rem; height: calc(100vh - 90px); }

.ed-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .6rem .9rem;
    border-radius: 6px;
    background: #263238;
}

.ed-title { color: #fff; }
.ed-actions { display: flex; gap: .4rem; margin-left: auto; flex-wrap: wrap; }
.ed-actions .rz-button { color: #fff !important; }

.ed-header {
    padding: .5rem .75rem;
    border: 1px solid var(--rz-border-color, #e0e0e0);
    border-radius: 6px;
    background: var(--rz-base-100, #fff);
}

.ed-meta { font-size: 12px; color: var(--rz-text-secondary-color, #607d8b); }

.ed-main { display: flex; gap: .5rem; flex: 1 1 auto; min-height: 0; }

.ed-canvas-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid var(--rz-border-color, #e0e0e0);
    border-radius: 6px;
    overflow: hidden;
    background: var(--rz-base-100, #fff);
}

.ed-canvas-wrap .gd-canvas { height: 100%; border: 0; border-radius: 0; }

.ed-side {
    flex: 0 0 300px;
    overflow-y: auto;
    border: 1px solid var(--rz-border-color, #e0e0e0);
    border-radius: 6px;
    background: var(--rz-base-100, #fff);
}

.ed-bottom {
    flex: 0 0 auto;
    max-height: 30vh;
    overflow-y: auto;
    border: 1px solid var(--rz-border-color, #e0e0e0);
    border-radius: 6px;
    background: var(--rz-base-100, #fff);
}

/* ---- palette ---- */
.ed-palette { padding: .5rem; }

.ed-cat {
    margin: .7rem 0 .3rem;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .5px;
}

.ed-widget {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .55rem;
    margin-bottom: .3rem;
    border: 1px solid var(--rz-border-color, #e0e0e0);
    border-left: 4px solid var(--ed-accent, #546e7a);
    border-radius: 5px;
    background: var(--rz-base-100, #fff);
    font-size: 12px;
    cursor: grab;
    user-select: none;
    transition: box-shadow .12s, transform .12s;
}

.ed-widget:hover { box-shadow: 0 2px 6px rgba(0,0,0,.12); transform: translateX(2px); }
.ed-widget:active { cursor: grabbing; }

/* ---- node ---- */
.ed-node.sel { box-shadow: 0 0 0 2px var(--rz-primary, #1565c0); }

.ed-acronym {
    padding: 1px 6px;
    border-radius: 9px;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .3px;
}

.ed-summary { font-size: 11px; line-height: 1.35; white-space: pre-line; }

.ed-masks { display: flex; gap: .4rem; flex-wrap: wrap; }

.ed-zoom {
    position: absolute;
    right: .5rem;
    bottom: .5rem;
    display: flex;
    gap: .1rem;
    padding: .15rem;
    border-radius: 5px;
    background: rgba(255,255,255,.9);
    box-shadow: 0 1px 4px rgba(0,0,0,.15);
}

/* ---- validation ---- */
.ed-findings { padding: .5rem; }

.ed-finding {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .3rem .4rem;
    border-bottom: 1px solid var(--rz-border-color, #eceff1);
    font-size: 12px;
}

.ed-sev {
    flex: 0 0 46px;
    padding: 1px 0;
    border-radius: 3px;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
}

.ed-sev.ok   { background: #4caf50; }
.ed-sev.warn { background: #ff9800; }
.ed-sev.err  { background: #f44336; }

/* ---- captions and header strip, matching the design mockup ---- */

.ed-canvas-caption,
.ed-bottom-caption {
    padding: .55rem .8rem .35rem;
    font-size: 13px;
    font-weight: 700;
    color: #37474f;
}

/* the canvas fills what is left once the caption has taken its height */
.ed-canvas-wrap { display: flex; flex-direction: column; }
.ed-canvas-wrap .gd-canvas { flex: 1 1 auto; min-height: 0; }

.ed-meta { display: inline-flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.ed-meta strong { color: var(--rz-text-title-color, #263238); font-weight: 600; }
.ed-sep { color: var(--rz-border-color, #cfd8dc); }

/* the library heading sits above the search box, as in the mockup */
.ed-side-title {
    padding: .6rem .7rem .2rem;
    font-size: 15px;
    font-weight: 700;
    color: #263238;
}

/* ==========================================================================
   Edit button on a node
   Sits above the node's own drag surface and carries gd-no-drag, so
   designer.js leaves its pointerdown alone and the click arrives normally.
   ========================================================================== */

.gd-edit-btn {
    position: absolute;
    top: -9px;
    right: -9px;
    width: 22px;
    height: 22px;
    padding: 0;
    line-height: 20px;
    text-align: center;
    font-size: 12px;
    border: 1px solid var(--rz-border-color, #cfd8dc);
    border-radius: 50%;
    background: #fff;
    color: var(--rz-primary, #1565c0);
    cursor: pointer;
    opacity: 0;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: opacity .12s, background .12s, color .12s;
}

/* always visible on the selected node, and on hover, so the canvas stays
   uncluttered while still being discoverable */
.gd-node:hover .gd-edit-btn,
.gd-node.sel .gd-edit-btn,
.tv-object:hover .gd-edit-btn,
.tv-object.sel .gd-edit-btn { opacity: 1; }

.gd-edit-btn:hover {
    background: var(--rz-primary, #1565c0);
    color: #fff;
    border-color: var(--rz-primary, #1565c0);
}

/* ---- apply bar in the properties pane ---- */
.ed-apply-bar {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    padding: .5rem;
    margin-top: .25rem;
    border-top: 1px solid var(--rz-border-color, #eceff1);
    background: var(--rz-base-50, #fafafa);
    position: sticky;
    bottom: 0;
}

/* the selected node should be unmistakable, so a click that worked never
   looks like one that did not */
.gd-node.sel {
    box-shadow: 0 0 0 3px var(--rz-primary, #1565c0), 0 4px 12px rgba(0,0,0,.18);
}

.gd-node.sel .gd-edit-btn {
    background: var(--rz-primary, #1565c0);
    color: #fff;
    border-color: var(--rz-primary, #1565c0);
}

/* ===========================================================================
   Shared small pieces used by all three Technology pages
   (Workflow Designer, Technology View, Widget Library).

   These live here rather than in site.css because all three pages load this
   stylesheet and nothing else does.

   .db-empty and .rf-mask are ported from SCADA480 dashboard.css. They were
   referenced by the pages from v2.11.81 onward but never defined in Gardener,
   so empty-state blocks rendered as unstyled paragraphs and the small
   monospace captions rendered in the body font — working, but visibly wrong.

   .wl-scope / .wl-scope-inline are the ownership line: the statement of which
   garden and system a drawing belongs to. They were introduced in v2.11.81
   with no rule at all, here or in SCADA480, so the lock icon and its text sat
   on the baseline with no background.
   =========================================================================== */

.db-empty {
    padding: 1.25rem;
    text-align: center;
    font-size: 12px;
    color: var(--rz-text-secondary-color, #90a4ae);
    border: 1px dashed var(--rz-border-color, #e0e0e0);
    border-radius: 6px;
}

.rf-mask {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 11px;
    color: var(--rz-text-secondary-color, #90a4ae);
}

/* the block form, inside a dialog */
.wl-scope {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    padding: 0.5rem 0.65rem;
    font-size: 12px;
    line-height: 1.45;
    color: var(--rz-text-secondary-color, #546e7a);
    background: var(--rz-base-200, #eceff1);
    border-left: 3px solid var(--rz-primary, #3f51b5);
    border-radius: 4px;
}

.wl-scope strong { color: var(--rz-text-color, #263238); }

/* the inline form, on a page header row */
.wl-scope-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    font-size: 12px;
    color: var(--rz-text-secondary-color, #546e7a);
    background: var(--rz-base-200, #eceff1);
    border-radius: 12px;
    white-space: nowrap;
}

.wl-scope-inline strong { color: var(--rz-text-color, #263238); }
