/* AirForge Pro: Library (contract G.3, G.5). Owner: ui-features.
 * Selectors are scoped to .lib, .libmain, .libtw, #libTbl and the pro-lib-* classes of pro/ui/library.js. */

/* ---- sticky: the toolbar (search, quick filters, views, Columns) stays above the table ---- */
.libmain > .row:has(> .search) {
  position: sticky;
  top: var(--pro-lib-top, var(--pro-stick, var(--pro-top, var(--af-topbar-h, 0px))));
  z-index: 5;
  background: var(--bg);
  padding: 8px 0;
  margin: -8px 0;
}
/* The table scrolls in its own box, sized to the room under the sticky toolbar. When the page itself is scrolled the
 * box slides up under the toolbar; library.js then lowers the column titles by the same amount (--pro-lib-thtop),
 * so they are always on screen right under the toolbar. */
.libmain .libtw {
  max-height: calc(100vh - var(--pro-lib-top, 140px) - var(--pro-lib-tool, 48px) - 28px) !important;
  min-height: 240px;
}
.libmain #libTbl thead th { position: sticky; top: var(--pro-lib-thtop, 0px); z-index: 3; background: var(--panel2); }
@media (max-width: 720px) {
  .libmain > .row:has(> .search) { position: static; margin: 0; padding: 0; }
  .libmain .libtw { max-height: calc(100vh - 140px) !important; }
  .libmain #libTbl thead th { top: 0; }
}

/* ---- custom field cells ---- */
#libTbl .pro-lib-cell {
  display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center;
  min-width: 34px; min-height: 22px; max-width: 100%;
  border: 1px dashed transparent; border-radius: 6px; background: none; padding: 1px 4px;
  cursor: pointer; color: var(--ink); font: inherit; text-align: left;
}
#libTbl .pro-lib-cell:hover, #libTbl .pro-lib-cell:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
#libTbl .pro-lib-plus { color: var(--dim); font-size: 12px; opacity: 0; }
#libTbl tr:hover .pro-lib-plus, #libTbl .pro-lib-cell:focus-visible .pro-lib-plus { opacity: 1; }
#libTbl .pro-lib-chip { background: var(--info-soft); color: var(--ink); }

/* ---- value pickers (menu and dialog) ---- */
.pro-lib-menu { padding: 6px 10px; display: flex; flex-direction: column; gap: 8px; min-width: 250px; }
.pro-lib-opts { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow: auto; }
.pro-lib-opt { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 13.5px; color: var(--ink); }
.pro-lib-opt:hover { background: var(--panel2); }
.pro-lib-opt input { flex: none; width: 16px; height: 16px; }
.pro-lib-addrow { display: flex; gap: 6px; align-items: center; }
.pro-lib-addrow .inp { flex: 1; min-width: 0; }
.pro-lib-addrow .btn { flex: none; width: auto; }
.pro-lib-btns { gap: 6px; }
.menu .pro-lib-btns button.btn { width: auto; border: 1px solid var(--line); padding: 5px 12px; }
.menu .pro-lib-btns button.btn.pri { background: var(--accent); border-color: var(--accent); color: #16203a; }
.pro-lib-note { font-size: 12.5px; padding: 4px 10px; }
.pro-lib-form { display: flex; flex-direction: column; gap: 14px; }
.pro-lib-radio { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; margin-right: 14px; cursor: pointer; }
.pro-lib-fchips { margin-top: 0; }

/* ---- the list rail (categories, groups, clients) stays beside the table while the page scrolls ----
 * AirForge's own rule for the long category list (.catlist.lbscroll, top: 87px, added by its script later in the page)
 * would put it behind the Pro strip and the sticky page header, so both forms are named here with the html prefix. */
@media (min-width: 861px) {
  html.pro .lib > .catlist,
  html.pro .lib > .catlist.lbscroll {
    position: sticky;
    top: calc(var(--pro-lib-top, var(--pro-stick, var(--pro-top, var(--af-topbar-h, 0px)))) + 8px);
    max-height: calc(100vh - var(--pro-lib-top, var(--pro-stick, 140px)) - 28px);
    overflow: auto;
  }
}
