/* Botpress Notification Bubble CSS */
:root {
    /* Change these to match your page's brand */
    --bubble-bg: linear-gradient(#e02b31, #c81d27);
    --bubble-fg: white;
}

.cb {
    position: fixed;
    right: 20px;
    bottom: 102px;
    z-index: 9999;

    display: none;
    /* shown by JS */
    background: var(--bubble-bg);
    color: var(--bubble-fg);
    border-radius: 16px;
    padding: 14px 16px 14px 24px;
    /* Increased left padding for longer text */
    max-width: 420px;
    /* Increased width to accommodate longer Norwegian text */
    min-width: 200px;
    line-height: 1.35;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .18);
    cursor: pointer;
    word-wrap: break-word;
    overflow-wrap: break-word;

    font-family: Roboto, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
    font-size: 15px;
    transition: width .3s ease, min-width .3s ease, max-width .3s ease, padding .3s ease, transform .2s ease, box-shadow .2s ease, opacity .2s ease;
    animation: bubble-in .28s cubic-bezier(.2, .8, .2, 1) both;
}

/* Compact state for typing indicator */
.cb.typing-state {
    min-width: 80px;
    max-width: 80px;
    min-height: 52px;
    /* Fixed height to prevent vertical expansion */
    height: 52px;
    padding: 0;
    /* Remove padding to center properly */
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: right center;
    /* Expand from the right */
}

/* Ensure typing indicator is perfectly centered in compact state */
.cb.typing-state .typing-indicator {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Normal state maintains the same height */
.cb:not(.typing-state) {
    min-height: 52px;
    /* Same height as typing state */
    transform-origin: right center;
}

/* Hide close button during typing */
.cb.typing-state .close-chip {
    display: none;
}

.cb:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
}

.cb:focus {
    outline: none;
}

/* Text content inside the bubble */
.cb #msgText {
    color: white;
    font-family: 'Bricolage Grotesque', sans-serif;
    opacity: 0;
    /* Start invisible */
    transition: opacity 0.4s ease-in-out;
    white-space: nowrap;
    /* Keep text on one line */
    overflow: hidden;
    text-overflow: ellipsis;
    /* Show ... if text is too long */
    display: inline-block;
    flex: 1;
    /* Take up available space */
    max-width: 330px;
    /* Increased to accommodate longer Norwegian text */
}

/* Message content container */
.cb .message-content {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    /* Use full bubble width */
    width: 100%;
    /* Take full available width */
    white-space: nowrap;
    /* Keep text and icon on one line */
    overflow: hidden;
    /* Handle overflow gracefully */
}

/* Text visible state */
.cb #msgText.visible {
    opacity: 1;
}

/* Sparkle icon styling */
.cb #sparkleIcon {
    opacity: 0;
    /* Start invisible */
    transition: opacity 0.4s ease-in-out;
    width: 22px;
    height: 22px;
    display: inline-block;
    vertical-align: middle;
}

/* Sparkle icon visible state */
.cb #sparkleIcon.visible {
    opacity: 1;
    animation: sparkle-twinkle 6s ease-in-out infinite;
}

/* Sparkle animation keyframes with color cycling */
@keyframes sparkle-twinkle {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }

    16.67% {
        transform: scale(1.1) rotate(5deg);
        opacity: 0.8;
    }

    33.33% {
        transform: scale(1.05) rotate(-5deg);
        opacity: 1;
    }

    50% {
        transform: scale(1.1) rotate(5deg);
        opacity: 0.9;
    }

    66.67% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }

    66.67%,
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Color cycling animation for sparkle SVG paths */
.cb #sparkleIcon.visible path {
    animation: sparkle-colors 3s ease-in-out infinite;
}

@keyframes sparkle-colors {

    0%,
    100% {
        stroke: #ffffff;
    }

    50% {
        stroke: #fdb9b9;
    }
}

/* Hide sparkle icon during typing */
.cb.typing-state #sparkleIcon {
    display: none;
}

/* Hide message content during typing */
.cb.typing-state .message-content {
    display: none;
}

/* Chat tail */
.tri-right.btm-right::after {
    content: "";
    position: absolute;
    right: 18px;
    bottom: -8px;
    width: 16px;
    height: 16px;
    background: #c81d27;
    transform: rotate(45deg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, .18);
    border-bottom-right-radius: 4px;
}

/* Close chip (optional, inside the bubble) */
.cb .close-chip {
    position: absolute;
    justify-content: center;
    top: 6px;
    right: 12px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    color: var(--bubble-fg);
    border: 0;
    cursor: pointer;
    padding-right: 10px;
    line-height: 1;
    font-size: 16px;
}

@keyframes bubble-in {
    from {
        transform: translateY(10px) scale(.98);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Typing indicator styles */
.typing-indicator {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 0;
}

.typing-indicator.active {
    display: flex;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--bubble-fg);
    opacity: 0.4;
    animation: typing-pulse 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-pulse {

    0%,
    60%,
    100% {
        opacity: 0.4;
        transform: scale(1);
    }

    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Online animated circle: green -> lighter green -> green */
.online-animated-circle {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #16a34a;
    /* green-600 */
    box-shadow: 0 0 6px rgba(22, 163, 74, 0.25);
    vertical-align: middle;
    margin-right: 6px;
    will-change: background-color, box-shadow;
    animation: online-pulse 3.5s ease-in-out infinite;
}

@keyframes online-pulse {
    0% {
        background-color: #16a34a;
        /* green */
        box-shadow: 0 0 6px rgba(22, 163, 74, 0.25);
    }

    50% {
        background-color: #86efac;
        /* lighter green */
        box-shadow: 0 0 10px rgba(134, 239, 172, 0.32);
    }

    100% {
        background-color: #16a34a;
        /* back to green */
        box-shadow: 0 0 6px rgba(22, 163, 74, 0.25);
    }
}