/* ================================================================
   3D Integration Flow Visualization
   Three-tier architecture: Platforms → ZATCA Connector → ZATCA Server
   Shows the real data flow with animated packets and processing steps
   ================================================================ */

/* ---------- Stage / Container ---------- */
.integration-3d-stage {
    position: relative;
    width: 100%;
    height: 520px;
    perspective: 1400px;
    perspective-origin: 50% 45%;
    overflow: visible;
}

.integration-3d-scene {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    animation: scene-breathe 14s ease-in-out infinite;
}

@keyframes scene-breathe {
    0%, 100% { transform: rotateX(6deg) rotateY(-3deg); }
    50%      { transform: rotateX(3deg) rotateY(3deg); }
}

/* ---------- Background grid ---------- */
.integration-3d-stage::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 50% 50%, rgba(102,71,238,0.025) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
    z-index: 0;
}

/* ---------- SVG Lines Layer ---------- */
.data-flow-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    overflow: visible;
}

.data-flow-line {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    opacity: 0.3;
    transition: opacity 0.3s, stroke-width 0.3s;
}

.data-flow-line--to-connector {
    stroke: url(#flow-gradient-in);
}

.data-flow-line--to-zatca {
    stroke: url(#flow-gradient-submit);
}

.data-flow-line--from-zatca {
    stroke: url(#flow-gradient-response);
}

.data-flow-line--to-platform {
    stroke: url(#flow-gradient-return);
}

/* ========== THREE HUBS ========== */

/* ---------- ZATCA Connector Hub (CENTER) ---------- */
.hub-connector {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    margin: -60px 0 0 -60px;
    border-radius: 50%;
    background: linear-gradient(145deg, #6647EE 0%, #4A36B2 100%);
    box-shadow:
        0 0 0 6px rgba(102, 71, 238, 0.10),
        0 0 0 16px rgba(102, 71, 238, 0.05),
        0 0 50px rgba(102, 71, 238, 0.22),
        inset 0 -3px 10px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transform-style: preserve-3d;
    transform: translateZ(35px);
    animation: hub-pulse 4s ease-in-out infinite;
}

.hub-connector::before {
    content: '';
    position: absolute;
    inset: -14px;
    border-radius: 50%;
    border: 1.5px dashed rgba(102, 71, 238, 0.15);
    animation: hub-ring-spin 28s linear infinite;
}

.hub-connector__icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    margin-bottom: 3px;
}

.hub-connector__label {
    color: #fff;
    font-weight: 700;
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    text-align: center;
    line-height: 1.15;
}

.hub-connector__sublabel {
    color: rgba(255,255,255,0.6);
    font-size: 0.48rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 1px;
}

/* ---------- ZATCA Server Hub (RIGHT) ---------- */
.hub-zatca-server {
    position: absolute;
    top: 50%;
    right: 2%;
    width: 90px;
    height: 90px;
    margin-top: -45px;
    border-radius: 50%;
    background: linear-gradient(145deg, #1B6B3A 0%, #0D4D26 100%);
    box-shadow:
        0 0 0 5px rgba(27, 107, 58, 0.10),
        0 0 0 14px rgba(27, 107, 58, 0.05),
        0 0 40px rgba(27, 107, 58, 0.18),
        inset 0 -3px 8px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transform-style: preserve-3d;
    transform: translateZ(20px);
}

.hub-zatca-server::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 1.5px dashed rgba(27, 107, 58, 0.15);
    animation: hub-ring-spin 35s linear infinite reverse;
}

.hub-zatca-server__icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    margin-bottom: 2px;
}

.hub-zatca-server__label {
    color: #fff;
    font-weight: 700;
    font-size: 0.55rem;
    letter-spacing: 0.03em;
    text-align: center;
    line-height: 1.15;
}

.hub-zatca-server__sublabel {
    color: rgba(255,255,255,0.55);
    font-size: 0.45rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ---------- Shared Keyframes ---------- */
@keyframes hub-ring-spin {
    to { transform: rotate(360deg); }
}

@keyframes hub-pulse {
    0%, 100% {
        box-shadow: 0 0 0 6px rgba(102,71,238,0.10), 0 0 0 16px rgba(102,71,238,0.05), 0 0 50px rgba(102,71,238,0.22), inset 0 -3px 10px rgba(0,0,0,0.15);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(102,71,238,0.15), 0 0 0 24px rgba(102,71,238,0.07), 0 0 80px rgba(102,71,238,0.30), inset 0 -3px 10px rgba(0,0,0,0.15);
    }
}

/* ---------- Processing Steps (floating labels around connector) ---------- */
.processing-step {
    position: absolute;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.52rem;
    font-weight: 600;
    color: #4A36B2;
    white-space: nowrap;
    z-index: 18;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
    box-shadow: 0 3px 12px rgba(0,0,0,0.06);
    border: 1px solid rgba(102,71,238,0.1);
}

.processing-step::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}

.processing-step--validate::before { background: #FF6B35; }
.processing-step--sign::before { background: #6647EE; }
.processing-step--xml::before { background: #00C9B1; }
.processing-step--pdf::before { background: #E91E63; }

/* Steps show when connector is active */
.hub-connector.is-processing ~ .processing-step,
.integration-3d-stage:hover .processing-step {
    opacity: 1;
    transform: translateY(0);
}

.processing-step--validate {
    top: calc(50% - 80px);
    left: calc(50% - 10px);
    transition-delay: 0s;
}

.processing-step--sign {
    top: calc(50% - 58px);
    left: calc(50% + 40px);
    transition-delay: 0.1s;
}

.processing-step--xml {
    top: calc(50% + 46px);
    left: calc(50% + 35px);
    transition-delay: 0.2s;
}

.processing-step--pdf {
    top: calc(50% + 68px);
    left: calc(50% - 15px);
    transition-delay: 0.3s;
}

/* ---------- Platform Nodes (LEFT SIDE) ---------- */
.platform-node {
    position: absolute;
    width: 100px;
    padding: 10px 8px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 14px;
    box-shadow:
        0 6px 24px rgba(0, 0, 0, 0.07),
        0 2px 5px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 10;
    transform-style: preserve-3d;
    cursor: default;
    transition: transform 0.45s cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 0.45s cubic-bezier(0.23, 1, 0.32, 1);
}

.platform-node:hover {
    transform: translateZ(25px) scale(1.06) !important;
    box-shadow: 0 16px 40px rgba(0,0,0,0.12), 0 3px 10px rgba(0,0,0,0.05);
    z-index: 30;
}

.platform-node__logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius: 6px;
}

.platform-node__name {
    font-size: 0.62rem;
    font-weight: 700;
    color: #1A1D29;
    text-align: center;
    line-height: 1.15;
}

.platform-node__type {
    font-size: 0.5rem;
    color: #6C757D;
    text-align: center;
    line-height: 1.1;
}

.platform-node__badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 99px;
    font-size: 0.48rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.platform-node__badge--live {
    background: rgba(0, 201, 177, 0.1);
    color: #00C9B1;
}

.platform-node__badge--live::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #00C9B1;
    animation: badge-pulse 2s ease-in-out infinite;
}

.platform-node__badge--batch {
    background: rgba(102, 71, 238, 0.08);
    color: #6647EE;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.7); }
}

/* ---------- Node Positions (LEFT COLUMN, stacked vertically) ---------- */
.platform-node[data-platform="quickbooks"]  { top: 3%;   left: 3%;  transform: translateZ(12px); }
.platform-node[data-platform="qbd"]         { top: 17%;  left: 12%; transform: translateZ(8px); }
.platform-node[data-platform="xero"]        { top: 31%;  left: 2%;  transform: translateZ(14px); }
.platform-node[data-platform="shopify"]     { top: 46%;  left: 14%; transform: translateZ(10px); }
.platform-node[data-platform="loyverse"]    { top: 60%;  left: 1%;  transform: translateZ(16px); }
.platform-node[data-platform="ggpos"]       { top: 74%;  left: 13%; transform: translateZ(7px); }
.platform-node[data-platform="manager"]     { top: 86%;  left: 2%;  transform: translateZ(11px); }
.platform-node[data-platform="freshbooks"]  { top: 86%;  left: 26%; transform: translateZ(9px); }

/* ---------- Data Flow Labels (mini text on the flow paths) ---------- */
.flow-label {
    position: absolute;
    font-size: 0.48rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 99px;
    z-index: 16;
    pointer-events: none;
    opacity: 0.7;
    white-space: nowrap;
}

.flow-label--invoices {
    top: 8%;
    left: 32%;
    color: #6647EE;
    background: rgba(102, 71, 238, 0.06);
    border: 1px solid rgba(102, 71, 238, 0.12);
}

.flow-label--xml {
    top: 38%;
    right: 14%;
    color: #1B6B3A;
    background: rgba(27, 107, 58, 0.06);
    border: 1px solid rgba(27, 107, 58, 0.12);
}

.flow-label--response {
    bottom: 34%;
    right: 14%;
    color: #00897B;
    background: rgba(0, 137, 123, 0.06);
    border: 1px solid rgba(0, 137, 123, 0.12);
}

.flow-label--pdf {
    bottom: 8%;
    left: 32%;
    color: #E91E63;
    background: rgba(233, 30, 99, 0.06);
    border: 1px solid rgba(233, 30, 99, 0.12);
}

/* ---------- Animated Data Packets ---------- */
.data-packet {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    z-index: 15;
    pointer-events: none;
    opacity: 0;
}

.data-packet--invoice {
    background: #6647EE;
    box-shadow: 0 0 8px rgba(102,71,238,0.5), 0 0 16px rgba(102,71,238,0.2);
}

.data-packet--xml {
    background: #1B6B3A;
    box-shadow: 0 0 8px rgba(27,107,58,0.5), 0 0 16px rgba(27,107,58,0.2);
}

.data-packet--response {
    background: #00C9B1;
    box-shadow: 0 0 8px rgba(0,201,177,0.5), 0 0 16px rgba(0,201,177,0.2);
}

.data-packet--pdf {
    background: #E91E63;
    box-shadow: 0 0 8px rgba(233,30,99,0.4), 0 0 16px rgba(233,30,99,0.15);
}

/* ---------- Floating Particles ---------- */
.integration-particle {
    position: absolute;
    border-radius: 50%;
    background: rgba(102, 71, 238, 0.12);
    pointer-events: none;
    z-index: 1;
}

/* ========== RESPONSIVE ========== */

@media (max-width: 992px) {
    .integration-3d-stage {
        height: 440px;
        perspective: 1000px;
        margin-top: 20px;
    }

    .hub-connector { width: 100px; height: 100px; margin: -50px 0 0 -50px; }
    .hub-connector__icon { width: 26px; height: 26px; }
    .hub-connector__label { font-size: 0.55rem; letter-spacing: normal; }

    .hub-zatca-server { width: 75px; height: 75px; margin-top: -37px; }
    .hub-zatca-server__icon { width: 22px; height: 22px; }
    .hub-zatca-server__label { font-size: 0.48rem; }

    .platform-node { width: 85px; padding: 7px 5px; border-radius: 10px; }
    .platform-node__logo { width: 24px; height: 24px; }
    .platform-node__name { font-size: 0.55rem; }
    .platform-node__type { font-size: 0.45rem; }

    .processing-step { font-size: 0.46rem; padding: 3px 7px; }
    .flow-label { font-size: 0.42rem; }
}

@media (max-width: 768px) {
    .integration-3d-stage {
        height: 400px;
        perspective: 800px;
    }

    @keyframes scene-breathe {
        0%, 100% { transform: rotateX(3deg) rotateY(-2deg); }
        50%      { transform: rotateX(2deg) rotateY(2deg); }
    }

    .hub-connector { width: 82px; height: 82px; margin: -41px 0 0 -41px; }
    .hub-connector__icon { width: 22px; height: 22px; }
    .hub-connector__label { font-size: 0.5rem; }
    .hub-connector__sublabel { display: none; }
    .hub-connector::before { display: none; }

    .hub-zatca-server { width: 62px; height: 62px; margin-top: -31px; }
    .hub-zatca-server__icon { width: 18px; height: 18px; }
    .hub-zatca-server__label { font-size: 0.42rem; }
    .hub-zatca-server__sublabel { display: none; }
    .hub-zatca-server::before { display: none; }

    .platform-node { width: 72px; padding: 5px 4px; border-radius: 8px; }
    .platform-node__logo { width: 20px; height: 20px; }
    .platform-node__name { font-size: 0.48rem; }
    .platform-node__type { display: none; }
    .platform-node__badge { font-size: 0.42rem; padding: 1px 4px; }

    .processing-step { display: none; }
    .flow-label { display: none; }
}

@media (max-width: 480px) {
    .integration-3d-stage {
        height: 340px;
        perspective: 600px;
    }

    .platform-node { width: 60px; padding: 4px 3px; border-radius: 7px; }
    .platform-node__logo { width: 18px; height: 18px; border-radius: 4px; }
    .platform-node__name { font-size: 0.44rem; }
    .platform-node__badge { display: none; }

    .hub-connector { width: 66px; height: 66px; margin: -33px 0 0 -33px; }
    .hub-connector__icon { width: 18px; height: 18px; }
    .hub-connector__label { font-size: 0.44rem; }

    .hub-zatca-server { width: 52px; height: 52px; margin-top: -26px; }
    .hub-zatca-server__icon { width: 15px; height: 15px; }
    .hub-zatca-server__label { font-size: 0.38rem; }
}
