/* CEO 10/05 — FAB stack collapse/expand pattern.
   Doctrine "ninvente rien juste arrange la" : regroupe les 3 FABs existants
   (feedback bottom 20px + page_assistant bottom 90px + cockpit bottom 160px)
   en pattern collapsed par défaut, expand au clic.

   Comportement :
   - Default : seul lp-fab-master (bouton primary "?") visible
   - Clic master : les FABs satellites apparaissent en cascade (anim 0.18s stagger)
   - Re-clic master ou click outside : retour collapsed
   - prefers-reduced-motion : pas d'animation (Galaxy J3 / handicap moteur)
*/

/* État collapsed par défaut : tous les FAB satellites cachés */
body:not(.lp-fab-stack-expanded) #lp-fdb-fab,
body:not(.lp-fab-stack-expanded) #lp-tour-restart,
body:not(.lp-fab-stack-expanded) #lp-cockpit-fab {
    opacity: 0;
    transform: translateY(20px) scale(0.7);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

/* CEO 12/05 R#3 — État expanded : satellites s'alignent HORIZONTALEMENT
   à GAUCHE du master button (avant : empilés verticalement, illisible).
   Master = bottom 20px right 20px (lp-assistant-btn ~56px de large).
   Satellites positionnés right 90 / 160 / 230 px sur même bottom 20px. */
body.lp-fab-stack-expanded #lp-fdb-fab,
body.lp-fab-stack-expanded #lp-tour-restart,
body.lp-fab-stack-expanded #lp-cockpit-fab {
    opacity: 1;
    transform: translateX(0) scale(1) !important;
    pointer-events: auto;
    bottom: 20px !important;
    position: fixed !important;
    transition: opacity 0.18s ease, transform 0.18s ease, right 0.18s ease;
}

/* Positions horizontales explicites (override CSS d'origine bottom: 90/160) */
body.lp-fab-stack-expanded #lp-fdb-fab {
    right: 90px !important;
}
body.lp-fab-stack-expanded #lp-tour-restart {
    right: 160px !important;
    transition-delay: 0.06s;
}
body.lp-fab-stack-expanded #lp-cockpit-fab {
    right: 230px !important;
    transition-delay: 0.12s;
}

/* Animation cascade entrée : depuis derrière le master (slide vers gauche) */
body:not(.lp-fab-stack-expanded) #lp-fdb-fab,
body:not(.lp-fab-stack-expanded) #lp-tour-restart,
body:not(.lp-fab-stack-expanded) #lp-cockpit-fab {
    transform: translateX(20px) scale(0.7);
}

/* Bouton master (lp-assistant-btn = .lpa-fab) reste toujours visible.
   Quand expanded : rotate icon pour signal close */
body.lp-fab-stack-expanded #lp-assistant-btn {
    transform: rotate(45deg);
    background: var(--text-primary, #0f172a);
    transition: transform 0.2s ease, background 0.2s ease;
    animation: none;  /* stop pulse quand actif */
}

#lp-assistant-btn {
    transition: transform 0.2s ease, background 0.2s ease;
}

/* Drag & drop user-positioned : data-lp-fab-x / data-lp-fab-y persistés localStorage */
.lp-fab-draggable {
    cursor: grab;
}

.lp-fab-draggable.lp-fab-dragging {
    cursor: grabbing;
    opacity: 0.85;
    z-index: 9999;
    transition: none;
}

/* Zone poubelle (drag pour désactiver session) */
#lp-fab-trash-zone {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 80px;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.95), rgba(185, 28, 28, 0.95));
    color: #fff;
    border-radius: 20px 20px 0 0;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: 0 -4px 20px rgba(220, 38, 38, 0.4);
    z-index: 9990;
    animation: lp-trash-pulse 1.2s ease-in-out infinite;
}

#lp-fab-trash-zone.lp-trash-active {
    display: flex;
}

@keyframes lp-trash-pulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.05); }
}

/* Reduced motion : désactive animations stagger + trash pulse */
@media (prefers-reduced-motion: reduce) {
    body:not(.lp-fab-stack-expanded) #lp-fdb-fab,
    body:not(.lp-fab-stack-expanded) #lp-tour-restart,
    body:not(.lp-fab-stack-expanded) #lp-cockpit-fab {
        transition: opacity 0.01ms, transform 0.01ms;
    }
    body.lp-fab-stack-expanded #lp-tour-restart,
    body.lp-fab-stack-expanded #lp-cockpit-fab {
        transition-delay: 0s;
    }
    #lp-fab-trash-zone {
        animation: none;
    }
    #lp-assistant-btn {
        transition: none;
    }
}

/* Petits écrans : masquer tour-restart si déjà collapsed (économie espace) */
@media (max-width: 360px) {
    body:not(.lp-fab-stack-expanded) #lp-tour-restart {
        display: none;
    }
}
