/* ================================
   Assistant panel: the left sidebar's mirror on the right
   (see components/agent_panel.html and agent_panel.js)
   ================================ */

:root {
    --agent-panel-w: 400px;
}

.agent-panel.offcanvas {
    --bs-offcanvas-width: var(--agent-panel-w);
}

/* While agent_panel.js applies the remembered state on load, so the panel
   doesn't slide into place */
.agent-panel-no-transition .agent-panel.offcanvas,
.agent-panel-no-transition .agent-panel-edge-toggle,
.agent-panel-no-transition body {
    transition: none !important;
}

/* Desktop: docked beside the content (override offcanvas) */
@media (min-width: 992px) {
    .agent-panel.offcanvas {
        top: 76px; /* Below the fixed navbar */
        height: calc(100vh - 76px);
        z-index: 1040; /* Below navbar (1050), like the sidebar */
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        transform: none;
        visibility: visible;
        transition: transform 0.3s ease, visibility 0s linear 0s;
    }

    /* Collapsed: slid off the right edge, and out of the tab order once there */
    .agent-panel.offcanvas.collapsed {
        transform: translateX(100%);
        visibility: hidden;
        transition: transform 0.3s ease, visibility 0s linear 0.3s;
    }

    /* Push content when the panel is open */
    body.has-agent-panel:not(.agent-panel-collapsed) {
        padding-right: var(--agent-panel-w);
    }
}

/* Both sidebars animate body padding; one transition list keeps both */
body.has-agent-panel {
    transition: padding-left 0.3s ease, padding-right 0.3s ease;
}

/* Mobile: Bootstrap's offcanvas, pulled out over the page. Nearly the whole
   width, leaving a strip for the edge tab to close it again. */
@media (max-width: 991.98px) {
    .agent-panel.offcanvas {
        --bs-offcanvas-width: calc(100% - 1.5rem);
        top: 76px;
        height: calc(100% - 76px);
        height: calc(100dvh - 76px); /* Shrinks with the on-screen keyboard */
    }
}

/* ================================
   Edge tab, halfway up the right edge
   ================================ */
.agent-panel-edge-toggle {
    position: fixed;
    top: 50%;
    right: var(--agent-panel-w);
    transform: translateY(-50%);
    width: 2rem;
    height: 3.25rem;
    border: 1px solid var(--bs-border-color-translucent);
    border-right: none;
    border-radius: 1rem 0 0 1rem;
    background: var(--bs-body-bg);
    color: var(--bs-primary);
    box-shadow: -1px 0 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    opacity: 0.85;
    transition: right 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    z-index: 1046; /* Above the open mobile offcanvas (1045) and its backdrop */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.agent-panel-edge-toggle:hover,
.agent-panel-edge-toggle:focus-visible {
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.25);
    opacity: 1;
    outline: none;
}

.agent-panel-edge-toggle.collapsed {
    right: 0;
    border-radius: 0.85rem 0 0 0.85rem;
}

/* Slim chevron drawn with two borders (no icon font needed). Drawn as ">"
   (push the panel away); .collapsed flips it to "<" (pull it out). */
#agentPanelToggleIcon {
    position: relative;
    display: block;
    width: 0.6rem;
    height: 0.9rem;
    transition: transform 0.3s ease;
}

#agentPanelToggleIcon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid currentColor;
    border-top: 2px solid currentColor;
    transform: translate(-75%, -50%) rotate(45deg);
}

.agent-panel-edge-toggle.collapsed #agentPanelToggleIcon {
    transform: rotate(180deg);
}

/* Mobile: slimmer but taller tab. While open it rides the offcanvas edge. */
@media (max-width: 991.98px) {
    .agent-panel-edge-toggle {
        right: calc(100% - 1.5rem); /* Mobile offcanvas width */
        width: 1.5rem;
        height: 3.5rem;
        border-radius: 0.75rem 0 0 0.75rem;
    }

    .agent-panel-edge-toggle.collapsed {
        right: 0;
    }
}
