/* Shared pieces of every page (UX2, owner 13 Nov 2026: "fix globally please ... try to reuse
   elements across all pages"). The Offers page's look is the model. Loaded by prices/base.html
   after pages.css, so every page gets the same tab bar, chips, "i" tip, time-since, tiny icons,
   stat line, detail list and form fields. One piece = one class here + one include in
   prices/templates/includes/ (see docs/UI_DESIGN_SYSTEM.md "Shared pieces (UX2)"). */

/* ── 1. Tab bar: one line, slides sideways, never wraps (the Offers category tabs) ── */
.tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs > .tab {
  flex: 0 0 auto;
  white-space: nowrap;
  scroll-snap-align: start;
}

/* A smaller second row under the main bar (e.g. Data Quality: Review names | Link to catalogue). */
.tabs.tabs-sub {
  gap: 0;
  margin-top: -18px;
  margin-bottom: 16px;
  border-bottom-color: var(--grey-150, var(--grey-200));
}

.tabs.tabs-sub > .tab {
  padding: 6px 12px;
  font-size: 11.5px;
}

.tab-count {
  margin-left: 5px;
  color: var(--grey-400);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

/* ── 2. Filter chips: small pills with a count, one sliding line ── */
.chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 1px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 11px;
  border: 1px solid var(--grey-200);
  border-radius: 999px;
  background: var(--white);
  color: var(--grey-600);
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--grey-300);
  color: var(--black);
}

.chip.is-current {
  border-color: var(--black);
  background: var(--black);
  color: var(--white);
}

.chip:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 2px;
}

.chip-count {
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.chip.is-alert:not(.is-current) .chip-count {
  color: var(--danger);
  opacity: 1;
}

/* ── 3. The small "i" helper tip (owner 3 Nov: "put all helpers texts in i icon with tooltip") ── */
.info-tip {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 4px;
  margin-right: 0;
  font-family: 'DM Sans', sans-serif;
  letter-spacing: normal;
  text-transform: none;
}

.info-tip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid var(--grey-300);
  border-radius: 50%;
  background: transparent;
  color: var(--grey-500);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 10px;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  cursor: help;
}

/* A 42 px tap square around the 16 px icon: 14 px inside its border + 2 x 14 (docs/UI_DESIGN_SYSTEM.md). */
.info-tip-button::before {
  content: "";
  position: absolute;
  inset: -14px;
}

.info-tip-button:hover,
.info-tip.is-open .info-tip-button,
.info-tip-button:focus-visible {
  border-color: var(--black);
  color: var(--black);
}

.info-tip-button:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 2px;
}

.info-tip-text {
  --info-tip-shift: 0px;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  z-index: 1300;
  width: max-content;
  max-width: min(280px, calc(100vw - 24px));
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--tooltip-bg, rgba(10, 10, 10, 0.92));
  color: var(--tooltip-fg, #fff);
  box-shadow: 0 8px 22px rgba(10, 10, 10, 0.18);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.45;
  letter-spacing: normal;
  text-align: left;
  text-transform: none;
  white-space: normal;
  transform: translateX(calc(-50% + var(--info-tip-shift)));
  display: none;
}

.info-tip.is-open .info-tip-text,
.info-tip:has(.info-tip-button:focus-visible) .info-tip-text,
.info-tip:has(.time-since-button:focus-visible) .info-tip-text {
  display: block;
}

@media (hover: hover) {
  .info-tip:hover .info-tip-text {
    display: block;
  }
}

/* Labels with a tip: label text and "i" on one line. */
.label-with-tip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* ── 4. "Time since" ("14m ago"): the full date on tap, hover or keyboard focus ── */
.info-tip.time-since {
  margin-left: 0;
  vertical-align: baseline;
  font-family: inherit;
}

.time-since-button {
  position: relative;
  display: inline;
  padding: 0;
  border: 0;
  border-bottom: 1px dotted var(--grey-300);
  background: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  cursor: help;
}

/* A 42 px tall tap area without changing how the text looks. */
.time-since-button::before {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  top: 50%;
  height: 42px;
  transform: translateY(-50%);
}

.time-since-button:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 2px;
}

/* ── 5. Page header: title + "i" + actions (no kicker, helper text behind the "i") ── */
.page-kicker {
  display: none;
}

.page-actions .button.page-add {
  gap: 4px;
}

/* Small secondary buttons (card links such as "See its offers"): small to look at, 42 px to tap on a phone. */
.button.small {
  position: relative;
  min-height: 30px;
  padding: 5px 11px;
  font-size: 12px;
  line-height: 18px;
}

.page-add-icon {
  flex: 0 0 auto;
}

/* ── 6. Tiny action icons on cards and rows: small to look at, 42 px to tap ── */
.icon-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.icon-actions form {
  display: inline-flex;
  margin: 0;
}

.icon-action {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--grey-500);
  cursor: pointer;
  text-decoration: none;
}

/* The invisible 42 px tap square (padding-free, so the icon row stays tiny): 28 px inside the border + 2 x 7. */
.icon-action::after {
  content: "";
  position: absolute;
  inset: -7px;
}

.icon-action svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-action:hover,
.icon-action:focus-visible {
  border-color: var(--grey-200);
  background: var(--grey-50, var(--grey-100));
  color: var(--black);
}

.icon-action:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 1px;
}

.icon-action.is-danger:hover,
.icon-action.is-danger:focus-visible {
  color: var(--danger);
}

.icon-action.is-primary {
  color: var(--black);
}

.icon-action:disabled,
.icon-action[aria-disabled="true"] {
  opacity: 0.4;
  cursor: default;
}

/* ── 7. Stat line: small bold number + grey words, inline (the Suppliers numbers) ── */
.stat-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: baseline;
  color: var(--grey-500);
  font-size: 12.5px;
  line-height: 1.4;
}

.stat strong {
  color: var(--black);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  color: var(--grey-400);
  font-size: 11.5px;
}

.stat.is-alert strong,
.stat.is-critical strong {
  color: var(--danger);
}

.stat a {
  color: inherit;
  text-decoration: none;
}

.stat a:hover strong {
  text-decoration: underline;
}

/* A linked number taps 42 px high (invisible square, the line keeps its height). */
.stat a {
  position: relative;
}

.stat a::after {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  height: 42px;
  transform: translateY(-50%);
}

/* Room between a linked number and its "i", so their tap squares do not touch. */
.stat > .info-tip {
  margin-left: 10px;
}

/* ── 8. Detail list: one compact two-column list, plain labels ── */
.detail-list dt {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  letter-spacing: normal;
  text-transform: none;
}

.detail-list dd {
  font-size: 12.5px;
}

/* ── 9. Form field: label above, compact input, help behind "i", error under it ── */
.field {
  display: grid;
  gap: 4px;
  min-width: 0;
  margin: 0 0 12px;
}

.field > label,
.field-label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--grey-600);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  width: 100%;
  max-width: 420px;
}

.field textarea {
  max-width: 640px;
}

.field-error {
  color: var(--danger);
  font-size: 12px;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
}

.field.is-switch {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
}

.field.is-switch > input[type="checkbox"] {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  appearance: none;
  position: relative;
  margin: 0;
  background: var(--grey-200);
  border: 1px solid var(--grey-300);
  cursor: pointer;
}

.field.is-switch > input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--white);
  transition: transform var(--transition);
}

.field.is-switch > input[type="checkbox"]:checked {
  background: var(--black);
  border-color: var(--black);
}

.field.is-switch > input[type="checkbox"]:checked::after {
  transform: translateX(14px);
}

.field.is-switch > .field-error {
  grid-column: 1 / -1;
}

.form-shell .field > label,
.form-shell .field .field-label {
  display: inline-flex;
  margin: 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  letter-spacing: normal;
  text-transform: none;
  color: var(--grey-600);
}

.field-required {
  color: var(--grey-400);
}

/* ── 10. Empty state: one calm line that says what to do next ── */
.empty-state {
  color: var(--grey-500);
  font-size: 12.5px;
}

/* ── Phone: 42 px tap areas, small looks ── */
@media (max-width: 767.98px) {
  .chip::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 42px;
    transform: translateY(-50%);
  }

  /* The "i" keeps 13 px from whatever is before it, so the tap squares never overlap. */
  .info-tip:not(.time-since) {
    margin-left: 13px;
  }

  .icon-action {
    width: 32px;
    height: 32px;
  }

  /* 30 px inside the border + 2 x 6 = 42 px; 12 px apart, so neighbouring squares never overlap. */
  .icon-action::after {
    inset: -6px;
  }

  .icon-actions {
    gap: 12px;
  }

  .tabs.tabs-sub {
    margin-top: -14px;
  }

  .page-actions .button {
    width: auto;
  }

  /* Header actions look small on a phone (owner: "keep everything tiny"); the tap area stays 42 px. */
  .page-header .page-actions .button,
  .page-header .page-actions summary.button {
    position: relative;
    min-height: 34px;
    min-width: 0;
    padding: 5px 11px;
    font-size: 12px;
  }

  .page-header .page-actions .button::before,
  .page-header .page-actions summary.button::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 42px;
    transform: translateY(-50%);
  }

  .button.small {
    min-width: 42px;
    min-height: 34px;
  }

  /* A title's "i" square must not reach into the chips right under it. */
  .card-title + .chips {
    margin-top: 8px;
  }

  /* Price history on a phone: the "Open" link of each day taps 42 px high. */
  .price-history-table td[data-label="Import"] a {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    margin: -11px 0;
  }

  .button.small::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 42px;
    transform: translateY(-50%);
  }
}

/* ── The staff home "Today" (UX2): one small line per job ── */
.today-group {
  display: grid;
  gap: 6px;
}

.today-group-title {
  margin: 0;
  color: var(--grey-500);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: normal;
}

.today-lines {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.today-line {
  display: flex;
  align-items: center;
  min-height: 34px;
  border-bottom: 1px solid var(--grey-150, var(--grey-200));
  font-size: 13px;
}

.today-line > a {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 0;
  color: var(--grey-700);
  text-decoration: none;
}

.today-line > a:hover {
  color: var(--black);
}

.today-line strong {
  min-width: 3ch;
  color: var(--black);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.today-line.is-alert strong {
  color: var(--danger);
}

.today-of {
  color: var(--grey-500);
}

.today-checked {
  margin: 0;
  color: var(--grey-400);
  font-size: 11.5px;
}

@media (max-width: 767.98px) {
  .today-line {
    min-height: 42px;
  }

  .today-line > a {
    align-items: center;
    min-height: 42px;
    padding: 0;
  }
}

/* A small list of checkboxes (UX2: instead of the browser's multi-select, which a phone shows as
   "Объектов: 0"). Same form field name, so the server reads it the same way. */
.check-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0 12px;
  max-height: 220px;
  overflow-y: auto;
  padding: 6px 10px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  background: var(--white);
}

.check-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: 12.5px;
  color: var(--grey-700);
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
}

.import-tool-submit {
  display: flex;
  align-items: flex-end;
}

/* A small capitals label right above a card title is a kicker: hidden, like the page kicker (UX2). */
.card-label:has(+ .card-title) {
  display: none;
}

@media (max-width: 767.98px) {
  .check-list-item {
    min-height: 42px;
  }
}

summary.icon-action {
  list-style: none;
}

summary.icon-action::-webkit-details-marker {
  display: none;
}

/* Data Quality: the switches inside the Filters fold, and the phone's sort buttons on one sliding line (UX2). */
.dq-fold-switches {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

@media (max-width: 767.98px) {
  body.dq-page .dq-mobile-sort {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    padding: 6px 1px;
    scrollbar-width: none;
  }

  body.dq-page .dq-mobile-sort::-webkit-scrollbar {
    display: none;
  }

  body.dq-page .dq-mobile-sort .button {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 12px;
  }

  body.dq-page #approve-all .page-actions .button {
    width: auto;
  }
}

/* Form save buttons stay compact on a phone (owner: "keep everything tiny"). */
@media (max-width: 767.98px) {
  .import-settings-actions .button,
  .form-actions .button {
    width: auto;
    flex: 0 0 auto;
  }
}

/* Our Catalogue: who sells this perfume (UX2, top-10 item 7). */
.our-product-supplier-facts {
  display: inline-block;
  margin-top: 4px;
  color: var(--grey-600);
  font-size: 12px;
  text-decoration: none;
}

.our-product-supplier-facts strong {
  color: var(--black);
  font-weight: 600;
}

.our-product-supplier-facts.is-empty {
  color: var(--grey-400);
}

/* Suppliers phone card: the name, the two numbers and "Last list 5mo ago" are small text but 42 px to tap
   (UX2 finish line: tap areas >= 42 px on phone cards). */
@media (max-width: 767.98px) {
  .supply-table .supply-supplier-link,
  .supply-table td.supply-col-stock a,
  .supply-table td.supply-col-tocheck a {
    position: relative;
  }

  .supply-table .supply-supplier-link::after,
  .supply-table td.supply-col-stock a::after,
  .supply-table td.supply-col-tocheck a::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: max(100% + 8px, 42px);
    height: 42px;
    transform: translate(-50%, -50%);
  }
}

@media (max-width: 767.98px) {
  /* Row checkboxes on phone cards: the label around the 18 px box is the 42 px tap area. */
  .table-workspace-row-check,
  .catalogue-row-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
  }
}

@media (max-width: 767.98px) {
  /* Offers phone card (the model page): open icon, name and supplier keep their look, 42 px to tap
     (follow-up from 12 Nov: "the open icon and supplier name tap areas are under 42 px"). */
  .products-mobile tr[data-product-id] > td[data-field="name"] .cell-name-open,
  .products-mobile tr[data-product-id] .cell-supplier,
  .products-mobile tr[data-product-id] > td[data-field="name"] .cell-name-copy {
    position: relative;
  }

  .products-mobile tr[data-product-id] > td[data-field="name"] .cell-name-open::after {
    content: "";
    position: absolute;
    inset: -11px -13px -11px -9px; /* 42 x 42 (20 px inside the border), not reaching into the name beside it */
  }

  .products-mobile tr[data-product-id] > td[data-field="name"] .cell-name-copy::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 42px;
    transform: translateY(-50%);
  }

  .products-mobile tr[data-product-id] .cell-supplier::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: max(100% + 8px, 42px);
    height: 42px;
    transform: translate(-50%, -50%);
  }
}

@media (max-width: 767.98px) {
  /* The title's "i" and the header buttons below it: tap squares never overlap. */
  .page-header {
    row-gap: 18px;
  }

  /* The "i" keeps 14 px from whatever is before it. */
  .info-tip:not(.time-since) {
    margin-left: 14px;
  }
}

@media (max-width: 767.98px) {
  /* Fragrantica phone card (owner 14 Nov: "too much spacing make cards height more compact"):
     the green box already says it is linked (the "Linked" badge is above it). */
  .fragrantica-match-panel {
    margin-top: 4px;
  }

  .fragrantica-match-panel-linked {
    gap: 6px;
    padding: 6px 10px;
  }

  .fragrantica-match-panel-linked .fragrantica-match-label {
    display: none;
  }

  .fragrantica-match-panel-linked .fragrantica-match-name {
    font-size: 13px;
  }
}

/* "5mo ago ......... 14/06/2026 23:20" (owner 14 Nov): time since on the left, the quiet full date on the right. */
.time-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
}

.time-row .time-date {
  margin-left: auto;
  color: var(--grey-400);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Detail list as compact rows: label left, value right, two columns on wide screens, one on phones
   (the supplier page facts and the Suppliers card; owner 14 Nov: "make cards height more compact"). */
.detail-list.is-rows {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 32px;
}

.detail-list.is-rows > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--grey-150, var(--grey-200));
}

.detail-list.is-rows dt {
  flex: 0 0 auto;
  margin: 0;
}

.detail-list.is-rows dd {
  min-width: 0;
  margin: 0;
  text-align: right;
}

.detail-list.is-rows dd .time-row {
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 767.98px) {
  .detail-list.is-rows,
  .supply-supplier-card .detail-list.is-rows {
    grid-template-columns: minmax(0, 1fr);
  }
}

.detail-list > .detail-list-wide {
  grid-column: 1 / -1;
}

.time-row .time-ago {
  white-space: nowrap;
}

/* ── Switch as a button: one click switches and posts its form (e.g. the supplier status on the
   supplier page). Same look as .field.is-switch; the whole label is the 42 px tap area. ── */
.switch-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 4px 0 0;
  border: 0;
  background: none;
  color: var(--grey-800);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.switch-button-track {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 20px;
  border: 1px solid var(--grey-300);
  border-radius: 999px;
  background: var(--grey-200);
  transition: background var(--transition);
}

.switch-button-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--white);
  transition: transform var(--transition);
}

.switch-button[aria-checked="true"] .switch-button-track {
  border-color: var(--black);
  background: var(--black);
}

.switch-button[aria-checked="true"] .switch-button-track::after {
  transform: translateX(14px);
}

/* A back link above a page title ("← Suppliers"): small and grey, with a 42 px tap height. */
.detail-back {
  margin: -10px 0 0;
  font-size: 12px;
}

.detail-back a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  color: var(--grey-500);
  text-decoration: none;
}

.detail-back a:hover {
  color: var(--grey-900);
}
