/* Connectors page; generic table/badge/dialog styling is in style.css. */
/* `hidden` must win over the display rules below (.progress-line etc.). */
[hidden] { display: none !important; }
/* Badges: body-colored text on the tinted background, so a green or amber
   badge still meets 4.5:1 contrast; the color carries in tint and border. */
#main .badge { color: inherit; border-color: color-mix(in srgb, var(--badge-color, var(--muted)) 55%, transparent); }
.lede { max-width: 60rem; margin: 0 0 1rem; color: var(--muted); }
.docs-link { white-space: nowrap; }
.notice { max-width: 60rem; margin: 0 0 1rem; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.9rem; }
.banner { margin: 0 0 1rem; padding: 0.6rem 0.8rem; border-radius: var(--radius-sm); border: 1px solid var(--border); border-left-width: 4px; }
.banner-warn { border-left-color: var(--color-warning); background: color-mix(in srgb, var(--color-warning) 10%, transparent); }

.node-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.node {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem;
  min-width: 12rem; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 6px;
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.node[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.node .node-name { font-weight: 600; display: flex; align-items: center; gap: 0.4rem; }
.node .node-meta { font-size: 0.8rem; color: var(--muted); }
.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--muted); flex: none; }
.dot.online { background: var(--color-success); }
.dot.offline { background: var(--color-critical); }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 1rem 0; }
button.primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 0.35rem 0.8rem; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.progress-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: -0.5rem 0 1rem; font-size: 0.9rem; }
.spinner { width: 0.9rem; height: 0.9rem; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.list-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 1rem; margin: 0 0 0.5rem; }
.list-tools label { margin: 0; font-size: 0.85rem; }
.list-tools label.grow { flex: 0 1 22rem; }
.list-tools label.grow input { display: block; width: 100%; margin-top: 0.2rem; font: inherit; padding: 0.3rem; }
.list-tools label.check { display: inline-flex; align-items: center; gap: 0.3rem; }
tr.group-head th { text-align: left; padding-top: 0.6rem; border-bottom: 1px solid var(--border); font-weight: normal; }
button.group-toggle { font: inherit; font-weight: 600; background: none; border: 0; padding: 0.1rem 0; color: inherit; cursor: pointer; }
.table-wrap { overflow-x: auto; position: relative; } /* contains .sr-only headers, which are absolute */
.hint.small, .small { font-size: 0.78rem; }
.poll-cell { min-width: 11rem; }
.poll-error { color: var(--color-critical); font-size: 0.8rem; overflow-wrap: anywhere; max-width: 22rem; }
.badge.poll-ok { --badge-color: var(--color-success); }
.badge.poll-partial { --badge-color: var(--color-warning); }
.badge.poll-error { --badge-color: var(--color-critical); }
.badge.poll-waiting { --badge-color: var(--muted); }
.mono { font-family: ui-monospace, monospace; font-size: 0.85em; }

/* The connector dialog: the body scrolls, the buttons stay put. */
dialog.wide { width: min(50rem, calc(100vw - 1rem)); max-width: none; max-height: calc(100dvh - 1rem); padding: 0; }
dialog.wide form { display: flex; flex-direction: column; max-height: calc(100dvh - 1rem); }
dialog.wide .dialog-body { padding: 1rem 1rem 0; overflow-y: auto; }
dialog.wide .dialog-actions { justify-content: flex-end; margin: 0; padding: 0.75rem 1rem; border-top: 1px solid var(--border); background: canvas; }
dialog .row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
dialog .row label { flex: 1 1 12rem; }
dialog .row label.narrow { flex: 0 1 7rem; }
fieldset.inline { border: 0; padding: 0; margin: 0 0 0.75rem; display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
fieldset.inline legend { float: left; margin-right: 0.75rem; font-size: 0.85rem; }
fieldset.inline label { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; white-space: nowrap; }
fieldset.inline input { width: auto; display: inline; margin: 0; }
.field-help { margin: -0.25rem 0 0.75rem; font-size: 0.8rem; color: var(--muted); }
.form-error { color: var(--color-critical); font-size: 0.85rem; }
.learn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; }

/* BACnet point picker */
.points-tools { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: flex-end; margin-top: 0.5rem; }
.points-tools label { margin: 0; }
.points-tools label.grow { flex: 1 1 14rem; }
.points-tools select { min-width: 10rem; }
.points-tools button { margin-bottom: 0.1rem; }
.pt-count { margin: 0.4rem 0 0; font-size: 0.85rem; font-weight: 600; }
.points-wrap { max-height: 22rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 0.5rem 0; }
.points-wrap table { width: 100%; border-collapse: collapse; }
.points-wrap thead th { position: sticky; top: 0; background: canvas; z-index: 1; }
.points-wrap th.cb, .points-wrap td.cb { width: 2rem; text-align: center; }
.points-wrap td.cb input, .points-wrap th.cb input { width: 1.1rem; height: 1.1rem; display: inline; margin: 0; }
.points-wrap input[type="text"], .points-wrap input[type="number"] { width: 100%; min-width: 9rem; margin: 0; }
.points-wrap td.mono { white-space: nowrap; }
/* Modbus register editor (Baler#128): ten columns at their natural width, scrolling sideways. */
.points-wrap #modbus-points { width: max-content; }
#modbus-points select { margin: 0; width: auto; }
#modbus-points .reg-label { width: 10rem; min-width: 0; }
#modbus-points .reg-num, #modbus-points .reg-scale, #modbus-points .reg-offset, #modbus-points .reg-unit { width: 5rem; min-width: 0; }
#modbus-points .reg-write { width: auto; display: inline; margin: 0; }
.pt-meta { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; overflow-wrap: anywhere; }
.narrow-only { display: none; }

@media (max-width: 640px) {
  .node { min-width: 0; flex: 1 1 100%; }
  #main { padding: 0.5rem; }
  /* The point name gets the row; object and value move under it. */
  .wide-only { display: none; }
  .narrow-only { display: block; }
  .points-wrap input[type="text"] { min-width: 0; }
  dialog.wide .dialog-body { padding: 0.75rem 0.75rem 0; }
  dialog.wide .dialog-actions { padding: 0.6rem 0.75rem; }
}
