/* Overlay positioned within the specific container (.square-5) */
.security-overlay {
    position: absolute;
    /* Changed from fixed */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    /* Very transparent, glass-like */
    z-index: 20;
    /* Above video (z-4) but sane */
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    /* backdrop-filter: blur(2px); */
    /* Slight blur or none to see video clearly */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    border-radius: 2rem;
    /* Match container radius */
}

.security-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

/* Network Container */
.network-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Central Hub */
.hub-center {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(0, 104, 255, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border: 1px solid #e5e7eb;
    position: relative;
}

.hub-center img {
    width: 60px;
    height: auto;
}

.hub-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #0068ff;
    animation: ripple 2s infinite;
    z-index: -1;
}

/* Nodes */
.node {
    position: absolute;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #0068ff;
    z-index: 5;
}

/* Position nodes relative to container center */
.node.left {
    left: 15%;
}

.node.right {
    right: 15%;
}

.node.right.zalo-wave-node {
    isolation: isolate;
    overflow: visible;
    transform-origin: 50% 60%;
    animation: zaloNodePulse 2.2s ease-in-out infinite, zaloWaveSwing 1s ease-in-out infinite;
}

.node.right.zalo-wave-node::before,
.node.right.zalo-wave-node::after {
    content: "";
    position: absolute;
    inset: -6px;
    border: 2px solid rgba(2, 123, 255, 0.5);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    animation: zaloWave 2.2s ease-out infinite;
}

.node.right.zalo-wave-node::after {
    animation-delay: 1.1s;
}

.zalo-node-icon {
    width: 40px;
    height: 40px;
    animation: zaloFloat 2.2s ease-in-out infinite, zaloGlow 2.2s ease-in-out infinite;
    transform-origin: center;
    position: relative;
    z-index: 2;
}

/* Connecting Lines */
.connection-line {
    position: absolute;
    top: 50%;
    height: 2px;
    background: rgba(0, 104, 255, 0.5);
    /* More visible blueish line */
    z-index: 1;
}

.line-left {
    left: calc(15% + 60px);
    /* node.left + width */
    right: calc(50% + 50px);
    /* center - half hub width */
    width: auto;
}

.line-right {
    left: calc(50% + 50px);
    right: calc(15% + 60px);
    width: auto;
}

/* Data Packet */
.data-packet {
    position: absolute;
    top: 50%;
    width: 36px;
    height: 36px;
    background: #fff;
    border: 2px solid #0068ff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #0068ff;
    font-size: 14px;
    z-index: 6;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(0, 104, 255, 0.4);
}

/* Status Text - Positioned at bottom of container */
.security-status {
    position: absolute;
    bottom: 40px;
    text-align: center;
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.security-status h3 {
    font-size: 18px;
    color: #0068ff;
    margin-bottom: 4px;
    font-weight: 700;
}

.security-status p {
    font-size: 14px;
    color: #555;
    margin: 0;
}

/* Animations matching JS logic */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes ripple {
    0% {
        width: 100%;
        height: 100%;
        opacity: 0.8;
        border-width: 2px;
    }

    100% {
        width: 160%;
        height: 160%;
        opacity: 0;
        border-width: 0px;
    }
}

@keyframes zaloFloat {
    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-4px) scale(1.05);
    }
}

@keyframes zaloGlow {
    0%,
    100% {
        filter: drop-shadow(0 0 0 rgba(2, 123, 255, 0.2));
    }

    50% {
        filter: drop-shadow(0 0 12px rgba(2, 123, 255, 0.55));
    }
}

@keyframes zaloWave {
    0% {
        transform: scale(0.9);
        opacity: 0.9;
    }

    70% {
        opacity: 0.2;
    }

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

@keyframes zaloNodePulse {
    0%,
    100% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), 0 0 0 rgba(2, 123, 255, 0);
    }

    50% {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14), 0 0 18px rgba(2, 123, 255, 0.35);
    }
}

@keyframes zaloWaveSwing {
    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-2px) rotate(-7deg);
    }

    50% {
        transform: translateY(-3px) rotate(0deg);
    }

    75% {
        transform: translateY(-2px) rotate(7deg);
    }
}

/* Keyframes need to match the new fluid widths. 
   Using percentages is safer for responsive container.
*/

/* Left Node is at ~15% + 30px(half width). Center Hub is at 50%.
   We can animate 'left' property from Node position to Center position.
*/
@keyframes flowLeftToCenter {
    0% {
        left: calc(15% + 30px);
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    90% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        left: 50%;
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
}

@keyframes flowCenterToRight {
    0% {
        left: 50%;
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    90% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        left: calc(85% - 30px);
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
}

@keyframes flowRightToCenter {
    0% {
        left: calc(85% - 30px);
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    90% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        left: 50%;
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
}

/* Success */
.success-icon {
    font-size: 50px;
    color: #00c853;
    animation: scaleUp 0.4s;
}

@keyframes scaleUp {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}
