/* Shared pieces: pictures, cards, chips and filter bars, page heads, choice cards, dialogs and their steps. */

/* Pictures: uploads and their default pictures (images.js). Logos are shown whole; photos fill their square. */
.thumb {
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: .5rem;
  object-fit: cover;
  background-color: var(--bs-tertiary-bg);
}

.thumb-lg {
  width: 3rem;
  height: 3rem;
  border-radius: .65rem;
}

.thumb-xl {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: .75rem;
}

.thumb-logo {
  object-fit: contain;
  background-color: #fff;
  border: 1px solid var(--bs-border-color-translucent);
}

/* Picture field in forms (image-picker.js) */
.image-picker {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.image-picker-body {
  min-width: 0;
}

.image-picker-preview {
  width: 5.5rem;
  height: 5.5rem;
  flex-shrink: 0;
  border: 1px solid var(--bs-border-color);
  border-radius: .75rem;
  object-fit: cover;
  background-color: var(--bs-tertiary-bg);
}

.image-picker-store .image-picker-preview,
.image-picker-qr .image-picker-preview {
  object-fit: contain;
  background-color: #fff;
}

.image-picker-qr .image-picker-preview {
  width: 8rem;
  height: 8rem;
}

.image-picker-person .image-picker-preview {
  border-radius: 50%;
}

/* Cards */
.admin-card {
  border: 0;
  border-radius: .75rem;
  box-shadow: var(--card-shadow);
}

.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: 1rem 1.25rem;
  background-color: transparent;
}

/* Keeps absolutely positioned bits of a wide table (a visually hidden header, say) inside its scroll area; otherwise
   they sit past the right edge and make a phone's page scroll sideways. */
.table-responsive {
  position: relative;
}

.admin-card .table > :not(caption) > * > * {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.admin-card .list-group-item {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Phones keep the room for the columns themselves */
@media (max-width: 575.98px) {
  .admin-card .table > :not(caption) > * > * {
    padding-left: .75rem;
    padding-right: .75rem;
  }
}

/* Filters as chips that show their counts: "Running low 2". The chosen one is filled. */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 2.25rem;
  padding: .3rem .85rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  font-size: .875rem;
  color: var(--bs-body-color);
  background: var(--bs-body-bg);
}

.filter-chip:hover {
  background: var(--bs-tertiary-bg);
}

.filter-chip:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.filter-chip [data-count] {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.filter-chip-warn [data-count] {
  color: var(--warn-text);
}

.filter-chip-danger [data-count] {
  color: var(--bs-danger-text-emphasis);
}

.filter-chip.active {
  border-color: var(--console-accent);
  color: #fff;
  background: var(--console-accent);
}

.filter-chip.active [data-count] {
  color: inherit;
}

/* Item categories: palette keys from CategoryColors */
.category-dot {
  display: inline-block;
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  flex-shrink: 0;
  background-color: var(--category-color);
}

.category-gray { --category-color: #9ca3af; }
.category-red { --category-color: #ef4444; }
.category-orange { --category-color: #f97316; }
.category-yellow { --category-color: #eab308; }
.category-green { --category-color: #22c55e; }
.category-teal { --category-color: #14b8a6; }
.category-blue { --category-color: #3b82f6; }
.category-purple { --category-color: #a855f7; }
.category-pink { --category-color: #ec4899; }

.color-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  cursor: pointer;
  background-color: var(--category-color);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6);
}

.btn-check:checked + .color-swatch {
  outline: 3px solid var(--console-accent);
  outline-offset: 2px;
}

.btn-check:focus-visible + .color-swatch {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Choice cards (new store wizard): a radio rendered as a selectable card */
.choice-card {
  display: block;
  height: 100%;
  padding: 1rem;
  border: 1px solid var(--bs-border-color);
  border-radius: .75rem;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.choice-card:hover {
  border-color: var(--console-accent);
}

.btn-check:checked + .choice-card {
  border-color: var(--console-accent);
  background-color: color-mix(in srgb, var(--console-accent) 6%, var(--bs-body-bg));
  box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--console-accent) 20%, transparent);
}

/* A radio card has room on the right for the tick that marks it chosen, so the choice isn't shown by colour alone */
label.choice-card {
  position: relative;
  padding-right: 2.5rem;
}

.btn-check:checked + label.choice-card::after {
  content: "";
  position: absolute;
  top: .75rem;
  right: .75rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--console-accent) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='m4 8.5 2.5 2.5 5.5-6'/%3e%3c/svg%3e") center / .8rem no-repeat;
}

.btn-check:disabled + .choice-card {
  opacity: .55;
  cursor: not-allowed;
}

.btn-check:focus-visible + .choice-card {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* A card that opens something rather than being chosen (Custom POS opens the contact panel) */
button.choice-card {
  width: 100%;
  text-align: start;
  background: none;
  color: inherit;
}

button.choice-card:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.choice-icon {
  font-size: 1.75rem;
  line-height: 1;
}

/* Dialogs that add something in steps and edit it in tabs (items, inventory): the tabs under the title */
.dialog-tabs {
  flex-wrap: nowrap;
  padding: .25rem 1rem 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--bs-border-color);
}

.dialog-tabs .nav-link {
  white-space: nowrap;
}

/* Under "Step 2 of 3 · How you buy it": a segment per step, filled up to the one showing */
.step-progress {
  display: flex;
  gap: .25rem;
  width: 9rem;
  margin-top: .4rem;
}

.step-progress > span {
  flex: 1 1 0;
  height: 4px;
  border-radius: 999px;
  background-color: var(--bs-border-color);
  transition: background-color .2s ease;
}

.step-progress > .is-done {
  background-color: var(--console-accent);
}

/* Dialogs that change height from step to step (items, inventory). On a computer they open near the top rather than in
   the middle, so the title stays put and only the bottom moves. On a phone they rise from the bottom of the screen like a
   sheet, which keeps Back and Next in the same place, under the thumb. */
@media (max-width: 575.98px) {
  .modal-sheet {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
    margin: 0;
  }

  .modal-sheet .modal-content {
    max-height: calc(100% - 1.5rem);
    border: 0;
    border-radius: 1rem 1rem 0 0;
  }

  .modal-sheet .modal-footer {
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
  }

  .modal.fade .modal-dialog.modal-sheet {
    transform: translateY(100%);
    transition: transform .25s ease-out;
  }

  .modal.show .modal-dialog.modal-sheet {
    transform: none;
  }
}

@media (max-width: 575.98px) and (prefers-reduced-motion: reduce) {
  .modal.fade .modal-dialog.modal-sheet {
    transition: none;
  }
}

/* What was entered on the earlier steps, as a reminder above the later ones */
.step-summary {
  margin-bottom: 1rem;
  padding: .5rem .75rem;
  border-radius: .5rem;
  background-color: var(--bs-tertiary-bg);
  font-size: .875rem;
  color: var(--bs-secondary-color);
}

/* A smaller choice card, for choices inside a dialog */
.choice-card-sm {
  padding: .75rem;
}

/* pcs / kg / g / L / ml as equal buttons */
.unit-choice .btn {
  flex: 1 1 0;
}

/* Money and amounts don't need the full width of a dialog */
.narrow-input {
  max-width: 16rem;
}

/* A dialog's buttons as one row, with Back or Delete on the left */
.dialog-buttons {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem;
}

/* The top of every store tab's page, under the store header: what the page is (an h2, since the store's name is the h1),
   one short line about it, and its main buttons on the right. Wraps under the text on a phone. */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1rem;
  margin-bottom: 1rem;
}

.page-head-text {
  flex: 1 1 18rem;
  min-width: 0;
}

.page-head-title {
  margin-bottom: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.page-head-lead {
  margin: .125rem 0 0;
  font-size: .875rem;
  color: var(--bs-secondary-color);
}

.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

/* A row of filters above a list: chips and selects on the left, the search at the end. */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  margin-bottom: 1rem;
}

.filter-bar-search {
  margin-left: auto;
}

@media (max-width: 575.98px) {
  .filter-bar-search {
    flex: 1 1 100%;
    margin-left: 0;
  }
}

.filter-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.filter-range .form-control {
  width: auto;
}

/* A row's "more actions" button: a target big enough to tap */
.row-menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
}

.store-card-link:hover .store-card-name {
  text-decoration: underline;
}

/* A finished step, e.g. an invoice just made (back office and register): a green tick in a soft circle */
.done-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background-color: rgba(var(--bs-success-rgb), .15);
  color: var(--bs-success);
  font-size: 1.25rem;
  font-weight: 700;
}

/* A toast's own button, e.g. Undo: a full-size target. */
.toast-action {
  min-height: 44px;
  padding-inline: .85rem;
}

/* Shifts: amounts line up in their column. */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}
/* Small things used on many pages */
.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.admin-search {
  flex: 1 1 260px;
  max-width: 360px;
}

#admin-content.is-loading {
  opacity: .55;
  pointer-events: none;
  transition: opacity .15s;
}

.min-w-0 {
  min-width: 0;
}

/* Card titles (h2/h3 in a card header) at DESIGN.md's Title size, 1.125rem, so they stand above the 16px body text. */
.admin-card-header :is(h2, h3, h4).h6 {
  font-size: 1.125rem;
  line-height: 1.3;
}

/* Paragraphs balance their last line, so a single word isn't left alone under a block (Chrome and Safari; others ignore it). */
.admin-content p,
.admin-content .form-text {
  text-wrap: pretty;
}

/* Staff form (employees.js): the basic details every Santai app keeps the same way, apart from the repair station sign-in. */
.basic-box { border: 2px solid var(--bs-primary-border-subtle); background-color: var(--bs-primary-bg-subtle); border-radius: .75rem; padding: .875rem 1rem 1rem; }
[data-bs-theme="dark"] .basic-box { background-color: rgba(13, 110, 253, .08); }
.basic-box .form-control, .basic-box .form-select { background-color: var(--bs-body-bg); }
.basic-head { display: flex; align-items: center; gap: .5rem; font-weight: 600; margin-bottom: .75rem; }
.basic-head > .bi { color: var(--bs-primary); }
.basic-shared { background-color: #cfe2ff; color: #052c65; font-weight: 600; }
[data-bs-theme="dark"] .basic-shared { background-color: #0a2a5c; color: #cfe2ff; }
