/* Floating AI assistant shortcut (components/AiFloatingButton.blade.php).
   An icon-only circle in the bottom corner at the end of the reading
   direction: bottom-left in Arabic, bottom-right in English, where it stacks
   above the WhatsApp button that Header.blade.php always pins bottom-right. */
.ai-fab {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    inset-inline-end: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(36, 50, 83, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Centred over the 53px-wide WhatsApp button at right: 20px, 12px above it. */
.ai-fab[dir="ltr"] {
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    inset-inline-end: 18px;
}

/* Expanding halo that repeatedly draws the eye to the button. */
.ai-fab::before,
.ai-fab::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background-color: #3a4f82;
    animation: ai-fab-pulse 2.4s ease-out infinite;
}

.ai-fab::after {
    animation-delay: 1.2s;
}

/* The circle itself; it sits above the halo, which paints first. */
.ai-fab__icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #3a4f82 0%, #243253 100%);
}

.ai-fab__icon i {
    animation: ai-fab-nudge 4s ease-in-out infinite;
}

.ai-fab:hover,
.ai-fab:focus-visible {
    color: #fff;
    transform: scale(1.08);
    box-shadow: 0 10px 26px rgba(36, 50, 83, 0.5);
}

/* Stop the motion once the user is already engaging with the button. */
.ai-fab:hover::before,
.ai-fab:hover::after,
.ai-fab:focus-visible::before,
.ai-fab:focus-visible::after,
.ai-fab:hover .ai-fab__icon i,
.ai-fab:focus-visible .ai-fab__icon i {
    animation: none;
}

.ai-fab:focus-visible {
    outline: 3px solid #8fb3ff;
    outline-offset: 3px;
}

@keyframes ai-fab-pulse {
    0% {
        transform: scale(1);
        opacity: 0.55;
    }

    100% {
        transform: scale(1.7);
        opacity: 0;
    }
}

/* A short "wave" of the robot, then a long rest. */
@keyframes ai-fab-nudge {
    0%, 70%, 100% {
        transform: rotate(0) translateY(0);
    }

    75% {
        transform: rotate(-14deg) translateY(-2px);
    }

    80% {
        transform: rotate(12deg) translateY(-2px);
    }

    85% {
        transform: rotate(-8deg) translateY(-1px);
    }

    90% {
        transform: rotate(4deg) translateY(0);
    }
}

@media (max-width: 768px) {
    .ai-fab {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        inset-inline-end: 16px;
    }

    .ai-fab[dir="ltr"] {
        bottom: calc(92px + env(safe-area-inset-bottom, 0px));
        inset-inline-end: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-fab,
    .ai-fab::before,
    .ai-fab::after,
    .ai-fab__icon i {
        animation: none;
        transition: none;
    }

    .ai-fab::before,
    .ai-fab::after {
        display: none;
    }

    .ai-fab:hover,
    .ai-fab:focus-visible {
        transform: none;
    }
}
