/* My Virtual World — Copyright (c) 2026 My Virtual World. Licensed under the PolyForm Noncommercial License 1.0.0 (see LICENSE). */
/* Agent Providers (client/js/ui/agent-providers.js): the top bar's button and its window — the providers on the left,
   the chosen one's page on the right. The window is the big windows' size (theme.css --win-w, --win-h), like the Agent
   Studio's. State colours: ok (connected), busy (connecting), wait (waiting for approval), bad (needs attention), off. */

/* ---- the top bar's button */
#topbar .provb { display: inline-flex; align-items: center; gap: 6px; position: relative; white-space: nowrap; font-weight: 600; }
#topbar .provb .pv-ic { font-size: 15px; line-height: 1; }
#topbar .provb .pv-dot { position: absolute; top: 3px; left: 20px; width: 8px; height: 8px; border-radius: 50%; display: none; box-shadow: 0 0 0 2px var(--panel-strong); }
#topbar .provb .pv-dot.ok, #topbar .provb .pv-dot.busy, #topbar .provb .pv-dot.wait, #topbar .provb .pv-dot.bad { display: block; }
.pv-dot.ok, .ap-dot.ok { background: var(--good, #34d399); }
.pv-dot.busy, .ap-dot.busy { background: #38bdf8; }
.pv-dot.wait, .ap-dot.wait { background: var(--warn, #e0a83a); }
.pv-dot.bad, .ap-dot.bad { background: var(--bad, #f87171); }
.ap-dot.off { background: var(--dim); }
@media (max-width: 980px) { #topbar .provb .pv-l { display: none; } }

/* ---- the window */
.ap-back { z-index: 6; }
.ap { --ac: #a78bfa; width: var(--win-w); height: var(--win-h); margin-top: var(--topbar-height, 56px); padding: 0; border-radius: 18px; overflow: hidden;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: radial-gradient(900px 420px at 88% -12%, color-mix(in srgb, var(--ac) 14%, transparent), transparent 62%), var(--panel-strong);
  border-color: color-mix(in srgb, var(--ac) 26%, var(--line)); animation: ap-in .26s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes ap-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.ap h2, .ap h3, .ap h4 { margin: 0; }
.ap .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.ap-head { display: flex; align-items: center; gap: 14px; padding: 14px 18px 12px; border-bottom: 1px solid var(--line); }
.ap-mark { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 25px; flex: none;
  background: linear-gradient(145deg, color-mix(in srgb, var(--ac) 30%, var(--bg2)), color-mix(in srgb, var(--ac) 8%, var(--bg2)));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ac) 40%, transparent), 0 6px 18px color-mix(in srgb, var(--ac) 22%, transparent); }
.ap-kicker { display: block; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: color-mix(in srgb, var(--ac) 72%, var(--text)); font-weight: 700; }
.ap-id h2 { font-size: 21px; line-height: 1.15; }
.ap-sub { font-size: 12px; color: var(--dim); }
.ap-head .spacer { flex: 1; }
.ap-main { display: grid; grid-template-columns: minmax(220px, 270px) minmax(0, 1fr); min-height: 0; }

/* ---- the providers */
.ap-side { border-right: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.ap-prov { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid transparent; background: none; color: inherit; font: inherit; cursor: pointer; }
.ap-prov:hover { background: color-mix(in srgb, var(--ac) 8%, transparent); }
.ap-prov.on { background: color-mix(in srgb, var(--ac) 14%, transparent); border-color: color-mix(in srgb, var(--ac) 38%, transparent); }
.ap-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ap-dot.busy { animation: ap-pulse 1.2s ease-in-out infinite; }
@keyframes ap-pulse { 50% { opacity: .35; } }
.ap-pl { display: flex; flex-direction: column; min-width: 0; }
.ap-pl b, .ap-pl small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-pl small { color: var(--dim); font-size: 11.5px; }
.ap-add { margin-top: 6px; justify-content: center; }
.ap-add.on { border-color: color-mix(in srgb, var(--ac) 50%, var(--line)); }

/* ---- one provider's page */
.ap-pane { padding: 16px 20px; overflow-y: auto; min-width: 0; }
.ap-ph { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.ap-ph > div:first-child { flex: 1; min-width: 220px; }
.ap-ph h3 { font-size: 19px; margin: 2px 0 6px; }
.ap-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.ap-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-right: 6px;
  background: color-mix(in srgb, var(--dim) 14%, transparent); }
.ap-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.ap-pill.ok { background: color-mix(in srgb, var(--good, #34d399) 16%, transparent); } .ap-pill.ok i { background: var(--good, #34d399); }
.ap-pill.busy i { background: #38bdf8; animation: ap-pulse 1.2s ease-in-out infinite; }
.ap-pill.wait { background: color-mix(in srgb, var(--warn, #e0a83a) 18%, transparent); } .ap-pill.wait i { background: var(--warn, #e0a83a); }
.ap-pill.bad { background: color-mix(in srgb, var(--bad, #f87171) 16%, transparent); } .ap-pill.bad i { background: var(--bad, #f87171); }
.ap-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 4px 0 14px; background: color-mix(in srgb, var(--bg2) 70%, transparent); }
.ap-card h4 { margin-bottom: 4px; }
.ap-card p { margin: 4px 0; }
.ap-card.wait { border-color: color-mix(in srgb, var(--warn, #e0a83a) 50%, var(--line)); background: color-mix(in srgb, var(--warn, #e0a83a) 8%, var(--bg2)); }
.ap-card.bad { border-color: color-mix(in srgb, var(--bad, #f87171) 50%, var(--line)); background: color-mix(in srgb, var(--bad, #f87171) 7%, var(--bg2)); }
.ap-cmd { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.ap-cmd code { padding: 6px 10px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); font-size: 12.5px; user-select: all; word-break: break-all; }
.ap-h { margin: 14px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.ap-agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.ap-agent { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--bg2) 60%, transparent); }
.ap-av { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; flex: none; background: color-mix(in srgb, var(--ac) 14%, var(--bg2)); }
.ap-an { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ap-an b, .ap-an small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-an small { color: var(--dim); font-size: 11.5px; }

/* ---- adding and editing */
.ap-form { max-width: 620px; }
.ap-form label { display: flex; flex-direction: column; gap: 4px; }
.ap-form small.hint { font-weight: 400; }
.ap-kinds { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.ap-kind { padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: inherit; font: inherit; cursor: pointer; }
.ap-kind.on { border-color: color-mix(in srgb, var(--ac) 60%, var(--line)); background: color-mix(in srgb, var(--ac) 14%, var(--bg2)); }
.ap-inrow { display: flex; gap: 6px; align-items: center; }
.ap-inrow .input { flex: 1; min-width: 0; }
.ap-found { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

@media (max-width: 760px) {
  .ap { width: 100vw; height: calc(100dvh - var(--topbar-height, 44px)); border-radius: 0; border: 0; }
  .ap-main { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .ap-side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .ap-prov { flex: none; }
}

/* ---- a provider's sub-menu (client/js/ui/providers/<menu>.js): tabs, lists, the settings, the confirmation */
.ap-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: -4px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.ap-tabs .tab { font-size: 13px; padding: 5px 10px; }
.ap-tabs .tab.on { border-color: color-mix(in srgb, var(--ac) 55%, var(--line)); background: color-mix(in srgb, var(--ac) 14%, var(--btn)); }
.op-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.op-grid .ap-card { margin: 0; }
.op-grid + .ap-h { margin-top: 16px; }
.op-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.op-row { display: flex; align-items: center; gap: 10px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--bg2) 55%, transparent); }
.op-main { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.op-main small { color: var(--dim); font-size: 12px; overflow-wrap: anywhere; }
.op-main .op-err { color: var(--bad); }
.op-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.op-search { width: 100%; box-sizing: border-box; margin-bottom: 10px; }
.op-form { gap: 8px; align-items: center; }
.op-policy { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; align-items: end; margin-bottom: 6px; }
.op-policy label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.op-set { display: grid; grid-template-columns: minmax(170px, 210px) minmax(0, 1fr); gap: 16px; min-height: 0; }
.op-secs { display: flex; flex-direction: column; gap: 10px; max-height: calc(var(--win-h) - 230px); overflow-y: auto; padding-right: 4px; }
.op-g { display: flex; flex-direction: column; gap: 2px; }
.op-sec { text-align: left; padding: 6px 10px; border-radius: 9px; border: 1px solid transparent; background: none; color: inherit; font: inherit; font-size: 13px; cursor: pointer; }
.op-sec:hover { background: color-mix(in srgb, var(--ac) 8%, transparent); }
.op-sec.on { background: color-mix(in srgb, var(--ac) 14%, transparent); border-color: color-mix(in srgb, var(--ac) 38%, transparent); font-weight: 600; }
.op-pane { min-width: 0; }
.op-crumbs { margin-bottom: 6px; font-size: 13px; }
.op-adv { font-size: 12.5px; margin: 4px 0 10px; }
.op-fields { display: flex; flex-direction: column; gap: 8px; }
.op-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 46%); gap: 12px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.op-field .op-fl { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.op-field .op-fl small { color: var(--dim); font-size: 12px; }
.op-field .input { width: 100%; box-sizing: border-box; }
.op-field .op-json { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; min-height: 60px; }
.op-field .op-json.bad { border-color: var(--bad); }
.op-into { display: flex; flex-direction: column; gap: 2px; text-align: left; width: 100%; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; grid-column: 1 / -1; }
.op-into small { color: var(--dim); font-size: 12px; }
.op-savebar { position: sticky; bottom: -16px; margin: 12px -20px -16px; padding: 10px 20px; display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  background: var(--panel-strong); border-top: 1px solid var(--line); }
.op-savebar .op-n { margin-right: auto; font-weight: 600; }
.ap-confirm { position: absolute; inset: 0; display: grid; place-items: center; background: var(--scrim); z-index: 2; }
.ap-confirm-card { width: min(640px, calc(100% - 40px)); max-height: calc(100% - 60px); overflow: auto; padding: 18px 20px; border-radius: 16px; }
.ap-confirm-card h3 { margin: 0 0 12px; }
.ap-diff { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 10px; }
.ap-diff th { text-align: left; color: var(--dim); font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.ap-diff td { padding: 6px 8px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); vertical-align: top; overflow-wrap: anywhere; }
.ap-diff td.was { color: var(--dim); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--dim) 50%, transparent); }
.ap-diff td.now { font-weight: 600; }
.ap { position: relative; }
@media (max-width: 760px) { .op-set { grid-template-columns: 1fr; } .op-field { grid-template-columns: 1fr; } }
.op-inline { gap: 6px; align-items: center; flex: none; } .op-inline .input { min-width: 180px; }
.op-main > b + .tag, .op-main .tag { align-self: flex-start; }
.op-main { align-items: flex-start; }
.op-main > small { align-self: stretch; }
.op-form .input { width: auto; flex: 1 1 180px; }
.op-form .op-emoji { flex: 0 0 76px; }
.op-sub .op-into { flex-direction: row; align-items: center; gap: 10px; }
.op-sub .op-into .op-fl { flex: 1; }
.op-go { font-size: 18px; color: var(--dim); flex: none; }
.op-sub:hover { border-color: color-mix(in srgb, var(--ac) 40%, var(--line)); }
/* the Tools page: tool profiles, tools by where they come from, plugins; a plugin's declarations before switching it on */
.ap .tag.set { color: var(--good); }
.ap .tag.warn { color: var(--warn, #e0a83a); }
.op-pick { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13px; }
.op-pick .input { width: auto; min-width: 200px; }
.op-prof .row { gap: 8px; align-items: center; }
.op-prof .input { flex: 1; min-width: 0; }
.op-tools { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.op-tgroup > summary { cursor: pointer; padding: 6px 2px; list-style-position: inside; }
.op-tgroup > summary small { color: var(--dim); margin-left: 4px; }
.op-tgroup .op-list { margin: 6px 0 4px; }
.op-main code { font-size: 11.5px; color: var(--dim); }
.ap-decl { margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.ap-decl p { margin: 0; overflow-wrap: anywhere; }
.ap-decl b { display: block; font-size: 12px; color: var(--dim); font-weight: 600; }
