/*
 * Shared components (spec 7.3, handoff section 6). Borders instead of shadows;
 * corners and control heights come from the frame through --radius-control
 * and --input-height (square and 50px on the site, 6px and 40px in the console).
 */
/* In the console, panels (cards, KPI tiles, tables) take 12px corners and a
   hairline edge; controls take the 8px of --radius-control. */
.console .card,
.console .kpi,
.console .table-wrap {
  border-color: rgba(239, 231, 218, 0.09);
  border-radius: 12px;
}

.console {
  --radius-control: var(--radius-console);
  --input-height: var(--input-height-console);
  --control-font-size: 14px;
}

/* Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: var(--target-min);
  margin: 0;
  border: 1px solid transparent;
  font-family: var(--font-text);
  font-weight: var(--weight-label);
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard),
    color var(--motion-fast) var(--ease-standard);
}

/* Site: 52px, tracked capitals, square. */
.btn--site {
  height: var(--button-height-site);
  padding: 0 28px;
  border-radius: var(--radius-site);
  font-size: var(--type-label-size);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* Console: 40px, sentence case, 6px corners. */
.btn--console {
  height: var(--button-height-console);
  padding: 0 var(--space-4);
  border-radius: var(--radius-console);
  font-size: 14px;
  letter-spacing: 0;
}

.btn--primary {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--ebony);
}

.btn--primary:hover {
  background: var(--brass-light);
  border-color: var(--brass-light);
}

.btn--primary:active {
  background: var(--brass-deep);
  border-color: var(--brass-deep);
}

.btn--secondary {
  background: transparent;
  border-color: var(--ivory);
  color: var(--ivory);
}

.btn--secondary.btn--console {
  border-color: var(--smoke);
}

.btn--secondary:hover {
  background: var(--walnut-2);
}

.btn--secondary:active {
  border-color: var(--brass);
}

.btn--text {
  min-width: 0;
  padding: 0 var(--space-1);
  background: transparent;
  color: var(--ivory);
  text-decoration-line: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
}

.btn--text:hover {
  text-decoration-color: var(--brass);
}

.btn--text.btn--console {
  color: var(--brass);
}

.btn--text.btn--console:hover {
  color: var(--brass-light);
  text-decoration-color: currentColor;
}

/* An icon before a button's label (ui_button()'s icon option). */
.btn__icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-left: -2px;
}

.btn--site .btn__icon {
  width: 18px;
  height: 18px;
}

/* Disabled buttons keep their colours but lose hover and pointer; the page
   says why nearby (component inventory, button-primary). */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Touch screens get 44px targets in the console too. */
@media (pointer: coarse) {
  .btn--console {
    height: var(--target-min);
  }
}

/* Fields ------------------------------------------------------------------ */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.field__label {
  font-size: 13px;
  line-height: 1.4;
  color: var(--sand);
}

.field__hint,
.field__error {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.field__hint {
  color: var(--sand);
}

.field__error {
  color: var(--alert);
}

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  margin: 0;
  background: var(--walnut-2);
  border: 1px solid var(--field-edge);
  border-radius: var(--radius-control);
  color: var(--ivory);
  font-family: var(--font-text);
  font-size: var(--control-font-size);
  caret-color: var(--brass);
  -webkit-appearance: none;
  appearance: none;
}

.input,
.select {
  height: var(--input-height);
  padding: 0 14px;
}

.textarea {
  min-height: 96px;
  padding: var(--space-3) 14px;
  line-height: 1.6;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--stone);
  opacity: 1;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
  border-color: var(--brass);
}

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

.input:disabled,
.select:disabled,
.textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Browsers paint autofilled fields light; an inset fill keeps them walnut. It
   is not a visible shadow. */
.input:-webkit-autofill {
  -webkit-text-fill-color: var(--ivory);
  box-shadow: 0 0 0 1000px var(--walnut-2) inset;
}

/* Native select with a sand chevron. */
.select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23B8AC99' stroke-width='1.4'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
}

.input--code {
  max-width: 14rem;
  font-size: 22px;
  letter-spacing: 0.3em;
  font-variant-numeric: tabular-nums;
}

/* The code as six boxes (assets/js/sign-in.js). The real field stays in the
   form, out of sight, and carries the digits. */
.field--otp .otp__source {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
  white-space: nowrap;
}

.otp {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  max-width: 400px;
}

.otp__cell {
  width: 100%;
  min-width: 0;
  height: 60px;
  padding: 0;
  border: 1px solid var(--field-edge);
  border-radius: var(--radius-control);
  background: var(--walnut);
  color: var(--ivory);
  font-family: var(--font-text);
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  caret-color: var(--brass);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--motion-fast) var(--ease-standard),
    background-color var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard);
}

.otp__cell:focus {
  outline: none;
  border-color: var(--brass);
  background: var(--walnut-2);
  box-shadow: 0 0 0 3px rgba(184, 150, 104, 0.28);
}

.otp--complete .otp__cell {
  border-color: var(--brass-deep);
}

.otp--sending .otp__cell {
  opacity: 0.6;
}

.otp--error .otp__cell {
  border-color: var(--alert);
}

.otp--shake {
  animation: otp-shake 420ms var(--ease-standard);
}

@keyframes otp-shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@media (max-width: 380px) {
  .otp {
    gap: 6px;
  }

  .otp__cell {
    height: 52px;
    font-size: 22px;
  }
}

/* Checkbox and radio: native controls, brass when checked, 44px hit area on the label. */
.checkbox {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: var(--space-3);
}

.checkbox__input,
.radio-group__input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--brass);
  cursor: pointer;
}

.checkbox__label,
.radio-group__label {
  display: flex;
  align-items: center;
  min-height: var(--target-min);
  font-size: 15px;
  line-height: 1.4;
  cursor: pointer;
}

.checkbox .field__hint,
.checkbox .field__error {
  grid-column: 2;
}

.checkbox--error .checkbox__input {
  outline: 2px solid var(--alert);
  outline-offset: 2px;
}

.radio-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.radio-group__legend {
  margin-bottom: var(--space-1);
  padding: 0;
  font-size: 13px;
  color: var(--sand);
}

.radio-group__option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.console .checkbox__label,
.console .radio-group__label {
  font-size: 14px;
}

/* Status chips: status colour on its own tint, fully rounded, led by a dot
   of the same colour; the word always carries the state. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: var(--weight-label);
  line-height: 1.4;
  white-space: nowrap;
}

.chip::before {
  content: '';
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chip--ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.chip--pending {
  color: var(--pending);
  background: var(--pending-bg);
}

.chip--alert {
  color: var(--alert);
  background: var(--alert-bg);
}

.chip--info {
  color: var(--info);
  background: var(--info-bg);
}

.chip--neutral {
  color: var(--sand);
  background: var(--smoke-soft);
}

/* Avatars: a person's initials on a muted tint (ui_avatar()). Six tints
   drawn from the palette's warm and water tones, never a status colour. */
.avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid transparent;
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: var(--weight-label);
  line-height: 1;
  letter-spacing: 0.02em;
  user-select: none;
}

.avatar--sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.avatar--lg {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.avatar--tone-0 { background: rgba(184, 150, 104, 0.16); border-color: rgba(184, 150, 104, 0.32); color: #D9C29C; }
.avatar--tone-1 { background: rgba(94, 126, 120, 0.2); border-color: rgba(94, 126, 120, 0.42); color: #A9C7C0; }
.avatar--tone-2 { background: rgba(176, 112, 86, 0.18); border-color: rgba(176, 112, 86, 0.38); color: #DDA58E; }
.avatar--tone-3 { background: rgba(138, 140, 96, 0.18); border-color: rgba(138, 140, 96, 0.4); color: #C7C79F; }
.avatar--tone-4 { background: rgba(110, 124, 152, 0.2); border-color: rgba(110, 124, 152, 0.42); color: #B3BFD6; }
.avatar--tone-5 { background: rgba(146, 108, 132, 0.18); border-color: rgba(146, 108, 132, 0.4); color: #CFB0C4; }

/* A name with its avatar, as a table's first cell or a list row's lead. */
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.person__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Tables ------------------------------------------------------------------ */
/* Narrow screens scroll the table inside its card; wide screens let the
   sticky header follow the page. */
.table-wrap {
  /* Positioned, so the visually hidden text inside a table scrolls with it
     instead of being placed against the page and widening it on a phone
     (phase 9 audit, WCAG 1.4.10). */
  position: relative;
  width: 100%;
  overflow-x: auto;
}

@media (min-width: 960px) {
  .table-wrap {
    overflow-x: visible;
  }
}

/* Below that, a console table keeps a readable width and scrolls inside its
   card, rather than squeezing names onto a letter a line. */
@media (max-width: 959px) {
  .console .table {
    min-width: 640px;
  }

  /* Names and their lines stay whole; the table scrolls instead. */
  .console .table .person__text > *,
  .console .table .residence-cell__text > * {
    white-space: nowrap;
  }
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.table th {
  position: sticky;
  top: var(--table-sticky-top, 0);
  z-index: 1;
  padding: 10px 14px;
  background: var(--walnut);
  border-bottom: 1px solid var(--smoke);
  color: var(--sand);
  font-size: 12px;
  font-weight: var(--weight-label);
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--smoke-soft);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td,
.table tbody tr[aria-selected="true"] td {
  background: var(--walnut-2);
}

.table .table__empty {
  padding: var(--space-6) 14px;
  color: var(--sand);
  text-align: center;
}

.table tbody tr:hover .table__empty {
  background: transparent;
}

/* Cards and KPI tiles: walnut on a smoke border, never a shadow. */
.card {
  min-width: 0;
  background: var(--walnut);
  border: 1px solid var(--smoke);
  border-radius: var(--radius-control);
}

.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 14px var(--space-5);
  border-bottom: 1px solid var(--smoke-soft);
}

.card__title {
  margin: 0;
  font-family: var(--font-text);
  font-size: 16px;
  font-weight: var(--weight-label);
  line-height: 1.4;
  color: var(--ivory);
}

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

.card__body {
  padding: var(--space-5);
}

/* A table that is the whole card body runs edge to edge. */
.card__body > .table-wrap:only-child {
  margin: calc(var(--space-5) * -1);
  width: calc(100% + var(--space-5) * 2);
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  padding: var(--space-4) var(--space-5);
  background: var(--walnut);
  border: 1px solid var(--smoke);
  border-radius: var(--radius-control);
}

.kpi__label {
  margin: 0;
  font-size: 13px;
  color: var(--sand);
}

/* Figures in Jost Light: the self-hosted Cormorant only has old-style
   figures, where 0 reads as a letter o. */
.kpi__value {
  margin: 0;
  font-family: var(--font-text);
  font-weight: 300;
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ivory);
  font-variant-numeric: lining-nums tabular-nums;
}

.kpi__sub {
  margin: 0;
  font-size: 13px;
  color: var(--stone);
}

/* Notices: the status colour on its tint, with a rule on the leading edge. */
.notice {
  padding: var(--space-3) var(--space-4);
  border-left: 2px solid currentColor;
  border-radius: var(--radius-control);
  font-size: 14px;
  line-height: 1.55;
}

.notice--ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.notice--pending {
  color: var(--pending);
  background: var(--pending-bg);
}

.notice--alert {
  color: var(--alert);
  background: var(--alert-bg);
}

.notice--info {
  color: var(--info);
  background: var(--info-bg);
}

/* Price line: one price, never struck through (hard rule 4). */
.price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
}

.price__amount {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  font-size: 32px;
  line-height: 1.1;
  color: var(--ivory);
  font-variant-numeric: lining-nums;
  text-decoration: none;
}

.price__suffix {
  font-size: 14px;
  color: var(--sand);
}

.price__privilege {
  margin: var(--space-1) 0 0;
  font-size: 14px;
  color: var(--brass);
}

/* Image placeholders: walnut blocks with a small stone caption until photos arrive. */
.placeholder {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--walnut);
  border-radius: var(--radius-control);
}

.placeholder--16-9 {
  aspect-ratio: 16 / 9;
}

.placeholder--4-3 {
  aspect-ratio: 4 / 3;
}

.placeholder--1-1 {
  aspect-ratio: 1 / 1;
}

.placeholder--3-4 {
  aspect-ratio: 3 / 4;
}

.placeholder--21-9 {
  aspect-ratio: 21 / 9;
}

.placeholder__caption {
  position: absolute;
  left: var(--space-5);
  bottom: var(--space-4);
  right: var(--space-5);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  color: var(--stone);
}

/* Media library photos: the <img> fills its frame at its own ratio; pages
   that crop (heroes, cards) set object-fit in their own stylesheet. */
.picture {
  display: block;
}

.picture__img {
  display: block;
  width: 100%;
  height: auto;
}

/* Logo: never narrower than 96px (handoff section 6). */
.logo {
  display: block;
  width: 104px;
  min-width: 96px;
  height: auto;
}

/* The confirmation dialog (console simplification design, Part 2) ----------
   One per page (ui_confirm_dialog()), filled in and opened by
   assets/js/confirm.js. A 12px panel with 8px controls in the console and the
   partner portal; square in My Luxuri, as the site. The alert colour marks a
   destructive action, on its icon and its action button. */
.confirm-dialog {
  width: min(440px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid rgba(239, 231, 218, 0.09);
  border-radius: 12px;
  background: var(--walnut);
  color: var(--ivory);
  font-family: var(--font-text);
}

.confirm-dialog--account {
  border-radius: 0;
}

.confirm-dialog::backdrop {
  background: rgba(20, 17, 14, 0.82);
}

.confirm-dialog__body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: var(--space-4);
  row-gap: var(--space-2);
  align-items: start;
  padding: var(--space-6) var(--space-6) var(--space-4);
}

.confirm-dialog__mark {
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--pending-bg);
  color: var(--brass);
}

.confirm-dialog__mark--danger,
.confirm-dialog[data-tone="danger"] .confirm-dialog__mark--default {
  display: none;
}

.confirm-dialog[data-tone="danger"] .confirm-dialog__mark--danger {
  display: inline-flex;
  background: var(--alert-bg);
  color: var(--alert);
}

.confirm-dialog__icon {
  width: 22px;
  height: 22px;
}

.confirm-dialog__title,
.confirm-dialog__text {
  grid-column: 2;
  margin: 0;
  /* An email address or a long name has nowhere to break; wrap it rather than
     run past the panel. */
  overflow-wrap: anywhere;
}

.confirm-dialog__title {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  font-size: 26px;
  line-height: 1.15;
  color: var(--ivory);
}

.confirm-dialog__text {
  font-size: 15px;
  font-weight: var(--weight-body);
  line-height: 1.55;
  color: var(--sand);
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6) var(--space-6);
}

.confirm-dialog[data-tone="danger"] .confirm-dialog__ok {
  background: var(--alert);
  border-color: var(--alert);
  color: var(--ebony);
}

.confirm-dialog[data-tone="danger"] .confirm-dialog__ok:hover {
  border-color: var(--ivory);
}

@media (max-width: 639px) {
  .confirm-dialog__body {
    padding: var(--space-5) var(--space-5) var(--space-3);
  }

  .confirm-dialog__actions {
    flex-direction: column;
    padding: var(--space-3) var(--space-5) var(--space-5);
  }

  .confirm-dialog__actions .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .confirm-dialog[open] {
    animation: confirm-dialog-in var(--motion-fast) var(--ease-standard);
  }

  .confirm-dialog[open]::backdrop {
    animation: confirm-dialog-fade var(--motion-fast) var(--ease-standard);
  }
}

@keyframes confirm-dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes confirm-dialog-fade {
  from {
    opacity: 0;
  }
}

/* The pressed button while its confirmed request runs (assets/js/confirm.js). */
.btn[data-confirm-working] {
  cursor: progress;
}
