/* Layout: page structure, three-column body grid, insets, frames, footers, and panel-state responsive rules. Cross-feature media queries live here. */
/* Page Structure */

.div-structure-page-container{
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100%;
}

/* Shared 24pt toolbar button/select sizing for the header and chat container */
.div-structure-header button,
.div-structure-header select,
.div-structure-chat-container button,
.div-structure-chat-container select {
	height: 24pt;
	font-size: 8pt;
	text-transform: uppercase;
	line-height: 12pt;
	border-radius: var(--DM-margin-q);
	padding: var(--DM-margin-q);
	min-width: 3em;
	cursor: pointer;
}

.div-structure-header button,
.div-structure-chat-container button {
	border: 1pt solid var(--AC-btn);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.div-structure-header select,
.div-structure-chat-container select {
	border: 1pt solid var(--BD-input);
}

.div-structure-header{
    padding: var(--DM-margin-q) var(--DM-margin-h);
    background-color: var(--BG-header);
    border-bottom: 1px solid var(--BD-fieldset);
    button {
        margin: 0 1em;
    }
    label {
        font-size: 13pt;
        margin-top: 16pt;
    }
}

.div-structure-header-inset {
    display: grid;
    grid-template-columns: auto 1fr auto;
}

.div-structure-body{
    display: grid;
    transition: grid-template-columns 0.3s ease-in-out;
}

.div-structure-left-inset,
.div-structure-center-inset{
    display: grid;
    grid-template-rows: 1fr;
    margin: var(--DM-margin) 0 var(--DM-margin) var(--DM-margin);
    min-width: 0;
    overflow: hidden;
}

.div-structure-right-inset{
    display: grid;
    grid-template-rows: 1fr;
    margin: var(--DM-margin);
    min-width: 0;
    overflow: hidden;
    background-color: var(--BG-panel);
}

.div-structure-left-content {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
    overflow: hidden;
}

.div-structure-center-index {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
    overflow: hidden;
}

.div-structure-right-chat{
    display: grid;
    grid-template-rows: auto auto 1fr auto auto;
    min-width: 0;
    overflow: hidden;
}

.div-structure-index-list,
.div-structure-center-index-list{
    background-color: var(--BG-panel);
    padding: var(--DM-margin);
    min-width: 0;
    overflow: hidden;
}

.div-structure-chat-container{
    min-height: 0;
    margin: 0 var(--DM-margin) var(--DM-margin-h) var(--DM-margin);
    background-color: var(--BG-base);
    /* the border closes the active tab above it, so it uses the tab's
       border color; all corners stay square to meet the tabs flush */
    border: 1pt solid var(--BD-panel);
    border-radius: 0;
    z-index: 10;
}

/* The same container doubles as the standalone "new" screen (no tabs above
   it), where it gets the rounded corners of the bigger panels. */
.div-structure-chat-container.div-chat-empty-state {
    border-radius: 0.5em;
}


/* Managed hosts carry no overflow of their own: SimpleBar derives
   scrollability from the content, and a native overflow here would reserve
   a scrollbar gutter and push the custom track off the frame edge. */
.div-index-container-scroll{
    height: 0;
    min-height: 100%;
    overflow-x: hidden;
    display: grid;
    grid-template-rows: 1fr;
    background-color: var(--BG-base);
    min-width: 0;
}

.div-center-index-container-scroll{
    height: 0;
    min-height: 100%;
    overflow-x: hidden;
    display: grid;
    grid-template-rows: 1fr;
    background-color: var(--BG-base);
    min-width: 0;
}

/* Frames wrap the index scroll containers: they carry the rounded corners and
   border, clipping the scroll box so its scrollbar never pokes past them. */
.div-index-container-frame,
.div-center-index-container-frame{
    height: 100%;
    box-sizing: border-box;
    display: grid;
    grid-template-rows: 1fr;
    border-radius: 0.5em;
    border: 1px solid var(--BD-panel-l);
    overflow: hidden;
    min-width: 0;
}

/* scroll-fill: panel-filling scroll hosts (height collapses to the frame) */
.scroll-fill {
    height: 0;
    min-height: 100%;
    display: grid;
    grid-template-rows: 1fr;
}

/* SimpleBar moves the children of a managed container into its content
   element: the bottom-stick grid lives there once initialized, with
   min-height so short content still fills the viewport. No scroll-behavior
   here: JS passes scrolling behavior explicitly. */
/* scroll-stick: bottom-stick hosts. SimpleBar moves the children into its
   content element: the bottom-stick grid lives there once initialized, with
   min-height so short content still fills the viewport. No scroll-behavior
   here: JS passes scrolling behavior explicitly. */
.scroll-stick .simplebar-content {
    display: grid;
    grid-template-rows: 1fr auto;
    min-height: 100%;
}

.div-structure-body-left{
    display: grid;
    grid-template-rows: 1fr;
    overflow: hidden;
    min-width: 0;
}

.div-structure-body-center{
    display: grid;
    grid-template-rows: 1fr;
    overflow: hidden;
    min-width: 0;
}

.div-structure-body-right{
    display: grid;
    grid-template-rows: 1fr;
    overflow: hidden;
    min-width: 0;
}
.div-structure-footer{
    background-color: var(--BG-panel);
    padding: var(--DM-margin-q) var(--DM-margin-h);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--DM-margin-q);
}

.div-structure-footer-cell.is-left{
    font-size: 8pt;
    line-height: 1.4;
    display: flex;
    align-items: center;
}

.span-footer-copyright,
.span-footer-sync{
    text-align: center;
}

.span-footer-sync{
    border-left: 1px solid var(--BD-divider);
    padding-left: var(--DM-margin-h);
    margin-left: var(--DM-margin-h);
}

.div-structure-footer-cell.is-right{
    justify-self: end;
    display: flex;
    align-items: center;
    gap: var(--DM-margin-q);
}

.div-structure-footer-cell.is-right select,
.div-structure-footer-cell.is-right button {
    height: 28pt;
    box-sizing: border-box;
}

.div-structure-footer-cell.is-right button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28pt;
    padding: 0;
    font-size: 11pt;
    border: 1pt solid var(--AC-btn);
    border-radius: var(--DM-margin-q);
    cursor: pointer;
}

.user-switcher-select{
    width: auto;
    min-width: 8em;
    font-size: 8pt;
}
.div-structure-body-v-i-c {
    grid-template-columns: 1fr 1fr 2fr 0fr;
}

.div-structure-body-v-c {
    grid-template-columns: 1fr 0fr 3fr 0fr;
}

.div-structure-body-i-c {
    grid-template-columns: 0fr 1fr 3fr 0fr;
}

.div-structure-body-c {
    grid-template-columns: 0fr 0fr 4fr 0fr;
}

/* Single-column mode: reduce last-panel side margins to widen the content
   area. Narrow viewports only — closing both panels at the two-column
   breakpoint keeps the normal margins. */
@media screen and (max-width: 780px) {
	.div-structure-body-c .div-structure-right-inset {
		margin-left: 0;
		margin-right: 0;
	}

	.div-structure-body-c .div-structure-chat-container {
		margin-left: calc(var(--DM-margin) / 2);
		margin-right: calc(var(--DM-margin) / 2);
	}

	.div-structure-body-c .div-chat-title-bar {
		padding-left: calc(var(--DM-margin) / 2);
		padding-right: calc(var(--DM-margin) / 2);
	}

	.div-structure-body-c #id-span-title-loading {
		right: calc(var(--DM-margin) / 2);
	}

	.div-structure-body-c .div-tab-bar {
		margin-left: calc(var(--DM-margin) / 2);
		margin-right: calc(var(--DM-margin) / 2);
	}

	.div-structure-body-c .div-chat-prompt-inset,
	.div-structure-body-c .div-chat-context-inset,
	.div-structure-body-c .div-chat-memory-inset {
		margin-left: calc(var(--DM-margin) / 2);
		margin-right: calc(var(--DM-margin) / 2);
	}
}
@media screen and (max-width: 1560px) {
    .div-structure-body-v-i-c {
        grid-template-columns: 1fr 0fr 2fr 0fr;
    }
    .div-structure-body-v-c{
        grid-template-columns: 1fr 0fr 2fr 0fr;
    }
    .div-structure-body-i-c {
        grid-template-columns: 0fr 1fr 2fr 0fr;
    }
    .div-structure-body-c {
        grid-template-columns: 0fr 0fr 3fr 0fr;
    }

    .div-structure-header button {
        margin: 0 .5em 0 0;
    }

    .div-structure-content-options {
        padding: var(--DM-margin-h);
    }

    .div-structure-left-inset {
        margin: 0;
    }

    .div-structure-center-inset {
        margin: 0;
    }

    .div-structure-right-inset {
        margin: 0;
    }

    .div-structure-index-list {
        padding: 0 var(--DM-margin-h);
    }

    .div-structure-center-index-list {
        padding: 0 var(--DM-margin-h);
    }

    /* parent scoping beats the base margins from index-lists.css */
    .div-structure-left-content .div-structure-content-options,
    .div-structure-center-index .div-structure-center-index-options,
    .div-structure-center-index .div-structure-center-document-options {
        margin-bottom: 0;
    }

}
/* Two-column mode: a panel border frames the chat side, and the third
   column keeps the margined, bordered panel it has in three-column mode. */
@media screen and (min-width: 781px) and (max-width: 1560px) {
	.div-structure-body-right {
		border-left: 1px solid var(--BD-panel-l);
		border-bottom: 1px solid var(--BD-panel-l);
		border-bottom-left-radius: 0.5em;
	}

	.div-structure-right-inset {
		margin: var(--DM-margin);
		border-radius: 0.5em;
		border: 1px solid var(--BD-panel-l);
	}

	.div-structure-chat-container {
		border: 1px solid var(--BD-panel);
	}
}

/* Single-column mode: the outer right panel runs edge-to-edge; the
   conversation panel keeps its border to match the tab bar. */
@media screen and (max-width: 780px) {
	.div-structure-right-inset {
		border: none;
		border-radius: 0;
		margin: 0;
		padding: 0;
	}

	.div-structure-chat-container {
		margin: 0;
	}

	/* flush panel: the tab bar aligns with the panel's side borders */
	.div-tab-bar {
		margin: 0;
	}

	/* a little separation between the prompt box and the content above */
	.div-chat-prompt-container {
		padding-top: var(--DM-margin-q);
	}

	.div-structure-right-chat .div-chat-empty-inset {
		margin: 0;
	}

	/* Welcome view: pad the buttons away from the panel frame; the inset
	   loses its margin in this mode, so the scroll container carries the
	   spacing. The frame's rounding is on the base container rule. */
	.div-structure-right-chat .div-chat-empty {
		padding: var(--DM-margin-h);
	}
}

@media screen and (min-width: 1561px) {
    .div-structure-index-list,
    .div-structure-center-index-list,
    .div-structure-right-inset,
    .div-structure-content-options,
    .div-structure-center-index-options,
    .div-structure-center-document-options {
        border-radius: 0.5em;
        border: 1px solid var(--BD-panel-l);
    }

    .div-structure-footer {
        border-top: 1px solid var(--BD-panel-l);
    }
}
@media screen and (max-width: 780px) {

    .div-structure-body-v-i-c .div-options-chips,
    .div-structure-body-v-c .div-options-chips,
    .div-structure-body-i-c .div-options-chips,
    .div-structure-body-c .div-options-chips {
        padding-bottom: 0;
    }

    .div-structure-body-v-i-c {
        grid-template-columns: 0fr 0fr 1fr 0fr;
    }
    .div-structure-body-v-c{
        grid-template-columns: 1fr 0fr 0fr 0fr;
    }
    .div-structure-body-i-c {
        grid-template-columns: 0fr 1fr 0fr 0fr;
    }
    .div-structure-body-c {
        grid-template-columns: 0fr 0fr 1fr 0fr;
    }

    .div-options-columns {
        flex-direction: column;
    }

    .div-structure-footer-cell.is-left {
        font-size: 6.5pt;
    }

}
