/*
 * Mamore UI v2 — utilities.
 *
 * Loaded LAST, so a utility always beats a component rule of equal specificity.
 * Deliberately small: this file exists for the handful of one-off needs that
 * recur across panels, not as a general-purpose styling toolbox. A utility that
 * appears only once belongs on the component instead.
 */

/* Spacing — the 4-based scale from tokens.css. */
.m-0  { margin: 0; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }

.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }
.px-4 { padding-inline: var(--space-4); }
.py-2 { padding-block: var(--space-2); }
.py-4 { padding-block: var(--space-4); }

/* Flex helpers that recur enough to be worth naming. */
.flex          { display: flex; }
.inline-flex   { display: inline-flex; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-start{ justify-content: flex-start; }
.justify-end   { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.flex-1        { flex: 1; min-width: 0; }
.flex-wrap     { flex-wrap: wrap; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }

/* Sizing. */
.w-full  { width: 100%; }
.h-full  { height: 100%; }
.min-w-0 { min-width: 0; }

/*
 * Overflow. `.scroll-x` is the ONLY sanctioned way to scroll horizontally, and
 * it marks the element as deliberately wide rather than accidentally so.
 * docs/ui-v2/RESPONSIVE_STRATEGY.md requires no page-level horizontal scroll.
 */
.scroll-x {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  /* A scrollbar that appears only on hover is calmer, but it must not hide the
     fact that the region scrolls, so it is always visible on focus-within. */
  scrollbar-width: thin;
}

.scroll-y { overflow-y: auto; overscroll-behavior-y: contain; }

/* Visibility helpers for permissions-driven UI. These improve UX only; the
   server is still the authority on every action (never rely on hiding UI). */
[hidden] { display: none !important; }

/* Density is a body-level attribute so a single choice applies to every table
   and list in the application, and can be persisted as a user preference.

   The defaults are declared on :root rather than only inside the two
   data-density rules, because `var(--row-pad-y)` with no fallback is invalid at
   computed-value time: on a page rendered before the preference is applied (or
   with the attribute absent) the declaration would be dropped and the row
   padding would silently disappear. A missing preference must degrade to the
   comfortable default, not to no padding. */
:root {
  --row-pad-y: var(--space-3);
  --row-font: var(--text-body);
}

body[data-density="compact"]    { --row-pad-y: var(--space-2); --row-font: var(--text-body-s); }
body[data-density="comfortable"] { --row-pad-y: var(--space-3); --row-font: var(--text-body); }

.density-row { padding-block: var(--row-pad-y); font-size: var(--row-font); }

/* Print. The web chrome is hidden and only the report body is printed, so a
   report does not come out wrapped in the application interface. */
@media print {
  .no-print, .sidebar, .topbar, .shell__sidebar, .toast, .skip-link { display: none !important; }

  .shell, .shell__main, .shell__content {
    display: block;
    max-width: none;
    padding: 0;
    background: #fff;
  }

  /* Never lose a row across a page break mid-table. */
  tr, .card, .metric, .incident-card { break-inside: avoid; }

  a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; }
}
