/*
 * components/server_metrics_panel.css — 24-hour detailed metrics panel.
 *
 * Paired with templates/server_dashboard.html (the <dialog#metrics-panel>)
 * and static/js/server-metrics-panel.js. Token-driven (D5). The dialog
 * opens at 90% of the viewport; Chart.js renders the 24h line chart
 * inside; an external HTML tooltip shows value + time on hover, positioned
 * at the top of the panel so it is always in the viewport and outside the
 * chart area (D9: Escape closes the dialog natively).
 */

/* --- Clickable metric cards ------------------------------------------ */

.metric-clickable {
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.metric-clickable:hover,
.metric-clickable:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* --- Byte-rate card face (Network / Disk I/O) ------------------------ */
/* Rate metrics have no fixed 0-100% maximum, so they show a current value
   plus small last-hour avg/peak stats instead of a progress bar. */

.metric-rate {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.metric-rate__value {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  color: var(--color-fg);
  line-height: 1.1;
}

.metric-rate__stats {
  display: flex;
  gap: var(--space-4);
  font-size: var(--fs-xs);
  color: var(--color-fg-muted);
}

.metric-rate__stat b {
  color: var(--color-fg);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}

/* --- 90%-viewport dialog --------------------------------------------- */

dialog.metrics-panel {
  width: 90vw;
  height: 90vh;
  max-width: 90vw;
  max-height: 90vh;
  padding: 0;
  border: var(--border-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  background: var(--color-surface);
  z-index: var(--z-modal);
}

dialog.metrics-panel::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

/* --- Header ---------------------------------------------------------- */

.metrics-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: var(--border-1);
  flex-shrink: 0;
}

.metrics-panel__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  margin: 0;
}

.metrics-panel__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-fg-muted);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
}

.metrics-panel__close:hover {
  background: var(--color-surface-2);
  color: var(--color-fg);
}

/* --- Body / chart area ----------------------------------------------- */

.metrics-panel__body {
  position: relative;
  padding: var(--space-4) var(--space-5);
  height: calc(90vh - 60px);
  min-height: 0;
}

.metrics-panel__body canvas {
  width: 100% !important;
  height: 100% !important;
}

.metrics-panel__empty {
  text-align: center;
  color: var(--color-fg-muted);
  font-size: var(--fs-md);
  padding: var(--space-8) 0;
}

/* --- External hover tooltip ------------------------------------------ */

.metrics-panel__tooltip {
  position: absolute;
  top: var(--space-2);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-terminal-bg);
  color: var(--color-terminal-fg);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  z-index: var(--z-popover);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.metrics-panel__tooltip-value {
  font-weight: var(--fw-bold);
  color: var(--color-accent);
}

.metrics-panel__tooltip-time {
  color: var(--color-terminal-muted);
}
