.ai-flow {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 15px;
}

.container-fluid {
    width: 100%;
    max-width: 1200px;
    display: flex;
    justify-content: center;
}

.main-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
           MOBILE LAYOUT - VERTICAL STACK (Default)
           ============================================ */
.mobile-layout {
    display: flex;
    flex-direction: column;
    gap: 25px;
    align-items: center;
    width: 100%;
    padding: 30px 20px;
}

.mobile-box {
    width: 100%;
    max-width: 280px;
    min-height: 80px;
    background: linear-gradient(145deg, #1e2d45, #2a3f5f);
    border-radius: 20px;
    border: 3px solid #3d5a7e;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    position: relative;
}

.mobile-box .sf-label {
    font-size: 1.05rem;
    color: #fff;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

.mobile-ai-module {
    width: 140px;
    height: 140px;
    background: linear-gradient(145deg, #ff6b6b, #ee5a6f);
    border-radius: 20px;
    border: 3px solid #ff8787;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 15px 40px rgba(255, 107, 107, 0.4);
    position: relative;
    margin: 10px 0;
}

.mobile-ai-module .ai-label {
    font-size: 1.1rem;
    color: #fff;
    font-weight: 700;
    text-align: center;
    position: relative;
    z-index: 11;
}

.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    border: 2px solid #ff6b6b;
    animation: pulse 2s ease-out infinite;
}

.pulse-ring:nth-child(2) {
    animation-delay: 0.5s;
}

.pulse-ring:nth-child(3) {
    animation-delay: 1s;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* Vertical flow lines for mobile */
.mobile-flow-line {
    width: 3px;
    height: 30px;
    background: linear-gradient(to bottom, transparent, #00d4ff, transparent);
    position: relative;
    margin: -5px 0;
}

.mobile-flow-line::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: #00d4ff;
    border-radius: 50%;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    animation: flowDown 2s ease-in-out infinite;
    filter: drop-shadow(0 0 6px #00d4ff);
}

@keyframes flowDown {

    0%,
    100% {
        top: 0;
        opacity: 0;
    }

    10%,
    90% {
        opacity: 1;
    }

    100% {
        top: 100%;
    }
}

/* Color Classes */
.purple-box {
    border-color: #9b59b6 !important;
    background: rgba(155, 89, 182, 0.15) !important;
}

.green-box {
    border-color: #00a86b !important;
    background: rgba(0, 168, 107, 0.15) !important;
}

.blue-box {
    border-color: #4169e1 !important;
    background: rgba(65, 105, 225, 0.15) !important;
}

.orange-box {
    border-color: #d35400 !important;
    background: rgba(211, 84, 0, 0.15) !important;
}

/* ============================================
           DESKTOP LAYOUT - CROSS PATTERN (769px and above)
           ============================================ */
.desktop-layout {
    display: none;
}

@media (min-width: 769px) {
    .mobile-layout {
        display: none;
    }

    .desktop-layout {
        display: block;
        position: relative;
        width: 100%;
        max-width: 800px;
        height: 650px;
    }

    /* AI Module - Center */
    .ai-module {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 140px;
        height: 150px;
        background: linear-gradient(145deg, #ff6b6b, #ee5a6f);
        border-radius: 20px;
        border: 3px solid #ff8787;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 15px 40px rgba(255, 107, 107, 0.4);
        z-index: 10;
    }

    .ai-label {
        color: #fff;
        font-size: 1.1rem;
        font-weight: 700;
        text-align: center;
        position: relative;
        z-index: 11;
    }

    /* Smart Factoring Boxes */
    .smart-factoring-box {
        position: absolute;
        background: linear-gradient(145deg, #1e2d45, #2a3f5f);
        border-radius: 20px;
        border: 3px solid #3d5a7e;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 15px 10px;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    }

    .sf-label {
        color: #fff;
        font-size: 1rem;
        font-weight: 600;
        text-align: center;
        line-height: 1.2;
    }

    .sf-top {
        top: 35px;
        left: 50%;
        transform: translateX(-50%);
        width: 240px;
        height: 80px;
    }

    .sf-bottom {
        bottom: 35px;
        left: 50%;
        transform: translateX(-50%);
        width: 240px;
        height: 80px;
    }

    .sf-left {
        top: 50%;
        left: -36px;
        transform: translateY(-50%);
        width: 230px;
        height: 80px;
    }

    .sf-right {
        top: 50%;
        right: -36px;
        transform: translateY(-50%);
        width: 230px;
        height: 80px;
    }

    /* SVG Paths */
    svg {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        pointer-events: none;
        z-index: 5;
    }

    .data-flow {
        stroke: #00d4ff;
        stroke-width: 2.5;
        fill: none;
        filter: drop-shadow(0 0 8px #00d4ff);
        stroke-dasharray: 10 5;
        animation: dashFlow 1s linear infinite;
    }

    @keyframes dashFlow {
        to {
            stroke-dashoffset: -50;
        }
    }

    .flow-particle {
        filter: drop-shadow(0 0 6px currentColor);
    }

    .particle-to-top {
        fill: #aa7fbd;
        offset-path: path('M 450 350 L 450 120');
        animation: flowToTop 2.5s ease-in-out infinite;
    }

    .particle-to-bottom {
        fill: #cfed8e;
        offset-path: path('M 450 350 L 450 580');
        animation: flowToBottom 2.5s ease-in-out infinite;
        animation-delay: 0.6s;
    }

    .particle-to-left {
        fill: #00a86b;
        offset-path: path('M 450 350 L 220 350');
        animation: flowToLeft 2.5s ease-in-out infinite;
        animation-delay: 1.2s;
    }

    .particle-to-right {
        fill: #ed7979;
        offset-path: path('M 450 350 L 680 350');
        animation: flowToRight 2.5s ease-in-out infinite;
        animation-delay: 1.8s;
    }

    @keyframes flowToTop {

        0%,
        100% {
            offset-distance: 0%;
            opacity: 0;
        }

        5%,
        95% {
            opacity: 1;
        }

        100% {
            offset-distance: 100%;
        }
    }

    @keyframes flowToBottom {

        0%,
        100% {
            offset-distance: 0%;
            opacity: 0;
        }

        5%,
        95% {
            opacity: 1;
        }

        100% {
            offset-distance: 100%;
        }
    }

    @keyframes flowToLeft {

        0%,
        100% {
            offset-distance: 0%;
            opacity: 0;
        }

        5%,
        95% {
            opacity: 1;
        }

        100% {
            offset-distance: 100%;
        }
    }

    @keyframes flowToRight {

        0%,
        100% {
            offset-distance: 0%;
            opacity: 0;
        }

        5%,
        95% {
            opacity: 1;
        }

        100% {
            offset-distance: 100%;
        }
    }
}

/* ============================================
           SMALL MOBILE ADJUSTMENTS
           ============================================ */
@media (max-width: 576px) {
    .ai-flow {
        padding: 0 10px;
    }

    .mobile-layout {
        gap: 20px;
        padding: 25px 15px;
    }

    .mobile-box {
        max-width: 100%;
        min-height: 70px;
        padding: 18px 12px;
    }

    .mobile-box .sf-label {
        font-size: 0.95rem;
    }

    .mobile-ai-module {
        width: 120px;
        height: 120px;
    }

    .mobile-ai-module .ai-label {
        font-size: 1rem;
    }

    .mobile-flow-line {
        height: 25px;
    }
}

@media (max-width: 400px) {
    .mobile-layout {
        gap: 18px;
        padding: 20px 12px;
    }

    .mobile-box {
        min-height: 65px;
        padding: 16px 10px;
        border-radius: 16px;
    }

    .mobile-box .sf-label {
        font-size: 14px;
    }

    .mobile-ai-module {
        width: 110px;
        height: 110px;
        border-radius: 18px;
    }

    .mobile-ai-module .ai-label {
        font-size: 0.95rem;
    }

    .pulse-ring {
        border-radius: 18px;
    }

    .mobile-flow-line {
        height: 22px;
    }
}

@media (max-width: 320px) {
    body {
        padding: 15px 0;
    }

    .ai-flow {
        padding: 0 8px;
    }

    .mobile-layout {
        gap: 15px;
        padding: 18px 10px;
    }

    .mobile-box {
        min-height: 60px;
        padding: 15px 8px;
        border-radius: 14px;
        border-width: 2px;
    }

    .mobile-box .sf-label {
        font-size: 0.85rem;
        letter-spacing: 0.2px;
    }

    .mobile-ai-module {
        width: 100px;
        height: 100px;
        border-radius: 16px;
        border-width: 2px;
    }

    .mobile-ai-module .ai-label {
        font-size: 0.9rem;
    }

    .pulse-ring {
        border-radius: 16px;
        border-width: 2px;
    }

    .mobile-flow-line {
        height: 20px;
        width: 2px;
    }

    .mobile-flow-line::before {
        width: 6px;
        height: 6px;
    }
}

/* Prevent text selection */
.ai-label,
.sf-label {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}