/* Workflow Studio - lightweight sci-fi panel */

#workflow-content {
    --wf-bg: #03070f;
    --wf-panel: rgba(9, 20, 34, 0.48);
    --wf-panel-2: rgba(12, 24, 39, 0.42);
    --wf-glass: rgba(255, 255, 255, 0.075);
    --wf-glass-strong: rgba(255, 255, 255, 0.12);
    --wf-line: rgba(198, 244, 255, 0.22);
    --wf-line-strong: rgba(99, 235, 255, 0.5);
    --wf-cyan: #63ebff;
    --wf-blue: #45a9ff;
    --wf-green: #2ecc71;
    --wf-violet: #a66cff;
    --wf-text-dim: rgba(236, 240, 241, 0.66);
    --wf-shadow: 0 14px 34px rgba(0, 0, 0, 0.36);
    padding: 0 !important;
    margin: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 999;
    background:
        radial-gradient(circle at 18% 12%, rgba(69, 169, 255, 0.18), transparent 30%),
        radial-gradient(circle at 88% 18%, rgba(166, 108, 255, 0.12), transparent 28%),
        linear-gradient(135deg, #02050d 0%, #061422 48%, #02070d 100%);
}

/* 标题不占布局空间，保留全局 neon-title 样式 */
#workflow-content .module-header {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    margin: 0;
    pointer-events: none;
}

.wf-container {
    display: flex;
    width: 100%;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    border-radius: 0;
    border: none;
    isolation: isolate;
    background:
        radial-gradient(circle at 56% 46%, rgba(46, 204, 113, 0.06), transparent 42%),
        linear-gradient(135deg, rgba(3, 10, 18, 0.78), rgba(5, 18, 31, 0.84));
}

.wf-container::before,
.wf-container::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.wf-container::before {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.038), transparent 24% 82%, rgba(99, 235, 255, 0.026));
    opacity: 0.48;
}

.wf-container::after {
    background:
        radial-gradient(ellipse at center, transparent 44%, rgba(0, 0, 0, 0.42) 100%);
    opacity: 0.36;
}

.wf-toolbar,
.wf-canvas-wrap {
    position: relative;
    z-index: 1;
}

.wf-toolbar {
    width: 220px;
    min-width: 220px;
    padding: 84px 0 0;
    border-right: 1px solid rgba(210, 248, 255, 0.18);
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow: hidden;
    min-height: 0;
    contain: layout paint style;
}

.wf-toolbar:hover {
    transform: none;
}

.wf-toolbar::before {
    display: none;
}

.wf-toolbar-search {
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.105);
    background: transparent;
}

.wf-toolbar-search input {
    height: 32px;
    font-size: 0.78rem;
    border-radius: 8px;
    border-color: rgba(210, 248, 255, 0.18);
    background: rgba(2, 8, 17, 0.44);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.wf-toolbar-search input:focus {
    border-color: rgba(99, 235, 255, 0.55);
    box-shadow: 0 0 12px rgba(99, 235, 255, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.wf-toolbar-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.4rem 0.46rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 235, 255, 0.45) transparent;
}

.wf-toolbar-list::-webkit-scrollbar {
    width: 6px;
}

.wf-toolbar-list::-webkit-scrollbar-thumb {
    background: rgba(99, 235, 255, 0.36);
    border-radius: 999px;
}

.wf-toolbar-category {
    margin-bottom: 0.35rem;
}

.wf-toolbar-category-title {
    font-size: 0.62rem;
    color: rgba(192, 247, 255, 0.58);
    text-transform: uppercase;
    letter-spacing: 1.4px;
    padding: 0.42rem 0.6rem 0.24rem;
    font-weight: 700;
}

.wf-toolbar-item {
    position: relative;
    padding: 0.42rem 0.62rem;
    margin-bottom: 0.08rem;
    font-size: 0.78rem;
    color: var(--text);
    cursor: grab;
    border-radius: 7px;
    border: 1px solid transparent;
    background: transparent;
    transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    overflow: hidden;
    contain: paint;
}

.wf-toolbar-item::before {
    display: none;
}

.wf-toolbar-item:hover {
    background: rgba(255, 255, 255, 0.055);
    border-color: rgba(210, 248, 255, 0.12);
    color: #fff;
    transform: none;
}

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

.wf-toolbar-item .wf-item-icon {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--wf-cyan);
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(99, 235, 255, 0.68);
}

.wf-toolbar-item.hidden {
    display: none;
}

.wf-toolbar-actions {
    padding: 0.7rem 0.68rem 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.105);
    background: linear-gradient(0deg, rgba(255, 255, 255, 0.075), transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.wf-canvas-wrap {
    flex: 1;
    overflow: hidden;
    background:
        radial-gradient(circle at 25% 24%, rgba(99, 235, 255, 0.08), transparent 24%),
        radial-gradient(circle at 76% 76%, rgba(46, 204, 113, 0.055), transparent 26%);
    cursor: grab;
    isolation: isolate;
}

.wf-canvas-wrap:active {
    cursor: grabbing;
}

.wf-canvas-wrap.connecting {
    cursor: crosshair;
}

.wf-canvas-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 22% 18%, rgba(99, 235, 255, 0.055), transparent 28%),
        radial-gradient(circle at 72% 80%, rgba(46, 204, 113, 0.04), transparent 30%);
    opacity: 0.72;
}

.wf-grid {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0.86;
}

.wf-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: visible;
    transform-origin: 0 0;
    will-change: transform;
}

.wf-svg path.wf-connection {
    fill: none;
    stroke: url(#wf-line-gradient);
    stroke-width: 2.5;
    stroke-linecap: round;
    pointer-events: stroke;
    cursor: pointer;
    transition: stroke-width 0.14s ease;
}

.wf-svg path.wf-connection:hover {
    stroke-width: 3.5;
}

.wf-svg path.wf-connection.selected {
    stroke: #e74c3c;
    stroke-width: 3.5;
}

.wf-svg path.wf-temp-line {
    fill: none;
    stroke: rgba(99, 235, 255, 0.66);
    stroke-width: 2;
    stroke-dasharray: 8 5;
    pointer-events: none;
    animation: wf-dash 0.5s linear infinite;
}

@keyframes wf-dash {
    to {
        stroke-dashoffset: -13;
    }
}

.wf-svg circle.wf-flow-dot {
    fill: var(--primary);
}

.wf-nodes-layer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    transform-origin: 0 0;
    will-change: transform;
}

.wf-node {
    position: absolute;
    min-width: 190px;
    min-height: 0;
    max-width: none;
    padding: 0.72rem;
    cursor: move;
    user-select: none;
    z-index: 3;
    overflow: visible;
    display: flex;
    flex-direction: column;
    contain: layout style;
}

.wf-node:hover {
    transform: none;
}

.wf-node.selected {
    border-color: var(--secondary);
    box-shadow: 0 0 15px var(--secondary);
}

.wf-node.dragging {
    opacity: 0.92;
    z-index: 100;
    box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.42),
        0 0 14px rgba(99, 235, 255, 0.1);
}

.wf-node.resizing {
    z-index: 100;
    transition: none;
}

.wf-node-header,
.wf-node-body,
.wf-node-result {
    position: relative;
    z-index: 1;
}

.wf-node-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 0.42rem;
    margin-bottom: 0.42rem;
    border-bottom: 1px solid rgba(64, 224, 255, 0.12);
    background: transparent;
}

.wf-node-header .wf-node-title {
    min-width: 0;
    font-size: 0.76rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.35px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.wf-node-header .wf-node-type-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.wf-node-type-dot.input {
    background: var(--wf-blue);
    box-shadow: 0 0 8px rgba(69, 169, 255, 0.64);
}

.wf-node-type-dot.cipher {
    background: var(--wf-green);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.6);
}

.wf-node-type-dot.output {
    background: var(--wf-violet);
    box-shadow: 0 0 8px rgba(166, 108, 255, 0.62);
}

.wf-node-delete {
    width: 20px;
    height: 20px;
    border-radius: 7px;
    border: 1px solid rgba(255, 112, 112, 0.24);
    background: rgba(231, 76, 60, 0.12);
    color: #ff8a8a;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.14s ease, transform 0.14s ease, background 0.14s ease, border-color 0.14s ease;
    line-height: 1;
}

.wf-node:hover .wf-node-delete {
    opacity: 1;
}

.wf-node-delete:hover {
    background: rgba(231, 76, 60, 0.32);
    border-color: rgba(255, 112, 112, 0.48);
    transform: scale(1.08);
}

.wf-node-body {
    padding: 0;
    overflow: hidden;
    flex: 0 0 auto;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 0.34rem;
}

.wf-node-body textarea,
.wf-node-body input,
.wf-node-body select {
    font-size: 0.74rem;
    margin-bottom: 0;
    padding: 0.34rem 0.48rem;
    border-radius: 8px;
    border-color: rgba(220, 250, 255, 0.16);
    background: rgba(1, 8, 18, 0.42);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.065);
    transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.wf-node-body textarea:focus,
.wf-node-body input:focus,
.wf-node-body select:focus {
    border-color: rgba(99, 235, 255, 0.48);
    box-shadow: 0 0 10px rgba(99, 235, 255, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.wf-node-body textarea {
    min-height: 30px;
    resize: vertical;
}

.wf-node-input-field {
    width: 100%;
    max-width: none;
}

.wf-node-input {
    height: 30px;
    min-height: 30px;
    max-height: none;
    resize: none;
    overflow-y: hidden;
    line-height: 1.35;
}

.wf-node-input::-webkit-scrollbar {
    display: none;
}

.wf-node-body label {
    font-size: 0.68rem;
    color: rgba(192, 247, 255, 0.62);
    display: block;
    margin-bottom: 0.12rem;
    text-transform: uppercase;
    letter-spacing: 0.65px;
}

.wf-node-field {
    margin-bottom: 0;
}

.wf-node-row {
    display: flex;
    gap: 0.34rem;
    margin-bottom: 0;
}

.wf-node-row>* {
    flex: 1;
}

.wf-hmac-panel {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.34rem;
    margin-top: 0;
}

.wf-hmac-panel input {
    margin-bottom: 0;
}

.wf-check-row {
    display: inline-flex !important;
    align-items: center;
    gap: 0.3rem;
    margin: 0 !important;
    white-space: nowrap;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

.wf-check-row input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
}

.wf-node-result {
    padding: 0.36rem 0 0;
    border-top: 1px solid rgba(64, 224, 255, 0.06);
    overflow: visible;
    flex: 1 1 auto;
    min-height: 44px;
    display: flex;
    margin-top: 0.36rem;
}

/* 节点结果：继承全局 .result 样式，仅覆盖尺寸 */
.wf-node-result .result {
    font-size: 0.72rem;
    min-height: 100%;
    padding: 0.36rem 0.42rem;
    max-height: none;
    width: 100%;
    flex: 1 1 auto;
    overflow-y: auto;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}

.wf-resize-handle {
    position: absolute;
    z-index: 9;
    opacity: 0;
}

.wf-node:hover .wf-resize-handle,
.wf-node.selected .wf-resize-handle,
.wf-node.resizing .wf-resize-handle {
    opacity: 1;
}

.wf-resize-right {
    top: 12px;
    right: -3px;
    width: 8px;
    bottom: 16px;
    cursor: ew-resize;
}

.wf-resize-bottom {
    left: 12px;
    right: 16px;
    bottom: -3px;
    height: 8px;
    cursor: ns-resize;
}

.wf-resize-corner {
    right: 2px;
    bottom: 2px;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
}

.wf-resize-corner::after {
    content: '';
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 8px;
    height: 8px;
    border-right: 1px solid rgba(99, 235, 255, 0.5);
    border-bottom: 1px solid rgba(99, 235, 255, 0.5);
}

.wf-node-result .result.error {
    border-color: var(--error);
    color: var(--error);
}

.wf-node-result .result.waiting {
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}

.wf-port {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(2, 10, 22, 0.98);
    border: 2px solid rgba(99, 235, 255, 0.65);
    position: absolute;
    cursor: crosshair;
    z-index: 10;
    transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
    box-shadow: 0 0 0 2px rgba(2, 10, 22, 0.75);
}

.wf-port::after {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.wf-port:hover {
    background: rgba(99, 235, 255, 0.42);
    border-color: rgba(99, 235, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(99, 235, 255, 0.08), 0 0 12px rgba(99, 235, 255, 0.48);
    transform: scale(1.25);
}

.wf-port.connected {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(2, 10, 22, 0.75), 0 0 10px rgba(46, 204, 113, 0.58);
}

.wf-port.port-in {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
}

.wf-port.port-out {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
}

.wf-port.port-out-input {
    top: 38%;
    border-color: rgba(69, 169, 255, 0.75);
}

.wf-port.port-out-input.connected {
    background: var(--wf-blue);
    border-color: var(--wf-blue);
    box-shadow: 0 0 0 2px rgba(2, 10, 22, 0.75), 0 0 10px rgba(69, 169, 255, 0.56);
}

.wf-port.port-out-result {
    top: 62%;
}

.wf-port.port-in:hover,
.wf-port.port-out:hover {
    transform: translateY(-50%) scale(1.25);
}

.wf-drag-ghost {
    position: fixed;
    transform: translate(-50%, -50%);
    padding: 0.42rem 0.82rem;
    font-size: 0.75rem;
    color: #fff;
    background: rgba(7, 18, 32, 0.94);
    border: 1px solid rgba(99, 235, 255, 0.52);
    border-radius: 8px;
    pointer-events: none;
    z-index: 10000;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.36), 0 0 16px rgba(99, 235, 255, 0.14);
}

.wf-minimap {
    position: absolute;
    bottom: 40px;
    right: 12px;
    width: 150px;
    height: 100px;
    background: var(--wf-panel);
    border: 1px solid var(--wf-line);
    border-radius: 8px;
    z-index: 20;
    overflow: hidden;
    display: none;
}

.wf-selection-box {
    position: absolute;
    border: 1px solid rgba(99, 235, 255, 0.55);
    background: rgba(99, 235, 255, 0.055);
    z-index: 50;
    pointer-events: none;
}

@media (max-width: 768px) {
    .wf-container {
        height: calc(100vh - 80px);
        flex-direction: column;
    }

    .wf-toolbar {
        width: 100%;
        min-width: unset;
        height: 148px;
        min-height: 148px;
        padding-top: 0;
        border-right: none;
        border-bottom: 1px solid rgba(99, 235, 255, 0.18);
    }

    .wf-toolbar-search {
        padding: 0.55rem 0.6rem;
    }

    .wf-toolbar-list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
        padding: 0.3rem;
    }

    .wf-toolbar-item {
        padding: 0.34rem 0.54rem 0.34rem 0.62rem;
        font-size: 0.7rem;
        flex-shrink: 0;
        margin-bottom: 0;
    }

    .wf-toolbar-category {
        display: contents;
    }

    .wf-toolbar-category-title {
        display: none;
    }

    .wf-node {
        min-width: 180px;
    }
}
