.floating-chat-box {
    position: fixed;
    bottom: var(--chat-fab-bottom);
    right: var(--chat-fab-right);
    width: 560px;
    max-height: calc(100vh - 160px);
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: visible;
    background: url("../img/rw-chat-bg.png") no-repeat;
    border: 1px solid #D9D9D6; /* Redwood neutral border */
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 4px 16px 0 rgba(23, 27, 30, 0.15);

}

.chat-header {
    padding: 12px 16px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-header);
    height: 56px;
    font-size: 20px;
}

.chat-body {
    border-top: 1px solid #D9D9D6;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.chat-body.ng-hide {
    display: none;
}

.chat-window {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
}

.chat-form {
    padding: 12px 16px 0 16px;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.chat-form textarea {
    resize: none;
    font-size: 14px;
    line-height: 20px;
    padding: 25px 12px;
    border-radius: 20px 20px 0 0;
    border: 1px solid #D9D9D6;
    background: #FFF;
    color: #191919;
    box-shadow: none;
    outline: 0;
    vertical-align: middle;
    display: inline-block;
}

.chat-form button {
    padding: 8px 16px;
    font-size: 14px;
    margin-left: 8px;
    border-radius: 4px;
    vertical-align: middle;
    border: none;
    outline: none;
}

/* Floating action button (FAB) to open chat when closed */
.chat-fab {
    position: fixed;
    bottom: var(--chat-fab-bottom);
    right: var(--chat-fab-right);
    border: none;
    z-index: 1001;
    cursor: pointer;
    background: none;
    padding: 0;
    height: var(--chat-fab-size);
}
.chat-fab .rw-icon {
    width: var(--chat-fab-size);
    height: var(--chat-fab-size);
    margin: 0; /* override global icon offset */
    background-size: contain; /* scale svg to fit */
    background-position: center; /* center inside the square */
}

/* Optional: Responsive tweak for mobile */
@media (max-width: 480px) {
    .floating-chat-box {
        width: 98vw;
        right: 1vw;
        left: 1vw;
        bottom: 12px;
    }
    .chat-form textarea {
        width: 65vw;
    }
}

button.chat-close {
    padding: 0;
}

/* Chat message alignment and avatar layout */
.chat-message {
    margin-bottom: 14px;
    font-size: 15px;
    line-height: 1.55;
}

.chat-message-grouped {
    margin-top: -12px;
}

.chat-message > .user,
.chat-message > .nsc {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

.chat-message > .user {
    flex-direction: row-reverse; /* icon on the right for user */
    justify-content: flex-start; /* align bubble+icon to the right */

}

.chat-message > .nsc {
    justify-content: flex-start; /* icon on the left for NSC */
}

.chat-message > .nsc .chat-avatar-placeholder {
    visibility: hidden;
}

/* Remove global icon margin offsets inside chat rows */
.chat-message > .user .rw-icon,
.chat-message > .nsc .rw-icon {
    margin: 0;
    background-size: contain;
    background-position: center;
    flex: 0 0 36px;
}

/* Prevent bubbles from overlapping icons and wrap long text */
.chat-message .chat-message-user,
.chat-message > .nsc .chat-message-ai-wrapper {
    max-width: calc(100% - 48px); /* 36px icon + 8px gap + small safety */
}

.chat-message .chat-message-user,
.chat-message .chat-message-ai {
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-message > .nsc .chat-message-ai-wrapper {
    display: inline-flex;
    flex-direction: column;
   align-items: flex-end;
}

.chat-message > .nsc .chat-message-ai {
    max-width: 100%;
}

.chat-message .chat-message-ai ol {
    margin: 4px 0 0 0;
    padding-left: 24px;
    list-style-type: decimal;
    list-style-position: outside;
}

/* Header actions layout (trash + close) */
.chat-header .chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-header .chat-actions .rw-icon {
    margin: 0;
}

/* Textarea with send button inside (bottom-right) */
.chat-form .textarea-wrapper {
    position: relative;
}
.chat-form .textarea-wrapper textarea.form-control {
    width: 100%;
    box-sizing: border-box;
    min-height: 72px;
    max-height: 120px;
    padding-right: 44px; /* space for the send button */
    overflow-y: hidden;
}
.chat-form .send-btn-inside,
.chat-message > .nsc .copy-btn,
.chat-message > .nsc .feedback-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-form .send-btn-inside {
    position: absolute;
    right: 12px;
    bottom: 22px;
}

.chat-message > .nsc .chat-message-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.chat-form .send-btn-inside:disabled {
    pointer-events: none;
}

.chat-form .send-btn-inside .rw-icon,
.chat-message > .nsc .copy-btn .rw-icon,
.chat-message > .nsc .feedback-btn .rw-icon {
    width: 20px;
    height: 20px;
    margin: 0;
    background-size: contain;
    background-position: center;
}

.chat-message .chat-message-ai {
    background: #FFFFFF;
    color: #17202A;
    padding: 8px 14px;
    border-radius: 6px;
    display: inline-block;
    text-align: left;
}

.chat-message .chat-message-user {
    background: #E4E1DD;
    padding: 8px 14px;
    border-radius: 6px;
    display: inline-block;
    text-align: left;
}
