/* The LLM key picker (admin LLM keys modal and the member's AI keys page).
   Layout: one column that fills its container; the model grid takes the remaining height and scrolls inside itself, in
   both directions, so a wide grid never widens the modal; Save sits in a footer that stays in view.
   Colours: FinCopy tokens only (fincopy.css, light and dark); status colours come from .fc-pill. */
.fc-llm-picker { display:flex; flex-direction:column; gap:1rem; height:100%; min-width:0; min-height:0; color:var(--fc-ink); }
.fc-llm-picker > * { min-width:0; }
.fc-llm-picker__key { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:.85rem 1rem; }
.fc-llm-picker label { display:grid; gap:.35rem; font-size:.85rem; font-weight:600; }
.fc-llm-picker input:not([type=checkbox]), .fc-llm-picker select { width:100%; min-width:0; border:1px solid var(--fc-line); border-radius:.45rem; padding:.55rem .65rem; color:var(--fc-ink); background:var(--fc-surface); font:inherit; font-weight:400; }
.fc-llm-picker input:focus-visible, .fc-llm-picker select:focus-visible, .fc-llm-picker button:focus-visible { outline:2px solid var(--fc-accent); outline-offset:1px; }
.fc-llm-picker__secret { grid-column:1/-1; }
.fc-llm-picker__secret span { display:flex; gap:.5rem; }
.fc-llm-picker__secret input { flex:1; }
.fc-llm-picker__secret small { color:var(--fc-muted); font-weight:400; }
.fc-llm-picker__plain { border:1px solid var(--fc-line); border-radius:.45rem; padding:.45rem .8rem; color:var(--fc-ink); background:var(--fc-surface); cursor:pointer; }
.fc-llm-picker__flags, .fc-llm-picker__toolbar, .fc-llm-picker__filters, .fc-llm-picker__chips { display:flex; align-items:center; gap:.65rem 1rem; flex-wrap:wrap; }
.fc-llm-picker__flags label, .fc-llm-picker__filters label { display:flex; align-items:center; gap:.4rem; font-weight:500; }
.fc-llm-picker__saved, .fc-llm-picker__toolbar span, .fc-llm-picker__selection small { color:var(--fc-muted); font-size:.8rem; font-weight:400; }
.fc-llm-picker__toolbar h3, .fc-llm-picker__selection h3 { margin:0 auto 0 0; font-size:1rem; }
.fc-llm-picker__filters > input[aria-label] { flex:1 1 18rem; }
.fc-llm-picker__filters select { flex:0 1 12rem; }

/* The models: this block takes the height the key fields and the selection leave. */
.fc-llm-picker__models { display:flex; flex-direction:column; gap:.65rem; flex:1 1 auto; min-height:18rem; }
.fc-llm-picker__grid-wrap { flex:1 1 auto; min-height:12rem; overflow:auto; border:1px solid var(--fc-line); border-radius:.5rem; background:var(--fc-surface); }
.fc-llm-picker__grid { min-width:100%; border-collapse:separate; border-spacing:0; font-size:.8rem; }
.fc-llm-picker__grid th, .fc-llm-picker__grid td { padding:.5rem .65rem; text-align:left; vertical-align:middle; border-bottom:1px solid var(--fc-line-soft); white-space:nowrap; background:var(--fc-surface); }
.fc-llm-picker__grid th { position:sticky; top:0; z-index:2; color:var(--fc-muted); font-size:.72rem; text-transform:uppercase; letter-spacing:.03em; border-bottom-color:var(--fc-line); }
.fc-llm-picker__grid .is-num { text-align:right; font-variant-numeric:tabular-nums; }
.fc-llm-picker__grid tbody tr:hover td { background:var(--fc-surface-soft); }
.fc-llm-picker__grid tr.is-picked td { background:color-mix(in srgb, var(--fc-accent) 8%, var(--fc-surface)); }

/* Frozen columns: the tick box and the model stay put while the rest of the row scrolls under them. */
.fc-llm-picker__grid .is-frozen { position:sticky; z-index:1; }
.fc-llm-picker__grid th.is-frozen { z-index:3; }
.fc-llm-picker__grid .col-pick { left:0; width:2.6rem; min-width:2.6rem; text-align:center; }
.fc-llm-picker__grid .col-model { left:2.6rem; min-width:16rem; max-width:24rem; box-shadow:inset -1px 0 0 var(--fc-line); }
.fc-llm-picker__modelcell { display:flex; align-items:center; gap:.5rem; min-width:0; }
.fc-llm-picker__name { display:grid; min-width:0; }
.fc-llm-picker__name b, .fc-llm-picker__name small { overflow:hidden; text-overflow:ellipsis; }
.fc-llm-picker__name small { color:var(--fc-muted); font-size:.72rem; }
.fc-llm-picker__more { flex:0 0 auto; width:1.6rem; height:1.6rem; border:1px solid var(--fc-line); border-radius:.35rem; color:var(--fc-muted); background:var(--fc-surface); cursor:pointer; line-height:1; }
.fc-llm-picker__more[aria-expanded="true"] { color:var(--fc-accent-strong); border-color:var(--fc-accent); }
.fc-llm-picker__sort { border:0; padding:0; color:inherit; background:none; font:inherit; font-weight:700; text-transform:inherit; letter-spacing:inherit; cursor:pointer; }

/* The expandable row: everything else the provider reports, held to the visible width of the grid. */
.fc-llm-picker__grid tr.is-detail td { white-space:normal; background:var(--fc-surface-soft); }
.fc-llm-picker__detail { position:sticky; left:0; display:grid; gap:.5rem; max-width:min(64rem, 86vw); }
.fc-llm-picker__detail p { margin:0; color:var(--fc-ink); line-height:1.45; }
.fc-llm-picker__detail .fc-pill b { font-weight:800; }
.fc-llm-picker__sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

.fc-llm-picker__selection { display:grid; gap:.6rem; }
.fc-llm-picker__chip { display:inline-flex; align-items:center; gap:.4rem; padding:.3rem .6rem; border:1px solid var(--fc-line); border-radius:999px; background:var(--fc-surface); font-size:.8rem; }
.fc-llm-picker__chip.is-main { border-color:var(--fc-accent); color:var(--fc-accent-strong); font-weight:700; }
.fc-llm-picker__chip button { border:0; padding:0 .15rem; color:var(--fc-muted); background:none; font:inherit; cursor:pointer; }
.fc-llm-picker__empty, .fc-llm-picker__error { margin:.75rem; color:var(--fc-muted); font-size:.85rem; }
.fc-llm-picker__error { color:var(--fc-danger); }

/* The footer: always in view at the bottom of the scrolling container, with room around the buttons. */
.fc-llm-picker__actions { position:sticky; bottom:0; z-index:4; display:flex; align-items:center; justify-content:flex-end; gap:.75rem; margin-top:auto; padding:.85rem 0 .25rem; border-top:1px solid var(--fc-line); background:var(--fc-surface); }

@media (max-width:720px) {
    .fc-llm-picker__key { grid-template-columns:1fr; }
    .fc-llm-picker__secret { grid-column:auto; }
    .fc-llm-picker__grid .col-model { min-width:12rem; }
}
