.knowledge-chat-widget {
    position: fixed;
    bottom: 48px;
    inset-inline-end: 24px;
    z-index: 10000;
    font-size: 13px;
}

.knowledge-chat-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 0 18px 0 16px;
    border-radius: 999px;
    border: 0;
    background: var(--theme-blue, #0d6efd);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 28px rgba(13, 110, 253, 0.35);
    animation: knowledge-chat-pulse 2.4s ease-in-out infinite;
}

.knowledge-chat-toggle:hover,
.knowledge-chat-toggle:focus {
    background: var(--header, #0b5ed7);
    color: #fff;
}

.knowledge-chat-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    font-size: 14px;
}

.knowledge-chat-toggle-label {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.knowledge-chat-panel {
    position: absolute;
    bottom: 72px;
    inset-inline-end: 0;
    width: min(360px, calc(100vw - 32px));
    max-height: 70vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.knowledge-chat-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    font-size: 13px;
}

.knowledge-chat-header strong {
    font-size: 14px;
}

.knowledge-chat-header .small {
    font-size: 11px;
}

.knowledge-chat-close {
    border: 0;
    background: transparent;
    font-size: 20px;
    line-height: 1;
}

.knowledge-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 220px;
}

.knowledge-chat-message {
    padding: 8px 10px;
    border-radius: 12px;
    max-width: 90%;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.knowledge-chat-message-user {
    align-self: flex-end;
    background: var(--theme-blue, #0d6efd);
    color: #fff;
}

.knowledge-chat-message-assistant {
    align-self: flex-start;
    background: #f1f3f5;
    color: #212529;
}

.knowledge-chat-sources {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.4;
    opacity: 0.8;
}

.knowledge-chat-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #eee;
}

.knowledge-chat-form textarea {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    resize: vertical;
}

.knowledge-chat-form .theme-btn {
    display: flex;
    width: 100%;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 13px;
    padding: 10px 14px;
}

[dir="rtl"] .knowledge-chat-message-user {
    align-self: flex-start;
}

[dir="rtl"] .knowledge-chat-message-assistant {
    align-self: flex-end;
}

@keyframes knowledge-chat-pulse {
    0%, 100% {
        box-shadow: 0 10px 28px rgba(13, 110, 253, 0.35);
    }

    50% {
        box-shadow: 0 10px 32px rgba(13, 110, 253, 0.55);
    }
}

@media (max-width: 575.98px) {
    .knowledge-chat-widget {
        bottom: 40px;
        inset-inline-end: 16px;
    }

    .knowledge-chat-toggle {
        min-height: 52px;
        padding-inline: 14px;
    }

    .knowledge-chat-toggle-label {
        max-width: 120px;
        font-size: 12px;
    }
}
