/* =========================================
   React Flow Workflow Canvas Styles
   ========================================= */

/* Canvas wrapper */
.workflow-canvas-wrapper {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    height: 460px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    position: relative;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: center center;
}

.workflow-canvas-wrapper.is-drop-target {
    border-color: rgba(0, 240, 255, 0.28);
    box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.1), 0 0 32px rgba(0, 240, 255, 0.08);
}

/* Override React Flow internals for dark theme */
.workflow-canvas-wrapper .react-flow__background {
    background: transparent !important;
}

.workflow-canvas-wrapper .react-flow__pane {
    cursor: grab;
}

.workflow-canvas-wrapper .react-flow__pane:active {
    cursor: grabbing;
}

/* Edges */
.workflow-canvas-wrapper .react-flow__edge-path {
    stroke: rgba(0, 240, 255, 0.35) !important;
    stroke-width: 2 !important;
}

.workflow-canvas-wrapper .react-flow__edge.animated .react-flow__edge-path {
    stroke-dasharray: 5 5;
    animation: wf-edge-flow 1s linear infinite;
}

@keyframes wf-edge-flow {
    to {
        stroke-dashoffset: -10;
    }
}

/* Hide default controls and attribution */
.workflow-canvas-wrapper .react-flow__controls,
.workflow-canvas-wrapper .react-flow__attribution {
    display: none !important;
}

/* =========================================
   Custom Node Styles
   ========================================= */

/* Terminal Node (Start / End) */
.wf-terminal-node {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(14, 18, 28, 0.96), rgba(8, 11, 18, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #eef6ff;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    min-width: 136px;
    justify-content: center;
    will-change: transform;
    overflow: visible;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.wf-terminal-start {
    border-color: rgba(50, 243, 194, 0.36);
    box-shadow: 0 0 0 1px rgba(50, 243, 194, 0.08), 0 12px 28px rgba(0, 0, 0, 0.36);
}

.wf-terminal-end {
    border-color: rgba(255, 111, 111, 0.34);
    box-shadow: 0 0 0 1px rgba(255, 111, 111, 0.08), 0 12px 28px rgba(0, 0, 0, 0.36);
}

.wf-node-label {
    color: #f7fbff;
    line-height: 1.1;
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}

.wf-terminal-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 12px currentColor;
}


/* Placeholder Node ("+") */
.wf-placeholder-node {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    border: 2px dashed rgba(0, 240, 255, 0.25);
    background: rgba(0, 240, 255, 0.03);
    cursor: pointer;
    transition: all 0.25s ease;
    will-change: transform, box-shadow;
    overflow: visible;
}

.wf-placeholder-node:hover {
    border-color: rgba(0, 240, 255, 0.6);
    background: rgba(0, 240, 255, 0.08);
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
}

.wf-placeholder-icon {
    font-size: 1.4rem;
    color: rgba(0, 240, 255, 0.5);
    font-weight: 300;
    line-height: 1;
    transition: color 0.25s;
}

.wf-placeholder-node:hover .wf-placeholder-icon {
    color: rgba(0, 240, 255, 0.9);
}

/* Workflow Step Node */
.wf-step-node {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(14, 18, 28, 0.96), rgba(8, 11, 18, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f6fbff;
    font-size: 0.86rem;
    font-weight: 700;
    font-family: 'Sora', sans-serif;
    letter-spacing: 0.01em;
    min-width: 156px;
    max-width: 188px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    transition: transform 0.28s ease, border-color 0.28s ease, box-shadow 0.28s ease, background 0.28s ease;
    animation: wf-node-appear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: transform, box-shadow;
    overflow: visible;
}

.wf-step-node:hover {
    transform: translateY(-2px);
    border-color: rgba(118, 247, 255, 0.34);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(118, 247, 255, 0.1);
    background: linear-gradient(180deg, rgba(18, 24, 36, 0.98), rgba(10, 14, 22, 0.98));
}

.wf-node {
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.wf-node.wf-node--dragging {
    cursor: grabbing;
}

@keyframes wf-node-appear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.wf-step-icon {
    font-size: 1rem;
    color: #7cf6ff;
    display: inline-flex;
    flex: 0 0 auto;
}

.wf-step-icon svg {
    display: block;
}

.wf-step-label {
    flex: 1;
    white-space: normal;
    line-height: 1.25;
    color: #f7fbff;
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.36);
}

.wf-step-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(0, 255, 157, 0.15);
    color: #00ff9d;
    font-weight: 600;
}

/* Handles (visible and easier to catch) */
.wf-handle {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    min-height: 30px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 999px !important;
    opacity: 1 !important;
    z-index: 5 !important;
    pointer-events: all !important;
    touch-action: none;
}

.wf-handle::before {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 999px;
    background: rgba(81, 238, 255, 0.72);
    box-shadow: 0 0 0 1px rgba(0, 240, 255, 0.35), 0 0 14px rgba(0, 240, 255, 0.4);
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.wf-handle.react-flow__handle-left {
    left: -15px !important;
}

.wf-handle.react-flow__handle-right {
    right: -15px !important;
}

.wf-step-node:hover .wf-handle::before,
.wf-terminal-node:hover .wf-handle::before,
.wf-placeholder-node:hover .wf-handle::before,
.wf-handle.connectingfrom::before,
.wf-handle.connectionindicator::before {
    transform: scale(1.18);
    background: rgba(118, 247, 255, 0.98);
    box-shadow: 0 0 0 1px rgba(118, 247, 255, 0.6), 0 0 18px rgba(0, 240, 255, 0.55);
}

/* =========================================
   Node Button Panel
   ========================================= */

.wf-button-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.wf-add-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.5), rgba(15, 15, 25, 0.6));
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: 'Sora', sans-serif;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: relative;
    isolation: isolate;
}

.wf-add-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(40, 40, 55, 0.8), rgba(20, 20, 35, 0.9));
    border-color: rgba(0, 240, 255, 0.4);
    color: #fff;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 240, 255, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.wf-add-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.wf-add-btn-icon {
    font-size: 1rem;
}

/* =========================================
   Right Panel Layout for Scene 3
   ========================================= */

.wf-right-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 55%;
    max-width: 600px;
    z-index: 60;
    margin-left: auto;
    margin-right: 10%;
    /* Move it slightly to the left */
    padding: 2rem;
}

.wf-right-panel h3 {
    font-size: 2rem;
    margin-bottom: 0;
    background: linear-gradient(to right, #fff, #888);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.wf-subtitle {
    font-size: 0.82rem;
    color: #666;
    margin-bottom: 8px;
}

/* Simulation log */
.wf-sim-log {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #222;
    border-radius: 10px;
    padding: 10px 14px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: #555;
    max-height: 80px;
    overflow-y: auto;
}

.wf-sim-log .log-new {
    color: #00ff9d;
}

/* Responsive */
@media (max-width: 900px) {
    .wf-right-panel {
        width: 95%;
        max-width: none;
        margin: 0 auto;
        margin-right: auto;
        padding: 1rem;
        align-items: center;
        text-align: center;
    }

    .wf-right-panel h3 {
        font-size: 1.6rem;
    }

    .workflow-canvas-wrapper {
        height: 70vh;
        min-height: 450px;
        width: 100%;
        margin-left: 0;
        border-radius: 14px;
    }

    /* Big touch targets for handles */
    .wf-handle {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
    }

    .wf-handle::before {
        inset: 12px;
    }

    /* Thick edges */
    .workflow-canvas-wrapper .react-flow__edge-path {
        stroke-width: 5 !important;
        stroke: rgba(0, 240, 255, 0.5) !important;
    }

    /* Big terminal nodes */
    .wf-terminal-node {
        padding: 14px 28px;
        font-size: 1rem;
        min-width: 140px;
        font-weight: 600;
        gap: 10px;
    }

    .wf-terminal-dot {
        width: 12px;
        height: 12px;
    }

    /* Big step nodes */
    .wf-step-node {
        padding: 20px 26px;
        font-size: 1.1rem;
        min-width: 170px;
        gap: 16px;
        border-radius: 20px;
    }

    .wf-step-icon {
        font-size: 1.4rem;
    }

    .wf-step-label {
        font-size: 1.05rem;
    }

    .wf-step-badge {
        font-size: 0.8rem;
        padding: 4px 10px;
    }

    /* Big placeholder */
    .wf-placeholder-node {
        width: 72px;
        height: 72px;
        border-width: 3px;
    }

    .wf-placeholder-icon {
        font-size: 2.2rem;
    }

    /* Big buttons */
    .wf-button-panel {
        justify-content: center;
        gap: 10px;
    }

    .wf-add-btn {
        padding: 14px 20px;
        font-size: 0.95rem;
        gap: 10px;
        border-radius: 14px;
    }

    .wf-add-btn-icon {
        font-size: 1.3rem;
    }

    .wf-subtitle {
        font-size: 0.85rem;
    }
}

/* ===== Storyboard workflow redesign ===== */
.workflow-storyboard {
    position: relative;
    height: 560px;
    padding: 22px;
    border-radius: 26px;
    border: 1px solid rgba(255,255,255,0.08);
    background:
        radial-gradient(80% 70% at 50% 12%, rgba(92, 114, 255, 0.08) 0%, transparent 60%),
        linear-gradient(180deg, rgba(9,11,20,0.96), rgba(5,7,14,0.96));
    overflow: hidden;
}

.workflow-story-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.workflow-story-lines path {
    fill: none;
    stroke: rgba(112, 238, 255, 0.38);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 9 9;
    filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.14));
}

.workflow-story-grid {
    position: relative;
    width: 100%;
    height: 100%;
}

.workflow-story-slot {
    position: absolute;
}

.workflow-story-slot--start { left: 3%; top: 44%; width: 15%; }
.workflow-story-slot--verify { left: 19%; top: 42%; width: 22%; }
.workflow-story-slot--lookup { left: 47%; top: 15%; width: 24%; }
.workflow-story-slot--update { left: 56%; top: 42%; width: 24%; }
.workflow-story-slot--handoff { left: 69%; top: 42%; width: 22%; }
.workflow-story-slot--end { left: 83%; top: 44%; width: 15%; }

.wf-story-node {
    min-height: 120px;
    padding: 18px 18px 16px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(18, 23, 36, 0.98), rgba(10, 14, 24, 0.98));
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 18px 44px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04);
    backdrop-filter: blur(18px);
}

.wf-story-node.is-terminal {
    min-height: 108px;
    padding: 16px 16px 14px;
    background: linear-gradient(180deg, rgba(14, 19, 29, 0.98), rgba(9, 12, 20, 0.98));
}

.wf-story-node.is-terminal:not(.is-end) {
    border-color: rgba(50, 243, 194, 0.28);
}

.wf-story-node.is-terminal.is-end {
    border-color: rgba(255, 111, 111, 0.25);
}

.wf-story-node-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.wf-story-node-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(124,246,255,0.1);
    color: #87f6ff;
}

.wf-story-node-kicker {
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(182,194,220,0.7);
    font-weight: 700;
}

.wf-story-node h4 {
    margin: 0 0 8px;
    color: #f4f7ff;
    font-size: 1rem;
    line-height: 1.25;
}

.wf-story-node p {
    margin: 0;
    color: #b5c0d4;
    font-size: 0.86rem;
    line-height: 1.55;
}

.workflow-story-pills-wrap {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.35rem;
}

.workflow-story-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.workflow-story-pill {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0.56rem 0.8rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.08);
    color: #e3ecfb;
    font-size: 0.8rem;
    font-weight: 700;
}

@media (max-width: 1100px) {
    .workflow-storyboard { height: 620px; }
    .workflow-story-slot--verify { left: 17%; width: 25%; }
    .workflow-story-slot--lookup { left: 45%; width: 27%; }
    .workflow-story-slot--update { left: 52%; width: 27%; }
    .workflow-story-slot--handoff { left: 67%; width: 24%; }
}

@media (max-width: 900px) {
    .workflow-storyboard {
        height: auto;
        min-height: 0;
        padding: 18px;
    }

    .workflow-story-lines {
        display: none;
    }

    .workflow-story-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .workflow-story-slot {
        position: static;
        width: 100% !important;
    }

    .wf-story-node,
    .wf-story-node.is-terminal {
        min-height: 0;
    }
}
