/**
 * Workflow Graph Styles (Drawflow-based)
 * Custom styling to match original component design
 */

/* ═══════════════════════════════════════════════════════
   CONTAINER
   ═══════════════════════════════════════════════════════ */

.workflow-graph-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100px; /* Reduced to allow container to shrink with card */
    background: var(--surface-primary);
    border-radius: 12px;
    overflow: hidden;
}

.workflow-drawflow-container {
    width: 100%;
    height: 100%;
}

/* ═══════════════════════════════════════════════════════
   DRAWFLOW OVERRIDES
   ═══════════════════════════════════════════════════════ */

.drawflow {
    background: var(--surface-primary);
    background-size: 20px 20px;
}

.workflow-drawflow-container.show-grid .drawflow {
    background-image:
        linear-gradient(var(--border-subtle) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
}

/* ═══════════════════════════════════════════════════════
   NODE STYLING
   ═══════════════════════════════════════════════════════ */

.drawflow-node {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    min-width: 150px;
}

.drawflow-node .inputs,
.drawflow-node .outputs {
    position: absolute;
}

.drawflow-node .inputs {
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
}

.drawflow-node .outputs {
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Socket styling - use !important to override Drawflow defaults */
.drawflow .drawflow-node .input,
.drawflow .drawflow-node .output {
    width: 20px !important;
    height: 20px !important;
    background: var(--blue-primary) !important;
    border: 2px solid var(--surface-primary) !important;
    border-radius: 50% !important;
    cursor: crosshair !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
}

.drawflow .drawflow-node .input:hover,
.drawflow .drawflow-node .output:hover {
    transform: scale(1.3) !important;
    box-shadow: 0 0 12px var(--blue-primary) !important;
}

/* Second output (branch) - position at bottom */
.drawflow .drawflow-node .output:nth-child(2) {
    position: absolute !important;
    right: auto !important;
    left: 50% !important;
    top: auto !important;
    bottom: -30px !important;
    transform: translateX(-50%) !important;
    background: var(--orange-primary) !important;
}

.drawflow .drawflow-node .output:nth-child(2):hover {
    transform: translateX(-50%) scale(1.3) !important;
    box-shadow: 0 0 12px var(--orange-primary) !important;
}

/* Node content */
.workflow-node-content {
    background: var(--surface-secondary);
    border: 2px solid var(--border-default);
    border-radius: 12px;
    padding: 12px 16px;
    min-width: 120px;
    cursor: grab;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.workflow-node-content:hover {
    border-color: var(--border-strong);
}

.drawflow-node.selected .workflow-node-content {
    border-color: var(--blue-primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.drawflow-node.highlighted .workflow-node-content {
    border-color: var(--green-primary);
    box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.2);
}

/* End node - green border */
.workflow-node-content.end-node {
    border-color: var(--green-primary);
}

/* Header */
.workflow-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.workflow-node-autotask {
    font-size: 12px;
}

.workflow-node-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Body - count display */
.workflow-node-body {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.workflow-node-count {
    font-size: 24px;
    font-weight: 700;
    color: var(--blue-primary);
    line-height: 1;
}

.workflow-node-count.warning {
    color: var(--orange-primary);
}

.workflow-node-count.critical {
    color: var(--red-primary);
}

.workflow-node-items {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ═══════════════════════════════════════════════════════
   CONNECTION STYLING
   ═══════════════════════════════════════════════════════ */

.drawflow .connection .main-path {
    stroke: var(--blue-primary);
    stroke-width: 2.5;
    fill: none;
}

.drawflow .connection .main-path:hover {
    stroke-width: 4;
}

/* Branch connections (from output_2) */
.drawflow .connection.output_2 .main-path {
    stroke: var(--orange-primary);
    stroke-dasharray: 8 4;
}

/* Selected connection */
.drawflow .connection.selected .main-path {
    stroke-width: 4;
    filter: drop-shadow(0 0 4px var(--blue-primary));
}

/* ═══════════════════════════════════════════════════════
   CONTROLS
   ═══════════════════════════════════════════════════════ */

.workflow-graph-controls {
    position: absolute;
    bottom: 4px;
    left: 4px;
    display: flex;
    gap: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    z-index: 10;
}

.workflow-control-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.workflow-control-btn:hover {
    background: var(--surface-tertiary);
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════
   DRAGGING STATE
   ═══════════════════════════════════════════════════════ */

.drawflow-node.selected {
    z-index: 10;
}

.drawflow-node:active .workflow-node-content {
    cursor: grabbing;
}

/* Connection being drawn */
.drawflow svg .connection path {
    pointer-events: stroke;
}
