/* ==========================================================================
   Billing Flow — Animated data-flow showcase
   ========================================================================== */

/* === Canvas === */
.flow-stage {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 20px;
    background: linear-gradient(135deg, #0d1117 0%, #151D33 50%, #1a2340 100%);
    min-height: 560px;
    box-shadow: 0 12px 50px rgba(21, 29, 51, 0.25);
}

/* === Scene interieure (transformable pour le zoom) === */
.flow-scene {
    position: absolute;
    inset: 0;
    transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.6s ease;
    transform-origin: center center;
}

/* === Grille de fond subtile === */
.flow-stage::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 1px, transparent 0);
    background-size: 40px 40px;
    z-index: 0;
}

/* === Noeud client (vue zoomee) === */
.flow-client {
    position: absolute;
    z-index: 10;
}

.flow-client-label {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    text-align: center;
}

/* Facture en construction au centre */
.flow-invoice-build {
    position: absolute;
    width: 260px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    z-index: 20;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.flow-invoice-build.visible {
    opacity: 1;
    transform: scale(1);
}

.flow-invoice-build-header {
    padding: 10px 14px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.75rem;
    font-weight: 600;
    color: #151D33;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flow-invoice-build-body {
    padding: 8px 14px;
    min-height: 60px;
}

.flow-invoice-line-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.68rem;
    color: #495057;
    border-bottom: 1px solid #f0f0f0;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.flow-invoice-line-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.flow-invoice-line-item.social {
    color: #0C97B1;
    padding-left: 6px;
    border-left: 2px solid #0C97B1;
}

.flow-invoice-line-item.exceptional {
    color: #e65100;
    padding-left: 6px;
    border-left: 2px solid #ff9800;
}

.flow-invoice-build-total {
    display: flex;
    justify-content: space-between;
    padding: 8px 14px;
    background: #151D33;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
}

/* === Bulle de donnee qui voyage === */
.flow-bubble {
    position: absolute;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.62rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 15;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.flow-bubble.ldm {
    background: #DFE160;
    color: #151D33;
}

.flow-bubble.silae {
    background: #2196F3;
    color: white;
}

.flow-bubble.temps {
    background: #0C97B1;
    color: white;
}

.flow-bubble.mali {
    background: #ff9800;
    color: white;
}

/* === Source icons (petits cercles autour) === */
.flow-source-icon {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    z-index: 12;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.flow-source-icon.visible {
    opacity: 1;
}

.flow-source-icon.ldm {
    background: linear-gradient(135deg, #DFE160, #c9c850);
    color: #151D33;
}

.flow-source-icon.silae {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
}

.flow-source-icon.temps {
    background: linear-gradient(135deg, #0C97B1, #0a7f94);
    color: white;
}

.flow-source-icon.mali {
    background: linear-gradient(135deg, #ff9800, #e65100);
    color: white;
}

.flow-source-label {
    position: absolute;
    font-size: 0.65rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    z-index: 12;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.flow-source-label.visible {
    opacity: 1;
}

/* === Trail lumineux derriere les bulles === */
.flow-trail {
    position: absolute;
    width: 3px;
    border-radius: 2px;
    z-index: 14;
    opacity: 0;
    pointer-events: none;
}

/* === Vue zoomee-out : mini factures === */
.flow-mini-grid {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
    padding: 30px;
    opacity: 0;
    z-index: 25;
    transition: opacity 0.8s ease;
}

.flow-mini-grid.visible {
    opacity: 1;
}

.flow-mini-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.4s ease, transform 0.4s ease, background 0.3s ease;
}

.flow-mini-card.visible {
    opacity: 1;
    transform: scale(1);
}

.flow-mini-card.highlight {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(223, 225, 96, 0.3);
    box-shadow: 0 0 20px rgba(223, 225, 96, 0.1);
}

.flow-mini-card-name {
    font-size: 0.68rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 4px;
}

.flow-mini-card-ref {
    font-size: 0.58rem;
    color: rgba(255, 255, 255, 0.35);
    margin-bottom: 8px;
}

.flow-mini-card-lines {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.flow-mini-line {
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.08);
}

.flow-mini-line.hon { background: rgba(255, 255, 255, 0.15); }
.flow-mini-line.soc { background: rgba(12, 151, 177, 0.4); }
.flow-mini-line.exc { background: rgba(255, 152, 0, 0.4); }

.flow-mini-card-total {
    font-size: 0.72rem;
    font-weight: 700;
    color: #DFE160;
    text-align: right;
    margin-top: 6px;
}

/* Badge "en cours" avec particule animee */
.flow-mini-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.55rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
    width: fit-content;
}

.flow-mini-card-badge.done {
    background: rgba(47, 179, 68, 0.15);
    color: #51cf66;
}

.flow-mini-card-badge.processing {
    background: rgba(12, 151, 177, 0.15);
    color: #0C97B1;
}

/* Pulse sur les cartes en traitement */
.flow-mini-card.processing {
    animation: miniCardPulse 2s ease-in-out infinite;
}

@keyframes miniCardPulse {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 15px rgba(12, 151, 177, 0.15); }
}

/* === Scenes post-generation (act) === */
.flow-act {
    position: absolute;
    inset: 0;
    z-index: 26;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.flow-act.visible {
    opacity: 1;
}

/* Hub eexpi (source a gauche) */
.flow-act-hub {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 10;
}

.flow-act-hub-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, #DFE160, #c9c850);
    color: #151D33;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 6px 25px rgba(223, 225, 96, 0.3);
}

.flow-act-hub-icon.compta {
    background: linear-gradient(135deg, #748ffc, #4c6ef5);
    color: white;
    box-shadow: 0 6px 25px rgba(116, 143, 252, 0.3);
}

.flow-act-hub-icon.sepa {
    background: linear-gradient(135deg, #ffd43b, #fab005);
    color: #151D33;
    box-shadow: 0 6px 25px rgba(255, 212, 59, 0.3);
}

.flow-act-hub-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

/* Boites mail (scene email) */
.flow-act-target {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.4s ease;
    z-index: 5;
}

.flow-act-target i {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.4s ease;
}

.flow-act-target.received {
    background: rgba(81, 207, 102, 0.1);
    border-color: rgba(81, 207, 102, 0.3);
    color: rgba(255, 255, 255, 0.9);
}

.flow-act-target.received i {
    color: #51cf66;
}

/* Avion en papier (element volant) */
.flow-plane {
    position: absolute;
    z-index: 15;
    opacity: 0;
    font-size: 1rem;
    color: #51cf66;
    pointer-events: none;
    filter: drop-shadow(0 2px 6px rgba(81, 207, 102, 0.5));
    transform: translate(-50%, -50%);
}

/* Document PDF volant (scene compta) */
.flow-doc {
    position: absolute;
    z-index: 15;
    opacity: 0;
    padding: 4px 10px;
    background: rgba(116, 143, 252, 0.15);
    border: 1px solid rgba(116, 143, 252, 0.3);
    border-radius: 6px;
    font-size: 0.6rem;
    font-weight: 600;
    color: #748ffc;
    white-space: nowrap;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.flow-doc i {
    color: #e74c3c;
    margin-right: 2px;
}

/* Ecran outil comptable (scene compta) */
.flow-act-compta-screen {
    position: absolute;
    right: 8%;
    top: 50%;
    transform: translateY(-50%);
    width: 320px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    z-index: 10;
}

.flow-act-compta-header {
    padding: 10px 14px;
    background: #4c6ef5;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.flow-act-compta-body {
    padding: 6px 0;
}

.flow-act-compta-row {
    display: flex;
    align-items: center;
    padding: 5px 14px;
    font-size: 0.68rem;
    color: #495057;
    border-bottom: 1px solid #f0f0f0;
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.flow-act-compta-row.visible {
    opacity: 1;
    transform: translateX(0);
}

.flow-act-compta-row .code {
    font-family: monospace;
    font-weight: 700;
    color: #4c6ef5;
    width: 60px;
    flex-shrink: 0;
}

.flow-act-compta-row span:nth-child(2) {
    flex: 1;
}

.flow-act-compta-row .amt {
    font-weight: 600;
    text-align: right;
    min-width: 80px;
}

.flow-act-compta-row .amt.credit {
    color: #2fb344;
}

.flow-act-compta-footer {
    padding: 8px 14px;
    background: #f8f9fa;
    font-size: 0.65rem;
    color: #868e96;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Fichier SEPA volant */
.flow-sepa-file {
    position: absolute;
    z-index: 15;
    opacity: 0;
    padding: 6px 14px;
    background: rgba(255, 212, 59, 0.15);
    border: 1px solid rgba(255, 212, 59, 0.4);
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fab005;
    white-space: nowrap;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.flow-sepa-file i {
    margin-right: 3px;
}

/* Banque (scene SEPA) */
.flow-act-bank {
    position: absolute;
    left: 50%;
    top: 18%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 10;
    transition: all 0.5s ease;
}

.flow-act-bank-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.5s ease;
}

.flow-act-bank.received .flow-act-bank-icon {
    background: rgba(255, 212, 59, 0.15);
    border-color: rgba(255, 212, 59, 0.5);
    color: #ffd43b;
    box-shadow: 0 0 30px rgba(255, 212, 59, 0.2);
}

.flow-act-bank-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
}

.flow-act-bank.received .flow-act-bank-label {
    color: rgba(255, 255, 255, 0.9);
}

/* Clients préleves (scene SEPA) */
.flow-act-debit {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.4s ease;
    z-index: 5;
}

.flow-act-debit.visible {
    opacity: 1;
    transform: translateY(0);
    background: rgba(255, 212, 59, 0.08);
    border-color: rgba(255, 212, 59, 0.25);
    color: rgba(255, 255, 255, 0.9);
}

.flow-act-debit i {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.25);
    transition: color 0.4s ease;
}

.flow-act-debit.visible i {
    color: #ffd43b;
}

.flow-act-debit span {
    font-weight: 600;
    font-size: 0.68rem;
}

.flow-act-debit em {
    font-style: normal;
    font-weight: 700;
    color: #51cf66;
    font-size: 0.7rem;
}

/* Fleche de prelevement (banque → client) */
.flow-debit-arrow {
    position: absolute;
    z-index: 15;
    opacity: 0;
    font-size: 1.4rem;
    color: #ffd43b;
    pointer-events: none;
    filter: drop-shadow(0 2px 8px rgba(255, 212, 59, 0.6));
    transform: translate(-50%, -50%);
}

/* === Texte narratif superpose === */
.flow-narration {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.flow-narration.visible {
    opacity: 1;
}

.flow-narration-text {
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    padding: 12px 28px;
    border-radius: 30px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.flow-narration-text strong {
    color: #DFE160;
    font-weight: 700;
}

/* === Stat band en bas === */
.flow-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 40px;
    padding: 24px;
    background: linear-gradient(135deg, var(--color-primary) 0%, #1e2845 100%);
    border-radius: 16px;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.flow-stat {
    text-align: center;
}

.flow-stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--color-accent);
    line-height: 1;
    margin-bottom: 4px;
}

.flow-stat-label {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.6);
}

.flow-stats-note {
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 8px;
}

/* === Responsive === */
@media (max-width: 768px) {
    .flow-stage {
        min-height: 400px;
    }

    .flow-mini-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        padding: 16px;
        gap: 8px;
    }

    .flow-mini-card:nth-child(n+10) {
        display: none;
    }

    .flow-invoice-build {
        width: 200px;
    }

    .flow-stats {
        gap: 20px;
        flex-wrap: wrap;
        padding: 20px;
    }

    .flow-stat-value {
        font-size: 1.3rem;
    }

    .flow-act-hub-icon {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .flow-act-target {
        padding: 5px 10px;
        font-size: 0.6rem;
    }

    .flow-act-compta-screen {
        width: 240px;
        right: 4%;
    }

    .flow-act-compta-row {
        font-size: 0.6rem;
        padding: 4px 10px;
    }

    .flow-act-bank-icon {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }

    .flow-act-debit {
        padding: 6px 10px;
        font-size: 0.58rem;
    }

    .flow-act-debit span {
        font-size: 0.6rem;
    }

    .flow-act-debit em {
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    .flow-stage {
        min-height: 340px;
        border-radius: 14px;
    }

    .flow-mini-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .flow-mini-card:nth-child(n+7) {
        display: none;
    }

    .flow-stats {
        gap: 16px;
    }
}
