/* Chat */
.chat-launcher-unit {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 110;
    display: flex;
    align-items: flex-end;
    gap: 0.55rem;
    max-width: calc(100vw - 32px);
}

.chat-toggle {
    position: relative;
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 0;
    background: linear-gradient(135deg, var(--olala-primary), var(--olala-accent));
    color: #fff;
    box-shadow: 0 16px 40px rgba(124, 58, 237, 0.35);
    font-size: 1.25rem;
    cursor: pointer;
}

.chat-invitation {
    position: relative;
    display: flex;
    align-items: stretch;
    max-width: 240px;
    border: 1px solid rgba(124, 58, 237, 0.16);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
    opacity: 0;
    transform: translateX(16px);
    pointer-events: none;
}

.chat-invitation[hidden] {
    display: none;
}

.chat-invitation.is-visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    animation: chat-invitation-enter 0.35s ease-out both;
}

.chat-invitation-open {
    display: flex;
    width: 100%;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.1rem;
    padding: 0.72rem 2rem 0.72rem 0.9rem;
    border: 0;
    background: #fff;
    color: var(--olala-text);
    font: inherit;
    font-size: 0.82rem;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
}

.chat-invitation-open strong {
    color: var(--olala-deep);
    font-size: 0.88rem;
}

.chat-invitation-open span {
    color: #64748b;
    white-space: nowrap;
}

.chat-invitation-dismiss {
    position: absolute;
    top: 0.2rem;
    right: 0.25rem;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #64748b;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.chat-invitation-open:focus-visible,
.chat-invitation-dismiss:focus-visible,
.chat-toggle:focus-visible {
    outline: 3px solid rgba(236, 72, 153, 0.45);
    outline-offset: 3px;
}

@keyframes chat-invitation-enter {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}

.chat-panel {
    position: fixed;
    right: 24px;
    bottom: 100px;
    width: min(390px, calc(100vw - 32px));
    height: 560px;
    background: #fff;
    border-radius: var(--olala-radius-xl);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
    overflow: hidden;
    display: none;
    z-index: 120;
    border: 1px solid var(--olala-border);
}

.chat-panel.open {
    display: flex;
    flex-direction: column;
}

.chat-head {
    background: linear-gradient(135deg, var(--olala-primary), var(--olala-accent));
    color: #fff;
    padding: 1rem 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-head .btn {
    padding: 0.65rem 1rem;
    background: rgba(255,255,255,0.16);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.18);
}

.chat-body {
    flex: 1;
    padding: 1rem;
    background: #f8fbff;
    overflow-y: auto;
}

.chat-msg {
    max-width: 85%;
    margin-bottom: 0.8rem;
    padding: 0.85rem 1rem;
    border-radius: var(--olala-radius-lg);
    line-height: 1.6;
    white-space: pre-wrap;
}

.chat-msg.user {
    margin-left: auto;
    background: linear-gradient(135deg, var(--olala-primary), var(--olala-accent));
    color: #fff;
    border-bottom-right-radius: 6px;
}

.chat-msg.bot {
    background: #fff;
    color: var(--olala-text);
    border: 1px solid var(--olala-border);
    border-bottom-left-radius: 6px;
}

.chat-form {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-top: 1px solid var(--olala-border);
    background: #fff;
}

.chat-form textarea {
    flex: 1;
    resize: none;
    min-height: 54px;
    max-height: 120px;
    border-radius: var(--olala-radius-lg);
    border: 1px solid var(--olala-border);
    padding: 0.9rem 1rem;
    font: inherit;
    color: var(--olala-text);
}

.chat-form textarea:focus {
    outline: none;
    border-color: rgba(124, 58, 237, 0.35);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.08);
}

.chat-head .chat-subtitle {
    color: #fff;
}

.chat-subtitle {
    color: rgba(255,255,255,0.78);
}

@media (max-width: 640px) {
    .chat-launcher-unit {
        right: 16px;
        bottom: 16px;
        max-width: calc(100vw - 32px);
    }

    .chat-invitation {
        max-width: calc(100vw - 112px);
    }

    .chat-invitation-open span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat-invitation,
    .chat-invitation.is-visible {
        animation: none;
        transition: none;
        transform: none;
    }
}
