/* ═══════════════════════════════════════════
   HQ Component Styles
   Reusable primitives: avatar, pills, tags,
   status dots, metrics, section headers,
   buttons, inputs.
   Depends on tokens.css.
   ═══════════════════════════════════════════ */

/* ── Avatar ────────────────────────────────── */
.avatar {
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  /* color and background set inline via JS (agent-specific) */
}

/* ── Project tag — pill with dot + name ────── */
.project-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  /* color and background set inline */
}

.project-tag.tiny {
  font-size: 9px;
  padding: 1px 5px;
}

.project-tag__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Pill — generic label ──────────────────── */
.pill {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  /* color and background set inline */
}

.pill.tiny {
  font-size: 9px;
  padding: 1px 5px;
}

/* ── Status dot ────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot--online {
  background: var(--color-green);
  box-shadow: 0 0 6px #5CB85C88;
  animation: pulse 2.2s ease-in-out infinite;
}

.status-dot--warning {
  background: var(--color-orange);
  box-shadow: 0 0 6px #E8943A88;
  animation: pulse 2.2s ease-in-out infinite;
}

.status-dot--offline {
  background: var(--color-red);
  box-shadow: 0 0 6px #E8555588;
}

/* ── Metric card ───────────────────────────── */
.metric-card {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 12px 14px;
  cursor: default;
  transition: border-color var(--transition-base);
}

.metric-card--clickable {
  cursor: pointer;
}

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

.metric-card__label {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-dim);
  margin-bottom: var(--space-1) + 2px;
  margin-bottom: 6px;
}

.metric-card__value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  /* color set inline per accent */
}

.metric-card__sub {
  font-size: var(--text-sm);
  color: var(--color-dim);
  margin-top: 4px;
}

/* ── Section header ────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 10px;
}

.section-header--inline {
  margin-bottom: 0;
}

.section-header__label {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-amber);
}

.section-header__count {
  font-size: var(--text-sm);
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--color-amber-dim);
  color: var(--color-amber);
  font-family: var(--font-mono);
}

.section-header__line {
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ── Buttons ───────────────────────────────── */
.btn-primary {
  background: var(--color-amber);
  color: var(--color-bg);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: var(--text-base);
  cursor: pointer;
  font-family: var(--font-body);
  transition: opacity var(--transition-fast);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.btn-primary:hover   { opacity: 0.9; }
.btn-primary:active  { opacity: 0.8; }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary.loading {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary.loading::after {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid transparent;
  border-top-color: var(--color-bg);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: var(--space-2);
}

.btn-outline {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-base);
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color var(--transition-fast), color var(--transition-fast);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.btn-outline:hover  { border-color: var(--color-muted); color: var(--color-text); }
.btn-outline:active { border-color: var(--color-dim); }
.btn-outline:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-dim);
  padding: 5px 10px;
  border-radius: var(--radius-md);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color var(--transition-fast), color var(--transition-fast);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-icon:hover  { border-color: var(--color-muted); color: var(--color-text); }
.btn-icon:active { background: var(--color-panel2); }
.btn-icon--danger:hover { border-color: var(--color-red); color: var(--color-red); }

/* TTS mute toggle (header). Icon-only square button, ≥44×44 on touch to
   meet the mobile-first touch-target floor (HQ CLAUDE.md / Rule 1 §1).
   Inherits .btn-icon hover/focus states. The muted state gets an amber
   accent border so the global silence is visually obvious in the header
   alongside Settings/Logout. */
.tts-mute-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 4px 8px;
  font-size: 16px;
  line-height: 1;
  justify-content: center;
}
.tts-mute-btn--muted {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.tts-mute-btn--muted:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
/* Honor the existing top-bar mobile rule (.top-bar__right .btn-icon
   pegs min-height to 40px). Touch-target floor for the mute toggle
   stays ≥44px even inside that container — explicit override. */
.top-bar__right .tts-mute-btn {
  min-width: 44px;
  min-height: 44px;
}

.filter-btn {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-dim);
  font-family: var(--font-body);
  transition: all var(--transition-fast);
  min-height: 32px;
}

.filter-btn:hover {
  border-color: var(--color-muted);
  color: var(--color-text);
}

.filter-btn.active {
  border-color: var(--color-amber-glow);
  background: var(--color-amber-dim);
  color: var(--color-amber);
}

/* ── Inputs ────────────────────────────────── */
.input {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  padding: 10px 12px;
  font-size: var(--text-md);
  font-family: var(--font-body);
  outline: none;
  width: 100%;
  transition: border-color var(--transition-base);
  min-height: 44px;
}

.input:focus {
  border-color: var(--color-amber-glow);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input.error {
  border-color: var(--color-red);
}

.textarea {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  padding: 10px 12px;
  font-size: var(--text-md);
  font-family: var(--font-body);
  outline: none;
  width: 100%;
  resize: none;
  transition: border-color var(--transition-base);
  min-height: 44px;
  overflow-y: hidden;
}

.textarea:focus {
  border-color: var(--color-amber-glow);
}

/* ── Spinner ───────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-amber);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Alert badge ───────────────────────────── */
.alert-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  background: #E8555522;
  border: 1px solid #E8555544;
  color: var(--color-red);
  font-size: 11px;
  font-weight: 700;
}

.alert-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-red);
  animation: pulse 1.6s ease-in-out infinite;
}

/* Rate meter styles removed 2026-04-24 (see public/js/app.js buildShell). */

/* ── Loading skeleton ──────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-panel) 0%,
    var(--color-panel2) 50%,
    var(--color-panel) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Error message ─────────────────────────── */
.error-msg {
  color: var(--color-red);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Chat list section label ───────────────── */
.chat-section-label {
  padding: 10px 14px 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-amber);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-section-label__count {
  color: var(--color-muted);
  font-family: var(--font-mono);
}

/* ── Streaming indicator ───────────────────── */
.streaming-cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--color-amber);
  border-radius: 1px;
  margin-left: 3px;
  animation: pulse 0.8s ease-in-out infinite;
  vertical-align: text-bottom;
}

/* ── Agent-processing indicator ─────────────
   Shown between "user message sent" and "first streamed token arrives."
   Three amber dots, staggered pulse. Replaces a rendered agent bubble once
   the stream event fires (see chat.js wireWs() and dashboard.js
   appendChiefStreamChunk()). Pure CSS — no JS-driven animation. */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 2px;
  min-height: 14px;
}

.typing-dots__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-amber);
  opacity: 0.35;
  animation: typing-bounce 1.1s ease-in-out infinite;
}

.typing-dots__dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dots__dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes typing-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-3px); }
}

/* Entry fade for the processing bubble — in chat.js it's injected after
   the user's optimistic message and removed when the stream begins. */
.message-row--processing {
  animation: processing-fade-in 140ms ease-out;
}

@keyframes processing-fade-in {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   Phone-size overrides
   Generic class-based inputs need their own 16px bump because the
   base `input { font-size: 16px }` rule in base.css is outranked by
   the `.input { font-size: var(--text-md) }` class selector.
   ═══════════════════════════════════════════ */
@media (max-width: 480px) {
  .input,
  .textarea,
  .chat-directory__search-input,
  .chief-input__field,
  .team-search,
  .login-input,
  .task-modal__input,
  .task-modal__select,
  .task-modal__textarea,
  .server-modal__input,
  .server-modal__textarea {
    font-size: 16px;
  }

  /* Alert badge stays clickable — bump minimum height. */
  .alert-badge {
    min-height: 36px;
  }

  /* Filter buttons: lower vertical footprint without killing tap. */
  .filter-btn {
    min-height: 36px;
    padding: 6px 10px;
  }
}

/* ── Top-bar status pills (rate-meter Phase 1) ───────────────────────── */
.top-bar-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.top-bar-status__pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-family: var(--font-mono);
  white-space: nowrap;
  background: var(--color-panel);
  color: var(--color-dim);
  border: 1px solid var(--color-border);
  line-height: 1.6;
}

/* 5h-window pill warn-level coloring. */
.top-bar-status__pill--ok {
  color: #4ea96b;
  border-color: rgba(78, 169, 107, 0.4);
}

.top-bar-status__pill--approach {
  color: #d4a574;
  border-color: rgba(212, 165, 116, 0.5);
  background: rgba(212, 165, 116, 0.08);
}

.top-bar-status__pill--critical {
  color: #d96c6c;
  border-color: rgba(217, 108, 108, 0.55);
  background: rgba(217, 108, 108, 0.1);
}

.top-bar-status__pill--stale {
  color: var(--color-dim);
  border-color: var(--color-border);
  font-style: italic;
}
