/* Node dashboard.
   Base styles, buttons, pills and modals come from theme.css. */

/* --- layout --------------------------------------------------- */

.dashboard-container {
  max-width: 1180px;
  margin: 1.75rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: stretch;     /* the two top panels share a baseline */
}

/* The live panel and job history both run the full width underneath. */
.task-panel,
.live-panel,
.selftest-panel {
  grid-column: 1 / -1;
}

.panel {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  /* A single hairline of light along the top edge stops the cards reading
     as flat rectangles without adding a visible border. */
  background-image: linear-gradient(
    to bottom, rgba(255, 255, 255, 0.035), transparent 90px);
  transition:
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease);
}

.panel:hover {
  border-color: var(--border-strong);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  border: none;
  font-size: 1.05rem;
  font-weight: 620;
}

.panel-head h2::before {
  content: "";
  width: 3px;
  height: 16px;
  border-radius: var(--r-pill);
  background: linear-gradient(to bottom, var(--accent), var(--success));
  flex-shrink: 0;
}

/* --- node details --------------------------------------------- */

.node-detail-group {
  display: grid;
  gap: 0.4rem;
}

.node-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--r-sm);
  background-color: var(--surface-2);
  font-size: 0.875rem;
  transition: background-color var(--t-fast) var(--ease);
}

.node-detail:hover {
  background-color: var(--surface-3);
}

.node-detail-label {
  min-width: 108px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.node-detail .mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.node-detail-heading {
  margin-top: 0.6rem;
  padding: 0 0.25rem;
  font-size: 0.7rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

#gpuDetailsContainer {
  display: grid;
  gap: 0.4rem;
}

#gpuDetailsContainer .node-detail {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

#gpuDetailsContainer .node-detail-label {
  min-width: 0;
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.875rem;
  font-weight: 620;
}

.gpu-line {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.gpu-temp { font-variant-numeric: tabular-nums; }
.gpu-temp.is-cool     { color: var(--success); }
.gpu-temp.is-warm     { color: var(--warning); }
.gpu-temp.is-critical { color: var(--danger); }
.gpu-temp.is-unknown  { color: var(--text-faint); }

/* Empty / error state inside a panel. */
.panel-notice {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.35rem;
  min-height: 150px;
  padding: 1.5rem 1.25rem;
  text-align: center;
  border-radius: var(--r-lg);
  background-color: var(--surface-2);
  border: 1px dashed var(--border-strong);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.panel-notice strong {
  color: var(--text);
  font-weight: 620;
  font-size: 0.95rem;
}

.panel-notice-action {
  margin-top: 0.6rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--r-pill);
  background-color: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  transition:
    background-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}

.panel-notice-action:hover {
  background-color: var(--accent-wash);
  border-color: var(--accent-edge);
  color: var(--accent-strong);
  transform: translateY(-1px);
}

/* Reserved for genuine failures, not for "nothing here yet". */
.panel-notice.is-error {
  background-color: var(--danger-wash);
  border-style: solid;
  border-color: rgba(248, 113, 113, 0.22);
}

.panel-notice.is-error strong { color: var(--danger); }

.compute-tag {
  margin-left: 0.5rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--r-pill);
  background-color: var(--surface-3);
  color: var(--text-faint);
  font-size: 0.65rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.compute-tag.is-measured {
  background-color: var(--accent-wash);
  color: var(--accent);
}

/* Explains a Disconnected pill instead of leaving the user guessing. */
.status-hint {
  display: block;
  flex-basis: 100%;
  margin-top: 0.4rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* --- usage meters ---------------------------------------------- */

.meter { margin-bottom: 1rem; }

.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.45rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.meter-head span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  color: var(--text);
}

.usage-bar {
  height: 8px;
  /* The old track sat almost invisibly against the panel. */
  background-color: rgba(255, 255, 255, 0.06);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  width: 0;
  min-width: 8px;                 /* a dot at 0%, so the meter never looks broken */
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width var(--t-slow) var(--ease-out);
}

/* --- actions --------------------------------------------------- */

.action-section {
  margin-top: auto;               /* sits on the panel floor */
  padding-top: 1.4rem;
  display: flex;
  justify-content: flex-end;
}

/* A link to a different job, not this page's main action -- that is the
   availability switch. It used to be the loudest thing on the screen. */
.action-button {
  background-color: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition:
    background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}

.action-button::after {
  content: "→";
  font-size: 0.95rem;
  line-height: 1;
  opacity: 0.7;
  transition: transform var(--t-fast) var(--ease);
}

.action-button:hover {
  background-color: var(--surface-3);
  border-color: var(--accent-edge);
  color: var(--accent-strong);
  transform: translateY(-1px);
}

.action-button:hover::after { transform: translateX(2px); }

.refresh-button {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--r-pill);
}

.refresh-button::before {
  content: "↻";
  font-size: 0.95rem;
  line-height: 1;
}

/* --- thermal ---------------------------------------------------- */

.thermal {
  display: grid;
  gap: 0.55rem;
  margin-top: 1.25rem;
  padding: 0.85rem 0.95rem;
  border-radius: var(--r-md);
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  transition: background-color var(--t) var(--ease), border-color var(--t) var(--ease);
}

.thermal.is-warn {
  background-color: var(--warning-wash);
  border-color: rgba(251, 191, 36, 0.28);
}

.thermal.is-stop {
  background-color: var(--danger-wash);
  border-color: rgba(248, 113, 113, 0.3);
}

.thermal-gpu {
  display: grid;
  grid-template-columns: minmax(140px, auto) minmax(80px, 1fr) auto auto;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.8125rem;
}

.thermal-name {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thermal-track {
  position: relative;
  height: 6px;
  border-radius: var(--r-pill);
  background-color: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.thermal-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--success), var(--warning));
  transition: width var(--t-slow) var(--ease-out), background var(--t) var(--ease);
}

.thermal-gpu.is-warn .thermal-fill { background: var(--warning); }
.thermal-gpu.is-stop .thermal-fill { background: var(--danger); }

/* Where the warning band begins on this particular card. */
.thermal-mark {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 10px;
  background-color: rgba(255, 255, 255, 0.35);
  border-radius: 1px;
}

.thermal-temp {
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  color: var(--text);
}

.thermal-gpu.is-warn .thermal-temp { color: var(--warning); }
.thermal-gpu.is-stop .thermal-temp { color: var(--danger); }

.thermal-limit,
.thermal-none {
  font-size: 0.75rem;
  color: var(--text-faint);
  white-space: nowrap;
}

.thermal-reason {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--warning);
}

.thermal.is-stop .thermal-reason { color: var(--danger); }

/* --- running now ------------------------------------------------- */

.live-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.75rem;
}

.live-name {
  font-size: 0.9rem;
  font-weight: 620;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-log {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  font-size: 0.75rem;
  line-height: 1.75;
  color: var(--text-muted);
  white-space: pre-wrap;
  background-color: var(--bg-elevated);
  scroll-behavior: smooth;
}

.live-idle {
  margin: 0;
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* --- availability ---------------------------------------------- */

.availability-container {
  margin-top: 1.5rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--border);
}

.switch-container {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.availability-text {
  display: grid;
  gap: 0.1rem;
  margin-right: auto;
}

.availability-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.availability-hint {
  margin: 0.7rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 25px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background-color: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  transition:
    background-color var(--t) var(--ease),
    border-color var(--t) var(--ease);
}

.slider::before {
  content: "";
  position: absolute;
  height: 17px;
  width: 17px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t) var(--ease-out);
}

input:checked + .slider {
  background-color: var(--accent);
  border-color: var(--accent);
}

input:checked + .slider::before {
  transform: translateX(19px);
  background-color: #04222a;
}

input:focus-visible + .slider { box-shadow: var(--ring); }

input:disabled + .slider {
  opacity: 0.45;
  cursor: not-allowed;
}

.toggle-processing {
  display: none;
  align-items: center;
}

.loading-dots {
  display: flex;
  gap: 4px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent);
  animation: hw-dots 1.4s var(--ease) infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes hw-dots {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1); }
}

.toggle-status-message:not(:empty) {
  display: inline-block;
  margin-top: 0.7rem;
  font-size: 0.8125rem;
  padding: 0.4rem 0.7rem;
}

/* --- approval --------------------------------------------------- */

.approval-mode {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.approval-mode input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.approval-prompt {
  /* Full width and first in the grid. As a plain child it would take the left
     column and sit beside Node details, which is not where an eye lands. */
  grid-column: 1 / -1;
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border-radius: var(--r-md);
  background-color: var(--accent-wash);
  border: 1px solid var(--accent-edge);
}

.approval-prompt[hidden] { display: none; }

.approval-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.approval-head strong { color: var(--text); font-size: 0.95rem; }

.approval-timer {
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 620;
}

.approval-detail {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text);
}

.approval-note {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.approval-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.approval-actions button { font-size: 0.875rem; }

/* --- running job overlay ---------------------------------------- */

.run-overlay { display: none; }

.run-panel {
  max-width: 760px;
  padding: 1.5rem;
}

.run-body { display: grid; gap: 0.9rem; }

/* --- progress --- */

.run-progress { display: grid; gap: 0.4rem; }

.run-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.run-progress-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  color: var(--text);
}

/* --- the numbers that matter while work runs --- */

.run-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 0.75rem 1rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.run-stat { display: grid; gap: 0.15rem; min-width: 0; }

.run-stat-label {
  color: var(--text-faint);
  font-size: 0.65rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.run-stat-value {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.run-stat.is-warn .run-stat-value { color: var(--warning); }
.run-stat.is-stop .run-stat-value { color: var(--danger); }

/* --- heat headroom --- */

.run-thermal {
  display: grid;
  grid-template-columns: minmax(130px, auto) minmax(80px, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.75rem;
}

.run-thermal-name {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-thermal.is-warn .thermal-fill { background: var(--warning); }
.run-thermal.is-stop .thermal-fill { background: var(--danger); }

.run-warning {
  margin: 0;
  padding: 0.6rem 0.8rem;
  border-radius: var(--r-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--warning);
  background-color: var(--warning-wash);
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.run-warning.is-stop {
  color: var(--danger);
  background-color: var(--danger-wash);
  border-color: rgba(248, 113, 113, 0.25);
}

.run-log-details summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.run-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding-right: 2.5rem;
}

.run-name {
  font-size: 1rem;
  font-weight: 620;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-log {
  margin: 0;
  max-height: 340px;
  overflow: auto;
  font-size: 0.75rem;
  line-height: 1.75;
  color: var(--text-muted);
  white-space: pre-wrap;
  background-color: var(--bg-elevated);
}

.run-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.live-expand {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--r-pill);
}

/* The job list moved to jobs.css; /distribution needs it too. */

/* --- responsive -------------------------------------------------- */

@media (max-width: 860px) {
  .dashboard-container {
    grid-template-columns: 1fr;
    margin: 1.25rem auto;
    padding: 0 1rem;
  }

  .panel { padding: 1.3rem; }

  .node-detail {
    flex-direction: column;
    align-items: flex-start;
  }

  .node-detail-label { min-width: 0; }

  .job-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
}

/* --- self test ---------------------------------------------------- */

.selftest-intro {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 70ch;
}

.selftest-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
}

.selftest-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.9rem 1rem;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.selftest-stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.selftest-stat-value {
  font-size: 1.3rem;
  font-weight: 650;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* The number worth scheduling on. */
.selftest-stat:first-child .selftest-stat-value {
  color: var(--accent);
}

.selftest-stat-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.selftest-note {
  margin: 0.85rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.selftest-note.is-ok     { color: var(--success); }
.selftest-note.is-warn   { color: var(--warning); }
.selftest-note.is-error  { color: var(--danger); }

.selftest-note.is-running {
  color: var(--accent);
  animation: selftest-pulse 1.4s var(--ease) infinite;
}

@keyframes selftest-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .selftest-note.is-running { animation: none; }
}

.selftest-data {
  margin-bottom: 1.1rem;
  padding: 0.9rem 1rem;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.selftest-data-label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.selftest-data-hint {
  margin: 0 0 0.7rem;
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--text-faint);
  max-width: 70ch;
}

.selftest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.selftest-actions .btn-ghost {
  font-size: 0.8125rem;
  padding: 0.45rem 0.9rem;
}

/* Stopping is the one destructive-looking action here, so it reads as one. */
.selftest-actions .is-stop {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.32);
}

.selftest-actions .is-stop:hover {
  background-color: var(--danger-wash);
  color: var(--danger);
}

.selftest-actions [hidden] {
  display: none;
}

/* Stop, in the running panel. Sits beside the close button but reads as an
   action rather than a dismissal — closing and stopping are different things
   and the difference matters here. */
.run-stop {
  margin-left: auto;
  margin-right: 0.5rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--r-pill);
  border: 1px solid rgba(248, 113, 113, 0.32);
  background-color: var(--danger-wash);
  color: var(--danger);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease);
}

.run-stop:hover {
  background-color: rgba(248, 113, 113, 0.2);
  transform: none;
  box-shadow: none;
}

.run-stop:disabled {
  opacity: 0.7;
  cursor: default;
}

/* The last step of setting a node up, which is a switch nobody told you to
   flick. Shown only while the node is idle, so it disappears the moment it
   stops being true. */
.availability-prompt[hidden] {
  display: none;
}

.availability-prompt {
  margin: 0.6rem 0 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--accent);
  border-left-width: 3px;
  border-radius: var(--r-xs);
  background-color: var(--surface-2);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text);
}

