/* ══════════════════════════════════════════════
   FOURNISSEURS — suppliers page
   Every class is prefixed .sup- ; colours, radii and type come from the tokens of style.css.
   Blue = interaction. Amber/sienna only for "not linked", open issues, errors and destructive actions.
══════════════════════════════════════════════ */

.sup { padding-top: 16px; }
.sup .section-head { margin: 28px 0 12px; align-items: center; }
.sup .field-hint { color: var(--text-muted); }

.sup-lede { max-width: 72ch; margin: 0 0 16px; font-size: var(--fs-sm); color: var(--text-muted); }
.sup-hint { max-width: 80ch; margin: 0 0 6px; font-size: var(--fs-sm); color: var(--text-muted); }
.sup-req { color: var(--text-muted); font-weight: 400; }
.sup-count { font-size: var(--fs-sm); font-weight: 400; color: var(--text-muted); }
.sup-banner__detail { display: block; margin-top: 2px; font-size: var(--fs-sm); font-weight: 400; }
.sup-form-title { font-size: var(--fs-base); font-weight: 500; margin: 0 0 12px; }
.sup-pref-none { font-size: var(--fs-sm); }

/* error line under a form: empty = takes no room */
.sup-form-error { font-size: var(--fs-sm); color: var(--danger-text); }
.sup-form-error:not(:empty) { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 10px; }

.sup-tag {
  display: inline-flex; align-items: center; padding: 1px 9px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); font-size: var(--fs-xs); font-weight: 400; color: var(--text-muted); white-space: nowrap;
}

/* ── Add a supplier ── */
.sup-add .section-title { margin-bottom: 12px; }
.sup-add__row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 0 14px; align-items: end; }
.sup-add__row .field { margin-bottom: 0; }
.sup-add__btn { height: 44px; }

/* ── Search boxes ── */
.sup-search { position: relative; }
.sup-search .input { padding-left: 40px; -webkit-appearance: none; appearance: none; }
.sup-search__icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); display: flex; color: var(--text-faint); pointer-events: none; }
.sup-search--grow { flex: 1 1 280px; min-width: 0; max-width: 460px; }

.sup-check { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; font-size: var(--fs-sm); font-weight: 500; }
.sup-check input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }

/* ── List of suppliers ── */
.sup-list { padding: 0; overflow: hidden; margin-top: 12px; }
.sup-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%;
  padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--border);
  transition: background var(--dur) var(--ease);
}
.sup-row:last-child { border-bottom: 0; }
.sup-row:hover { background: var(--surface-2); }
.sup-row:focus-visible { outline-offset: -3px; }
.sup-row__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sup-row__name { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-weight: 500; overflow-wrap: anywhere; }
.sup-row__meta { font-size: var(--fs-sm); color: var(--text-muted); }
.sup-row__notes { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sup-row__side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sup-row__chev { display: flex; color: var(--text-faint); }
.sup-row.is-inactive .sup-row__name { color: var(--text-muted); }
@media (max-width: 560px) {
  .sup-row { padding: 13px 14px; gap: 10px; align-items: flex-start; }
  .sup-row__side { flex-direction: column-reverse; align-items: flex-end; gap: 6px; }
}

@keyframes sup-flash { from { background: var(--blue-tint); } to { background: transparent; } }
.sup-row.is-new, .sup-sku-row.is-new, .sup-sku-row.is-new td { animation: sup-flash 2.4s var(--ease) 1; }

/* ── Supplier header ── */
.sup-head { padding: 20px; }
.sup-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 14px; }
.sup-title { font-size: var(--fs-xl); font-weight: 500; letter-spacing: -0.01em; overflow-wrap: anywhere; min-width: 0; }
.sup-title:focus { outline: none; }
.sup-title-row__btn { margin-left: auto; }
.sup-rename { margin-bottom: 14px; }
.sup-rename__row { display: flex; gap: 10px; flex-wrap: wrap; }
.sup-rename__row .input { flex: 1 1 240px; width: auto; min-width: 0; }
.sup-notes .field { margin-bottom: 8px; }
.sup-notes textarea.input { min-height: 64px; }
.sup-notes__actions { display: flex; justify-content: flex-end; }
.sup-head__foot {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 16px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.sup-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sup-active-hint { margin-top: 6px; }
.sup-merge:empty { display: none; }
.sup-merge { margin-top: 14px; padding: 16px; background: var(--surface-2); border-radius: var(--radius-sm); }
.sup-merge__row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.sup-merge__row .field { flex: 1 1 260px; margin-bottom: 0; }
.sup-merge__btns { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.sup-merge__btns .inline-confirm { flex-wrap: wrap; }
.sup-merge .field-hint { display: block; margin-top: 10px; }

.sup-tiles { margin: 14px 0 0; }
.sup-tiles .stat-tile__value { font-size: var(--fs-2xl); }

@media (max-width: 560px) {
  .sup-head { padding: 16px; }
  .sup-head__actions { width: 100%; }
  .sup-head__actions .btn { flex: 1 1 auto; }
  .sup-add__row { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .sup-add__btn { width: 100%; }
}

/* ── Add a SKU ── */
.sup-sku-form { margin-bottom: 14px; }
.sup-sku-form__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr); gap: 0 14px; align-items: start; }
.sup-sku-form__generic { grid-column: 1 / -1; }
.sup-form-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
@media (max-width: 700px) {
  .sup-sku-form__grid { grid-template-columns: minmax(0, 1fr); }
  .sup-form-actions .btn { width: 100%; }
}

/* ── Generic ID search box ── */
.sup-gp__selected {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 44px; padding: 4px 6px 4px 14px; border-radius: var(--radius-sm); background: var(--blue-tint);
}
.sup-gp__chosen { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sup-gp__list { margin-top: 8px; gap: 4px; max-height: 300px; overflow-y: auto; }
.sup-gp__list.is-busy { opacity: 0.55; pointer-events: none; }
.sup-gp__opt { padding: 9px 12px; border-radius: var(--radius-sm); }
.sup-gp__opt .pick-row__main { min-width: 0; }
.sup-gp__opt .pick-row__title, .sup-gp__opt .pick-row__sub { display: block; overflow-wrap: anywhere; }
.sup-gp__opt.is-active { border-color: var(--accent); background: var(--blue-tint); }

/* ── SKU table toolbar ── */
.sup-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 10px; }
.sup-summary { margin: 6px 0 8px; min-height: 20px; font-size: var(--fs-sm); color: var(--text-muted); }

/* ── SKU table (wide layout) ── */
.sup-table-host { container-type: inline-size; container-name: sup-table; }
.sup-table th, .sup-table td { padding: 10px 12px; }
.sup-table th:first-child, .sup-table td:first-child { padding-left: 16px; }
.sup-table th:last-child, .sup-table td:last-child { padding-right: 12px; }
.sup-table th { white-space: normal; line-height: 1.25; vertical-align: bottom; }
.sup-table td { font-size: var(--fs-sm); line-height: 1.4; }
.sup-table .col-sku { min-width: 120px; max-width: 200px; }
.sup-table .col-name { min-width: 200px; }
.sup-table .col-generic { min-width: 150px; }
.sup-table .col-pref { width: 1%; white-space: nowrap; }
.sup-table .col-upb, .sup-table .col-stock { white-space: nowrap; }
.sup-table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.sup-sku { font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sup-clamp {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere;
}
.sup-generic { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sup-generic__name { font-size: var(--fs-xs); color: var(--text-muted); }
.sup-sub { display: block; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 400; white-space: normal; }

/* row buttons: icon-only in the table, with text in the card layout */
.sup-actions { position: relative; display: inline-flex; align-items: center; justify-content: flex-end; gap: 2px; }
.sup-act { gap: 8px; }
.sup-act--danger:hover:not(:disabled) { background: var(--sienna-tint); color: var(--danger-text); }
.sup-act__text, .sup-star__text {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.sup-star { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); }
.sup-star .icon { fill: currentColor; }

/* the question next to a row's trash button floats over the row, so the columns do not move */
.sup-actions.is-confirming .sup-act { visibility: hidden; }
.sup-actions .inline-confirm {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 4;
  width: max-content; max-width: 560px; flex-wrap: nowrap; white-space: nowrap; justify-content: flex-end; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}

/* ── SKU table (card layout), chosen by the width of the table itself ── */
@container sup-table (max-width: 899px) {
  .sup-table, .sup-table tbody { display: block; }
  .sup-table thead {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .sup-table tbody tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
  }
  .sup-table tbody tr:last-child { border-bottom: 0; }
  .sup-table td, .sup-table td:first-child, .sup-table td:last-child {
    display: block; min-width: 0; max-width: none; padding: 0; border: 0; white-space: normal; text-align: left;
  }
  .sup-table td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 2px;
    font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted);
  }
  .sup-table .num { text-align: left; }
  .sup-table tr:hover td { background: transparent; }
  .sup-table td.is-empty { display: none; }
  .sup-table .col-sku { grid-column: 1 / -1; order: 1; font-size: var(--fs-base); }
  .sup-table .col-name { grid-column: 1 / -1; order: 2; }
  .sup-table .col-generic { grid-column: 1 / -1; order: 3; }
  .sup-table .col-pref { order: 4; }
  .sup-table .col-upb { order: 5; }
  .sup-table .col-stock { order: 6; }
  .sup-table .col-actions { grid-column: 1 / -1; order: 7; }
  .sup-table .col-pref, .sup-table .col-actions { width: auto; }
  .sup-clamp { display: block; -webkit-line-clamp: unset; line-clamp: unset; overflow: visible; }
  .sup-generic { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
  .sup-actions { position: static; display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
  .sup-actions .sup-act.btn-icon { width: auto; height: 32px; padding: 0 12px; }
  .sup-act__text, .sup-star__text { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal; }
  .sup-actions .inline-confirm { position: static; transform: none; width: auto; max-width: none; padding: 0; background: transparent; border: 0; box-shadow: none; justify-content: flex-start; flex-wrap: wrap; white-space: normal; }
}
@container sup-table (max-width: 479px) {
  .sup-table tbody tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sup-table .col-stock { grid-column: 1 / -1; }
}

/* ── "Preferred supplier of" buttons ── */
.sup-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; margin: 0 0 12px; padding: 0; }
.sup-chip {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 8px 12px; text-align: left;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.sup-chip:hover { border-color: var(--accent); background: var(--blue-tint); }
.sup-chip .gcode { flex-shrink: 0; }
.sup-chip__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); color: var(--text-muted); }

/* ── Dialogs (they live outside .sup, in the modal) ── */
.sup-dlg__sku { margin-bottom: 4px; overflow-wrap: anywhere; }
.sup-dlg__current { margin-bottom: 14px; font-size: var(--fs-sm); }
.sup-dlg__note { margin: 0 0 8px; font-size: var(--fs-sm); }
.sup-dlg__list { margin: 8px 0 12px; padding-left: 20px; list-style: disc; }
.sup-dlg__list li { margin-bottom: 4px; }
.sup-dlg__h { margin: 16px 0 6px; padding-top: 14px; border-top: 1px solid var(--border); font-size: var(--fs-base); font-weight: 500; }
.modal .sup-form-error { font-size: var(--fs-sm); color: var(--danger-text); }
.modal .sup-form-error:not(:empty) { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 10px; }
.modal .field-hint { color: var(--text-muted); }
.modal .result-banner { padding: 12px 14px; gap: 10px; margin: 12px 0; font-size: var(--fs-sm); }
.modal .result-banner__text { font-weight: 400; }
.sup-dlg__actions .inline-confirm { flex-wrap: wrap; margin-right: auto; }
.sup-dlg__unlink { margin-right: auto; }
.modal .sup-gp__selected { margin-bottom: 4px; }

@media (prefers-reduced-motion: reduce) {
  .sup-row.is-new, .sup-sku-row.is-new, .sup-sku-row.is-new td { animation: none; }
}
