/* ============================================
   COMMAND CENTER — Shared Components
   Canonical badge / button / card / modal /
   popover / empty-state / meta-row / kbd.
   Legacy class names are aliased into these
   groups so existing JS keeps working.
   ============================================ */

/* ---------- Badges ---------- */
.badge,
.detail-badge,
.coms-pill,
.coms-badge,
.skill-health-chip,
.chronicle-type-badge,
.lookup-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-sunken);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.badge-neutral { background: var(--bg-sunken); color: var(--text-secondary); border-color: var(--border-default); }
.badge-accent { background: var(--accent-bg); color: var(--accent); border-color: transparent; }
.badge-success { background: var(--emerald-bg); color: var(--emerald); border-color: transparent; }
.badge-warning { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.badge-danger { background: var(--rose-bg); color: var(--rose); border-color: transparent; }
.badge-info { background: var(--cyan-bg); color: var(--cyan); border-color: transparent; }

.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.detail-badge-overdue { background: var(--rose-bg); color: var(--rose); border-color: transparent; }

/* ---------- Buttons ---------- */
.btn,
.detail-btn,
.ticket-action-btn,
.briefing-btn,
.theme-toggle-btn,
.settings-reset,
.detail-thread-refresh,
.subtab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--btn-bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition-base), border-color var(--transition-base);
  user-select: none;
}

.btn:hover,
.detail-btn:hover,
.theme-toggle-btn:hover,
.settings-reset:hover,
.subtab-btn:hover {
  background: var(--btn-hover-bg);
  border-color: var(--border-strong);
}

.btn-primary,
.detail-btn-primary,
.detail-btn-approve {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse);
}

.btn-primary:hover,
.detail-btn-primary:hover,
.detail-btn-approve:hover {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
}

.btn-secondary { background: var(--btn-bg); }

.btn-ghost,
.ticket-action-btn,
.detail-thread-refresh {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover,
.ticket-action-btn:hover,
.detail-thread-refresh:hover {
  background: var(--bg-hover);
  border-color: transparent;
  color: var(--text-primary);
}

.btn-danger {
  background: transparent;
  border-color: var(--border-default);
  color: var(--rose);
}

.btn-danger:hover {
  background: var(--rose-bg);
  border-color: var(--rose);
}

.btn-sm { height: 24px; padding: 0 8px; font-size: var(--text-xs); }
.btn-lg { height: 32px; padding: 0 16px; font-size: var(--text-base); }
.btn-icon { width: 28px; padding: 0; }
.btn-sm.btn-icon { width: 24px; }

.btn:disabled,
.detail-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Cards ---------- */
.card,
.queue-ticket,
.ticket-card,
.cc-card,
.briefing-ticket,
.metric-card,
.skill-card,
.sched-card,
.coms-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.card:hover,
.queue-ticket:hover,
.ticket-card:hover {
  border-color: var(--border-strong);
}

.card-selected { border-color: var(--accent); background: var(--accent-bg); }
.card-flagged { border-left: 3px solid var(--amber); }

/* ---------- Modals ---------- */
.modal-backdrop,
.settings-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal,
.settings-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: calc(100% - 32px);
  max-height: 85vh;
  overflow: auto;
}

.modal-sm { max-width: 360px; }
.modal-md { max-width: 480px; }
.modal-lg { max-width: 680px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-md);
  font-weight: 600;
}

.modal-body { padding: var(--space-lg); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

/* ---------- Popovers ---------- */
.popover,
.flag-popover,
.report-popover,
.merge-popover {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 320px;
}

/* ---------- Empty states ---------- */
.empty-state,
.detail-empty,
.coms-empty,
.queue-empty,
.column-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-muted);
  font-size: var(--text-base);
  text-align: center;
}

.empty-state-sm {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  align-items: flex-start;
  text-align: left;
}

.empty-state-title {
  font-weight: 500;
  color: var(--text-secondary);
}

.empty-state-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ---------- Meta rows ---------- */
.meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  min-width: 0;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-item + .meta-item::before {
  content: "\00b7";
  margin-right: 6px;
  color: var(--text-muted);
}

/* ---------- Keyboard hint chips ---------- */
.kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border-default);
  background: var(--bg-sunken);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.4;
}

/* ---------- Section headers (uppercase label pattern) ---------- */
.section-heading {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* ---------- Toasts ---------- */
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
}

.toast.success { border-left-color: var(--emerald); }
.toast.error { border-left-color: var(--rose); }
.toast.warning { border-left-color: var(--amber); }
