/* 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;
}

/* A store's payment QRs (Store > Settings): the picture, its name and note, then its actions. */
.payment-qr-row {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .75rem 1.25rem;
}

.payment-qr-thumb {
  width: 3.5rem;
  height: 3.5rem;
  flex-shrink: 0;
  padding: .125rem;
  border: 1px solid var(--bs-border-color);
  border-radius: .5rem;
  object-fit: contain;
  background-color: #fff;
}

.payment-qr-text {
  flex: 1;
  min-width: 0;
}

.payment-qr-actions {
  display: flex;
  flex-shrink: 0;
  gap: .375rem;
}

.payment-qr-actions .btn {
  min-width: 36px;
  min-height: 36px;
}

/* Fingers: 44px, whatever the root size (it's 14px on phones). */
@media (any-pointer: coarse), (max-width: 767.98px) {
  .payment-qr-row {
    gap: .625rem;
    padding-inline: .75rem;
  }

  .payment-qr-actions .btn {
    min-width: 44px;
    min-height: 44px;
  }
}

.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;
}

/* Fingers: 44px, as every touch target. */
@media (any-pointer: coarse), (max-width: 767.98px) {
  .filter-chip {
    min-height: 44px;
  }
}

/* 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 (inventory, purchases, trade-ins, transfers, counts). 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. The item
   dialog no longer uses it: it is a drawer (.item-drawer in store.css), full height, so its buttons never move. */
@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;
}

/* A table row that opens its own page when clicked anywhere (the first cell also has a real link). */
.row-link {
  cursor: pointer;
}

/* The phone field's country code beside the number, as narrow as its longest code ("+880 BD"). */
.input-group > .phone-code {
  flex: 0 0 6.5rem;
  width: 6.5rem;
  padding-right: 1.75rem;
  background-position: right .5rem center;
}

/* Add store: a tile to pick the logo, beside the name (the same in Santai Repair). */
.logo-pick-wrap { position: relative; width: 4rem; }
.logo-pick { display: grid; place-items: center; width: 4rem; height: 4rem; padding: 0; overflow: hidden; border: 1px dashed var(--bs-border-color); border-radius: .75rem; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); font-size: 1.5rem; }
.logo-pick:hover { border-color: var(--bs-primary); color: var(--bs-primary); }
.logo-pick:focus-visible { outline: 3px solid var(--bs-primary); outline-offset: 2px; }
.logo-pick img { width: 100%; height: 100%; object-fit: contain; }
.logo-pick-clear { position: absolute; top: -.4rem; right: -.4rem; display: grid; place-items: center; width: 1.4rem; height: 1.4rem; padding: 0; border: 1px solid var(--bs-border-color); border-radius: 50%; background: var(--bs-body-bg); color: var(--bs-secondary-color); font-size: .65rem; }
.logo-pick-clear:hover { color: var(--bs-danger); }
@media (any-pointer: coarse) { .logo-pick-clear { width: 2rem; height: 2rem; top: -.75rem; right: -.75rem; } }

/* Address suggestions under a field (the same in Santai Repair). */
.suggest-list { position: absolute; z-index: 5; top: calc(100% + .25rem); left: 0; right: 0; max-height: 16rem; overflow-y: auto; margin: 0; padding: .25rem; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: .5rem; box-shadow: 0 .5rem 1.25rem rgba(0, 0, 0, .15); }
.suggest-list [role="option"] { padding: .5rem .625rem; border-radius: .375rem; font-size: .875rem; cursor: pointer; }
.suggest-list [role="option"]:hover, .suggest-list [role="option"][aria-selected="true"] { background: var(--bs-tertiary-bg); }
.suggest-list .suggest-credit { padding: .375rem .625rem .125rem; font-size: .6875rem; color: var(--bs-secondary-color); }
.suggest-list .suggest-credit a { color: inherit; }
@media (any-pointer: coarse) { .suggest-list [role="option"] { padding: .75rem .625rem; } }

/* A field's icon, inside it at the left (rule in CLAUDE.md): the same icon the card shows for that fact. */
.field-icon { position: relative; }
.field-icon > .field-icon-mark { position: absolute; z-index: 4; left: .8rem; top: .55rem; font-size: 1.05rem; color: var(--bs-secondary-color); pointer-events: none; }
.field-icon > .form-control { padding-left: 2.5rem; }
.field-icon > .position-relative > .form-control { padding-left: 2.5rem; }
.field-icon > .input-group > .phone-code, .field-icon > .input-group > .repair-phone-code { flex-basis: 8.5rem; width: 8.5rem; padding-left: 2.5rem; }

/* What's wrong, said with an icon (form-design-system in CLAUDE.md): a field's message and a form's alert. */
.invalid-feedback::before,
.modal .alert-danger::before,
.item-label-settings .alert-danger::before,
.modal .alert-warning::before,
#item-modal .alert-danger::before,
#item-modal .alert-warning::before,
#option-rows-error:not(:empty)::before,
.sell-line [data-reason]::before {
  font-family: bootstrap-icons !important;
  font-style: normal;
  content: "\f333";
  margin-right: .35rem;
  vertical-align: -.1em;
}

/* An icon inside an input-group (a number with its unit, a name with its button): the first control leaves room for it. */
.input-group.field-icon > .field-icon-mark + .form-control { padding-left: 2.5rem; margin-left: 0; border-top-left-radius: var(--bs-border-radius); border-bottom-left-radius: var(--bs-border-radius); }
.input-group.field-icon > .field-icon-mark { z-index: 4; }
.field-icon:has(> .form-control-lg) > .field-icon-mark { top: .8rem; font-size: 1.2rem; }
.field-icon:has(> .form-control-sm) > .field-icon-mark { top: .4rem; font-size: .95rem; }
.input-group-lg.field-icon > .field-icon-mark { top: .8rem; font-size: 1.2rem; }
.input-group-sm.field-icon > .field-icon-mark { top: .4rem; font-size: .95rem; }

/* A wizard's Next carries its arrow (the label, "Next: Stock", is set by the page). */
#item-next::after,
#stock-item-next::after {
  font-family: bootstrap-icons !important;
  font-style: normal;
  content: "\f138";
  margin-left: .4rem;
  vertical-align: -.1em;
}

/* A field's icon sits beside its label, before the words (form-design-system in CLAUDE.md). A field with no visible label
   (a search, a filter) keeps its icon inside, as .field-icon. */
.label-icon { margin-right: .4rem; font-size: 1em; color: var(--bs-secondary-color); vertical-align: -.1em; }

/* Staff form (employees.js): the basic details every Santai app keeps the same way, apart from SantaiPOS's own 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; }
