/*
 * repiLab product table. Colours, radius and font follow the approved design (design/index.html);
 * a theme overrides them through these custom properties (the new theme maps them to theme.json presets).
 */
.repilab-table {
  --rt-accent: var(--wp--preset--color--brand, #a50000);
  --rt-accent-dark: var(--wp--preset--color--brand-dark, #870000);
  --rt-ink: var(--wp--preset--color--ink, #16181b);
  --rt-muted: var(--wp--preset--color--muted, #5f6368);
  --rt-line: var(--wp--preset--color--line, #e4e2de);
  --rt-soft: var(--wp--preset--color--soft, #f3f1ee);
  --rt-bg: var(--wp--preset--color--base, #ffffff);
  --rt-ok: #1d6b3a;
  --rt-wait: #8a5a00;
  --rt-radius: 6px;
  --rt-tap: 44px;
  --rt-font: inherit;

  font-family: var(--rt-font);
  color: var(--rt-ink);
  margin-block: 1.5rem 3rem;
}

.repilab-table__app { min-height: 24rem; }
.repilab-table__app[aria-busy="true"] { display: grid; place-items: center; }
.repilab-table__loading { color: var(--rt-muted); }

.repilab-table__prompt {
  margin: 0 0 1rem;
  padding: 0.875rem 1rem;
  background: var(--rt-soft);
  border-left: 3px solid var(--rt-accent);
  border-radius: var(--rt-radius);
}
.repilab-table__prompt a { color: var(--rt-accent); font-weight: 600; }

/* ---- toolbar ---------------------------------------------------------------- */
.repilab-table__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem 1rem;
  padding: 1rem;
  background: var(--rt-soft);
  border-radius: var(--rt-radius);
}
.repilab-table__filters { display: contents; }
/* a select may be narrower than its longest option (long Lithuanian category names on a small phone) */
.repilab-table__field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.25rem; min-width: min(10rem, 100%); max-width: 100%; }
.repilab-table__field--search { flex: 2 1 18rem; }
/* the lists share the rest of the line evenly, whatever the length of their longest option */
.repilab-table__field:has(select) { flex: 1 1 12rem; }
@media (min-width: 600px) { .repilab-table__field:has(select) { max-width: 20rem; } }  /* one alone on a line stays a list, not a bar */
.repilab-table__field--check { display: flex; align-items: center; gap: 0.5rem; min-height: var(--rt-tap); min-width: 0; }
.repilab-table__field label { font-size: 0.8125rem; font-weight: 600; color: var(--rt-muted); }
.repilab-table__field--check label { font-size: 0.9375rem; color: var(--rt-ink); font-weight: 500; cursor: pointer; }
.repilab-table__field--check input { width: 1.25rem; height: 1.25rem; accent-color: var(--rt-accent); margin: 0; }

.repilab-table input[type="search"],
.repilab-table select,
.repilab-table__qty {
  min-height: var(--rt-tap);
  padding: 0 0.75rem;
  font: inherit;
  font-size: 1rem;
  color: var(--rt-ink);
  background: var(--rt-bg);
  border: 1px solid var(--rt-line);
  border-radius: var(--rt-radius);
  box-sizing: border-box;
}
.repilab-table input[type="search"] { width: 100%; }
.repilab-table__field select { width: 100%; min-width: 0; text-overflow: ellipsis; }
.repilab-table input:focus-visible,
.repilab-table select:focus-visible,
.repilab-table button:focus-visible,
.repilab-table a:focus-visible {
  outline: 2px solid var(--rt-accent);
  outline-offset: 2px;
}

.repilab-table__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0 0.5rem;
}
.repilab-table__count { margin: 0; color: var(--rt-muted); font-size: 0.9375rem; }

/* ---- buttons: one family, step on hover, press on click ------------------------ */
.repilab-table button {
  min-height: var(--rt-tap);
  padding: 0 1rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--rt-radius);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
/* the table is for choosing and filtering: its buttons only change colour on hover (client decision 2026-11-13) */
.repilab-table button:disabled { cursor: not-allowed; opacity: 0.5; }

.repilab-table__add,
.repilab-table__add-selected {
  color: #fff;
  background: var(--rt-accent);
  border: 1px solid var(--rt-accent);
}
.repilab-table__add:hover:not(:disabled),
.repilab-table__add-selected:hover:not(:disabled) { background: var(--rt-accent-dark); border-color: var(--rt-accent-dark); }

.repilab-table__page,
.repilab-table__reset {
  color: var(--rt-ink);
  background: var(--rt-bg);
  border: 1px solid var(--rt-line);
}
.repilab-table__page:hover:not(:disabled):not([aria-current]),
.repilab-table__reset:hover { border-color: var(--rt-ink); }

/* ---- pages (client note 2026-11-15: pages of 50 instead of "Show more") ----------- */
.repilab-table__pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.375rem; margin-top: 1.5rem; }
.repilab-table .repilab-table__page { min-width: var(--rt-tap); padding: 0 0.75rem; font-variant-numeric: tabular-nums; }
.repilab-table__page--step { font-size: 1.25rem; font-weight: 500; }
.repilab-table__page[aria-current="page"] { color: #fff; background: var(--rt-accent); border-color: var(--rt-accent); cursor: default; }
.repilab-table__gap { min-width: 1.5rem; text-align: center; color: var(--rt-muted); }
.repilab-table [hidden] { display: none !important; }

/* ---- table ---------------------------------------------------------------------- */
.repilab-table__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  margin: 0;
}
.repilab-table__table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--rt-muted);
  background: var(--rt-bg);
  border-bottom: 2px solid var(--rt-line);
}
.repilab-table__table td {
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--rt-line);
}
.repilab-table__table tbody tr { transition: background-color 0.15s ease; }
.repilab-table__table tbody tr:hover { background: var(--rt-soft); }

.repilab-table .col-sku { width: 6.5rem; white-space: nowrap; color: var(--rt-muted); font-variant-numeric: tabular-nums; }
.repilab-table .col-image { width: 4.5rem; }
.repilab-table .col-image img { display: block; width: 56px; height: 56px; object-fit: contain; border-radius: 4px; background: var(--rt-soft); }
.repilab-table__noimage { display: block; width: 56px; height: 56px; border-radius: 4px; background: var(--rt-soft); }
.repilab-table .col-name a { color: var(--rt-ink); font-weight: 500; text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size 0.2s ease; }
.repilab-table .col-name a:hover { background-size: 100% 1px; }
.repilab-table .col-price { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.repilab-table .col-price small { font-weight: 400; color: var(--rt-muted); }
.repilab-table .col-stock { width: 9rem; white-space: nowrap; }
/* without price and buy columns (a guest) the stock goes to the far edge, so the rows fill the
   width of the page instead of leaving its right half empty (client note 2026-11-15). The column
   is as wide as its longest text and its texts start on one line, so the dots stand in a column. */
.repilab-table:not(.is-cards) .repilab-table__table:not(:has(.col-price)) .col-stock { width: 1%; text-align: left; }
.repilab-table .col-buy { width: 15rem; }

.repilab-stock { display: inline-flex; align-items: center; gap: 0.375rem; font-weight: 500; }
.repilab-stock::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; flex: none; }
.repilab-stock--in-stock { color: var(--rt-ok); }
.repilab-stock--available-on-backorder { color: var(--rt-wait); }
.repilab-stock--out-of-stock { color: var(--rt-muted); }

.repilab-table__buy { display: flex; justify-content: flex-end; gap: 0.5rem; }
.repilab-table:not(.is-cards) .repilab-table__table th.col-buy { text-align: right; }
.repilab-table__add { white-space: nowrap; }
.repilab-table__qty { width: 4.5rem; padding: 0 0.5rem; text-align: center; font-variant-numeric: tabular-nums; }
.repilab-table__row-error { margin: 0.375rem 0 0; font-size: 0.8125rem; color: var(--rt-accent); }

.repilab-table__empty { padding: 3rem 1rem; text-align: center; color: var(--rt-muted); }

/* ---- cart bar ------------------------------------------------------------------- */
.repilab-table__bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--rt-bg);
  border: 1px solid var(--rt-line);
  border-radius: var(--rt-radius);
  box-shadow: 0 -6px 18px rgb(22 24 27 / 0.06);
}
.repilab-table__selected { font-weight: 600; font-variant-numeric: tabular-nums; }
.repilab-table__message { margin: 0; flex: 1 1 12rem; font-size: 0.9375rem; }
.repilab-table__message[data-state="error"] { color: var(--rt-accent); }
.repilab-table__message a { color: var(--rt-accent); font-weight: 600; }
.repilab-table__add-selected { margin-left: auto; }

/* ---- cards (the root gets .is-cards below the configured width) ------------------ */
/* the stock gets the same width in every card (room for "On order, 1–3 days") and starts on its
   left, so the dots stand in one column down the list */
.repilab-table.is-cards { --rt-card-stock: 9.5rem; }
.repilab-table.is-cards .repilab-table__table,
.repilab-table.is-cards .repilab-table__table tbody { display: block; }
.repilab-table.is-cards .repilab-table__table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.repilab-table.is-cards .repilab-table__table tbody { display: grid; gap: 0.75rem; }
.repilab-table.is-cards .repilab-table__table tr {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) var(--rt-card-stock);
  grid-template-areas: "image name name" "image sku stock" "price price price" "buy buy buy";
  gap: 0.25rem 0.75rem;
  padding: 0.875rem;
  border: 1px solid var(--rt-line);
  border-radius: var(--rt-radius);
}
.repilab-table.no-images.is-cards .repilab-table__table tr {
  grid-template-columns: minmax(0, 1fr) var(--rt-card-stock);
  grid-template-areas: "name name" "sku stock" "price price" "buy buy";
}
.repilab-table.is-cards .repilab-table__table tbody tr:hover { background: var(--rt-bg); }
.repilab-table.is-cards .repilab-table__table td { display: block; padding: 0; border: 0; width: auto; }
.repilab-table.is-cards .col-image { grid-area: image; }
.repilab-table.is-cards .col-name { grid-area: name; font-size: 1rem; }
.repilab-table.is-cards .col-sku { grid-area: sku; font-size: 0.8125rem; white-space: normal; }
.repilab-table.is-cards .col-sku::before { content: attr(data-label) " "; }
.repilab-table.is-cards .col-stock { grid-area: stock; text-align: left; font-size: 0.875rem; }
.repilab-table.is-cards .col-price { grid-area: price; font-size: 1.0625rem; margin-top: 0.25rem; }
.repilab-table.is-cards .col-buy { grid-area: buy; margin-top: 0.5rem; }
.repilab-table.is-cards .col-buy:empty,
.repilab-table.is-cards .col-price:empty { display: none; }
.repilab-table.is-cards .repilab-table__buy .repilab-table__qty { width: 5rem; }
.repilab-table.is-cards .repilab-table__buy .repilab-table__add { flex: 1; }
.repilab-table.is-cards .repilab-table__field { flex: 1 1 100%; }
.repilab-table.is-cards .repilab-table__add-selected { flex: 1 1 100%; margin-left: 0; }

@media (prefers-reduced-motion: reduce) {
  .repilab-table *, .repilab-table *::before { transition: none !important; }
}
