/* ===================================================
   AI AUTOMATION PAIN - SEQUENTIAL ANIMATION
   =================================================== */

.builder-pain {
    display: flex;
    flex-direction: column;
    background: #F5F5F7;
    border-radius: 8px;
    width: 620px;
    height: 520px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.15), inset 0 0 0 1px rgba(255, 255, 255, 0.8);
    border-radius: 18px;
}

/* Red Shadow on Error */
.builder-pain.error-state::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 100;
    animation: error-glow 0.6s ease-out 5s forwards;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@keyframes error-glow {
    to {
        box-shadow: inset 0 0 80px rgba(255, 84, 84, 0.3);
    }
}

/* Header */
.pain-header {
    font-size: 13px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #333;
    z-index: 10;
    height: 44px;
    background: radial-gradient(circle at center, #fcfcfc, #fcfcfc);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 8px;
    content: 'ИИ чат-бот';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.pain-title {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #24292E;
}

.pain-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 84, 84, 0);
    opacity: 0;
    animation: status-appear 0.4s ease-out 5.2s forwards;
}

@keyframes status-appear {
    to {
        opacity: 1;
        color: #FF5454;
    }
}

.pain-status span:first-child {
    font-size: 8px;
    animation: pulse-red 1.2s ease-in-out 5.4s infinite;
}

@keyframes pulse-red {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* Canvas */
.workflow-canvas {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at center, #F5F5F7, #E0E0E5);
    padding: 30px 20px;
    overflow: hidden;
    box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.15), inset 0 0 0 1px rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-top-right-radius: 0;
    border-top-left-radius: 0;
    border-top: 0;
}

.canvas-grid {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Node - SEQUENTIAL ANIMATION */
.flow-node {
    position: absolute;
    width: 80px;
    background: #FFFFFF;
    border: 2px solid #D1D5DA;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0;
    animation: node-appear 0.4s ease-out forwards;
}

/* Initial appearance */
.flow-node[data-step="1"] {
    animation-delay: 0.3s;
}

.flow-node[data-step="2"] {
    animation-delay: 0.5s;
}

.flow-node[data-step="3"] {
    animation-delay: 0.7s;
}

.flow-node[data-step="4"] {
    animation-delay: 0.9s;
}

.flow-node[data-step="5"] {
    animation-delay: 1.1s;
}

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

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

/* GREEN ACTIVATION */
.flow-node[data-step="1"] {
    animation: node-appear 0.4s ease-out 0.3s forwards,
        node-activate 0.5s ease-out 1.5s forwards;
}

.flow-node[data-step="2"] {
    animation: node-appear 0.4s ease-out 0.5s forwards,
        node-activate 0.5s ease-out 2.2s forwards;
}

.flow-node[data-step="3"] {
    animation: node-appear 0.4s ease-out 0.7s forwards,
        node-activate 0.5s ease-out 2.9s forwards;
}

.flow-node[data-step="4"] {
    animation: node-appear 0.4s ease-out 0.9s forwards,
        node-activate 0.5s ease-out 3.6s forwards;
}

/* END NODE - RED ERROR */
.flow-node[data-step="5"] {
    animation: node-appear 0.4s ease-out 1.1s forwards,
        node-error 0.6s ease-out 4.3s forwards;
}

@keyframes node-activate {
    to {
        border-color: #10B981;
        background: rgba(16, 185, 129, 0.1);
        box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
    }
}

@keyframes node-error {
    0% {
        border-color: #2a2a2a;
        background: #1a1a1a;
    }

    50% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }

    100% {
        border-color: #FF5454;
        background: rgba(255, 84, 84, 0.15);
        box-shadow: 0 0 24px rgba(255, 84, 84, 0.6);
        transform: translateX(0);
    }
}

/* Node Icon */
.node-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: #F5F5F7;
    transition: all 0.3s ease;
}

/* Node Label */
.node-name {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: #24292E;
    text-align: center;
}

/* Connections - SEQUENTIAL */
.flow-connections {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.conn {
    stroke-width: 2;
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    opacity: 0;
}

.conn[data-conn="1"] {
    animation: conn-activate 0.5s ease-out 1.8s forwards;
}

.conn[data-conn="2"] {
    animation: conn-activate 0.5s ease-out 2.5s forwards;
}

.conn[data-conn="3"] {
    animation: conn-activate 0.5s ease-out 3.2s forwards;
}

.conn[data-conn="4"] {
    animation: conn-error 0.5s ease-out 3.9s forwards;
}

@keyframes conn-activate {
    to {
        opacity: 1;
        stroke: #10B981;
        filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.5));
    }
}

@keyframes conn-error {
    to {
        opacity: 1;
        stroke: #FF5454;
        stroke-dasharray: 5 3;
        filter: drop-shadow(0 0 4px rgba(255, 84, 84, 0.6));
    }
}

/* Big Question */
.big-question-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 120px;
    color: rgba(255, 84, 84, 0.06);
    font-weight: 900;
    pointer-events: none;
    opacity: 0;
    animation: question-appear 0.6s ease-out 4.8s forwards;
}

@keyframes question-appear {
    to {
        opacity: 1;
        animation: question-fade 3s ease-in-out infinite;
    }
}

@keyframes question-fade {

    0%,
    100% {
        opacity: 0.08;
    }

    50% {
        opacity: 0.15;
    }
}

/* Error Panel */
.error-panel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(255, 84, 84, 0.3);
    border-radius: 8px;
    padding: 12px 20px;
    backdrop-filter: blur(20px);
    opacity: 0;
    animation: panel-appear 0.5s ease-out 5.5s forwards;
    max-width: 520px;
}

@keyframes panel-appear {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.panel-title {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #FF5454;
    margin-bottom: 8px;
}

.panel-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 12px;
    color: #586069;
    line-height: 1.5;
}

/* Result */
.pain-result {
    background: rgba(239, 68, 68, 0.08);
    border-top: 1px solid rgba(239, 68, 68, 0.2);
    padding: 14px 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 160, 160, 0.9);
    text-align: center;
}