/* printers page (redesign). Loaded after styles.css; owned by views for this page. */

/* ── Page bar ─────────────────────────────── */
.pt-search {
  width: 340px; max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--input-bg); color: var(--text);
  font: inherit; font-size: 13.5px;
}
.pt-search:focus { outline: none; box-shadow: 0 0 0 2px var(--ring); }
.pt-seg-n { font-variant-numeric: tabular-nums; }
.seg > button:disabled { cursor: default; opacity: .6; }

/* Phone-only scope picker (opens the tree in a drawer). */
.pt-scope-btn {
  display: none; width: 100%; align-items: center; gap: 6px;
  padding: 8px 12px; margin-bottom: 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--card-bg); color: var(--text);
  font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.pt-scope-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.pt-scope-btn .pt-scope-k { color: var(--text-muted); }
.pt-scope-btn b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Two panes ─────────────────────────────── */
.pt-split { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.pt-list { min-width: 0; }
.pt-loading { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13.5px; padding: 16px 8px; }

/* ── Tree ─────────────────────────────── */
.pt-tree {
  position: sticky; top: 0;
  max-height: calc(100vh - 140px); overflow: auto;
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 6px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-alt);
  font-size: 13.5px;
}
.pt-tree [role="group"] { display: flex; flex-direction: column; gap: 1px; }
.pt-tree-empty { color: var(--text-muted); font-size: 12.5px; padding: 6px 10px; }
.pt-tn {
  display: flex; align-items: center; gap: 6px;
  min-height: 30px;
  padding: 4px 4px 4px calc(6px + var(--d, 0) * 16px);
  border-radius: var(--radius-md);
  color: var(--text); cursor: pointer; outline: none;
}
.pt-tn:hover { background: var(--hover-strong); }
.pt-tn:focus-visible { box-shadow: inset 0 0 0 2px var(--ring); }
.pt-tn.is-sel { background: var(--select-bg); color: var(--primary-text); font-weight: 600; }
.pt-tn.is-muted .pt-tl { color: var(--text-muted); }
.pt-tn.is-muted.is-sel .pt-tl { color: var(--primary-text); }
.pt-tw {
  width: 16px; height: 16px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-faint); border-radius: var(--radius-sm);
}
.pt-tw svg { transition: transform .15s; }
.pt-tw.open svg { transform: rotate(90deg); }
.pt-tw[data-act]:hover { background: var(--border); color: var(--text); }
.pt-tl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-tc { font-size: 11.5px; font-weight: 400; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pt-tn.is-sel .pt-tc { color: var(--primary-text); }
.pt-tm {
  flex: none; width: 22px; height: 20px;
  border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--text-muted); font-size: 16px; line-height: 1; cursor: pointer;
  opacity: 0;
}
.pt-tn:hover .pt-tm, .pt-tn:focus .pt-tm, .pt-tn:focus-within .pt-tm, .pt-tn.is-sel .pt-tm { opacity: 1; }
.pt-tm:hover { background: var(--border); color: var(--text); }
@media (hover: none) { .pt-tm { opacity: 1; } }
.pt-tsep { border-top: 1px solid var(--border); margin: 6px 4px; }

/* Tree inside the phone drawer. */
.pt-tree.pt-tree-drawer { position: static; max-height: none; overflow: visible; border: 0; background: none; padding: 0; }
.pt-tree-drawer .pt-tn { min-height: 38px; }

/* ── Scope header ─────────────────────────────── */
.pt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-height: 30px; margin-bottom: 10px; }
.pt-crumb { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; min-width: 0; font-size: 14px; color: var(--text-muted); }
.pt-crumb b { color: var(--text); font-weight: 600; }
.pt-crumb-link { font: inherit; border: 0; background: none; padding: 0; color: var(--link); cursor: pointer; }
.pt-crumb-link:hover { text-decoration: underline; }
.pt-crumb-sep { color: var(--text-faint); }
.pt-crumb-meta { margin-left: 2px; }
.pt-sp { flex: 1; }
.pt-head-note { flex-basis: 100%; font-size: 12.5px; color: var(--text-muted); }
.pt-search-note { font-size: 13px; color: var(--text-muted); margin: -2px 0 10px; }
.pt-link { font: inherit; border: 0; background: none; padding: 0; color: var(--link); cursor: pointer; text-decoration: underline; }
.pt-link:hover { color: var(--link-hover); }
.pt-empty { padding: 32px 16px; }
.pt-empty p { margin-bottom: 12px; }
.pt-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.bulk-bar [aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* ── Table ─────────────────────────────── */
/* One <tbody> per printer group (printer + its variants), so keep row borders between groups. */
.pt-table tbody tr:last-child td { border-bottom: 1px solid var(--border); }
.pt-table tbody:last-child tr:last-child td { border-bottom: 0; }
.pt-table th.num { text-align: right; }
.pt-table td.pt-col-printer { min-width: 220px; }
.pt-cb { width: 1%; white-space: nowrap; }
.pt-cb input[type="checkbox"] { margin: 0; vertical-align: middle; cursor: pointer; }
.pt-actions { width: 1%; white-space: nowrap; text-align: right; }
.pt-actions .btn { margin-right: 2px; }
.pt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pt-row { cursor: pointer; }

.pt-sort {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: none; padding: 0;
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit;
  cursor: pointer;
}
.pt-sort:hover { color: var(--text); }
.pt-sort:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 2px; }
.pt-sort-ind { font-size: 9px; min-width: 8px; }

/* Status pills. */
.pt-pill {
  display: inline-flex; align-items: center;
  padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 20px; white-space: nowrap;
}
.pt-pill-ok    { background: var(--success-bg); color: var(--success-dark); }
.pt-pill-bad   { background: var(--danger-bg);  color: var(--danger-dark); }
.pt-pill-warn  { background: var(--warning-bg); color: var(--warning-dark); }
.pt-pill-off   { background: var(--bg-muted);   color: var(--text-muted); }
.pt-pill-muted { background: transparent; color: var(--text-muted); box-shadow: inset 0 0 0 1px var(--border); }

/* Printer cell. */
.pt-p1 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.pt-p2 { font-size: 12px; color: var(--text-muted); margin-top: 2px; padding-left: 24px; }
.pt-name { font-weight: 600; color: var(--text); text-decoration: none; }
.pt-name:hover { color: var(--link); text-decoration: underline; }
.pt-row.is-frozen .pt-name { color: var(--text-muted); }
.pt-err { color: var(--danger-dark); }
.pt-meta { font-size: 12px; color: var(--text-muted); }
.pt-caret, .pt-caret-sp, .pt-vline { flex: none; width: 18px; height: 18px; }
.pt-caret {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--text-muted); cursor: pointer; padding: 0;
}
.pt-caret svg { transition: transform .15s; }
.pt-caret.open svg { transform: rotate(90deg); }
.pt-caret:hover { background: var(--hover-strong); color: var(--text); }
.pt-vline { position: relative; }
.pt-vline::before {
  content: ''; position: absolute; left: 8px; top: -4px; width: 8px; height: 13px;
  border-left: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong);
  border-bottom-left-radius: 4px;
}
.pt-table .pt-vrow td { background: var(--bg-alt); }
.pt-table .pt-vrow td.pt-col-printer { padding-left: 28px; }
.pt-table .pt-vrow .pt-name { font-weight: 500; }

/* Chips beside the printer name. */
.pt-chip {
  display: inline-flex; align-items: center;
  padding: 0 6px; line-height: 18px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-muted); color: var(--text-btn);
  font: inherit; font-size: 11px; font-weight: 500; white-space: nowrap;
}
button.pt-chip { cursor: pointer; }
button.pt-chip:hover { border-color: var(--border-strong); color: var(--text); }
.pt-chip-sticker { font-family: var(--font-mono); }
.pt-chip-add { background: transparent; border-style: dashed; color: var(--text-faint); opacity: 0; }
.pt-row:hover .pt-chip-add, .pt-chip-add:focus-visible { opacity: 1; }
.pt-chip-var { background: var(--variant-bg); color: var(--variant-text); border-color: transparent; }
.pt-chip-shared { background: var(--primary-light); color: var(--primary-text); border-color: transparent; }
.pt-p1 .pr-op-pill { width: 22px; height: 18px; border: 0; padding: 0; font: inherit; }
.pt-sticker-input {
  width: 64px; height: 20px; padding: 0 6px;
  border: 1px solid var(--primary); border-radius: var(--radius-sm);
  background: var(--input-bg); color: var(--text);
  font-family: var(--font-mono); font-size: 11px; outline: none;
}

/* Toner. */
.pt-toner { display: inline-flex; align-items: center; gap: 6px; }
.pt-toner-bar { display: inline-block; width: 48px; height: 6px; border-radius: 3px; background: var(--bg-muted); overflow: hidden; box-shadow: inset 0 0 0 1px var(--border); }
.pt-toner-bar i { display: block; height: 100%; background: var(--success); }
.pt-toner.warn .pt-toner-bar i { background: var(--warning); }
.pt-toner.crit .pt-toner-bar i { background: var(--danger); }
.pt-toner-pct { min-width: 32px; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pt-toner.crit .pt-toner-pct { color: var(--danger-dark); font-weight: 600; }

/* Drag to reorder. */
.pt-drag {
  display: inline-flex; vertical-align: middle; margin-right: 6px;
  color: var(--text-faint); cursor: grab; touch-action: none;
}
.pt-drag:active { cursor: grabbing; }
.pt-row:hover .pt-drag { color: var(--text-muted); }
.pt-group.is-dragging td { opacity: .45; }
.pt-group.pt-drop-before tr:first-child td { box-shadow: inset 0 2px 0 var(--primary); }
.pt-group.pt-drop-after tr:last-child td { box-shadow: inset 0 -2px 0 var(--primary); }
body.pt-noselect { user-select: none; -webkit-user-select: none; }

/* ── Modals ─────────────────────────────── */
.pt-modal-note { font-size: 12.5px; color: var(--text-muted); margin: 4px 0 0; }
.pt-optional { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.pt-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.form-group .pt-label-row label { margin-bottom: 0; }
.form-group .pt-inline-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 400; color: var(--text-muted); cursor: pointer; }
.form-group .pt-inline-check input[type="checkbox"] { width: auto; padding: 0; margin: 0; }

/* Searchable driver picker. */
.pt-dp-box { position: relative; display: flex; align-items: center; }
.form-group .pt-dp-box .pt-dp-input { padding-right: 34px; }
.pt-dp-spin { position: absolute; right: 10px; }
.pt-dp-clear {
  position: absolute; right: 6px; width: 24px; height: 24px;
  border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--text-muted); font-size: 18px; line-height: 1; cursor: pointer;
}
.pt-dp-clear:hover { background: var(--hover-strong); color: var(--text); }
.pt-dp-list { margin-top: 4px; max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--card-bg); }
.pt-dp-opt { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; font-size: 13.5px; cursor: pointer; }
.pt-dp-opt:hover, .pt-dp-opt.is-active { background: var(--hover-strong); }
.pt-dp-opt.is-sel .pt-dp-name { font-weight: 600; color: var(--primary-text); }
.pt-dp-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.pt-dp-empty { padding: 8px 10px; font-size: 13px; color: var(--text-muted); }
.pt-dp-hint { margin-top: 4px; font-size: 12px; color: var(--text-muted); }

/* API key. */
.pt-key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 16px; }
.pt-key {
  flex: 1; min-width: 0; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-alt);
  font-family: var(--font-mono); font-size: 12.5px; overflow-wrap: anywhere;
}
.pt-key-danger { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--danger-border); border-radius: var(--radius-md); }
.pt-key-danger > div { flex: 1; min-width: 0; }

/* Shared printer connections. */
.pt-csp-sec { margin-bottom: 16px; }
.pt-csp-h { font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.pt-csp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pt-csp-row select, .pt-csp-row input {
  flex: 1; min-width: 120px; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--input-bg); color: var(--text); font: inherit; font-size: 13.5px;
}
.pt-conn { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.pt-conn-host { flex: 1; font-size: 13.5px; font-weight: 500; }

/* Add variant. */
.pt-variant-form .form-group { margin-bottom: 12px; }
.pt-variant-form .nv-deploy-choice { margin-bottom: 12px; }
.pt-qv-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.pt-qv-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: center; }
.pt-qv-row input, .pt-qv-row select {
  width: 100%; padding: 4px 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--input-bg); color: var(--text); font: inherit; font-size: 12.5px;
}

/* ── Phone ─────────────────────────────── */
@media (max-width: 768px) {
  .pt-split { grid-template-columns: minmax(0, 1fr); }
  .pt-split > .pt-tree { display: none; }
  .pt-scope-btn { display: flex; }
  .pt-bar .pt-search { order: 5; flex-basis: 100%; width: 100%; }
  .pt-table th.pt-col-folder, .pt-table td.pt-col-folder,
  .pt-table th.pt-col-ip, .pt-table td.pt-col-ip,
  .pt-table th.pt-col-toner, .pt-table td.pt-col-toner,
  .pt-table th.pt-col-comp, .pt-table td.pt-col-comp { display: none; }
  .pt-table td.pt-col-printer { min-width: 160px; }
  .pt-chip-add { display: none; }
  .pt-p2 { padding-left: 0; }
  .pt-key-danger { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  .pt-tw svg, .pt-caret svg { transition: none; }
}

/* Medium widths: keep rows to one or two lines. The table drops its secondary
   columns when its own pane gets narrow (sidebar + tree leave little room on a
   laptop), instead of wrapping every cell. */
.pt-list { container-type: inline-size; }
.pt-table td.pt-col-folder { white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.pt-table td.pt-col-ip, .pt-table td.pt-col-status { white-space: nowrap; }
@container (max-width: 820px) {
  .pt-table .pt-col-toner { display: none; }
}
@container (max-width: 680px) {
  .pt-table .pt-col-folder, .pt-table .pt-col-ip { display: none; }
}

/* Laptop and narrower: the sidebar plus a 260px tree would leave the table
   about 400px, so the tree moves into the "Scope" drawer and the table takes
   the full width. Phone-only column hiding stays in the 768px block above. */
@media (max-width: 1100px) {
  .pt-split { grid-template-columns: minmax(0, 1fr); }
  .pt-split > .pt-tree { display: none; }
  .pt-scope-btn { display: flex; }
}
