/* ============================================================
   PERUN — stránka InfiniBand (k perun-ib.js)
   Záložky v stránke, karta "Čo treba riešiť", tabuľka switchov,
   skupiny uzlov a farby panelov/schémy riadené témou (svetlá aj tmavá).
   Načítava sa po inline štýloch šablóny → rovnaká špecifickosť stačí.
   ============================================================ */

[data-ibsec].ib-off { display: none !important; }

/* ---------- záložky ---------- */
.ib-sectabs {
  display: flex; gap: 4px; margin: 0 0 18px; padding: 4px; width: max-content; max-width: 100%;
  background: var(--bg-input); border-radius: 12px; overflow-x: auto; scrollbar-width: none;
}
.ib-sectabs::-webkit-scrollbar { display: none; }
.ib-sectabs button {
  display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0;
  padding: 8px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--text-muted);
  white-space: nowrap; transition: background .15s, color .15s;
}
.ib-sectabs button:hover { color: var(--text); }
.ib-sectabs button.active {
  background: var(--bg-elevated, var(--bg-card)); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.14), 0 0 0 1px var(--border);
}
.ib-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; line-height: 20px; text-align: center;
  font-size: 11.5px; font-weight: 700; background: var(--warn-soft); color: var(--warn);
}
.ib-badge.crit { background: var(--crit-soft); color: var(--crit); }

/* ---------- "Čo treba riešiť" ---------- */
.ib-overview { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
.ib-overview > .card { margin: 0 0 16px; }
.ib-problems .card-header, .ib-swtable .card-header { justify-content: space-between; }
.ib-problems-sum { display: flex; gap: 6px; flex-wrap: wrap; }
.ib-problem-list { display: flex; flex-direction: column; gap: 6px; }
.ib-problem {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; grid-template-areas: "dot text go" "dot detail go";
  column-gap: 12px; row-gap: 1px; align-items: center; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 10px; background: var(--bg-input); border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.ib-problem:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.ib-problem > i { grid-area: dot; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
.ib-problem.crit > i { background: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); }
.ib-p-text { grid-area: text; font-size: 13.5px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-p-detail { grid-area: detail; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ib-p-go { grid-area: go; font-size: 12px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.ib-more { font-size: 12px; color: var(--text-muted); padding: 6px 4px 0; }
.ib-allgood {
  padding: 14px 16px; border-radius: 12px; font-size: 13.5px; color: var(--text);
  background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent);
}
.ib-allgood b { color: var(--ok); }
.ib-empty { color: var(--text-muted); padding: 12px; text-align: center; }
.ib-hint, .ib-muted { font-size: 12px; color: var(--text-muted); font-weight: 400; }

/* ---------- tabuľka switchov ---------- */
.ib-swrow { cursor: pointer; }
.ib-util { display: inline-block; width: 70px; height: 6px; border-radius: 999px; background: var(--bg-input); overflow: hidden; vertical-align: middle; margin-right: 8px; }
.ib-util > div { height: 100%; border-radius: 999px; background: var(--accent); }

/* ---------- uzly ---------- */
.ib-nodefilter { margin-left: auto; }
.ib-grp { grid-column: 1 / -1; font-size: 14px; font-weight: 700; color: var(--text); padding: 10px 2px 0; }
.ib-grp:first-child { padding-top: 0; }
.ib-grp[hidden], .vmib-node[hidden] { display: none !important; }
.ib-nodes-empty { grid-column: 1 / -1; }
.vmib-node.ib-has-problem { border-color: var(--warn) !important; }
@keyframes ibFlash { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 30% { box-shadow: 0 0 0 4px var(--accent); } }
.ib-flash { animation: ibFlash 1.4s ease-in-out 2; border-radius: 8px; }

/* ---------- panely switchov a uzlov: farby z témy (nie natvrdo tmavohnedé) ---------- */
.ibp { background: var(--bg-input); border: 1px solid var(--border); }
.ibp.node { background: var(--bg-card); border: 1px solid var(--border); }
.ibp.node:hover { border-color: var(--border-strong); }
.ibp.node.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ibp-t { color: var(--text); }
.ibp-s, .ibp-num { color: var(--text-muted); }
.ibp-sub { color: var(--text-muted); }
.ibp-sub .warn { color: var(--warn); font-weight: 600; }
.ibp-jack { border-color: var(--border-strong); background: var(--bg-card); border-radius: 4px; }
.ibp-jack.sw { border-color: var(--accent); }
.ibp-jack.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--accent); }
.vmib-box { border-color: var(--border-strong); background: var(--bg-card); }
.vmib-box.sw { border-color: var(--accent); }

/* ---------- schéma zapojenia: tlmené farby káblov v tmavom režime ---------- */
.ibf-sw { background: var(--bg-card); }
:root[data-theme="dark"] .ibf-cage { color: var(--text); }
:root[data-theme="dark"] .ibf-c-opt  { background: color-mix(in srgb, #8fbf6e 26%, var(--bg-card)); }
:root[data-theme="dark"] .ibf-c-aoc5 { background: color-mix(in srgb, #7fb0e0 26%, var(--bg-card)); }
:root[data-theme="dark"] .ibf-c-aoc4 { background: color-mix(in srgb, #f0a07a 26%, var(--bg-card)); }
:root[data-theme="dark"] .ibf-c-y3   { background: color-mix(in srgb, #f2cf55 24%, var(--bg-card)); }
:root[data-theme="dark"] .ibf-c-g2   { background: color-mix(in srgb, #b8bcc4 16%, var(--bg-card)); }
:root[data-theme="dark"] .ibf-c-g15  { background: color-mix(in srgb, #7ccf3a 30%, var(--bg-card)); }
:root[data-theme="dark"] .ibf-c-none { background: var(--bg-input); }
:root[data-theme="dark"] .ibf-p { background: rgba(255,255,255,.05); }
:root[data-theme="dark"] .ibf-p > i { background: color-mix(in srgb, var(--accent) 35%, transparent); }
:root[data-theme="dark"] .ibf-lg i { box-shadow: 0 0 0 1px rgba(255,255,255,.12); }

/* ---------- mobil ---------- */
@media (max-width: 1100px) {
  .ib-overview { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  /* na telefóne najprv "Čo treba riešiť", až potom čísla a grafy */
  .page.active[data-page="vm-ib"] { display: flex; flex-direction: column; }
  .page[data-page="vm-ib"] > .vm-tabs, .page[data-page="vm-ib"] > .sl-page-header, .page[data-page="vm-ib"] > .ib-sectabs { order: -2; }
  .page[data-page="vm-ib"] > .ib-overview { order: -1; }
  .page[data-page="vm-ib"] .dn-tiles { gap: 8px !important; }
  .page[data-page="vm-ib"] .dn-tiles .stat { padding: 12px 14px; }
  .page[data-page="vm-ib"] .dn-tiles .stat-value { font-size: 22px !important; }
  .ib-sectabs { width: 100%; }
  .ib-sectabs button { padding: 8px 12px; font-size: 13px; }
  .ib-problem { grid-template-columns: 10px minmax(0, 1fr); grid-template-areas: "dot text" "dot detail" "dot go"; }
  .ib-p-text, .ib-p-detail { white-space: normal; }
  .ib-p-go { margin-top: 4px; }
  .ib-nodefilter { margin-left: 0; }
  .ibf-sw { overflow-x: auto; }
  .ibf-grid { min-width: 720px; }
}

/* meno uzla/switcha pod číslom portu switcha, prietok na dlaždici uzla, detail uzla */
.ibp-port.vmibsw-port { width: 30px; }
.ibp-own { font-size: 8.5px; line-height: 1.1; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: clip; max-width: 30px; margin: 0 auto; }
.ibp-rate { margin-top: 6px; font-size: 10.5px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.ibp-rate-now { color: var(--text-muted); font-size: 10px; }
.ibp-top { font-size: 10px; font-weight: 700; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 0 5px; line-height: 15px; }
.ib-nd-h { font-size: 12px; font-weight: 700; margin: 4px 0 6px; }
.ib-nd-h ~ .ib-nd-h { margin-top: 14px; }
.ib-nd-charthead { font-size: 12px; font-weight: 700; margin: 14px 0 6px; }
#ib-node-detail { border-color: var(--accent); }
#ib-node-detail[hidden] { display: none !important; }

/* ---------- Ethernet switche (perun-eth.js) ---------- */
.eth-sw { background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.eth-h { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.eth-h b { font-size: 15px; }
.eth-h .dn-chip { margin-left: auto; }
.eth-scroll { overflow-x: auto; padding-bottom: 4px; }
.eth-row { display: flex; gap: 14px; width: max-content; }
.eth-grid { display: grid; grid-template-rows: repeat(2, auto); grid-auto-flow: column; gap: 3px; }
.eth-up { padding-left: 12px; border-left: 2px dashed var(--border-strong); }
.eth-p { position: relative; width: 62px; height: 36px; border-radius: 5px; padding: 11px 3px 2px; font-size: 9.5px; line-height: 1.15; text-align: center;
         cursor: pointer; overflow: hidden; border: 2px solid transparent; color: #1c1917; box-sizing: border-box; }
.eth-p b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eth-p em { display: block; font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .8; }
.eth-n { position: absolute; top: 1px; left: 3px; font-size: 8px; opacity: .65; }
.eth-empty { background: transparent; border: 1px dashed var(--border); cursor: default; color: var(--text-muted); }
.eth-c-blue { background: #9db8e3; }
.eth-c-gray { background: #c9c9c9; }
.eth-c-y25 { background: #f5e04a; }
.eth-c-o100 { background: #eab05a; }
.eth-p.st-crit, .eth-sw-c.st-crit { border-color: var(--crit); box-shadow: 0 0 0 1px var(--crit); }
.eth-p.st-warn, .eth-sw-c.st-warn { border-color: var(--warn); }
.eth-p.st-ok { border-color: color-mix(in srgb, var(--ok) 70%, transparent); }
.eth-p.hit { outline: 3px solid var(--accent); outline-offset: 1px; }
.eth-p.sel { outline: 3px solid var(--text); outline-offset: 1px; }
.eth-p.rel { outline: 3px dashed var(--accent); outline-offset: 1px; }
.eth-sw-c { display: inline-block; width: 14px; height: 10px; border-radius: 3px; vertical-align: middle; margin-right: 4px; border: 2px solid transparent; }
.eth-lg { white-space: nowrap; }
.eth-detail { margin-top: 10px; border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.eth-detail[hidden] { display: none !important; }
.eth-d-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.eth-d-h .eth-close { margin-left: auto; }
.eth-d-live { margin-top: 6px; }
.eth-d-sub { margin-top: 10px; font-size: 12px; font-weight: 700; }
.eth-rel { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.eth-jump { font-size: 12px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text); cursor: pointer; }
.eth-jump:hover { border-color: var(--accent); }
.eth-p.ln-up, .eth-sw-c.ln-up { border-color: var(--ok); }
.eth-p.ln-down, .eth-sw-c.ln-down { border-color: var(--crit); box-shadow: 0 0 0 1px var(--crit); opacity: .75; }
.eth-p.ln-extra, .eth-sw-c.ln-extra { border: 2px dashed var(--warn); cursor: pointer; color: var(--warn); }
.eth-util { position: absolute; left: 0; bottom: 0; height: 3px; background: #1d4ed8; border-radius: 0 2px 0 0; }
.eth-snmp { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.eth-d-snmp { margin-top: 6px; }
.eth-d-chart { height: 200px; margin-top: 10px; }

/* ---------- Sieť uzlov (perun-net.js) ---------- */
.nn-node { cursor: pointer; }
.nn-node.nn-bad { border-color: var(--crit); }
.nn-line { font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; }
.nn-line span { display: inline-block; min-width: 22px; color: var(--text-muted); }
.nn-muted { color: var(--text-muted); }
.nn-warn { font-size: 10.5px; color: var(--warn); margin-top: 3px; }
#nn-detail[hidden] { display: none !important; }
#nn-detail { border-color: var(--accent); }

/* ── Priorita a fairshare (perun-prio.js) + vysvetlivky ── */
.prio-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--bg-elevated); min-width: 140px; }
.prio-bar span { display: block; height: 100%; }
.prio-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 4px 0 8px; vertical-align: middle; }
.prio-legend { background: var(--bg-card, var(--bg-elevated)); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; font-size: 12px; }
.prio-legend summary { cursor: pointer; font-weight: 600; color: var(--accent-hover); }
.prio-legend-body { margin-top: 8px; line-height: 1.55; color: var(--text); }
.prio-legend-body ul { margin: 6px 0 8px 18px; padding: 0; }
.prio-legend-body .prio-dot { margin-left: 0; }
.prio-legend-body code { background: var(--bg-elevated); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.prio-note { font-size: 11px; color: var(--text-muted); padding: 8px 12px 10px; }
.prio-note a { color: var(--accent-hover); }
#ugm-prio-body .prio-legend { margin-top: 10px; }
th[data-psort]:hover { color: var(--accent-hover); }
.prio-arrow { font-size: 10px; color: var(--accent-hover); }

/* ── Sieťový plán (perun-netplan.js) ── */
.np-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.np-grid-wide { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.np-net, .np-dep { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--bg-elevated); font-size: 12px; }
.np-net-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; font-size: 13px; }
.np-net-row { color: var(--text-muted); margin-top: 3px; }
.np-net-desc { margin: 4px 0; line-height: 1.45; }
.np-badge { font-size: 10px; border: 1px solid var(--accent); color: var(--accent-hover); border-radius: 4px; padding: 0 5px; }
.np-badge.muted { border-color: var(--border); color: var(--text-muted); }
.np-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.np-chip { font-size: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 1px 7px; cursor: pointer; }
.np-chip:hover { border-color: var(--accent); color: var(--accent-hover); }
.np-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; background: var(--text-muted); opacity: .5; }
.np-dot.ok { background: var(--ok); opacity: 1; }
.np-dot.bad { background: var(--crit); opacity: 1; }
.np-row { cursor: pointer; }
.np-row.sel td { background: rgba(99, 102, 241, .12); }
@media (max-width: 520px) { .np-grid-wide { grid-template-columns: 1fr; } }
.np-deps-table { width: 100%; }
.np-deps-table td { vertical-align: top; }
.np-deps-table td.np-sys { border-right: 1px solid var(--border); min-width: 170px; }
.np-cov { font-size: 10px; border-radius: 10px; padding: 1px 7px; border: 1px solid var(--border); white-space: nowrap; }
.np-cov.ok { border-color: var(--ok); color: var(--ok); }
.np-cov.part { border-color: var(--warn); color: var(--warn); }
.np-cov.none { border-color: var(--text-muted); color: var(--text-muted); }
.np-chip.miss { border-color: var(--warn); color: var(--warn); }
