/*
 * Barbot LLM Wiki assistant — custom chat widget (no third-party embed chrome).
 */

.bb-chat {
    --bb-chat-blue: #7f4cbf;
    --bb-chat-dark: #17141b;
    --bb-chat-light: #fbf8f1;
    --bb-chat-panel: #1c1c1a;
    --bb-chat-lime: #d8f35a;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 80;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    font-family: 'Outfit', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
}

.bb-chat.has-launcher-pos {
    right: auto;
    bottom: auto;
}

.bb-chat-toggle {
    position: relative;
    min-height: 64px;
    border: 1px solid var(--bb-chat-dark);
    border-radius: 999px;
    padding: 8px 16px 8px 8px;
    background: var(--bb-chat-dark);
    color: var(--bb-chat-light);
    box-shadow: 6px 6px 0 var(--bb-chat-lime);
    cursor: grab;
    touch-action: none;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

.bb-chat-toggle:hover,
.bb-chat-toggle:focus-visible {
    transform: translateY(-2px);
    background: #241e2a;
}

.bb-chat-toggle-mark {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #2a2430;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.bb-chat-toggle-mark svg {
    width: 30px;
    height: 30px;
    display: block;
}

.bb-chat-toggle-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.bb-chat-toggle-copy strong {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.bb-chat-toggle-copy em {
    font-style: normal;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: #d8f35a;
    opacity: 0.92;
}

.bb-chat-toggle-x {
    display: none;
    width: 48px;
    height: 48px;
    place-items: center;
    font-size: 28px;
    line-height: 1;
}

.bb-chat.is-open .bb-chat-toggle {
    min-height: 56px;
    padding: 4px;
    box-shadow: 4px 4px 0 var(--bb-chat-lime);
}

.bb-chat.is-open .bb-chat-toggle-copy,
.bb-chat.is-open .bb-chat-toggle-mark {
    display: none;
}

.bb-chat.is-open .bb-chat-toggle-x {
    display: grid;
}

.bb-chat-teaser {
    width: min(22rem, calc(100vw - 24px));
    padding: 14px 16px;
    border: 1px solid var(--bb-chat-dark);
    background: var(--bb-chat-lime);
    color: var(--bb-chat-dark);
    box-shadow: 6px 6px 0 var(--bb-chat-dark);
}

.bb-chat-teaser p {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
}

.bb-chat-teaser-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.bb-chat-teaser-go,
.bb-chat-teaser-dismiss {
    border: 1px solid var(--bb-chat-dark);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 10px;
}

.bb-chat-teaser-go {
    background: var(--bb-chat-dark);
    color: var(--bb-chat-light);
}

.bb-chat-teaser-dismiss {
    background: transparent;
    color: var(--bb-chat-dark);
}

.bb-chat.has-teaser .bb-chat-toggle::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: inherit;
    border: 2px solid var(--bb-chat-lime);
    pointer-events: none;
    animation: bb-chat-pulse 1.8s ease-out infinite;
}

@keyframes bb-chat-pulse {
    0% { opacity: 0.85; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
    .bb-chat.has-teaser .bb-chat-toggle::after {
        animation: none;
    }
    .bb-chat-toggle:hover,
    .bb-chat-toggle:focus-visible {
        transform: none;
    }
}

.bb-chat-panel {
    position: absolute;
    right: 0;
    bottom: 88px;
    width: min(28rem, calc(100vw - 24px));
    height: min(42rem, calc(100vh - 120px));
    background: var(--bb-chat-light);
    color: var(--bb-chat-dark);
    border-radius: 16px;
    box-shadow: 0 18px 48px rgba(20, 20, 19, 0.28);
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.bb-chat.is-open .bb-chat-panel {
    display: flex;
}

.bb-chat-header {
    background: var(--bb-chat-dark);
    color: var(--bb-chat-light);
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.bb-chat.is-dragging,
.bb-chat.is-dragging .bb-chat-header,
.bb-chat.is-dragging-launcher,
.bb-chat.is-dragging-launcher .bb-chat-toggle {
    cursor: grabbing;
}

.bb-chat.is-dragging-launcher .bb-chat-toggle:hover,
.bb-chat.is-dragging-launcher .bb-chat-toggle:focus-visible {
    transform: none;
}

.bb-chat.is-dragging .bb-chat-messages,
.bb-chat.is-dragging .bb-chat-form {
    pointer-events: none;
}

.bb-chat-brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.bb-chat-brand strong {
    font-size: 15px;
    letter-spacing: 0.04em;
}

.bb-chat-brand span {
    font-size: 12px;
    opacity: 0.72;
}

.bb-chat-product {
    margin-top: 6px;
    color: #9ec0ff;
    font-size: 12px;
    text-decoration: none;
}

.bb-chat-product:hover,
.bb-chat-product:focus-visible {
    text-decoration: underline;
}

.bb-chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.bb-chat-header a,
.bb-chat-header button {
    cursor: pointer;
    user-select: auto;
    touch-action: auto;
}

.bb-chat-header button {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 12px;
    padding: 4px 0;
    opacity: 0.8;
}

.bb-chat-header button:hover,
.bb-chat-header button:focus-visible {
    opacity: 1;
}

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

.bb-chat-msg {
    max-width: 96%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.bb-chat-msg.is-user {
    align-self: flex-end;
    background: var(--bb-chat-blue);
    color: #fff;
    white-space: pre-wrap;
}

.bb-chat-msg.is-bot {
    align-self: flex-start;
    background: #eceae3;
    color: var(--bb-chat-dark);
}

.bb-chat-msg.is-error {
    background: #f4d6cf;
}

.bb-chat-msg a {
    color: inherit;
    text-decoration: underline;
}

.bb-chat-md {
    min-width: 0;
}

.bb-chat-md > :first-child {
    margin-top: 0;
}

.bb-chat-md > :last-child {
    margin-bottom: 0;
}

.bb-chat-md p,
.bb-chat-md ul,
.bb-chat-md ol,
.bb-chat-md blockquote,
.bb-chat-md pre,
.bb-chat-md table {
    margin: 0.55em 0;
}

.bb-chat-md h1,
.bb-chat-md h2,
.bb-chat-md h3,
.bb-chat-md h4 {
    margin: 0.8em 0 0.35em;
    font-size: 15px;
    line-height: 1.35;
}

.bb-chat-md ul,
.bb-chat-md ol {
    padding-left: 1.3em;
}

.bb-chat-md blockquote {
    border-left: 3px solid rgba(20, 20, 19, 0.2);
    padding-left: 10px;
    color: rgba(20, 20, 19, 0.78);
}

.bb-chat-md hr {
    border: 0;
    border-top: 1px solid rgba(20, 20, 19, 0.12);
    margin: 0.8em 0;
}

.bb-chat-md code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    background: rgba(20, 20, 19, 0.06);
    padding: 1px 5px;
    border-radius: 4px;
}

.bb-chat-md pre {
    overflow-x: auto;
    background: #1c1c1a;
    color: #faf9f5;
    padding: 10px 12px;
    border-radius: 8px;
}

.bb-chat-md pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.bb-chat-md table {
    display: block;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
}

.bb-chat-md th,
.bb-chat-md td {
    border: 1px solid rgba(20, 20, 19, 0.12);
    padding: 6px 8px;
    text-align: left;
    font-size: 13px;
}

.bb-chat-md thead th {
    background: rgba(20, 20, 19, 0.06);
}

.bb-chat-md tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.45);
}

.bb-chat-cite {
    display: inline;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    background: #dfe8fb;
    color: #1c3d8f;
    padding: 1px 6px;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
}

.bb-chat-cite:hover,
.bb-chat-cite:focus-visible {
    text-decoration: underline;
}

.bb-chat-think {
    margin: 0 0 10px;
    background: rgba(20, 20, 19, 0.04);
    border-radius: 8px;
    padding: 6px 8px;
}

.bb-chat-think summary {
    cursor: pointer;
    font-size: 12px;
    color: rgba(20, 20, 19, 0.68);
    list-style: none;
}

.bb-chat-think summary::-webkit-details-marker {
    display: none;
}

.bb-chat-think-body {
    margin: 8px 0 2px;
    white-space: pre-wrap;
    font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: rgba(20, 20, 19, 0.72);
    max-height: 180px;
    overflow: auto;
}

.bb-chat-steps {
    margin: 0 0 10px;
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bb-chat-steps li {
    position: relative;
    padding-left: 16px;
    font-size: 12px;
    color: rgba(20, 20, 19, 0.7);
}

.bb-chat-steps li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.45em;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #c4c2ba;
}

.bb-chat-steps li.is-success::before {
    background: #3d8b5a;
}

.bb-chat-steps li.is-start::before {
    background: var(--bb-chat-blue);
}

.bb-chat-step-label {
    display: inline;
}

.bb-chat-step-tool {
    display: block;
    margin-top: 2px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: rgba(20, 20, 19, 0.55);
}

.bb-chat-pending {
    margin: 0;
    color: rgba(20, 20, 19, 0.45);
}

.bb-chat-samples {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px 10px;
}

.bb-chat-sample {
    border: 1px solid rgba(20, 20, 19, 0.12);
    background: #fff;
    color: var(--bb-chat-dark);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
}

.bb-chat-sample:hover,
.bb-chat-sample:focus-visible {
    border-color: var(--bb-chat-blue);
    color: var(--bb-chat-blue);
}

.bb-chat-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(20, 20, 19, 0.08);
    background: #fff;
}

.bb-chat-form textarea {
    flex: 1;
    min-height: 42px;
    max-height: 96px;
    resize: none;
    border: 1px solid rgba(20, 20, 19, 0.12);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    font-size: 14px;
    background: var(--bb-chat-light);
}

.bb-chat-form textarea:focus {
    outline: 2px solid rgba(28, 100, 242, 0.35);
    border-color: var(--bb-chat-blue);
}

.bb-chat-form button[type="submit"] {
    border: 0;
    border-radius: 10px;
    background: var(--bb-chat-blue);
    color: #fff;
    padding: 0 14px;
    cursor: pointer;
    font-size: 14px;
    align-self: flex-end;
    height: 42px;
}

.bb-chat-form button:disabled {
    opacity: 0.55;
    cursor: default;
}

@media (max-width: 520px) {
    .bb-chat {
        right: 12px;
        bottom: 12px;
    }

    .bb-chat-toggle {
        padding-right: 14px;
        box-shadow: 4px 4px 0 var(--bb-chat-lime);
    }

    .bb-chat-toggle-copy strong {
        font-size: 15px;
    }

    .bb-chat-panel {
        width: calc(100vw - 24px);
        height: min(38rem, calc(100vh - 96px));
    }
}
