﻿.flow-grid {
    position: relative;
    display: grid;
    grid-auto-rows: var(--node-h);
    grid-auto-columns: var(--node-w);
    gap: var(--gap);
    padding: 10px;
    margin: 0 auto;
    min-width: fit-content;
}

.flow-node {
    border: 2px solid #333;
    border-radius: 10px;
    background: #fff;
    font-weight: 600;
    font-size: 20px;
    white-space: pre-line;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: all .2s ease;
    padding: 8px 6px; /* Giảm padding để chữ có nhiều không gian hơn */
    box-sizing: border-box;
    min-height: 70px;
    line-height: 1.4; /* Tăng line-height để chữ không bị dính */
    word-break: break-word; /* Tự động xuống dòng khi cần */
    overflow: hidden; /* Ẩn phần thừa */
}

    /* CANH CHỈNH CHỮ ĐẸP HƠN */
    .flow-node::before {
        content: '';
        display: inline-block;
        height: 100%;
        vertical-align: middle;
    }

    .flow-node > span {
        display: inline-block;
        vertical-align: middle;
        max-width: 100%;
        width: 100%;
        padding: 2px;
    }

    .flow-node:hover {
        background: #f5f5f5;
        border-color: #0d6efd;
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }

.flow-svg {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: visible;
}

/* ===== ARROW BASE ===== */
.flow-arrow {
    fill: none;
    stroke: #333;
    stroke-width: 2;
    pointer-events: none;
}

    /* ===== ARROW TYPE ===== */
    .flow-arrow.main {
        stroke: #0d6efd;
    }

    .flow-arrow.bom {
        stroke: #198754;
        stroke-dasharray: 5;
    }

    .flow-arrow.ie {
        stroke: #fd7e14;
        stroke-dasharray: 5 3;
    }

/* ===== ARROW HEAD ===== */
.arrow-head {
    fill: #333;
}

    .arrow-head.main {
        fill: #0d6efd;
    }

    .arrow-head.bom {
        fill: #198754;
    }

    .arrow-head.ie {
        fill: #fd7e14;
    }

/* ===== NODE HIGHLIGHT EFFECTS ===== */
.flow-node.node-highlight {
    border-color: #0d6efd !important;
    background: #e3f2fd !important;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2) !important;
    z-index: 100 !important;
}

.flow-node.node-connected {
    border-color: #198754 !important;
    background: #e8f5e9 !important;
}

/* ===== ARROW HIGHLIGHT ===== */
.flow-arrow.highlight {
    stroke-width: 3 !important;
    opacity: 1 !important;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.3));
}

/* Smooth transition for arrow hover */
.flow-arrow {
    transition: stroke-width 0.15s ease, opacity 0.15s ease;
}

/* ===== FIX CONTAINER HEIGHT ===== */
.sop-flow-wrapper {
    width: 100%;
    overflow-x: auto;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#flow {
    position: relative;
    min-height: 600px;
    padding-bottom: 40px;
}

/* ===== LEGEND ===== */
.flow-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    color: #555;
    font-weight: 500;
}

.legend-line {
    width: 40px;
    height: 3px;
    border-radius: 2px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1400px) {
    .flow-node {
        font-size: 18px;
        padding: 7px 5px;
        min-height: 65px;
        line-height: 1.35;
    }
}

@media (max-width: 1200px) {
    .flow-grid {
        transform: scale(0.9);
        transform-origin: top left;
    }

    .flow-node {
        font-size: 17px;
        padding: 6px 4px;
        min-height: 60px;
        line-height: 1.3;
    }

    .legend-item {
        font-size: 16px;
        gap: 10px;
    }
}

@media (max-width: 992px) {
    .flow-grid {
        transform: scale(0.85);
        transform-origin: top left;
    }

    .flow-node {
        font-size: 16px;
        padding: 5px 3px;
        min-height: 55px;
        line-height: 1.3;
    }

    .legend-item {
        font-size: 15px;
    }

    .sop-flow-wrapper {
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .flow-grid {
        transform: scale(0.75);
        transform-origin: top left;
    }

    .flow-node {
        font-size: 14px;
        padding: 4px 2px;
        min-height: 50px;
        line-height: 1.25;
    }

    .legend-item {
        font-size: 14px;
        gap: 8px;
    }

    .legend-line {
        width: 30px;
        height: 2px;
    }

    .flow-legend {
        gap: 20px;
    }
}

@media (max-width: 576px) {
    .flow-grid {
        transform: scale(0.65);
        transform-origin: top left;
    }

    .flow-node {
        font-size: 13px;
        padding: 3px 1px;
        min-height: 45px;
        line-height: 1.2;
    }

    .legend-item {
        font-size: 13px;
        gap: 6px;
    }

    .legend-line {
        width: 25px;
    }

    .sop-flow-wrapper {
        padding: 10px;
    }

    .flow-legend {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}

/* Animation for nodes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flow-node {
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0;
}

    /* Stagger animation for nodes */
    .flow-node:nth-child(1) {
        animation-delay: 0.1s;
    }

    .flow-node:nth-child(2) {
        animation-delay: 0.15s;
    }

    .flow-node:nth-child(3) {
        animation-delay: 0.2s;
    }

    .flow-node:nth-child(4) {
        animation-delay: 0.25s;
    }

    .flow-node:nth-child(5) {
        animation-delay: 0.3s;
    }

    .flow-node:nth-child(6) {
        animation-delay: 0.35s;
    }

    .flow-node:nth-child(7) {
        animation-delay: 0.4s;
    }

    .flow-node:nth-child(8) {
        animation-delay: 0.45s;
    }

    .flow-node:nth-child(9) {
        animation-delay: 0.5s;
    }

    .flow-node:nth-child(10) {
        animation-delay: 0.55s;
    }

    .flow-node:nth-child(11) {
        animation-delay: 0.6s;
    }

    .flow-node:nth-child(12) {
        animation-delay: 0.65s;
    }

    .flow-node:nth-child(13) {
        animation-delay: 0.7s;
    }

    .flow-node:nth-child(14) {
        animation-delay: 0.75s;
    }

    .flow-node:nth-child(15) {
        animation-delay: 0.8s;
    }

    .flow-node:nth-child(16) {
        animation-delay: 0.85s;
    }

    .flow-node:nth-child(17) {
        animation-delay: 0.9s;
    }

    .flow-node:nth-child(18) {
        animation-delay: 0.95s;
    }
    .flow-node:nth-child(19) {
        animation-delay: 1.0s;
    }
    .flow-node:nth-child(20) {
        animation-delay: 1.05s;
    }
    .flow-node:nth-child(21) {
        animation-delay: 1.1s;
    }
    .flow-node:nth-child(22) {
        animation-delay: 1.15s;
    }
    .flow-node:nth-child(23) {
        animation-delay: 1.2s;
    }
    .flow-node:nth-child(24) {
        animation-delay: 1.25s;
    }
    .flow-node:nth-child(25) {
        animation-delay: 1.3s;
    }
    .flow-node:nth-child(26) {
        animation-delay: 1.35s;
    }
    .flow-node:nth-child(27) {
        animation-delay: 1.4s;
    }
    .flow-node:nth-child(28) {
        animation-delay: 1.45s;
    }
    .flow-node:nth-child(29) {
        animation-delay: 1.5s;
    }
    .flow-node:nth-child(30) {
        animation-delay: 1.55s;
    }
    .flow-node:nth-child(31) {
        animation-delay: 1.6s;
    }
    .flow-node:nth-child(32) {
        animation-delay: 1.65s;
    }
    .flow-node:nth-child(33) {
        animation-delay: 1.7s;
    }
    .flow-node:nth-child(34) {
        animation-delay: 1.75s;
    }
    .flow-node:nth-child(35) {
        animation-delay: 1.8s;
    }


