/* WATTER Web Dashboard */

body {
  background-color: #1a1a2e;
  color: #e0e0e0;
}

/* Machine cards */
.machine-card {
  background-color: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.machine-card .card-header {
  background-color: #0f3460;
  border-bottom: 1px solid #1a4080;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.machine-card .card-header .machine-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: #e0e0e0;
}

.machine-card .card-header .machine-location {
  font-size: 0.8rem;
  color: #8899aa;
}

.machine-card .card-header .device-id {
  font-size: 0.75rem;
  color: #668899;
  font-family: monospace;
}

.machine-card .card-body {
  padding: 1rem;
}

.machine-card .card-footer {
  background-color: #0d1b3e;
  border-top: 1px solid #0f3460;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: #667788;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

/* Section headers within cards */
.section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #556677;
  margin-bottom: 0.25rem;
  margin-top: 0.75rem;
}

.section-label:first-child {
  margin-top: 0;
}

/* Connection status dot */
.conn-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.conn-dot.connected {
  background-color: #28a745;
  box-shadow: 0 0 4px #28a745;
}

.conn-dot.disconnected {
  background-color: #dc3545;
  box-shadow: 0 0 4px #dc3545;
}

.conn-dot.connecting {
  background-color: #ffc107;
  box-shadow: 0 0 4px #ffc107;
}

/* Temperature bars */
.temp-row {
  display: flex;
  align-items: center;
  margin-bottom: 3px;
}

.temp-label {
  width: 30px;
  font-size: 0.75rem;
  color: #8899aa;
  flex-shrink: 0;
}

.temp-bar-container {
  flex: 1;
  height: 18px;
  background-color: #0d1b3e;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.temp-bar {
  height: 100%;
  border-radius: 3px;
  min-width: 2px;
  transition: width 0.5s ease, background-color 0.5s ease;
}

.temp-value {
  width: 45px;
  text-align: right;
  font-size: 0.8rem;
  font-family: monospace;
  flex-shrink: 0;
  padding-left: 6px;
}

/* Coolant/ambient row */
.temp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 4px;
}

.temp-grid-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  padding: 2px 6px;
  background-color: #0d1b3e;
  border-radius: 3px;
}

.temp-grid-item .tg-label {
  color: #8899aa;
  font-size: 0.7rem;
}

.temp-grid-item .tg-value {
  font-family: monospace;
}

/* GPU rows */
.gpu-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid #0f3460;
  font-size: 0.8rem;
}

.gpu-row:last-child {
  border-bottom: none;
}

.gpu-status-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gpu-status-icon.rented {
  background-color: #28a745;
  box-shadow: 0 0 3px #28a745;
}

.gpu-status-icon.oasis {
  background-color: #e040fb;
  box-shadow: 0 0 3px #e040fb;
}

.gpu-status-icon.idle-job {
  background-color: #d2b48c;
}

.gpu-status-icon.idle {
  background-color: #555;
}

.gpu-label {
  width: 40px;
  color: #8899aa;
  flex-shrink: 0;
}

.gpu-field {
  font-family: monospace;
  flex-shrink: 0;
}

.gpu-field.temp { width: 42px; }
.gpu-field.util { width: 35px; text-align: right; }
.gpu-field.power { width: 50px; text-align: right; }
.gpu-field.mem { flex: 1; text-align: right; color: #8899aa; font-size: 0.7rem; }

/* State badges */
.state-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.state-badge.idle { background-color: #444; color: #999; }
.state-badge.coolant { background-color: #1a3a6e; color: #5599dd; }
.state-badge.heat_low { background-color: #6e1a1a; color: #ee5555; }
.state-badge.heat_high { background-color: #992222; color: #ff6666; font-weight: 700; }
.state-badge.shutdown { background-color: #333; color: #777; }
.state-badge.start { background-color: #333; color: #777; }

.state-badge.off { background-color: #333; color: #777; }
.state-badge.booting { background-color: #4a3a00; color: #ffcc33; }
.state-badge.standby { background-color: #444; color: #999; }
.state-badge.processing { background-color: #6e1a1a; color: #ee5555; }
.state-badge.emergency { background-color: #990000; color: #ff3333; font-weight: 700; }

/* GPIO indicators */
.gpio-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gpio-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: #667788;
}

.gpio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.gpio-dot.active {
  background-color: #28a745;
  box-shadow: 0 0 3px #28a745;
}

.gpio-dot.inactive {
  background-color: #444;
}

/* State row */
.state-row {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.state-row .state-label {
  font-size: 0.7rem;
  color: #8899aa;
}

/* Error indicator */
.error-indicator {
  display: none;
  color: #ff4444;
  font-size: 0.75rem;
}

.error-indicator.visible {
  display: inline-block;
}

/* No-data placeholder */
.no-data {
  color: #445566;
  font-style: italic;
  font-size: 0.8rem;
}

/* Dashboard header */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.dashboard-header h2 {
  margin-bottom: 0;
}

/* Override navbar for dark theme */
.navbar {
  border-bottom: 1px solid #0f3460;
}

/* Dashboard card link styles */
a.machine-name {
  text-decoration: none;
  color: #e0e0e0;
}

a.machine-name:hover {
  color: #5599dd;
}

/* ── Machine Detail Page ─────────────────────────────────────── */

.machine-detail {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px); /* minus navbar */
}

.machine-detail-header {
  background-color: #0f3460;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-shrink: 0;
}

.machine-detail-header .back-link {
  color: #8899aa;
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
}

.machine-detail-header .back-link:hover {
  color: #5599dd;
}

.machine-detail-header .header-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.machine-detail-header .machine-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: #e0e0e0;
}

.machine-detail-header .device-id {
  font-size: 0.75rem;
  color: #668899;
  font-family: monospace;
}

.machine-detail-header .machine-location {
  font-size: 0.8rem;
  color: #8899aa;
}

/* Main display area */
.machine-display {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* Detail panels */
.detail-panel {
  background-color: #16213e;
  border: 1px solid #0f3460;
  border-radius: 6px;
  padding: 0.75rem;
}

.panel-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #d2b48c;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

/* Tank visualization */
.tank-viz {
  margin-bottom: 0.5rem;
}

.tank-row {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.tank-label {
  width: 28px;
  font-size: 0.75rem;
  color: #8899aa;
  flex-shrink: 0;
}

.tank-bar-container {
  flex: 1;
  height: 22px;
  background-color: #0d1b3e;
  border-radius: 3px;
  overflow: hidden;
}

.tank-bar {
  height: 100%;
  border-radius: 3px;
  min-width: 2px;
  transition: width 0.5s ease, background-color 0.5s ease;
}

.tank-value {
  width: 50px;
  text-align: right;
  font-size: 0.85rem;
  font-family: monospace;
  flex-shrink: 0;
  padding-left: 6px;
}

.tank-info {
  border-top: 1px solid #0f3460;
  padding-top: 0.4rem;
}

.tank-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 1px 0;
}

.tank-info-label {
  color: #8899aa;
  font-size: 0.75rem;
}

.tank-info-value {
  font-family: monospace;
}

/* GPU detail grid */
.gpu-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.5rem;
}

.gpu-detail-card {
  background-color: #0d1b3e;
  border-radius: 4px;
  padding: 0.5rem;
}

.gpu-detail-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}

.gpu-detail-name {
  font-weight: 600;
  color: #e0e0e0;
}

.gpu-detail-status-label {
  margin-left: auto;
  font-size: 0.7rem;
  color: #8899aa;
}

/* Metric bars (GPU detail) */
.metric-bar-row {
  display: flex;
  align-items: center;
  margin-bottom: 3px;
}

.metric-bar-label {
  width: 40px;
  font-size: 0.7rem;
  color: #8899aa;
  flex-shrink: 0;
}

.metric-bar-container {
  flex: 1;
  height: 14px;
  background-color: #1a1a2e;
  border-radius: 2px;
  overflow: hidden;
}

.metric-bar {
  height: 100%;
  border-radius: 2px;
  min-width: 1px;
  transition: width 0.5s ease;
}

.metric-bar-temp { background-color: #dd5555; }
.metric-bar-util { background-color: #5599dd; }
.metric-bar-power { background-color: #ddaa33; }
.metric-bar-mem { background-color: #55aa55; }

.metric-bar-value {
  width: 55px;
  text-align: right;
  font-size: 0.75rem;
  font-family: monospace;
  flex-shrink: 0;
  padding-left: 4px;
}

.gpu-detail-extras {
  display: flex;
  gap: 1rem;
  font-size: 0.7rem;
  color: #8899aa;
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px solid #16213e;
}

/* State detail */
.state-detail {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.state-detail-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.state-detail-label {
  font-size: 0.75rem;
  color: #8899aa;
}

/* CPU / Fluid / Ambient info grids */
.cpu-info-grid,
.fluid-info-grid,
.ambient-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 6px;
}

.cpu-info-item,
.fluid-info-item,
.ambient-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 8px;
  background-color: #0d1b3e;
  border-radius: 3px;
  font-size: 0.8rem;
}

.cpu-info-label,
.fluid-info-label,
.ambient-info-label {
  color: #8899aa;
  font-size: 0.7rem;
}

.cpu-info-value,
.fluid-info-value,
.ambient-info-value {
  font-family: monospace;
}

/* Log panel */
.log-entries {
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.75rem;
  font-family: monospace;
  background-color: #0d1b3e;
  border-radius: 3px;
  padding: 0.4rem;
}

.log-entry {
  padding: 1px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-time {
  color: #556677;
}

.log-label {
  font-weight: 600;
}

.label-state { color: #5599dd; }
.label-error { color: #ff4444; }
.label-flow { color: #44cccc; }

/* Info footer */
.machine-detail-footer {
  background-color: #0d1b3e;
  border-top: 1px solid #0f3460;
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
  color: #667788;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  flex-shrink: 0;
}

/* Timeline bar */
.timeline-bar {
  background-color: #0a0f2e;
  border-top: 1px solid #0f3460;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.timeline-btn {
  background: none;
  border: 1px solid #334;
  color: #8899aa;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.timeline-btn:hover {
  color: #e0e0e0;
  border-color: #5599dd;
}

.timeline-time {
  font-family: monospace;
  font-size: 0.8rem;
  color: #aabbcc;
  min-width: 80px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Timeline track (slider + markers wrapper) */
.timeline-track {
  flex: 1;
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
}

.timeline-markers {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 7px;
  right: 7px;
  pointer-events: none;
  z-index: 0;
}

.timeline-marker {
  position: absolute;
  width: 2px;
  top: 0;
  bottom: 0;
  opacity: 0.8;
}

.timeline-marker.error {
  background-color: #ff4444;
}

.timeline-marker.flow {
  background-color: #44cccc;
}

/* Timeline slider */
.timeline-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(22, 33, 62, 0.7);
  border-radius: 3px;
  outline: none;
  position: relative;
  z-index: 1;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #5599dd;
  cursor: pointer;
  border: 2px solid #0a0f2e;
}

.timeline-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #5599dd;
  cursor: pointer;
  border: 2px solid #0a0f2e;
}

/* Range controls */
.timeline-range-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.range-btn {
  background: #16213e;
  border: 1px solid #0f3460;
  color: #8899aa;
  padding: 3px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  border-radius: 3px;
}

.range-btn:hover {
  color: #e0e0e0;
  border-color: #5599dd;
}

.range-btn.active {
  background-color: #0f3460;
  color: #5599dd;
  border-color: #5599dd;
}

/* Responsive */
@media (max-width: 576px) {
  .gpu-field.mem {
    display: none;
  }

  .temp-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .timeline-bar {
    flex-wrap: wrap;
  }

  .timeline-track {
    order: 10;
    width: 100%;
    flex: none;
  }

  .gpu-detail-grid {
    grid-template-columns: 1fr;
  }
}
