/* =========================================================================
 * Gauges — base card + type-specific styling
 * ========================================================================= */

.gauge {
  background: var(--u-bg-elev);
  border: 1px solid var(--u-border);
  border-radius: 6px;
  padding: 14px;
  min-height: 110px;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.gauge:hover { border-color: var(--u-border-accent); }

.gauge-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 1;
}
.gauge-title {
  font-family: var(--u-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--u-text-dim);
  margin-bottom: 4px;
  transition: color 0.4s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gauge-value {
  font-family: var(--u-mono);
  font-size: 24px;
  font-weight: 300;
  line-height: 1.1;
  color: var(--u-text);
  transition: color 0.4s, text-shadow 0.4s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gauge-status {
  font-family: var(--u-mono);
  font-size: 10px;
  color: var(--u-text-dim);
  margin-top: 3px;
}
.gauge-status.is-error { color: var(--u-warn); }

/* ---------- status indicator (LED + label) ---------- */

.gauge.gauge-status-indicator {
  min-height: 0;
  padding: 8px 12px;
  align-items: center;
  gap: 10px;
}
.gauge-led {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #555;
  box-shadow: 0 0 4px #555;
  transition: background 0.3s, box-shadow 0.3s;
}
.gauge-led[data-status="ok"] {
  background: var(--u-ok);
  box-shadow: 0 0 5px var(--u-ok), 0 0 12px rgba(34,204,68,0.5);
}
.gauge-led[data-status="warn"] {
  background: var(--u-caution);
  box-shadow: 0 0 5px var(--u-caution), 0 0 12px rgba(240,192,64,0.5);
}
.gauge-led[data-status="critical"] {
  background: var(--u-warn);
  box-shadow: 0 0 6px var(--u-warn), 0 0 14px rgba(255,34,34,0.55);
  animation: gauge-led-pulse 1.1s ease-in-out infinite;
}
.gauge-led[data-status="unknown"] { background: #555; box-shadow: none; opacity: 0.4; }
@keyframes gauge-led-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}
.gauge-status-title {
  font-family: var(--u-mono);
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--u-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gauge-status-value {
  font-family: var(--u-mono);
  font-size: 10px;
  color: var(--u-text-dim);
  margin-top: 2px;
}

/* ---------- stat (single big number) ---------- */

.gauge.gauge-stat { align-items: stretch; }
.gauge-stat .gauge-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.gauge-stat-value {
  font-family: var(--u-mono);
  font-size: 36px;
  font-weight: 300;
  line-height: 1;
  color: var(--u-text);
  transition: color 0.4s;
  margin: 4px 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gauge-stat-unit {
  font-size: 18px;
  font-weight: 400;
  color: var(--u-text-dim);
  margin-left: 4px;
}
@media (max-width: 768px) {
  .gauge-stat-value { font-size: 26px; }
  .gauge-stat-unit  { font-size: 14px; }
}

/* ---------- gauge ---------- */

.gauge-thermo-canvas,
.gauge-bw-canvas {
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  display: block;
}

@media (max-width: 768px) {
  .gauge { padding: 10px; min-height: 90px; gap: 8px; }
  .gauge-thermo-canvas,
  .gauge-bw-canvas { width: 72px; height: 72px; }
  .gauge-value { font-size: 18px; }
  .gauge-title { font-size: 10px; }
}

/* ---------- camera (snapshot) ---------- */

.gauge.gauge-camera {
  position: relative;
  padding: 0;
  display: block;
  overflow: hidden;
  min-height: 220px;        /* stable placeholder when img fails */
  aspect-ratio: 16 / 9;
  background: #000;
}
.gauge-camera-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.92;
}
.gauge-camera-label {
  position: absolute;
  top: 6px;
  left: 8px;
  z-index: 2;
  font-family: var(--u-mono);
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--u-accent);
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 6px;
  border-radius: 3px;
}
.gauge-camera-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--u-bg-elev);
  color: var(--u-text-dim);
  font-family: var(--u-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
/* Explicit display wins over the `hidden` attribute, so re-assert it. */
.gauge-camera-fallback[hidden] { display: none; }
.gauge-camera-icon { font-size: 20px; }

/* ---------- camera (PiP) ---------- */

.gauge.gauge-pip {
  padding: 0;
  display: block;
  overflow: hidden;
  background: #000;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 16 / 9;
  margin: 0 auto;
}
.gauge-pip-frame {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
}
.gauge-pip-main {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.92;
}
.gauge-pip-main-fb { /* extends .gauge-camera-fallback */ }
.gauge-pip-overlay {
  position: absolute;
  border: 2px solid var(--u-accent-glow);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  z-index: 2;
  background: #000;
}
.gauge-pip-overlay img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gauge-pip-overlay .gauge-camera-label {
  font-size: 9px;
  padding: 1px 5px;
  top: 3px;
  left: 5px;
}
.gauge-pip-bottom-right { bottom: 10px; right: 10px; }
.gauge-pip-bottom-left  { bottom: 10px; left:  10px; }
.gauge-pip-top-right    { top:    10px; right: 10px; }
.gauge-pip-top-left     { top:    10px; left:  10px; }

/* ---------- stub (unknown type / error) ---------- */

.gauge.gauge-stub {
  justify-content: center;
  text-align: center;
  font-family: var(--u-mono);
  font-size: 11px;
  color: var(--u-text-dim);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
