/* Trang providers — CSS riêng của trang (giao diện kiểu 9router). Mọi class có tiền tố .pv- */

/* token phụ: lớp phủ trắng/đen rất mờ như bg-white/[0.02] của 9router */
:root, [data-theme="light"] {
  --pv-soft: rgba(0, 0, 0, .015); --pv-line: rgba(0, 0, 0, .05); --pv-row: rgba(0, 0, 0, .03);
  --pv-ctl-bg: rgba(0, 0, 0, .02); --pv-ctl-border: rgba(0, 0, 0, .1); --pv-ctl-hover: rgba(0, 0, 0, .05); --pv-code: rgba(0, 0, 0, .05);
}
[data-theme="dark"] {
  --pv-soft: rgba(255, 255, 255, .02); --pv-line: rgba(255, 255, 255, .03); --pv-row: rgba(255, 255, 255, .03);
  --pv-ctl-bg: rgba(255, 255, 255, .03); --pv-ctl-border: rgba(255, 255, 255, .1); --pv-ctl-hover: rgba(255, 255, 255, .1); --pv-code: rgba(255, 255, 255, .05);
}

/* ============ danh sách #/providers ============ */
.pv-page, .pv-sections { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.pv-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.pv-filter, .pv-search { height: 32px; border-radius: 8px; border: 1px solid var(--pv-ctl-border); background-color: var(--pv-ctl-bg);
  color: var(--text); font-size: 12px; transition: background-color .15s, border-color .15s, box-shadow .15s; }
.pv-filter { padding: 0 8px; min-width: 120px; outline: none; }
.pv-filter:hover, .pv-search:hover { background-color: var(--pv-ctl-hover); }
.pv-filter:focus-visible { border-color: rgba(229, 106, 74, .5); }
.pv-search { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; width: 240px; cursor: text; }
.pv-search .ms { font-size: 16px; color: var(--text-muted); }
.pv-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 12px; color: var(--text); }
.pv-search input::placeholder { color: var(--text-muted); }
.pv-search:focus-within { border-color: rgba(229, 106, 74, .4); box-shadow: 0 0 0 2px rgba(229, 106, 74, .2); }

.pv-section { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pv-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.pv-sec-head h2 { font-size: 20px; line-height: 1.25; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.pv-sec-actions { display: flex; align-items: center; gap: 8px; flex: none; }
[data-theme="light"] .pv-sec-actions .btn.white { border-color: var(--border); }

.pv-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.pv-grid > .card { margin: 0; }
@media (min-width: 640px) { .pv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1024px) { .pv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .pv-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* card nhà cung cấp (ApiKeyProviderCard) */
.card.pv-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; height: 100%; min-width: 0;
  cursor: pointer; transition: background-color .15s, opacity .15s; }
.card.pv-card:hover { background-image: linear-gradient(var(--pv-soft), var(--pv-soft)); }
.card.pv-card.off { opacity: .5; }
.card.pv-card:focus-visible { outline: 2px solid rgba(229, 106, 74, .6); outline-offset: 2px; }
.pv-card-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pv-card-text { min-width: 0; }
.pv-card-text h3 { font-size: 16px; line-height: 24px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; font-size: 12px; line-height: 16px; }
.pv-none { color: var(--text-muted); }
.pv-status .badge, .pv-badges .badge { font-size: 10px; line-height: 16px; padding: 2px 8px; gap: 6px; }
.pv-status .badge .ms, .pv-badges .badge .ms { font-size: 12px; }
.pv-card-side { display: flex; align-items: center; gap: 8px; flex: none; }
.pv-card-add .ms { font-size: 18px; color: var(--text-muted); }
.card.pv-card:hover .pv-card-add .ms { color: var(--primary); }
@media (min-width: 640px) {
  .pv-card-side { opacity: 0; transition: opacity .15s; }
  .card.pv-card:hover .pv-card-side, .card.pv-card:focus-within .pv-card-side { opacity: 1; }
}

/* ô icon nhà cung cấp (ProviderIcon fallback) */
.pv-icon { display: flex; align-items: center; justify-content: center; flex: none; border-radius: 8px; }
.pv-icon-text { font-weight: 700; line-height: 1; letter-spacing: .01em; }

/* nút "Kiểm tra tất cả" */
.pv-testall { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-muted); font-size: 12px; line-height: 18px; font-weight: 500;
  white-space: nowrap; transition: color .15s, border-color .15s, background-color .15s; }
.pv-testall .ms { font-size: 18px; }
.pv-testall:hover:not(:disabled) { color: var(--text); border-color: rgba(229, 106, 74, .4); }
.pv-testall:disabled { opacity: .5; }
.pv-testall.testing { opacity: 1; background: rgba(229, 106, 74, .2); border-color: rgba(229, 106, 74, .4); color: var(--primary);
  animation: pv-pulse 2s cubic-bezier(.4, 0, .6, 1) infinite; }
@keyframes pv-pulse { 50% { opacity: .55; } }

.pv-empty { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; border: 1px dashed var(--border);
  border-radius: 12px; color: var(--text-muted); font-size: 14px; line-height: 20px; text-align: center; }
.pv-empty .ms { font-size: 18px; }
.pv-nomatch { text-align: center; padding: 32px 16px; border: 1px dashed var(--border); border-radius: 12px; color: var(--text-muted); font-size: 14px; }
.pv-nomatch .ms { font-size: 32px; display: block; margin: 0 auto 8px; }

/* ============ chi tiết #/providers/<id> ============ */
.pv-detail { display: flex; flex-direction: column; gap: 32px; min-width: 0; }
.pv-back { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; margin-bottom: -16px; font-size: 14px;
  color: var(--text-muted); transition: color .15s; }
.pv-back .ms { font-size: 18px; }
.pv-back:hover { color: var(--primary); }
.pv-notfound { text-align: center; padding: 80px 0; color: var(--text-muted); }
.pv-notfound a { display: inline-block; margin-top: 16px; }
.pv-detail .card + .card { margin-top: 0; }
.pv-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.pv-card-head h2, .pv-ident-text h2 { font-size: 18px; line-height: 28px; font-weight: 600; }
.pv-title-row { display: flex; align-items: center; gap: 8px; }
.pv-head-actions { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }

/* thẻ thông tin */
.pv-info-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pv-ident { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 1 1 320px; }
.pv-ident .pv-icon { border-radius: 10px; }
.pv-ident-text { min-width: 0; }
.pv-ident-text h2 { font-size: 24px; line-height: 32px; letter-spacing: -.025em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-ident-text p { font-size: 14px; line-height: 20px; color: var(--text-muted); overflow-wrap: anywhere; }
.pv-info-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pv-enable { display: inline-flex; align-items: center; gap: 8px; margin-left: 4px; font-size: 12px; font-weight: 500; color: var(--text-muted); cursor: pointer; }
.pv-info-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px 24px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-subtle); }
@media (min-width: 640px) { .pv-info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pv-info-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pv-info-row .k { width: 112px; flex: none; font-size: 12px; color: var(--text-muted); }
.pv-info-row .v { min-width: 0; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-info-row .v.mono { font-family: var(--mono); font-size: 13px; }
.pv-info-row a { display: inline-flex; align-items: center; gap: 4px; color: var(--primary); }
.pv-info-row a:hover { text-decoration: underline; }
.pv-info-row a .ms { font-size: 14px; }

/* thẻ Kết nối */
.pv-strategy { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pv-strategy .lbl { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.pv-mini { height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background-color: var(--bg); color: var(--text);
  font-size: 12px; outline: none; }
.pv-mini:focus { border-color: var(--primary); }
.pv-mini.num { width: 56px; }
.pv-run { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-bottom: 16px; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--pv-ctl-border); background: var(--pv-ctl-bg); font-size: 12px; color: var(--text-muted); }
.pv-run .icon-btn { margin-left: auto; }
.pv-conn-list { display: flex; flex-direction: column; max-height: 620px; overflow-y: auto; padding-right: 4px; min-width: 0; }
.pv-conn + .pv-conn { border-top: 1px solid var(--pv-line); }
.pv-conn { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px; border-radius: 8px; min-width: 0;
  transition: background-color .15s; }
.pv-conn:hover { background-color: var(--pv-soft); }
.pv-conn.off { opacity: .6; }
.pv-conn-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.pv-prio { display: flex; flex-direction: column; flex: none; }
.pv-prio button { display: grid; place-items: center; padding: 2px; border: 0; border-radius: 4px; background: transparent; color: var(--text-muted); }
.pv-prio button .ms { font-size: 14px; }
.pv-prio button:hover:not(:disabled) { background: var(--surface-2); color: var(--primary); }
.pv-prio button:disabled { opacity: .3; }
.pv-auth { font-size: 16px; color: var(--text-muted); }
.pv-conn-body { flex: 1; min-width: 0; }
.pv-conn-name { font-size: 14px; line-height: 20px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-conn-sub { font-size: 12px; line-height: 16px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 4px; min-width: 0; font-size: 12px; line-height: 16px; }
.pv-err { max-width: 300px; font-size: 12px; color: #ef4444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-prio-no { font-size: 12px; color: var(--text-muted); }
.pv-cd { display: inline-flex; align-items: center; gap: 4px; font: 12px/16px var(--mono); color: #f97316; }
.pv-cd .ms { font-size: 13px; }
.pv-rt.request-timer { padding-block: 0; font-size: 12px; line-height: 16px; }
.pv-proxy-line, .pv-models-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px; font-size: 11px; line-height: 16px; color: var(--text-muted); min-width: 0; }
.pv-proxy-line code { font-size: 10px; padding: 1px 4px; border-radius: 4px; background: var(--pv-code); color: var(--text-muted); }
.pv-proxy-line .warn-text { font-size: 11px; }
.pv-models-line { gap: 4px 6px; }
.pv-mchip { padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--text); font-weight: 500; }
.pv-mchip i { font-style: normal; font-weight: 400; color: var(--text-muted); }
.pv-mchip.na { opacity: .6; }
.pv-conn-side { display: flex; align-items: center; gap: 8px; flex: none; }
.pv-acts { display: flex; gap: 4px; }
.pv-act { display: flex; flex-direction: column; align-items: center; min-width: 40px; padding: 4px 8px; border: 0; border-radius: 4px;
  background: transparent; color: var(--text-muted); transition: background-color .15s, color .15s; }
.pv-act .ms { font-size: 18px; }
.pv-act .l { font-size: 10px; line-height: 1.25; white-space: nowrap; }
.pv-act:hover:not(:disabled) { background: var(--hover); color: var(--primary); }
.pv-act.on { color: var(--primary); }
.pv-act.red, .pv-act.red:hover:not(:disabled) { color: #ef4444; }
.pv-act.red:hover:not(:disabled) { background: rgba(239, 68, 68, .1); }
.pv-act:disabled { opacity: .6; }
.pv-conn-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.pv-conn-empty { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pv-conn-empty-l { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pv-conn-empty-l p { font-size: 14px; }
.pv-conn-empty-l p.small { font-size: 12px; }
.pv-ring { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.pv-ring .ms { font-size: 18px; }
.pv-conn-empty-r { display: flex; gap: 8px; flex-wrap: wrap; }

/* thẻ Model (ModelRow) */
.pv-model-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.pv-model { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; transition: background-color .15s; }
.pv-model:hover { background-color: var(--pv-soft); }
.pv-model-ic { font-size: 16px; color: var(--text-muted); }
.pv-model-body { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.pv-model-body code { max-width: 360px; padding: 2px 6px; border-radius: 4px; background: var(--surface-2); color: var(--text-muted); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-model-sub { display: flex; gap: 6px; min-width: 0; max-width: 100%; padding-left: 4px; font-size: 10px; line-height: 14px; color: var(--text-muted); opacity: .8; }
.pv-model-sub > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-copy { display: grid; place-items: center; flex: none; padding: 2px; border: 0; border-radius: 4px; background: transparent; color: var(--text-muted); }
.pv-copy .ms { font-size: 14px; }
.pv-copy:hover { background: var(--surface-2); color: var(--primary); }
.pv-add-model { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px; border: 1px dashed rgba(229, 106, 74, .4);
  border-radius: 8px; background: transparent; color: var(--primary); font-size: 12px; transition: border-color .15s, background-color .15s; }
.pv-add-model .ms { font-size: 14px; }
.pv-add-model:hover { border-color: var(--primary); background: rgba(229, 106, 74, .05); }

/* ============ modal ============ */
.pv-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pv-preset { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); text-align: left; transition: border-color .15s, background-color .15s; }
.pv-preset b { font-size: 13px; line-height: 18px; font-weight: 600; }
.pv-preset .badge { font-size: 10px; padding: 1px 8px; }
.pv-preset:hover { border-color: rgba(229, 106, 74, .4); }
.pv-preset.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.pv-note { margin: -4px 0 14px; font-size: 12px; color: var(--text-muted); }
.pv-form2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.pv-check { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; font-size: 13px; }
.pv-guide { margin-bottom: 16px; }
.pv-guide > p { margin-bottom: 8px; }
.pv-lead { margin-bottom: 12px; }
.pv-link-status { display: grid; gap: 8px; margin-top: 10px; }
.pv-screen-link { justify-self: start; text-decoration: none; }
.pv-pool-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary); }
.pv-pool-link .ms { font-size: 16px; }
.pv-pool-link:hover { text-decoration: underline; }
.modal .callout + .pv-pool-link { margin-top: 12px; }

/* kết quả "Kiểm tra tất cả" */
.pv-res { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pv-res-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 4px; font-size: 12px; }
.pv-res-total { margin-left: auto; }
.pv-res-tag { padding: 2px 8px; border-radius: 4px; font-weight: 500; }
.pv-res-tag.ok { background: rgba(16, 185, 129, .15); color: var(--c-green); }
.pv-res-tag.bad { background: rgba(239, 68, 68, .15); color: var(--c-red); }
.pv-res-row { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 12px; border-radius: 8px; background: var(--pv-row); font-size: 12px; }
.pv-res-row > .ms { font-size: 16px; }
.pv-res-row > .ms.ok { color: #10b981; }
.pv-res-row > .ms.bad { color: #ef4444; }
.pv-res-name { flex: 1 1 160px; min-width: 0; }
.pv-res-name .b { font-weight: 500; }
.pv-res-err { margin-top: 2px; color: var(--c-red); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-res-ms { flex: none; font-family: var(--mono); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pv-res-row .pv-res-tag { flex: none; padding: 2px 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.pv-res-empty { padding: 16px; text-align: center; font-size: 14px; color: var(--text-muted); }

/* ============ mobile ============ */
@media (max-width: 639px) {
  .pv-toolbar { justify-content: stretch; }
  .pv-search { flex: 1; width: auto; }
  .pv-sec-head { flex-direction: column; align-items: stretch; }
  .pv-sec-head h2 { font-size: 18px; }
  .pv-sec-actions > * { flex: 1; }
  .pv-detail { gap: 24px; }
  .pv-back { margin-bottom: -8px; }
  .pv-card-head { flex-direction: column; align-items: stretch; }
  .pv-head-actions { align-items: stretch; }
  .pv-head-actions > .btn { flex: 1; }
  .pv-ident { flex-basis: 100%; gap: 12px; }
  .pv-ident-text h2 { font-size: 20px; line-height: 28px; }
  .pv-info-actions { width: 100%; }
  .pv-info-actions > .btn { flex: 1; }
  .pv-conn-list { max-height: none; overflow: visible; padding-right: 0; }
  .pv-conn { flex-direction: column; align-items: stretch; }
  .pv-conn-main { align-items: flex-start; gap: 8px; }
  .pv-conn-side { justify-content: space-between; }
  .pv-acts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); flex: 1; }
  .pv-conn-foot > .btn, .pv-conn-empty-r > .btn, .pv-conn-empty-r { flex: 1; }
  .pv-model { width: 100%; }
  .pv-model-body code { max-width: 72vw; }
  .pv-add-model { width: 100%; }
  .pv-form2 { grid-template-columns: minmax(0, 1fr); }
  .pv-res-total { margin-left: 0; }
}

/* Thẻ Model Gemini Web: nhóm Mặc định · Tiêu chuẩn · Extended thinking */
.pv-mgroups { display: flex; flex-direction: column; gap: 20px; }
.pv-mnote { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; line-height: 18px; color: var(--text-muted); }
.pv-mnote .ms { margin-top: 2px; }
.pv-mgroup { display: flex; flex-direction: column; gap: 10px; }
.pv-mgroup-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.pv-mgroup-ic { font-size: 18px; color: var(--primary); }
.pv-mgroup-desc { font-size: 12px; color: var(--text-muted); }
.pv-wmodel { align-items: flex-start; min-width: 240px; }
.pv-wmodel .pv-model-ic { margin-top: 2px; color: var(--primary); }
.pv-wmodel.thinking .pv-model-ic { color: var(--c-purple); }
.pv-wmodel.pending { border-style: dashed; }
.pv-wmodel.pending .pv-model-ic { color: var(--text-muted); }
.pv-model-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.pv-mchip-ic { color: var(--c-purple); margin-left: 3px; vertical-align: -2px; }
@media (max-width: 640px) { .pv-wmodel { min-width: 0; } }
