/* Above cookie banner (1080) so the FAB stays visible on first visit / private mode */
.public-chat-launcher {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1090;
}

/* Lift above the cookie bar while it is showing */
body:has(#cookie-consent-banner:not([hidden])) .public-chat-launcher {
    bottom: 6.5rem;
}

body:has(#cookie-consent-banner:not([hidden])) .public-chat-panel {
    bottom: 10.5rem;
}

.public-chat-launcher__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-width: 3.25rem;
    height: 3.25rem;
    padding: 0 1.1rem;
    border: 3px solid #fff;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow:
        0 0 0 2px #1e3a8a,
        0 8px 28px rgba(16, 24, 40, 0.4),
        0 0 0 6px rgba(37, 99, 235, 0.28);
    cursor: pointer;
    animation: public-chat-bounce 2.4s ease-in-out infinite;
    transform-origin: center bottom;
}

.public-chat-launcher__btn:hover,
.public-chat-launcher__btn:focus-visible {
    background: #1d4ed8;
    animation-play-state: paused;
    box-shadow:
        0 0 0 2px #1e3a8a,
        0 10px 32px rgba(16, 24, 40, 0.45),
        0 0 0 7px rgba(37, 99, 235, 0.35);
}

/* Stop bouncing while the chat panel is open */
body:has(#publicChatPanel.is-open) .public-chat-launcher__btn {
    animation: none;
}

@keyframes public-chat-bounce {
    0%, 100% { transform: translateY(0); }
    12% { transform: translateY(-7px); }
    24% { transform: translateY(0); }
    36% { transform: translateY(-4px); }
    48% { transform: translateY(0); }
    /* rest of cycle idle so it feels like a light attention nudge, not constant motion */
}

.public-chat-launcher__label {
    line-height: 1;
}

.public-chat-panel {
    position: fixed;
    right: 1.25rem;
    bottom: 5.25rem;
    width: min(22rem, calc(100vw - 1.5rem));
    max-height: min(28rem, calc(100vh - 7rem));
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(16, 24, 40, 0.18);
    display: none;
    flex-direction: column;
    z-index: 1090;
    overflow: hidden;
}

.public-chat-panel.is-open {
    display: flex;
}

.public-chat-panel__header {
    padding: 0.85rem 1rem;
    background: #1e3c72;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.public-chat-panel__title {
    font-weight: 600;
    font-size: 0.95rem;
}

.public-chat-panel__actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.public-chat-panel__leave {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.65);
    color: #fff;
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.public-chat-panel__close {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
}

.public-chat-bubble--system {
    align-self: stretch;
    background: #eef2ff;
    color: #1e3a8a;
}

.public-chat-panel__body {
    padding: 1rem;
    overflow: auto;
    flex: 1 1 auto;
}

.public-chat-panel__messages {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 8rem;
    margin-bottom: 0.75rem;
}

.public-chat-bubble {
    max-width: 90%;
    padding: 0.45rem 0.65rem;
    border-radius: 10px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.9rem;
}

.public-chat-bubble--guest {
    align-self: flex-end;
    background: #e8f0fe;
}

.public-chat-bubble--csm {
    align-self: flex-start;
    background: #f3f4f6;
}

.public-chat-bubble__name {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
    opacity: 0.75;
}

.public-chat-panel__compose {
    display: flex;
    gap: 0.4rem;
}

.public-chat-panel__compose textarea {
    flex: 1 1 auto;
    resize: none;
    min-height: 2.5rem;
    max-height: 5rem;
}

.public-chat-status {
    font-size: 0.85rem;
    color: #4b5563;
    margin-bottom: 0.75rem;
}
