/* ==========================================================================
   Service Catalogue — Business

   What the practice charges for: the sections on the invoice builder and the
   services under them. One scrolling page showing all of it at once, because
   this screen is read with a fee schedule beside it and a price list you have
   to page through is a price list nobody checks.

   Scrolls as a page rather than as a table filling the viewport, the way the
   bulk importer's hub does — it is panels and tables together rather than one
   listing (see components/bulk_import and components/table).
   ========================================================================== */
.service-catalogue__scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding-bottom: var(--space-6);
}

/* The standing note about what a price change does and does not touch, and the
   same note over the edit form. Informational rather than a warning: nothing
   here is dangerous, it is just the thing everybody wants confirming. */
.service-catalogue__note {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  background-color: var(--tint-navy-04);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary-dark);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: var(--font-size-medium);
}

.service-catalogue__note .minor-icon {
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--color-primary-dark);
}

.service-catalogue__note strong {
  color: var(--color-text);
}

/* == A section == */
.service-catalogue__section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  /* Anchored to after a change, so the browser must not park it under the
     sticky page header (see ServiceCatalogueSectionsController). */
  scroll-margin-top: var(--space-6);
}

.service-catalogue__section-header {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

/* The whole heading is the fold's toggle: a header you can only open by hitting
   a chevron is a header most people never open. Stripped back to text so it
   reads as the heading it is rather than as a button. */
.service-catalogue__section-toggle {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0;
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.service-catalogue__section-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.service-catalogue__section-chevron {
  display: flex;
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform var(--transition-base);
}

/* Points down when the section is open, right when it is folded — the direction
   it will move in rather than the state it is in. */
.service-catalogue__section:not(.is-open) .service-catalogue__section-chevron {
  transform: rotate(-90deg);
}

/* The gap between the header and the body belongs to the body, so a folded
   section is the header and nothing else rather than a header with a hole
   under it (see the section's own `gap`). */
.service-catalogue__section-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.service-catalogue__section-body[hidden] {
  display: none;
}

.service-catalogue__section-heading {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  min-width: 0;
}

.service-catalogue__section-title {
  font-size: var(--font-size-large);
  font-family: var(--font-family-bold);
  font-weight: 600;
  color: var(--color-primary-dark);
  margin: 0;
}

.service-catalogue__section-count,
.service-catalogue__section-empty {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  margin: 0;
}

.service-catalogue__section-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

/* == The list of services == */
.service-catalogue__table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-medium);
}

.service-catalogue__table th,
.service-catalogue__table td {
  padding: var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.service-catalogue__table thead th {
  font-size: var(--font-size-small);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}

.service-catalogue__table tbody tr:last-child th,
.service-catalogue__table tbody tr:last-child td {
  border-bottom: none;
}

.service-catalogue__row:hover {
  background-color: var(--tint-navy-04);
}

.service-catalogue__row {
  scroll-margin-top: var(--space-6);
}

.service-catalogue__name {
  font-weight: 500;
  color: var(--color-text);
}

/* The one column anybody scans down. Tabular figures so the decimal points line
   up, which is the whole reason to right-align a price at all. */
.service-catalogue__price-column {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.service-catalogue__table th.service-catalogue__price-column {
  text-align: right;
}

.service-catalogue__treatment-none {
  color: var(--color-text-muted);
}

.service-catalogue__tag {
  display: inline-block;
  padding: 2px var(--space-2);
  margin-right: var(--space-1);
  font-size: var(--font-size-small);
  color: var(--color-primary-dark);
  background-color: var(--tint-navy-06);
  border-radius: var(--radius-full);
  cursor: help;
}

.service-catalogue__row-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* `button_to` wraps each button in a form, which is a block element and would
   otherwise break the row of actions onto its own line. */
.service-catalogue__row-actions form,
.service-catalogue__section-actions form {
  display: inline-flex;
  margin: 0;
}

/* == Up and down == */
.service-catalogue__move {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.service-catalogue__move-form {
  display: inline-flex;
  margin: 0;
}

.service-catalogue__move-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background-color: var(--color-surface);
  color: var(--color-primary-dark);
  cursor: pointer;
}

.service-catalogue__move-form + .service-catalogue__move-form .service-catalogue__move-button {
  border-left: 1px solid var(--color-border);
}

.service-catalogue__move-button:hover:not(:disabled) {
  background-color: var(--tint-navy-10);
}

.service-catalogue__move-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* The end of the list keeps its buttons and greys them, rather than dropping
   one — a row of actions that changes width as you move down the table takes
   the next button out from under the pointer. */
.service-catalogue__move-button:disabled {
  color: var(--color-text-muted);
  opacity: 0.4;
  cursor: default;
}

/* == The retired drawer == */
.service-catalogue__archived {
  padding: var(--space-4) var(--space-5);
  background-color: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
}

.service-catalogue__archived-summary {
  cursor: pointer;
  font-size: var(--font-size-medium);
  font-weight: 500;
  color: var(--color-primary-dark);
}

.service-catalogue__archived-note {
  margin: var(--space-3) 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

/* == Empty catalogue, and the restore offer == */
.service-catalogue__empty {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-6);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.service-catalogue__empty h2 {
  font-size: var(--font-size-large);
  color: var(--color-primary-dark);
  margin: 0;
}

.service-catalogue__empty p,
.service-catalogue__restore p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-medium);
  max-width: 62ch;
}

.service-catalogue__empty-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-2);
}

.service-catalogue__empty-actions form,
.service-catalogue__restore form {
  margin: 0;
}

.service-catalogue__restore {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  background-color: var(--tint-navy-04);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
}

/* == The two forms == */
.service-catalogue__form {
  max-width: 640px;
}

.service-catalogue__flags {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  border: none;
  padding: 0;
  margin: 0;
}

/* The checkbox rows carry a title and an explanation rather than a single line,
   so they align to the top of the box instead of the middle of the block. */
.service-catalogue__flags .form__checkbox-option {
  align-items: flex-start;
}

.service-catalogue__flags .form__checkbox-option strong {
  display: block;
  color: var(--color-text);
}

.service-catalogue__flags .form__hint {
  margin-top: var(--space-1);
}
