/*
 * Namirial design system - utility classes (LEGACYPORTAL-4757).
 * Loaded by every template (public and private), so markup can replace inline styles and <br/> spacing
 * with these classes on any page. Values follow the design system tokens.
 */

/* ---------- Spacing scale (4 / 8 / 12 / 16 / 24 / 32 px) ---------- */
.nds-mt-0 { margin-top: 0 !important; }
.nds-mt-4 { margin-top: 4px !important; }
.nds-mt-8 { margin-top: 8px !important; }
.nds-mt-12 { margin-top: 12px !important; }
.nds-mt-16 { margin-top: 16px !important; }
.nds-mt-24 { margin-top: 24px !important; }
.nds-mt-32 { margin-top: 32px !important; }
.nds-mb-0 { margin-bottom: 0 !important; }
.nds-mb-4 { margin-bottom: 4px !important; }
.nds-mb-8 { margin-bottom: 8px !important; }
.nds-mb-12 { margin-bottom: 12px !important; }
.nds-mb-16 { margin-bottom: 16px !important; }
.nds-mb-24 { margin-bottom: 24px !important; }
.nds-mb-32 { margin-bottom: 32px !important; }
.nds-ml-8 { margin-left: 8px !important; }
.nds-mr-8 { margin-right: 8px !important; }
.nds-my-16 { margin-top: 16px !important; margin-bottom: 16px !important; }
/* separates two consecutive blocks (e.g. two data tables) by one section height */
.nds-section-gap { margin-top: 32px !important; }

/* ---------- Layout helpers ---------- */
/* vertical stack of blocks with a regular gap (replaces <br/> between blocks) */
.nds-stack { display: flex; flex-direction: column; gap: 16px; }
.nds-stack-8 { display: flex; flex-direction: column; gap: 8px; }
/* row of buttons / actions */
.nds-btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.nds-btn-row-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.nds-btn-row-center { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
/* compact group of icon-only actions inside a table cell */
.nds-actions { display: inline-flex; flex-wrap: nowrap; align-items: center; gap: 4px; }
.nds-float-right { float: right; }
.nds-w-auto { width: auto !important; }
.nds-w-full { width: 100% !important; }
.nds-nowrap { white-space: nowrap; }

/* ---------- Text ---------- */
.nds-text-secondary { color: var(--nds-text-muted, #62625f); font-size: 13px; font-style: normal; }
.nds-text-strong { font-weight: 600; }
.nds-text-center { text-align: center; }
.nds-text-right { text-align: right; }
.nds-text-error { color: var(--nds-negative-700, #87001d); font-weight: 600; }
.nds-section-title {
  display: block;
  margin: 0 0 12px 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  color: var(--nds-text-default, #090908);
}

/* ---------- Status tags (design system Tag: soft background, medium text, radius-sm) ---------- */
.nds-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 18px;
  font-weight: 600;
  white-space: nowrap;
  background-color: var(--nds-neutral-50, #eff1db);
  color: var(--nds-neutral-800, #3b3d23);
}
.nds-tag-positive { background-color: var(--nds-positive-50, #cdffd9); color: var(--nds-positive-600, #0e7e38); }
.nds-tag-warning { background-color: var(--nds-warning-50, #ffffc2); color: var(--nds-warning-600, #886d00); }
.nds-tag-negative { background-color: var(--nds-negative-50, #ffcdd7); color: var(--nds-negative-600, #b50034); }
.nds-tag-info { background-color: var(--nds-info-50, #d2feff); color: var(--nds-info-600, #1f709e); }
.nds-tag-neutral { background-color: var(--nds-neutral-50, #eff1db); color: var(--nds-neutral-800, #3b3d23); }
/* accent: the medium step (#508000) is below 4.5:1 on #e7ffcf (4.43:1), so the text uses
   the next darker step of the same palette (accent-700) */
.nds-tag-accent { background-color: var(--nds-accent-50, #e7ffcf); color: var(--nds-accent-700, #376100); }

/* ---------- Alert / callout (design system Callout: bg *-50, border *-700, text *-950) ----------
   Usable on a wrapper div (children span/label stack with a 4px gap) or directly on a
   single span/label: the class itself is display:block. */
.nds-alert {
  display: block;
  position: relative;
  padding: 12px 16px;
  padding-left: 40px;
  border-radius: 8px;
  border-left: 3px solid var(--nds-neutral-600, #646646);
  font-size: 14px;
  line-height: 20px;
  margin: 12px 0;
  color: var(--nds-neutral-800, #3b3d23);  /* olive-800: DS callout-secondary foreground */
  background-color: var(--nds-neutral-50, #eff1db);
}
.nds-alert > span,
.nds-alert > label {
  display: block;
}
.nds-alert > span + span,
.nds-alert > span + label,
.nds-alert > label + span,
.nds-alert > label + label {
  margin-top: 4px;
}
.nds-alert-info {
  background-color: var(--nds-info-50, #d2feff);
  border-left-color: var(--nds-info-700, #055882);
  color: var(--nds-info-950, #001830);
}
.nds-alert-warning {
  background-color: var(--nds-warning-50, #ffffc2);
  border-left-color: var(--nds-warning-700, #685000);
  color: var(--nds-warning-950, #231300);
}
/* leading icon (Lucide, CSS mask), coloured with the intent 700; absolutely positioned
   on the first line so wrapped lines of text align with each other */
.nds-alert::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 14px;
  width: 16px;
  height: 16px;
  background-color: var(--nds-neutral-600, #646646);
  -webkit-mask: url("/javax.faces.resource/images/icons/lucide-info.svg.xhtml?ln=namirial&v=20261201233332") center / 16px 16px no-repeat;
  mask: url("/javax.faces.resource/images/icons/lucide-info.svg.xhtml?ln=namirial&v=20261201233332") center / 16px 16px no-repeat;
}
.nds-alert-info::before {
  background-color: var(--nds-info-700, #055882);
  -webkit-mask-image: url("/javax.faces.resource/images/icons/lucide-info.svg.xhtml?ln=namirial&v=20261201233332");
  mask-image: url("/javax.faces.resource/images/icons/lucide-info.svg.xhtml?ln=namirial&v=20261201233332");
}
.nds-alert-warning::before {
  background-color: var(--nds-warning-700, #685000);
  -webkit-mask-image: url("/javax.faces.resource/images/icons/lucide-triangle-exclamation-point.svg.xhtml?ln=namirial&v=20261201233332");
  mask-image: url("/javax.faces.resource/images/icons/lucide-triangle-exclamation-point.svg.xhtml?ln=namirial&v=20261201233332");
}

/* ---------- Buttons sizes (design system v2, W11: md 40px default, sm 32px) ---------- */
body .ui-button.nds-btn-sm {
  height: var(--nds-btn-height-sm, 32px);
  padding: var(--nds-btn-padding-sm, 0 12px);
  border-radius: var(--nds-btn-radius-sm, 8px);
  font-size: var(--nds-btn-font-size-sm, 14px);
}
/* icon-only action button: 32px square, radius 8px (used in table rows) */
body .ui-button.nds-btn-icon,
body .ui-button.ui-button-icon-only.nds-btn-icon {
  width: var(--nds-btn-icon-only-size-sm, 32px);
  height: var(--nds-btn-icon-only-size-sm, 32px);
  min-width: var(--nds-btn-icon-only-size-sm, 32px);
  padding: 0;
  border-radius: var(--nds-btn-radius-sm, 8px);
}

/* ---------- Segmented control (design system "Button Segmented") ----------
   Apply styleClass="nds-segmented" (and layout="lineDirection") to an existing p:selectOneRadio:
   same component, same value and ajax behaviour, rendered as joined buttons. */
table.ui-selectoneradio.nds-segmented {
  display: inline-table;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--nds-segmented-border, #7a7c59);
  border-radius: 8px;
  overflow: hidden;
  background-color: var(--nds-surface-50, #ffffff);
}
/* base: the native radio stays visible, in normal flow, next to its label — the look
   every browser gets (also the fallback for browsers without :has()) */
table.ui-selectoneradio.nds-segmented td {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-left: 1px solid var(--nds-segmented-border, #7a7c59);
}
table.ui-selectoneradio.nds-segmented td:first-child {
  border-left: 0 none;
}
table.ui-selectoneradio.nds-segmented .ui-radiobutton {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  opacity: 1;
}
table.ui-selectoneradio.nds-segmented .ui-radiobutton .ui-radiobutton-box {
  width: auto;
  height: auto;
  cursor: pointer;
}
table.ui-selectoneradio.nds-segmented label {
  display: block;
  margin: 0;
  /* sm control height (32px) around the 20px line: 6px + 20px + 6px */
  padding: calc((var(--nds-segmented-height, 32px) - 20px) / 2) 16px;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  color: var(--nds-surface-950, #010101);
  cursor: pointer;
  pointer-events: auto;
}
table.ui-selectoneradio.nds-segmented td:hover label {
  background-color: var(--nds-bg-subtle, #eff1db);
}
/* enhancement for browsers with :has(): the radio becomes an invisible overlay on the
   whole segment (the box stays clickable) and the selected segment is highlighted on its label */
@supports selector(:has(*)) {
  table.ui-selectoneradio.nds-segmented td {
    display: table-cell;
    padding: 0;
  }
  table.ui-selectoneradio.nds-segmented .ui-radiobutton {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    margin: 0;
    opacity: 0;
  }
  table.ui-selectoneradio.nds-segmented .ui-radiobutton .ui-radiobutton-box {
    width: 100%;
    height: 100%;
  }
  table.ui-selectoneradio.nds-segmented label {
    pointer-events: none;
  }
  /* the label fills the whole segment: no gap left of the radio (beats ".ui-radiobutton + label" in namirial-ds.css) */
  body table.ui-selectoneradio.nds-segmented td .ui-radiobutton + label {
    margin: 0;
  }
  table.ui-selectoneradio.nds-segmented td:has(.ui-radiobutton-box.ui-state-active) label {
    background-color: var(--nds-action-primary-bg, #141513);
    color: var(--nds-action-primary-fg, #ffffff);
    font-weight: 600;
  }
  table.ui-selectoneradio.nds-segmented td:has(.ui-radiobutton-box.ui-state-focus) label {
    outline: 2px solid var(--nds-focus-700, #055882);
    outline-offset: -3px;
  }
}

/* ---------- Inline group of options (checkboxes/radios with their label), wraps only when there is no room ---------- */
.nds-inline-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 32px; padding: 4px 0; }
.nds-check-item { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.nds-check-item .ui-chkbox,
.nds-check-item .ui-radiobutton { flex: 0 0 auto; }

/* ---------- Field + hint text (hint shown under the field, never overlapping it) ---------- */
.nds-field { display: block; margin-bottom: 16px; }
.nds-field > .md-inputfield { display: block; }
.nds-field-hint { display: block; margin-top: 6px; font-size: 12px; line-height: 16px; color: var(--nds-text-muted, #62625f); }

/* ---------- Select field: visible label above a p:selectOneMenu (LEGACYPORTAL-4757) ----------
   The select keeps its own width; when it had width:100% it stays as is. */
.nds-field-select { display: flex; flex-direction: column; }
.nds-field-select > label { display: block; margin: 0 0 4px 0; font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--nds-text-default, #090908); }

/* ---------- Loading overlay (p:ajaxStatus) ---------- */
/* Full-page centred overlay shown while a global ajax request runs; fades in only after
   400ms so fast requests never flash it. While hidden it lets clicks through. */
.nds-ajax-status { display: contents; }

.nds-loading-overlay {
  position: fixed;
  inset: 0;
  /* above PrimeFaces modal dialogs and their masks (incremental z-index ~1000-10000+) */
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.6);
  cursor: progress;
  /* start invisible and non-blocking; become visible (and blocking) via the animation.
     Fail-safe: if the complete/error facet never shows (e.g. a JS error while PrimeFaces
     processes the ajax response), a second animation releases the overlay after 20s so the
     page stays usable; a genuinely longer request simply loses the overlay. */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  animation: nds-overlay-in 150ms ease-out 400ms forwards,
             nds-overlay-release 300ms ease-in 20s forwards;
}

@keyframes nds-overlay-in {
  to {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

@keyframes nds-overlay-release {
  to {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

.nds-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--nds-border-default, #d6d9b9);
  border-top-color: var(--nds-accent-700, #376100);
  border-radius: 50%;
  animation: nds-spin 0.8s linear infinite;
}

@keyframes nds-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .nds-spinner { animation-duration: 2s; }
}

