/*
 * QMApp PageAgent sidebar (version 3: minimizable)
 * Builds on Bootstrap 4.5.2 (uses its CSS variables --primary, --light, --info, --warning, ...),
 * so the sidebar follows the QMApp theme automatically.
 */

:root {
    --qm-pa-width: 400px;
    --qm-pa-rail-width: 2.75rem;
    --qm-pa-z: 2147483645; /* above the PageAgent mask (2147483641) so the user can always stop the agent */
}

/* Floating button in the bottom right corner */
.qm-pa-sidebar[hidden],
.qm-pa-toggle[hidden] {
    display: none !important;
}

.qm-pa-toggle {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: var(--qm-pa-z);
    border-radius: 1.5rem;
    padding: .5rem 1.125rem;
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .25);
}

/* Spinner in the floating button while a task is running in the background */
.qm-pa-toggle .qm-pa-toggle-spinner {
    display: none;
    margin-right: .375rem;
    vertical-align: -.125em;
}

.qm-pa-toggle.qm-pa-busy .qm-pa-toggle-spinner {
    display: inline-block;
}

/* Dot for a new answer that has not been read yet */
.qm-pa-toggle.qm-pa-unread::after,
.qm-pa-unread .qm-pa-rail-expand::after {
    content: "";
    position: absolute;
    top: .25rem;
    right: .25rem;
    width: .625rem;
    height: .625rem;
    background-color: var(--danger);
    border: 2px solid #fff;
    border-radius: 50%;
}

/* Sidebar */
.qm-pa-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    width: var(--qm-pa-width);
    max-width: 100vw;
    z-index: var(--qm-pa-z);
    font-size: .875rem;
    box-shadow: -.25rem 0 1rem rgba(0, 0, 0, .12);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .2s ease-out, width .2s ease-out, visibility 0s linear .2s;
}

.qm-pa-sidebar.qm-pa-open {
    transform: none;
    visibility: visible;
    transition: transform .2s ease-out, width .2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .qm-pa-sidebar,
    .qm-pa-sidebar.qm-pa-open {
        transition: none;
    }
}

/* On wide screens the page moves aside instead of being covered */
@media (min-width: 1200px) {
    body.qm-pa-push {
        margin-right: var(--qm-pa-width);
    }

    body.qm-pa-push .fixed-top,
    body.qm-pa-push .fixed-bottom {
        right: var(--qm-pa-width);
    }
}

@media (min-width: 576px) {
    body.qm-pa-push-rail {
        margin-right: var(--qm-pa-rail-width);
    }

    body.qm-pa-push-rail .fixed-top,
    body.qm-pa-push-rail .fixed-bottom {
        right: var(--qm-pa-rail-width);
    }
}

/* Minimized: narrow bar at the right edge, the rest of the sidebar is hidden */
.qm-pa-sidebar .qm-pa-rail {
    display: none;
    flex: 1 1 auto;
}

.qm-pa-sidebar.qm-pa-minimized {
    width: var(--qm-pa-rail-width);
}

.qm-pa-sidebar.qm-pa-minimized > :not(.qm-pa-rail) {
    display: none !important;
}

.qm-pa-sidebar.qm-pa-minimized > .qm-pa-rail {
    display: flex;
}

.qm-pa-rail-expand {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    color: var(--primary);
    background: none;
    border: 0;
    border-radius: 0;
}

.qm-pa-rail-expand:hover,
.qm-pa-rail-expand:focus {
    background-color: var(--light);
    outline: none;
}

.qm-pa-rail-expand:focus-visible {
    box-shadow: inset 0 0 0 .2rem rgba(0, 0, 0, .15);
}

.qm-pa-rail-label {
    margin-top: .75rem;
    font-weight: 600;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.qm-pa-sidebar .qm-pa-rail-spinner {
    display: none;
    margin-top: .75rem;
}

.qm-pa-sidebar.qm-pa-busy .qm-pa-rail-spinner {
    display: inline-block;
}

.qm-pa-header-button {
    padding: .125rem .375rem;
    color: var(--secondary);
    line-height: 1;
}

.qm-pa-header-button:hover,
.qm-pa-header-button:focus {
    color: var(--dark);
}

.qm-pa-header {
    min-height: 3.5rem;
    padding-top: .5rem;
    padding-bottom: .5rem;
}

/* Title as div with own styles, headings are styled globally in site.css */
.qm-pa-title {
    margin: 0;
    padding: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--dark);
    background: none;
}

.qm-pa-header .min-width-0 {
    min-width: 0;
}

/* Busy indicator: thin bar in the theme color under the header */
.qm-pa-sidebar.qm-pa-busy .qm-pa-header {
    box-shadow: inset 0 -2px 0 var(--primary);
}

.qm-pa-body {
    min-height: 0;
}

.qm-pa-scroll {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Messages */
.qm-pa-msg {
    max-width: 88%;
    margin-bottom: .75rem;
    padding: .5rem .75rem;
    overflow-wrap: anywhere;
}

.qm-pa-msg-text {
    white-space: pre-wrap;
}

.qm-pa-msg-agent .qm-pa-msg-text {
    white-space: normal;
}

.qm-pa-msg-user {
    margin-left: auto;
    color: #fff;
    background-color: var(--primary);
    border-radius: .75rem .75rem .125rem .75rem;
}

.qm-pa-msg-agent {
    margin-right: auto;
    background-color: var(--light);
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: .75rem .75rem .75rem .125rem;
}

.qm-pa-msg-agent a {
    overflow-wrap: anywhere;
}

.qm-pa-msg-question {
    border-left: 3px solid var(--info);
}

.qm-pa-msg-incomplete {
    border-left: 3px solid var(--warning);
}

.qm-pa-msg-label {
    margin-bottom: .25rem;
    font-size: .75rem;
    font-weight: 700;
    color: var(--secondary);
}

.qm-pa-files {
    margin-top: .375rem;
}

.qm-pa-file-badge {
    display: inline-block;
    max-width: 100%;
    margin: .125rem .25rem 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.qm-pa-info {
    margin: 0 0 .75rem;
    font-size: .75rem;
    color: var(--secondary);
    text-align: center;
}

.qm-pa-alert {
    padding: .5rem .75rem;
    margin-bottom: .75rem;
    overflow-wrap: anywhere;
}

/* Agent steps (collapsible) */
.qm-pa-steps {
    margin: 0 0 .75rem;
    font-size: .8125rem;
    color: var(--secondary);
}

.qm-pa-steps > summary {
    display: inline-block;
    cursor: pointer;
    padding: .125rem .5rem;
    border-radius: .25rem;
    list-style: none;
}

.qm-pa-steps > summary::-webkit-details-marker {
    display: none;
}

.qm-pa-steps > summary::before {
    content: "\25B8";
    display: inline-block;
    width: 1em;
    transition: transform .15s;
}

.qm-pa-steps[open] > summary::before {
    transform: rotate(90deg);
}

.qm-pa-steps > summary:hover,
.qm-pa-steps > summary:focus {
    background-color: var(--light);
    outline: none;
}

.qm-pa-steps > summary:focus-visible {
    box-shadow: 0 0 0 .2rem rgba(0, 0, 0, .15);
}

.qm-pa-step-list {
    margin: .375rem 0 0 .5rem;
    padding-left: 1.25rem;
    border-left: 2px solid var(--light);
}

.qm-pa-step-list > li {
    margin-bottom: .375rem;
    color: var(--dark);
}

.qm-pa-step-tool {
    font-weight: 600;
}

.qm-pa-step-output {
    font-size: .75rem;
    color: var(--secondary);
    overflow-wrap: anywhere;
}

/* Welcome */
.qm-pa-welcome {
    padding: 1rem .25rem;
}

.qm-pa-example {
    display: block;
    width: 100%;
    margin-bottom: .5rem;
    text-align: left;
    white-space: normal;
}

/* Activity line */
.qm-pa-activity {
    background-color: #fff;
}

/* Drop zone */
.qm-pa-drop {
    position: absolute;
    top: .5rem;
    right: .5rem;
    bottom: .5rem;
    left: .5rem;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: center;
    background-color: rgba(255, 255, 255, .94);
    border: 2px dashed var(--primary);
    border-radius: .5rem;
    pointer-events: none;
}

.qm-pa-drop.d-none {
    display: none !important;
}

.qm-pa-drop-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
}

.qm-pa-drop-busy {
    display: none;
}

.qm-pa-drop.qm-pa-drop-blocked {
    border-color: var(--secondary);
}

.qm-pa-drop.qm-pa-drop-blocked .qm-pa-drop-title,
.qm-pa-drop.qm-pa-drop-blocked .qm-pa-drop-hint {
    display: none;
}

.qm-pa-drop.qm-pa-drop-blocked .qm-pa-drop-busy {
    display: block;
}

/* Composer */
.qm-pa-composer textarea {
    resize: none;
    font-size: .875rem;
}

.qm-pa-attachments {
    display: flex;
    flex-wrap: wrap;
}

.qm-pa-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    margin: 0 .25rem .25rem 0;
    padding: .25rem .25rem .25rem .5rem;
    font-weight: 400;
    border: 1px solid rgba(0, 0, 0, .125);
}

.qm-pa-chip-name {
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qm-pa-chip-size {
    margin-left: .375rem;
    color: var(--secondary);
}

.qm-pa-chip-remove {
    margin-left: .375rem;
    padding: 0 .25rem;
    font-size: 1rem;
    line-height: 1;
}

.qm-pa-notice {
    padding: .375rem .625rem;
    margin-bottom: .5rem;
    font-size: .8125rem;
}

/* History */
.qm-pa-history-item {
    display: flex;
    align-items: flex-start;
    padding: 0;
}

.qm-pa-history-open {
    flex: 1 1 auto;
    min-width: 0;
    padding: .625rem 0 .625rem 1rem;
    color: inherit;
    text-align: left;
    background: none;
    border: 0;
}

.qm-pa-history-open:focus {
    outline: none;
}

.qm-pa-history-open:focus-visible {
    box-shadow: inset 0 0 0 .2rem rgba(0, 0, 0, .15);
}

.qm-pa-history-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qm-pa-history-meta {
    display: block;
    opacity: .75;
}

.qm-pa-history-remove {
    padding: .5rem 1rem;
    color: inherit;
}

.qm-pa-history-item.active .qm-pa-history-remove {
    color: #fff;
    text-shadow: none;
}

@media (max-width: 575.98px) {
    .qm-pa-sidebar {
        width: 100vw;
    }

    .qm-pa-sidebar.qm-pa-minimized {
        width: var(--qm-pa-rail-width);
    }
}
