/* Customer numbers (客編, CUSTOMER-NUMBER-001). Every rule starts with a .cn- class, except the four name rules at the end, which
   put the customer's name back the way records-workbench.css and customer-flags.css draw it once the number sits in front of it.
   Colours are the site's own theme variables (ui-theme-mode.css defines them for the dark default and for html[data-theme="light"]).
   Each var() keeps the dark value as its fallback, for when that file is not loaded. */

.cn-card {
  box-sizing: border-box;
  width: 100%;
  max-width: min(860px, 100%);
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid var(--boba-border, rgba(255, 255, 255, 0.09));
  border-radius: 12px;
  background: var(--boba-surface, #131920);
  color: var(--boba-text, #f3f0e9);
}

.cn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.cn-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--boba-text, #f3f0e9);
}

.cn-state {
  font-size: 13px;
  color: var(--boba-text-secondary, #c9c7c1);
}

.cn-hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--boba-text-secondary, #c9c7c1);
  overflow-wrap: anywhere;
}

.cn-error {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--boba-danger, #ed746e);
  overflow-wrap: anywhere;
}

.cn-error:empty {
  display: none;
}

/* The words of the switch are for screen readers only; the label stays attached to the switch through "for". */
.cn-switch-label {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

/* A sliding switch: 44 by 24 pixels, the same as the label QR switch above it. */
.cn-switch {
  -webkit-appearance: none !important;
  appearance: none !important;
  position: relative;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 44px !important;
  height: 24px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid var(--boba-border, rgba(255, 255, 255, 0.09)) !important;
  border-radius: 12px !important;
  background: var(--boba-control, #0a1015) !important;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.cn-switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--boba-text-secondary, #c9c7c1);
  transition: transform 0.15s ease, background-color 0.15s ease;
}

/* Same weight as the label QR switch's "on" rule (the site's light-mode input rule is !important, so this one adds the id). */
.cn-card .cn-switch:checked:is(#cn-switch) {
  background: var(--boba-success, #59cb8c) !important;
  border-color: var(--boba-success, #59cb8c) !important;
}

.cn-switch:checked::before {
  transform: translateX(20px);
  background: var(--boba-surface, #131920);
}

.cn-switch:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cn-switch:focus-visible,
.cn-edit:focus-visible,
.cn-button:focus-visible,
.cn-input:focus-visible {
  outline: 2px solid var(--boba-brand, #d4a650);
  outline-offset: 2px;
}

/* The number on a customer: monospaced digits in a small outlined box. Explicit colours, so it reads the same in both modes. */
.cn-badge {
  display: inline-block;
  flex: 0 0 auto;
  box-sizing: border-box;
  padding: 1px 6px;
  border: 1px solid var(--boba-border-strong, rgba(224, 178, 91, 0.34));
  border-radius: 6px;
  background: var(--boba-control, #0a1015);
  color: var(--boba-text, #f3f0e9);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The number line on the customers page's name, and in the customer's header the badge sits before the name. */
.cn-editor {
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  width: 100%;
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--boba-text, #f3f0e9);
}

.cn-editor-label {
  font-size: 13px;
  color: var(--boba-text-secondary, #c9c7c1);
}

.cn-editor-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.cn-none {
  font-weight: 400;
  color: var(--boba-text-secondary, #c9c7c1);
}

.cn-edit,
.cn-button {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--boba-border-strong, rgba(224, 178, 91, 0.34));
  border-radius: 8px;
  background: transparent;
  color: var(--boba-text, #f3f0e9);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.cn-button-primary {
  background: var(--boba-brand, #d4a650);
  border-color: var(--boba-brand, #d4a650);
  color: var(--boba-surface, #131920);
  font-weight: 600;
}

.cn-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cn-dialog {
  box-sizing: border-box;
  width: min(380px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 20px;
  border: 1px solid var(--boba-border-strong, rgba(224, 178, 91, 0.34));
  border-radius: 14px;
  background: var(--boba-surface-raised, #181f27);
  color: var(--boba-text, #f3f0e9);
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.45);
}

.cn-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.cn-dialog-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 700;
  color: var(--boba-text, #f3f0e9);
}

.cn-field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--boba-text-secondary, #c9c7c1);
}

.cn-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--boba-border-strong, rgba(224, 178, 91, 0.34));
  border-radius: 8px;
  background: var(--boba-control, #0a1015);
  color: var(--boba-text, #f3f0e9);
  font: inherit;
  font-size: 16px;
}

.cn-dialog-error {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--boba-danger, #ed746e);
  overflow-wrap: anywhere;
}

.cn-dialog-error:empty {
  display: none;
}

.cn-open-holder {
  margin-top: 8px;
}

.cn-open-holder[hidden] {
  display: none;
}

.cn-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* The name on the customers page: the same text rules as .rw-person>strong, now one level down inside the number line. */
.rw-person>.cn-name-line {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
  font-size: inherit;
  color: inherit;
}

.rw-person>.cn-name-line>strong {
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

/* A customer with a flag: the flag's own line keeps the 12px muted text that .rw-person>span gave it before. */
.rw-person>.cn-name-line>.cf-record-name {
  min-width: 0;
  font-size: 12px;
  color: var(--rw-muted, #9aa3ad);
}

@media (max-width: 480px) {
  .cn-card {
    padding: 10px 12px;
  }
}

/* CUSTOMER-NUMBER-001-R2 section 3: in a customer's title, the number and the name keep the same gap as in the list, on the phone
   and on the desktop (the title is not a flex line, so the gap is a margin). */
h2 > .cn-badge {
  margin-right: 6px;
  vertical-align: middle;
}
