/* ══════════════════════════════════════════════════════════
   HEALTH AGENT — chat panel + health pulse + insights
   Embedded in vu-tracker.html via #page-health-agent
   ══════════════════════════════════════════════════════════ */

[id="page-health-agent"] {
  --ha-accent: #4ae890;
  --ha-blue: #4a8ae8;
  --ha-amber: #f0c040;
  --ha-rose: #e85d2a;
}

.ha-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

.ha-section-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.ha-sidebar-section { margin-bottom: 18px; }
.ha-sidebar-section:last-child { margin-bottom: 0; }

/* ── HEALTH PULSE — metric cards ──────────────────────────── */
.ha-pulse-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ha-pulse-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.ha-pulse-head {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}
.ha-pulse-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  color: var(--text);
  line-height: 1.05;
  letter-spacing: 0.02em;
}
.ha-pulse-sub {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.04em;
}
.ha-delta {
  font-family: 'DM Mono', monospace;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.ha-delta.up { color: var(--ha-accent); }
.ha-delta.down { color: var(--ha-rose); }
.ha-delta.flat { color: var(--muted); }

/* ── 10K TRAINING card ────────────────────────────────────── */
.ha-10k-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.ha-10k-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
}
.ha-10k-pct {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--ha-accent);
}
.ha-10k-bar {
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}
.ha-10k-bar-fill {
  height: 100%;
  background: var(--ha-accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.ha-10k-target {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}
.ha-10k-runs-label {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.ha-10k-runs-dots {
  display: flex;
  gap: 5px;
}
.ha-run-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface3);
  transition: background 0.15s;
}
.ha-run-dot.done { background: var(--ha-accent); }
.ha-run-dot.today { box-shadow: 0 0 0 2px rgba(74,232,144,0.3); }

/* ── INSIGHTS cards ──────────────────────────────────────── */
.ha-insights {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ha-insight {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  display: flex;
  gap: 8px;
  border-left: 3px solid var(--border2);
  background: var(--surface);
}
.ha-insight.info { border-left-color: var(--ha-blue); background: rgba(74,138,232,0.07); }
.ha-insight.good { border-left-color: var(--ha-accent); background: rgba(74,232,144,0.07); }
.ha-insight.warn { border-left-color: var(--ha-amber); background: rgba(240,192,64,0.07); }
.ha-insight-icon { font-size: 14px; flex-shrink: 0; line-height: 1.3; }

/* ── CHAT panel ───────────────────────────────────────────── */
.ha-chat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  min-height: 600px;
  max-height: 900px;
  overflow: hidden;
}
.ha-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ha-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(74,232,144,0.15);
  border: 1px solid rgba(74,232,144,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.ha-chat-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  line-height: 1.2;
}
.ha-chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-top: 4px;
}
.ha-status-dot {
  width: 6px;
  height: 6px;
  background: var(--ha-accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(74,232,144,0.2);
}

.ha-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ha-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 88%;
}
.ha-msg-row.user {
  flex-direction: row-reverse;
  align-self: flex-end;
}
.ha-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  color: var(--muted);
}
.ha-msg-row.assistant .ha-msg-avatar {
  background: rgba(74,232,144,0.1);
  border: 1px solid rgba(74,232,144,0.3);
}
.ha-msg-row.user .ha-msg-avatar {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  background: var(--ha-accent);
  color: var(--bg);
}
.ha-msg-bubble {
  background: var(--surface2);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  word-wrap: break-word;
  white-space: pre-wrap;
}
.ha-msg-row.user .ha-msg-bubble {
  background: rgba(74,232,144,0.12);
  border: 1px solid rgba(74,232,144,0.25);
}
.ha-msg-bubble em {
  color: var(--ha-accent);
  font-style: italic;
}
.ha-msg-meta {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-top: 5px;
}
.ha-msg-row.user .ha-msg-meta { text-align: right; }
.ha-typing-bubble {
  font-style: italic;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ha-typing-bubble::after {
  content: '...';
  display: inline-block;
  animation: ha-typing 1.2s infinite;
}
@keyframes ha-typing {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
.ha-msg-tools {
  display: inline-block;
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  color: var(--ha-accent);
  background: rgba(74,232,144,0.08);
  border: 1px solid rgba(74,232,144,0.2);
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 4px;
  letter-spacing: 0.04em;
}

/* ── Quick action chips ─────────────────────────────────── */
.ha-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ha-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
.ha-chip:hover {
  background: rgba(74,232,144,0.1);
  border-color: var(--ha-accent);
  color: var(--ha-accent);
}

/* ── Input row ──────────────────────────────────────────── */
.ha-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ha-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s;
}
.ha-input:focus { border-color: var(--ha-accent); }
.ha-input::placeholder { color: var(--muted); }
.ha-send {
  background: var(--ha-accent);
  border: none;
  color: var(--bg);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}
.ha-send:hover { opacity: 0.85; }
.ha-send:disabled { opacity: 0.4; cursor: not-allowed; }

.ha-loading {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.1em;
}

/* ── Mobile: stack ──────────────────────────────────────── */
@media (max-width: 900px) {
  .ha-layout { grid-template-columns: 1fr; }
  .ha-chat { height: 70vh; min-height: 500px; }
}
