/* Stabilise Finance — utilities.
 * Small set of opt-in utility classes. Use sparingly; component classes
 * carry the most styling. These are for ad-hoc layout in EJS templates.
 */

/* ── Text colour ─────────────────────────────────────────── */
.text-warning  { color: var(--warning-fg); }
.text-positive { color: var(--positive-fg); }
.text-negative { color: var(--negative-fg); }

/* ── Display ─────────────────────────────────────────────── */
.flex   { display: flex; }
.grid   { display: grid; }
.block  { display: block; }
.inline { display: inline; }
.inline-flex  { display: inline-flex; }

/* ── Flex direction & alignment ──────────────────────────── */
.flex-row  { flex-direction: row; }
.flex-col  { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1    { flex: 1 1 0; min-width: 0; }
.items-start  { align-items: flex-start; }
.items-center { align-items: center; }
.items-end    { align-items: flex-end; }
.justify-start  { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end    { justify-content: flex-end; }
.justify-between{ justify-content: space-between; }

/* ── Gap ─────────────────────────────────────────────────── */
.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-6 { gap: var(--space-6); }

/* ── Margin ──────────────────────────────────────────────── */
.m-0  { margin: 0; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

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

/* ── Grid columns (12-col + named) ───────────────────────── */
.grid--cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.grid--cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.grid--cols-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.grid--cols-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-3); }

/* Five-in-a-row at every reasonable screen width. Below 900 we fall back. */
@media (max-width: 900px) {
  .grid--cols-3, .grid--cols-4, .grid--cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Compact KPI cards when packed five-up so the value text never overflows. */
.grid--cols-5 .kpi { padding: var(--space-4); }
.grid--cols-5 .kpi__value { font-size: var(--text-xl); }
@media (max-width: 600px) {
  .grid--cols-2, .grid--cols-3, .grid--cols-4, .grid--cols-5 { grid-template-columns: 1fr; }
}

/* Split-screen 7:3 for supplier review with PDF preview */
.grid--split-7-3 {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
  gap: var(--space-4);
}
@media (max-width: 900px) {
  .grid--split-7-3 { grid-template-columns: 1fr; }
}

/* ── Text helpers ────────────────────────────────────────── */
.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }
.text-2xl  { font-size: var(--text-2xl); }

.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.font-mono { font-family: var(--font-mono); }
.font-heading { font-family: var(--font-heading); }

.text-left   { text-align: left; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

.uppercase { text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.tabular   { font-variant-numeric: tabular-nums; }

.muted     { color: var(--muted-foreground); }
.positive  { color: var(--positive-fg); }
.negative  { color: var(--negative-fg); }
.warning   { color: var(--warning-fg); }
.critical  { color: var(--critical); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* ── Width / max-width ──────────────────────────────────── */
.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }

/* ── Other ──────────────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }
.no-underline   { text-decoration: none; }
.hidden         { display: none; }
.relative       { position: relative; }
.sticky-top {
  position: sticky;
  top: 0;
  z-index: 5;
  background-color: var(--background);
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}
