#bwd-chatbot-root {
    --bwd-chatbot-accent: #1f6feb;
    color: #1d2327;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.bwd-chatbot-button,
.bwd-chatbot-panel {
    position: fixed;
    z-index: 999999;
}

.bwd-chatbot-button {
    align-items: center;
    bottom: 22px;
    display: flex;
    justify-content: center;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: var(--bwd-chatbot-accent);
    color: #fff;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    padding: 0;
}

.bwd-chatbot-button img {
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.bwd-chatbot-button span {
    display: block;
    line-height: 1;
}

.bwd-chatbot-button.bottom-right,
.bwd-chatbot-panel.bottom-right {
    right: 22px;
}

.bwd-chatbot-button.bottom-left,
.bwd-chatbot-panel.bottom-left {
    left: 22px;
}

.bwd-chatbot-panel {
    bottom: 90px;
    display: none;
    width: min(380px, calc(100vw - 32px));
    height: min(620px, calc(100vh - 120px));
    background: #fff;
    border: 1px solid #d8dee4;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
}

.bwd-chatbot-panel.open {
    display: flex;
    flex-direction: column;
}

.bwd-chatbot-header {
    align-items: center;
    background: var(--bwd-chatbot-accent);
    color: #fff;
    display: flex;
    justify-content: space-between;
    min-height: 52px;
    padding: 0 14px;
}

.bwd-chatbot-identity {
    align-items: center;
    display: flex;
    gap: 9px;
    min-width: 0;
}

.bwd-chatbot-header-avatar {
    align-items: center;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    display: flex;
    flex: 0 0 30px;
    height: 30px;
    justify-content: center;
    overflow: hidden;
    width: 30px;
}

.bwd-chatbot-header-avatar img {
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.bwd-chatbot-header strong {
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bwd-chatbot-close {
    background: transparent;
    border: 0;
    color: #fff;
    cursor: pointer;
    font-size: 24px;
}

.bwd-chatbot-language {
    border-bottom: 1px solid #e5e7eb;
    padding: 8px 12px;
}

.bwd-chatbot-language select {
    width: 100%;
}

.bwd-chatbot-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 14px;
}

.bwd-chatbot-row {
    align-items: flex-end;
    display: flex;
    gap: 8px;
    max-width: 100%;
}

.bwd-chatbot-row.bot {
    align-self: flex-start;
}

.bwd-chatbot-row.user {
    align-self: flex-end;
    justify-content: flex-end;
}

.bwd-chatbot-avatar {
    align-items: center;
    background: var(--bwd-chatbot-accent);
    border-radius: 50%;
    color: #fff;
    display: flex;
    flex: 0 0 30px;
    font-size: 15px;
    height: 30px;
    justify-content: center;
    margin-bottom: 2px;
    overflow: hidden;
    width: 30px;
}

.bwd-chatbot-avatar img {
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.bwd-chatbot-message {
    border-radius: 8px;
    line-height: 1.45;
    max-width: 88%;
    padding: 10px 12px;
    white-space: pre-wrap;
}

.bwd-chatbot-message.bot {
    background: #f3f4f6;
    white-space: normal;
}

.bwd-chatbot-message.user {
    background: var(--bwd-chatbot-accent);
    color: #fff;
}

.bwd-chatbot-message-name {
    color: #57606a;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
}

.bwd-chatbot-message p {
    margin: 0 0 8px;
}

.bwd-chatbot-message p:last-child {
    margin-bottom: 0;
}

.bwd-chatbot-message ul {
    margin: 0 0 8px 18px;
    padding: 0;
}

.bwd-chatbot-message li {
    margin: 0 0 5px;
}

.bwd-chatbot-message a {
    color: var(--bwd-chatbot-accent);
    overflow-wrap: anywhere;
    text-decoration: underline;
}

.bwd-chatbot-row.is-loading .bwd-chatbot-message p {
    display: none;
}

.bwd-chatbot-row.is-loading .bwd-chatbot-message::after {
    animation: bwd-chatbot-dots 1.2s infinite steps(4, end);
    content: "";
    display: inline-block;
    font-size: 20px;
    letter-spacing: 2px;
    min-width: 34px;
}

@keyframes bwd-chatbot-dots {
    0% {
        content: "";
    }
    25% {
        content: ".";
    }
    50% {
        content: "..";
    }
    75%,
    100% {
        content: "...";
    }
}

.bwd-chatbot-sources {
    font-size: 12px;
    margin-top: 8px;
}

.bwd-chatbot-sources a {
    display: block;
    color: inherit;
    margin-top: 4px;
}

.bwd-chatbot-form {
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    padding: 10px;
}

.bwd-chatbot-form input {
    border: 1px solid #d0d7de;
    border-radius: 6px;
    flex: 1;
    min-width: 0;
    padding: 10px;
}

.bwd-chatbot-form button {
    background: var(--bwd-chatbot-accent);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    padding: 0 14px;
}

/* Greeting bubble */
.bwd-chatbot-greeting {
    position: fixed;
    bottom: 130px;
    right: 28px;
    z-index: 999998;
    background: #fff;
    color: #111;
    padding: 10px 14px;
    border-radius: 12px;
    box-shadow: 0 8px 26px rgba(0,0,0,0.18);
    border: 1px solid #e6ebf0;
    max-width: 240px;
    display: block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 260ms ease, transform 260ms ease;
}

.bwd-chatbot-greeting.bwd-chatbot-greeting-show {
    opacity: 1;
    transform: translateY(0);
}

.bwd-chatbot-greeting::after {
    content: "";
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

.bwd-chatbot-greeting .bwd-chatbot-greeting-text {
    display: block;
    padding-left: 6px;
    border-left: 4px solid var(--bwd-chatbot-accent);
}

.bwd-chatbot-greeting .bwd-chatbot-greeting-close {
    background: transparent;
    border: 0;
    color: #6b7280;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    position: absolute;
    top: 6px;
    right: 8px;
}

/* Hide greeting when chat root has open state */
#bwd-chatbot-root.open .bwd-chatbot-greeting {
    display: none !important;
}
