:root {
    --ai-assistant-sidebar-width: 440px;
}

.ai-assistant-sidebar-host {
    position: fixed;
    inset: 0;
    z-index: 5000;
    visibility: hidden;
    pointer-events: none;
}

.ai-assistant-sidebar-host--open {
    visibility: visible;
}

.ai-assistant-sidebar__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 31, 47, 0.18);
    opacity: 0;
    pointer-events: auto;
    transition: opacity 0.2s ease;
}

.ai-assistant-sidebar-host--open .ai-assistant-sidebar__backdrop {
    opacity: 1;
}

.ai-assistant-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: clamp(400px, 34vw, 480px);
    height: 100vh;
    height: 100dvh;
    color: #304050;
    background: #fff;
    box-shadow: -12px 0 32px rgba(15, 41, 61, 0.22);
    outline: none;
    pointer-events: auto;
    transform: translateX(100%);
    transition: transform 0.2s ease;
}

.ai-assistant-sidebar-host--open .ai-assistant-sidebar {
    transform: translateX(0);
}

.ai-assistant-sidebar__splitter {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -6px;
    z-index: 3;
    display: none;
    width: 12px;
    padding: 0;
    background: transparent;
    border: 0;
    outline: none;
    cursor: col-resize;
    touch-action: none;
}

.ai-assistant-sidebar__splitter::before {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 5px;
    width: 2px;
    content: '';
    background: #a9bdca;
    opacity: 0.6;
    transition: width 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}

.ai-assistant-sidebar__splitter:hover::before,
.ai-assistant-sidebar__splitter:focus-visible::before {
    width: 3px;
    background: #268dcc;
    opacity: 1;
}

.ai-assistant-sidebar__header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    height: var(--site-header-height, 60px);
    min-height: var(--site-header-height, 60px);
    padding: 8px 14px 8px 18px;
    color: white;
    background: #123a59;
    border-bottom: 1px solid #0b2d47;
}

.ai-assistant-sidebar__title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ai-assistant-sidebar__icon {
    color: #62bff1;
    font-size: 17px;
}

.ai-assistant-sidebar__title {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: inherit;
    font-family: inherit;
    font-size: 17px;
    font-weight: 500;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-assistant-sidebar__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: #d9edf8;
    background: transparent;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
}

.ai-assistant-sidebar__close:hover,
.ai-assistant-sidebar__close:focus-visible {
    color: white;
    background: rgba(255, 255, 255, 0.12);
    outline: none;
}

.ai-assistant-sidebar__close:focus-visible {
    box-shadow: 0 0 0 2px #80bdff;
}

.ai-assistant-sidebar__body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 18px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    background: #f7f9fb;
}

.ai-assistant-sidebar__body::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.ai-assistant-sidebar__assistant-scrollbar {
    position: absolute;
    top: calc(var(--site-header-height, 60px) + 40px);
    right: 3px;
    bottom: 40px;
    z-index: 2;
    width: 12px;
    background: transparent;
    outline: none;
    pointer-events: auto;
    touch-action: none;
}

.ai-assistant-sidebar__assistant-scrollbar-thumb {
    position: absolute;
    top: 0;
    right: 2px;
    width: 7px;
    min-height: 36px;
    background: rgba(75, 105, 126, 0.4);
    border-radius: 999px;
    transition: width 0.12s ease, background-color 0.12s ease;
}

.ai-assistant-sidebar__assistant-scrollbar:hover .ai-assistant-sidebar__assistant-scrollbar-thumb,
.ai-assistant-sidebar__assistant-scrollbar:focus-visible .ai-assistant-sidebar__assistant-scrollbar-thumb,
.ai-assistant-sidebar__assistant-scrollbar--dragging .ai-assistant-sidebar__assistant-scrollbar-thumb {
    width: 8px;
    background: rgba(49, 81, 106, 0.65);
}

.ai-assistant-sidebar__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 180px;
    color: #47728f;
    font-size: 14px;
}

.ai-assistant-sidebar__error {
    padding: 14px;
    color: #8b2534;
    background: #fff0f2;
    border: 1px solid #efb5be;
    border-radius: 8px;
    font-size: 14px;
}

html.ai-assistant-sidebar-scroll-lock,
html.ai-assistant-sidebar-scroll-lock body {
    overflow: hidden;
}

html.ai-assistant-sidebar-resizing,
html.ai-assistant-sidebar-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

html.ai-assistant-sidebar-resizing body,
html.ai-assistant-sidebar-resizing .ai-assistant-sidebar {
    transition: none !important;
}

@media only screen and (min-width: 1024px) {
    body {
        transition: margin-inline-end 0.2s ease;
    }

    html.ai-assistant-sidebar-docked body {
        /* MadCap applies body { margin: 0 !important }, so the docked margin
           must also be important to reserve real layout space. */
        box-sizing: border-box;
        height: 100vh;
        height: 100dvh;
        margin-inline-end: var(--ai-assistant-sidebar-width) !important;
        overflow-x: hidden;
        overflow-y: auto;
        overflow-anchor: none;
        scrollbar-width: none;
    }

    html.ai-assistant-sidebar-docked body::-webkit-scrollbar {
        width: 0;
        height: 0;
    }

    html.ai-assistant-sidebar-docked {
        --index--width: calc(100vw - var(--ai-assistant-sidebar-width) - 42pt);
        --main--width: calc(100vw - var(--ai-assistant-sidebar-width) - 42pt);
        overflow: hidden;
    }

    .ai-assistant-sidebar__backdrop {
        display: none;
    }

    .ai-assistant-sidebar__page-scrollbar {
        position: absolute;
        top: 40px;
        right: calc(var(--ai-assistant-sidebar-width) + 6px);
        bottom: 40px;
        z-index: 2;
        width: 12px;
        background: transparent;
        outline: none;
        pointer-events: auto;
        touch-action: none;
    }

    .ai-assistant-sidebar__page-scrollbar-thumb {
        position: absolute;
        top: 0;
        right: 2px;
        width: 7px;
        min-height: 36px;
        background: rgba(75, 105, 126, 0.4);
        border-radius: 999px;
        transition: width 0.12s ease, background-color 0.12s ease;
    }

    .ai-assistant-sidebar__page-scrollbar:hover .ai-assistant-sidebar__page-scrollbar-thumb,
    .ai-assistant-sidebar__page-scrollbar:focus-visible .ai-assistant-sidebar__page-scrollbar-thumb,
    .ai-assistant-sidebar__page-scrollbar--dragging .ai-assistant-sidebar__page-scrollbar-thumb {
        width: 8px;
        background: rgba(49, 81, 106, 0.65);
    }

    .ai-assistant-sidebar {
        width: var(--ai-assistant-sidebar-width);
        border-left: 1px solid #a9bdca;
        box-shadow: -7px 0 22px rgba(15, 41, 61, 0.14);
    }

    .ai-assistant-sidebar__splitter {
        display: block;
    }
}

@media only screen and (max-width: 640px) {
    .ai-assistant-sidebar {
        width: 100%;
        max-width: none;
    }

    .ai-assistant-sidebar__backdrop {
        background: rgba(12, 31, 47, 0.35);
    }

    .ai-assistant-sidebar__body {
        padding: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body,
    .ai-assistant-sidebar,
    .ai-assistant-sidebar__backdrop {
        transition: none;
    }
}
