/* ── PoC Temperature Monitor Styles ── */
:root {
  --bg: #f5f7f8;
  --bg-card: #ffffff;
  --bg-input: #f0f2f5;
  --border: #e2e6ea;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-bright: #0f172a;
  --primary: #0056b2;
  --blue: #42a5f5;
  --blue-dark: #1565c0;
  --red: #ef5350;
  --red-dark: #e53935;
  --yellow: #f9a825;
  --green: #4caf50;
  --orange: #ff9800;
  --cyan: #00bcd4;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
.page-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-header h1 { font-size: 18px; color: var(--text-bright); white-space: nowrap; }
.page-header nav { display: flex; gap: 4px; flex-wrap: wrap; }
.page-header nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 14px;
  transition: background 0.15s;
}
.page-header nav a:hover {
  background: var(--bg-input);
  color: var(--text-bright);
  text-decoration: none;
}
.logout-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.logout-btn:hover {
  background: #ffebee;
  color: var(--red-dark);
  border-color: var(--red);
}

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card h2 { font-size: 16px; color: var(--text-bright); margin-bottom: 12px; }

/* ── Connection bar ── */
.connection-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.connection-bar label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}
.connection-bar input[type="text"] {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  width: 160px;
  font-family: 'SF Mono', Consolas, monospace;
}
.connection-bar button {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #fff;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.connection-bar button:hover { background: #004494; }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.disconnected { background: var(--red); }
.status-dot.connected { background: var(--green); }
.status-dot.connecting { background: var(--yellow); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.status-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: -8px;
}

/* ── Gauge grid ── */
.gauge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.gauge-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.gauge-card h3 {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.gauge-svg {
  display: block;
  margin: 0 auto;
}

/* ── Chart ── */
.chart-wrap {
  width: 100%;
  height: 300px;
  position: relative;
}
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

.chart-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 8px;
}
.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.chart-legend-swatch {
  width: 14px;
  height: 3px;
  border-radius: 2px;
}
.chart-legend-swatch.valve-swatch {
  height: 10px;
  border-radius: 2px;
}

/* ── Valve control panel ── */
.valve-panel.hidden { display: none; }
.valve-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.valve-header h2 { margin-bottom: 0; }

.valve-mode-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.valve-mode-badge.auto { background: #e8f5e9; color: #2e7d32; }
.valve-mode-badge.override { background: #fff3e0; color: #e65100; }

.valve-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.valve-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: 8px;
  font-size: 13px;
}
.valve-label {
  font-weight: 600;
  min-width: 120px;
  color: var(--text-bright);
}
.valve-label-sub {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}
.valve-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.valve-dot.open { background: var(--green); }
.valve-dot.closed { background: var(--red); }

.valve-state {
  font-weight: 700;
  font-size: 12px;
  min-width: 56px;
  letter-spacing: 0.3px;
}
.valve-state.open { color: var(--green); }
.valve-state.closed { color: var(--red); }

.valve-cooldown-label {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: auto;
}
.valve-cooldown {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  min-width: 40px;
  color: var(--text-muted);
}
.valve-cooldown.active { color: var(--orange); }

.settling-bar {
  padding: 6px 12px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #e65100;
  margin-bottom: 12px;
  animation: pulse 2s infinite;
}
.settling-bar.hidden { display: none; }

.valve-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.valve-controls-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.valve-btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.valve-btn-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 2px;
}
.valve-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.valve-btn:hover { background: #e2e6ea; color: var(--text-bright); }
.valve-btn.on.active { background: #e8f5e9; border-color: var(--green); color: #2e7d32; }
.valve-btn.off.active { background: #ffebee; border-color: var(--red); color: #c62828; }
.valve-btn.auto-btn.active { background: #e8f5e9; border-color: var(--green); color: #2e7d32; }

.valve-info {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Info table ── */
.info-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.info-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.info-table td { padding: 6px 8px; }
.info-table tr:nth-child(even) td { background: #f8fafc; }
.info-table .val { font-family: 'SF Mono', Consolas, monospace; font-weight: 600; }

/* ── Time range buttons ── */
.time-range-btns {
  display: flex;
  gap: 4px;
}
.time-range-btns button {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}
.time-range-btns button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Event log ── */
.event-log {
  max-height: 200px;
  overflow-y: auto;
  font-size: 12px;
  font-family: 'SF Mono', Consolas, monospace;
  background: var(--bg-input);
  border-radius: 6px;
  padding: 8px 12px;
}
.event-log .entry { padding: 2px 0; border-bottom: 1px solid var(--border); }
.event-log .time { color: var(--text-muted); }
.event-log .error { color: var(--red); }
.event-log .ok { color: var(--green); }
.event-log .warn { color: var(--orange); }
.event-log .valve-open { color: var(--green); font-weight: 600; }
.event-log .valve-closed { color: var(--red); font-weight: 600; }
.event-log .settling { color: var(--orange); font-style: italic; }
.event-log .cooldown { color: #8d6e63; font-style: italic; }
.event-log .info { color: #546e7a; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .container { padding: 12px; }
  .connection-bar { flex-direction: column; align-items: flex-start; }
  .gauge-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ── Push Notification Toggle ── */
.push-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
}
.push-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.push-btn:hover { background: var(--border); }
.push-btn.subscribed {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.push-status {
  font-size: 12px;
  color: var(--text-muted);
}
