/* detail-components-v2: restyle pagine di dettaglio, solo sotto body.test-environment. Specifica: docs/PianoRestyleDettaglio.md. Ritorno: tag pre-restyle-dettaglio o git revert. */

/* ---------- Scala dei livelli (BlazorLevelScale) ---------- */
body.test-environment .nh-scale {
  position: relative;
}

body.test-environment .nh-scale::before {
  content: "";
  position: absolute;
  left: 19px;
  top: 19px;
  bottom: 19px;
  width: 2px;
  border-radius: 2px;
  background: var(--border-strong);
}

body.test-environment .nh-scale-slot {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  cursor: pointer;
}

body.test-environment .nh-scale-slot:hover {
  background: rgba(var(--primary-rgb), .07);
}

body.test-environment .nh-scale-slot:focus-visible,
body.test-environment .nh-scale-tag.is-grab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

body.test-environment .nh-scale-other,
body.test-environment .nh-scale-me {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: none;
  transition: transform .32s cubic-bezier(.16, 1, .3, 1);
}

body.test-environment .nh-scale-other {
  z-index: 2;
  color: var(--muted);
}

body.test-environment .nh-scale-me {
  z-index: 3;
}

body.test-environment .nh-scale-num {
  position: relative;
  z-index: 1;
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: border-color .2s, background .2s, color .2s;
}

body.test-environment .nh-scale-num.is-moved {
  border-color: var(--warning);
  background: var(--warning-soft);
  color: #b45309;
}

body.test-environment .nh-scale-other .nh-scale-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.test-environment .nh-scale-me .nh-scale-num {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 5px rgba(var(--primary-rgb), .18);
  color: #fff;
  font-size: 15px;
}

body.test-environment .nh-scale-tag {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--primary-ink);
  box-shadow: 0 10px 20px -10px rgba(30, 58, 138, .7);
  color: #fff;
}

body.test-environment .nh-scale-tag b {
  overflow: hidden;
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.test-environment .nh-scale-tag.is-grab {
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: box-shadow .15s;
}

body.test-environment .nh-scale-tag.is-grab:hover {
  box-shadow: 0 12px 24px -10px rgba(30, 58, 138, .8);
}

body.test-environment .nh-scale.is-dragging .nh-scale-me {
  transition: none;
}

body.test-environment .nh-scale.is-dragging .nh-scale-tag.is-grab {
  cursor: grabbing;
  box-shadow: 0 16px 28px -10px rgba(30, 58, 138, .85);
}

/* ---------- Dati collegati (BlazorLinkedDataTable) ---------- */
body.test-environment .nh-linked-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 800;
}

body.test-environment .nh-linked-count {
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

body.test-environment .nh-linked-search {
  margin: 0 0 12px;
}

body.test-environment .nh-linked-none {
  padding: 18px 2px;
  color: var(--muted);
  font-size: 14px;
}

body.test-environment .nh-linked-scroll {
  position: relative;
  max-height: 296px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

body.test-environment .nh-linked-scroll.is-fit {
  max-height: none;
  overflow: visible;
}

/* Senza scorrimento l'intestazione non deve restare "appiccicata". */
body.test-environment .nh-linked-scroll.is-fit .nh-linked-table th {
  position: static;
}

body.test-environment .nh-linked-scroll:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

body.test-environment .nh-linked-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

body.test-environment .nh-linked-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0 8px 10px 2px;
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

body.test-environment .nh-linked-table td {
  padding: 12px 8px 12px 2px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  vertical-align: top;
}

body.test-environment .nh-linked-table td:nth-child(2) {
  color: var(--muted);
  font-weight: 500;
}

body.test-environment .nh-linked-table td:last-child,
body.test-environment .nh-linked-table th:last-child {
  padding-right: 2px;
  text-align: right;
  white-space: nowrap;
}

body.test-environment .nh-linked-table td:last-child {
  color: var(--muted);
  font-weight: 500;
}

/* Sfumatura sul bordo basso: nascosta di default (senza animation-timeline coprirebbe sempre l'ultima riga);
   compare solo dove il browser sa spegnerla a fine scorrimento. Lo scorrimento pilotato non e' movimento: vale anche con reduced-motion. */
body.test-environment .nh-linked-fade {
  display: none;
  position: sticky;
  bottom: 0;
  height: 44px;
  margin-top: -44px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--surface) 85%);
  pointer-events: none;
}

@supports (animation-timeline: scroll()) {
  body.test-environment .nh-linked-fade {
    display: block;
    animation: nh-linked-fade-out linear both;
    animation-timeline: scroll(nearest block);
    animation-range: calc(100% - 60px) 100%;
  }
}

@keyframes nh-linked-fade-out {
  to { opacity: 0; }
}

@media (max-width: 560px) {
  /* Intestazione nascosta alla vista ma letta dalle tecnologie assistive (display:none le toglierebbe). */
  body.test-environment .nh-linked-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  body.test-environment .nh-linked-table,
  body.test-environment .nh-linked-table tbody,
  body.test-environment .nh-linked-table tr,
  body.test-environment .nh-linked-table td {
    display: block;
  }

  body.test-environment .nh-linked-table tr {
    padding: 12px 2px;
    border-bottom: 1px solid var(--border);
  }

  body.test-environment .nh-linked-table td {
    padding: 0;
    border: 0;
  }

  /* Seconda linea: tipo e dettaglio affiancati. */
  body.test-environment .nh-linked-table td:nth-child(2),
  body.test-environment .nh-linked-table td:nth-child(3) {
    display: inline;
    font-size: 13px;
    text-align: left;
    white-space: normal;
  }

  body.test-environment .nh-linked-table td:nth-child(2)::after {
    content: " \00b7 ";
  }

  body.test-environment .nh-linked-table td:nth-child(1) {
    margin-bottom: 2px;
  }
}

/* Sezione dati collegati sotto il form di una pagina di dettaglio. */
body.test-environment .nh-detail-linked {
  margin: 24px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

/* ---------- Campo composto (non <label>): etichetta + scala/valore precedente ---------- */
/* Stesso aspetto delle etichette dei campi (forms-v2.css, label.field > span:first-child). */
body.test-environment .nh-field-block > .nh-field-label {
  display: block;
  margin-bottom: 8px;
  color: #334155;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 15px;
  letter-spacing: 0;
  text-transform: none;
}

/* Testo per le tecnologie assistive (livello in sola lettura). */
body.test-environment .nh-scale-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Valore precedente (BlazorFieldWas) ---------- */
body.test-environment .nh-was {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  padding: 9px 9px 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 18px -10px rgba(15, 23, 42, .28);
}

body.test-environment .nh-was-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.test-environment .nh-was .btn {
  flex: none;
  text-decoration: none;
}

@media (max-width: 560px) {
  body.test-environment .nh-was .btn {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.test-environment .nh-scale-other,
  body.test-environment .nh-scale-me,
  body.test-environment .nh-scale-num {
    transition: none;
  }
}
