/* =====================================================================
   utilities.css — Helpers, toasts, tooltips
   ===================================================================== */

[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.text-muted { color: var(--text-muted); }
.text-mono { font-family: var(--font-mono); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-2 { gap: var(--sp-2); }
.mt-2 { margin-top: var(--sp-2); }
.full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }

/* ---- Toasts ---- */
.toast-stack {
  position: fixed; top: calc(var(--header-h) + var(--sp-3)); right: var(--sp-5);
  z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--sp-2);
  width: min(360px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--sp-3);
  background: #fff; border: 1px solid var(--color-border);
  border-left: 4px solid var(--toast-accent, var(--color-primary));
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: var(--sp-3) var(--sp-4);
  animation: toast-in var(--t-slow) var(--ease-out);
  overflow: hidden;
}
.toast.is-leaving { animation: toast-out var(--t-base) var(--ease) forwards; }
.toast-success { --toast-accent: var(--color-success); }
.toast-warning { --toast-accent: var(--color-warning); }
.toast-danger  { --toast-accent: var(--color-danger); }
.toast-info    { --toast-accent: var(--color-info); }
.toast-icon { color: var(--toast-accent); flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text-strong); }
.toast-msg { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 1px; word-break: break-word; }
.toast-action {
  margin-top: var(--sp-2); font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  color: var(--color-primary); text-decoration: underline;
}
.toast-close { color: var(--text-faint); font-size: 18px; line-height: 1; flex-shrink: 0; width: 18px; height: 18px; }
.toast-close:hover { color: var(--text-strong); }
.toast-progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--toast-accent); opacity: 0.5; }

/* ---- Tooltips (CSS only via data-tip) ---- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--text-strong); color: #fff; font-size: var(--fs-xs); font-weight: var(--fw-medium);
  padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity var(--t-fast), transform var(--t-fast); z-index: var(--z-dropdown);
  box-shadow: var(--shadow-sm);
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Generic pill */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  padding: 2px 8px; border-radius: var(--radius-pill);
  background: var(--color-muted-soft); color: var(--text-muted);
}
.pill.ok { background: var(--color-success-soft); color: #1c7a32; }
.pill.warn { background: var(--color-warning-soft); color: #9a7700; }
.pill.bad { background: var(--color-danger-soft); color: #b02a37; }
.pill.info { background: var(--color-info-soft); color: #0c6f80; }
