/* ── PID Controller Page Styles ─────────────────────── */

/* Layout */
.pid-layout {
  display: grid;
  grid-template-columns: 280px 1fr 260px;
  gap: 16px;
  max-width: 1340px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

/* Controls Panel */
.controls-panel {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

.controls-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 !important;
}

.ctrl-section {
  padding: 14px 16px;
}

.ctrl-section-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.plant-params-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Gain sliders + val badge row */
.control-group {
  position: relative;
}

.val-badge {
  position: absolute;
  right: 0;
  top: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--cyan);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 7px;
  line-height: 1.6;
  pointer-events: none;
}

/* Status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: blink 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* Preset grid */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.preset-btn {
  font-size: 0.72rem;
  padding: 7px 10px;
}

/* Metrics grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.metric-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color var(--transition);
}

.metric-card:hover { border-color: var(--border-2); }

.metric-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cyan);
  line-height: 1.1;
}

.metric-unit {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Charts column */
.charts-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.chart-panel { width: 100%; }

.chart-wrap {
  padding: 10px 12px !important;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 180px !important;
  display: block;
}

.two-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.two-charts .chart-wrap canvas {
  height: 140px !important;
}

/* Legend */
.legend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

/* Info panel */
.info-panel {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 1100px) {
  .pid-layout {
    grid-template-columns: 260px 1fr;
  }
  .info-panel { display: none; }
}

@media (max-width: 820px) {
  .pid-layout {
    grid-template-columns: 1fr;
  }
  .controls-panel, .info-panel {
    position: static;
    max-height: none;
  }
  .info-panel { display: block; }
  .two-charts {
    grid-template-columns: 1fr;
  }
  .chart-wrap canvas {
    height: 160px !important;
  }
}

@media (max-width: 500px) {
  .preset-grid { grid-template-columns: 1fr 1fr 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}
