/* ============================================================
   Unified Header — shared across all agents
   Prefix: uh- (unified header)
   Uses canonical CSS variables from design-system.md
   ============================================================ */

/* --- Header Container --- */
.uh {
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: var(--bg-surface, var(--bg-panel, #ffffff));
  border-bottom: 1px solid var(--border, var(--border-subtle, #e5e7eb));
  flex-shrink: 0;
  box-sizing: border-box;
  position: relative;
  z-index: 10;
}

/* --- Left Section --- */
.uh-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

/* Mobile menu button — hidden on desktop */
.uh-mobile-menu {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border, var(--border-subtle, #e5e7eb));
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-surface, var(--bg-panel, #ffffff));
  color: var(--text-secondary, #6b7280);
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.uh-mobile-menu:hover {
  background: var(--accent-light, rgba(0, 190, 140, 0.08));
  color: var(--accent, #00be8c);
  border-color: var(--accent, #00be8c);
}

/* Page title icon */
.uh-title-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, #6b7280);
  flex-shrink: 0;
}

.uh-title-icon svg,
.uh-title-icon i {
  width: 16px;
  height: 16px;
}

/* Page title */
.uh-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary, #111827);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Right Section --- */
.uh-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* --- Stats --- */
.uh-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.uh-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.uh-stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, var(--text-secondary, #9ca3af));
  line-height: 1;
}

.uh-stat-value {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary, #111827);
  line-height: 1.2;
  white-space: nowrap;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

/* --- Live Indicator --- */
.uh-live {
  display: flex;
  align-items: center;
  gap: 6px;
}

.uh-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success, #10b981);
  animation: uhLivePulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes uhLivePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}

.uh-live-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--success, #10b981);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* --- Separator --- */
.uh-sep {
  width: 1px;
  height: 24px;
  background: var(--border, var(--border-subtle, #e5e7eb));
  flex-shrink: 0;
}

/* --- Action Buttons Slot --- */
.uh-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Activity Toggle --- */
.uh-activity-toggle {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm, 6px);
  color: var(--text-secondary, #6b7280);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.uh-activity-toggle:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.04));
  color: var(--text-primary, #111827);
}

.uh-activity-toggle:focus-visible {
  outline: 2px solid var(--accent, #00be8c);
  outline-offset: 2px;
}

.uh-activity-toggle.active {
  color: var(--accent, #00be8c);
}

.uh-activity-toggle svg,
.uh-activity-toggle i {
  width: 16px;
  height: 16px;
  font-size: 16px;
}

.uh-activity-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--accent, #00be8c);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

/* --- User Profile --- */
.uh-user-wrapper {
  position: relative;
}

.uh-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.625rem 0.25rem 0.25rem;
  border-radius: var(--radius-md, 8px);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.uh-user:hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: var(--border, var(--border-subtle, #e5e7eb));
}

.uh-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--agent-brand, #00be8c);
  color: var(--text-inverse, #ffffff);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}

.uh-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary, #111827);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uh-user-chevron {
  font-size: 0.5rem;
  color: var(--text-muted, #9ca3af);
  transition: transform 0.2s ease;
  margin-left: -0.125rem;
  flex-shrink: 0;
}

.uh-user-chevron svg {
  width: 10px;
  height: 10px;
}

.uh-user.active .uh-user-chevron {
  transform: rotate(180deg);
}

/* --- User Dropdown --- */
.uh-user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--bg-surface, var(--bg-panel, #ffffff));
  border: 1px solid var(--border, var(--border-subtle, #e5e7eb));
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  z-index: var(--z-dropdown, 50);
  display: none;
  overflow: hidden;
}

.uh-user-dropdown.show {
  display: block;
  animation: uhSlideDown 0.2s ease;
}

@keyframes uhSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.uh-dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, var(--border-subtle, #e5e7eb));
  background: var(--bg-muted, var(--bg-secondary, rgba(0, 0, 0, 0.02)));
}

.uh-dropdown-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary, #111827);
}

.uh-dropdown-email {
  font-size: 0.6875rem;
  color: var(--text-muted, #9ca3af);
  margin-top: 2px;
  word-break: break-all;
}

.uh-dropdown-body {
  padding: 0.5rem 0;
}

.uh-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  color: var(--text-secondary, #6b7280);
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.uh-dropdown-item:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.04));
  color: var(--text-primary, #111827);
}

.uh-dropdown-item i,
.uh-dropdown-item svg {
  width: 16px;
  height: 16px;
  font-size: 16px;
  color: var(--text-muted, #9ca3af);
  flex-shrink: 0;
}

.uh-dropdown-item:hover i,
.uh-dropdown-item:hover svg {
  color: var(--accent, #00be8c);
}

.uh-dropdown-divider {
  height: 1px;
  background: var(--border, var(--border-subtle, #e5e7eb));
  margin: 0.25rem 0;
}

/* --- MarCo Filter Bar (below header, MarCo only) --- */
.uh-filter-bar {
  height: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  background: var(--bg-surface, #ffffff);
  border-bottom: 1px solid var(--border, #e5e7eb);
  flex-shrink: 0;
}

.uh-filter-bar:empty,
.uh-filter-bar[hidden] {
  display: none;
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
  .uh {
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    padding: 0 0.75rem;
  }

  .uh-mobile-menu {
    display: flex;
  }

  .uh-stats,
  .uh-live,
  .uh-sep:has(+ .uh-stats),
  .uh-stats + .uh-sep {
    display: none;
  }

  .uh-user-name {
    display: none;
  }

  .uh-user-chevron {
    display: none;
  }

  .uh-user {
    padding: 0.25rem;
    border: none;
  }

  /* Title + icon: constrained so activity toggle stays visible */
  .uh-title {
    font-size: 0.875rem;
    max-width: 140px;
  }

  .uh-title-icon {
    display: none;
  }

  /* Activity toggle: always visible on mobile */
  .uh-activity-toggle {
    display: flex;
  }

  /* Actions slot: hide on mobile (too cramped) */
  .uh-actions {
    display: none;
  }

  .uh-filter-bar {
    height: auto;
    min-height: 36px;
    padding: 0.25rem 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

/* Fallback for browsers without :has() — hide stats separator via JS */
@media (max-width: 768px) {
  .uh-sep.uh-sep--stats {
    display: none;
  }
}
