/* Shared layout + density rules for "library" panels — DPanel-wrapped
   BbDataGrids that adapt their page size to the available viewport
   height (see Common/WindowResizeService + the panel's RecomputePageSize).
   Global stylesheet (not scoped) so the descendant selectors below work
   without ::deep, since BbDataGrid renders generated class names that
   scoped CSS can't reach. Loaded from index.html. */

/* Panel root: fill the workspace cell and become a flex column so the
   DPanel header + body chain through correctly. */
.library-panel {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* DPanel body must flex-fill so the grid wrapper can shrink to it. */
.library-panel .dpanel-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Empty-state placeholder used when the underlying VM reports zero rows. */
.library-empty {
    padding: 1.5rem;
    color: hsl(var(--muted-foreground));
}

/* Fit container — direct parent of the BbDataGrid. JS measures this
   element's bounding rect to compute the adaptive page size. Position:
   relative so the floating "columns" button can anchor to its top-right. */
.library-fit {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Column-visibility ("Columns") menu trigger — rendered through the grid's
   <Toolbar> slot (BbDataGridColumnVisibility requires being a descendant of
   BbDataGrid) and absolutely positioned over the top-right corner of the
   .library-fit container. z-index keeps it above the sticky header. */
.library-columns-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    z-index: 2;
}

/* The grid root inherits flex-fill so it fills the fit container. */
.library-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* The BbDataGrid wraps content in its own divs. Make every direct child a
   flex column, but only let the table-wrapper child grow — the toolbar
   and the pagination strip stay at their intrinsic heights. */
.library-grid > div {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: 0;
}

/* Any nested "table"-class wrapper between the grid root and the table
   absorbs the remaining vertical space; toolbar/pagination are siblings
   that stay at their natural heights above/below. */
.library-grid [class*="table"]:not(table):not(thead):not(tbody):not(tr):not(td):not(th) {
    flex: 1 1 auto;
    min-height: 0;
}

/* Footer button row docked at the bottom of the DPanel body (sibling of
   .library-fit). Houses bulk-action buttons like "Delete selected" that
   apply to the current grid selection. */
.library-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid hsl(var(--border));
    background: hsl(var(--muted) / 0.3);
}


/* Tight, single-line rows: 32px effective row height. The page-size calc
   measures the actual rendered row height live, so changing this number
   here will adapt automatically without code edits. */
.library-grid table td,
.library-grid table th {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-grid table tbody tr {
    height: 32px;
}

/* Small inline icon (badges, type column). */
.library-icon-sm {
    width: 0.875rem;
    height: 0.875rem;
    margin-right: 0.25rem;
}

/* Context-menu item icon. */
.library-menu-icon {
    width: 1rem;
    height: 1rem;
    margin-right: 0.5rem;
}

/* Clickable linked-count cell (descriptor / media link columns). Rendered
   inside FacetedGrid templates, which strip scoped-CSS attributes — kept
   global here so the style still applies. */
.library-link-count {
    display: inline-flex;
    align-items: center;
    gap: 0.125rem;
    border: none;
    background: transparent;
    padding: 0.125rem 0.375rem;
    border-radius: calc(var(--radius) - 4px);
    color: var(--primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.library-link-count:hover {
    background: color-mix(in oklab, var(--primary) 12%, transparent);
    text-decoration: underline;
}

.library-link-count.is-empty {
    color: var(--muted-foreground);
    font-weight: 400;
    cursor: default;
}
