/*
 * Hospitality Layer for QloApps - hsprates: front office (FOLIO_ERP_RATES_REPORTS §5.4 - §5.5).
 * Room page: the meal plans inside hspcore's ONE "Meal plan" fieldset (its option cards come from hspcore-board.css,
 * the description line of a meal plan is styled here), the restrictions note, the "Rate" choice cards (name, what the
 * rate changes for the stay, refundable or not as word + icon + tone, the policy in a disclosure), the service charge.
 * Cart: "Meal plan and rate" of a room group and its editor. Order detail / confirmation: the rooms' meal plan and rate.
 * hspui tokens (DESIGN_SYSTEM §5; colours without fallbacks, sizes with), logical properties only (RTL mirrors by
 * itself; prices are LTR islands in the text), 44px targets, the selected card unmistakable (surface + border + inset
 * ring + filled radio), only opacity animates, reduced motion and forced colours respected, one column at 375px.
 *
 * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
 */

/* the hidden attribute is the state of the editor, its messages and the "not available" lines */
.hsp-rates-book [hidden],
.hsp-rates-cart [hidden],
.hsp-rates-order [hidden] {
  display: none !important; /* allow-list: the hidden attribute is the state */
}

.hsp-rates-sr {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ meal plans in hspcore's fieldset */

.hsp-board-option--meal .hsp-board-option__desc {
  font-size: var(--hsp-fs-xs, 1.3rem);
  line-height: var(--hsp-lh-xs, 1.4);
  color: var(--hsp-color-text-muted);
}

.hsp-board-option--meal .hsp-board-option__name i {
  inline-size: 1.6rem;
  text-align: center;
}

.hsp-board-option--meal:has(input:checked) .hsp-board-option__desc {
  color: var(--hsp-color-text-secondary);
}

/* ------------------------------------------------------------------ room page block */

.hsp-rates-book {
  display: flex;
  flex-direction: column;
  gap: var(--hsp-space-3, 12px);
  margin: 0 0 var(--hsp-space-4, 16px);
}

.hsp-rates-book:empty {
  display: none;
}

/* notices: why these dates cannot be booked, a replaced rate (tone + icon + words) */
.hsp-rates-notice {
  display: flex;
  align-items: flex-start;
  gap: var(--hsp-space-2, 8px);
  margin: 0;
  padding: var(--hsp-space-3, 12px);
  font-size: var(--hsp-fs-sm, 1.4rem);
  line-height: var(--hsp-lh-sm, 1.45);
  border: var(--hsp-border-w, 1px) solid transparent;
  border-radius: var(--hsp-radius-md, 8px);
}

.hsp-rates-notice > i {
  flex: none;
  margin-block-start: 0.2rem;
  font-size: var(--hsp-icon-sm, 1.6rem);
}

.hsp-rates-notice--warning {
  color: var(--hsp-tone-warning-fg);
  background-color: var(--hsp-tone-warning-bg);
  border-color: color-mix(in srgb, var(--hsp-tone-warning-solid) 35%, transparent);
}

.hsp-rates-notice--info {
  color: var(--hsp-tone-info-fg);
  background-color: var(--hsp-tone-info-bg);
  border-color: color-mix(in srgb, var(--hsp-tone-info-solid) 30%, transparent);
}

.hsp-rates-notice__body {
  min-inline-size: 0;
}

.hsp-rates-notice__title {
  margin: 0 0 var(--hsp-space-1, 4px);
  font-weight: var(--hsp-fw-semibold, 600);
}

.hsp-rates-notice__list {
  margin: 0 0 var(--hsp-space-1, 4px);
  padding-inline-start: var(--hsp-space-5, 20px);
}

.hsp-rates-notice__list li + li {
  margin-block-start: var(--hsp-space-1, 4px);
}

.hsp-rates-notice__hint {
  margin: 0;
  color: var(--hsp-color-text-secondary);
}

/* the "Rate" fieldset: same card language as the meal plan options */
.hsp-rates-choice {
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
  transition: opacity var(--hsp-dur-fast, 150ms) var(--hsp-ease-standard, ease);
}

.hsp-rates-choice[aria-busy="true"] {
  opacity: 0.6;
}

.hsp-rates-choice__legend {
  float: none;
  inline-size: auto;
  margin: 0 0 var(--hsp-space-2, 8px);
  padding: 0;
  font-size: var(--hsp-fs-body, 1.6rem);
  font-weight: var(--hsp-fw-semibold, 600);
  line-height: 1.4;
  color: var(--hsp-color-text-strong);
  border: 0;
}

.hsp-rates-choice__options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--hsp-space-2, 8px);
}

.hsp-rates-option {
  display: flex;
  align-items: flex-start;
  gap: var(--hsp-space-3, 12px);
  min-block-size: var(--hsp-fo-control-md, 4.8rem);
  margin: 0;
  padding: var(--hsp-space-3, 12px) var(--hsp-space-4, 16px);
  font-weight: var(--hsp-fw-regular, 400);
  color: var(--hsp-color-text);
  background-color: var(--hsp-color-surface);
  border: var(--hsp-border-w, 1px) solid var(--hsp-color-border-control);
  border-radius: var(--hsp-radius-md, 8px);
  cursor: pointer;
}

.hsp-rates-option:hover {
  background-color: var(--hsp-color-surface-hover);
}

.hsp-rates-option:has(input:checked) {
  color: var(--hsp-color-text-selected);
  background-color: var(--hsp-color-surface-selected);
  border-color: var(--hsp-color-border-selected);
  box-shadow: inset 0 0 0 1px var(--hsp-color-border-selected);
}

.hsp-rates-option:has(input:focus-visible) {
  outline: 2px solid transparent;
  box-shadow: var(--hsp-focus-ring);
}

.hsp-rates-option.is-disabled {
  color: var(--hsp-color-text-disabled);
  background-color: var(--hsp-color-surface-muted);
  border-style: dashed;
  cursor: not-allowed;
}

.hsp-rates-option__input {
  flex: none;
  margin: 0.3rem 0 0;
  accent-color: var(--hsp-color-action);
}

.hsp-rates-option__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--hsp-space-1, 4px);
  min-inline-size: 0;
}

.hsp-rates-option__head,
.hsp-rates-option__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--hsp-space-1, 4px) var(--hsp-space-2, 8px);
}

.hsp-rates-option__name {
  font-size: var(--hsp-fs-body, 1.6rem);
  font-weight: var(--hsp-fw-semibold, 600);
  color: var(--hsp-color-text-strong);
}

.hsp-rates-option__name i {
  color: var(--hsp-color-action);
}

/* what the rate is (−10 %, −$15.00 per room per night): a quiet chip, a saving in the success tone */
.hsp-rates-option__change {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--hsp-space-2, 8px);
  font-size: var(--hsp-fs-xs, 1.3rem);
  font-weight: var(--hsp-fw-medium, 500);
  line-height: 2.2rem;
  color: var(--hsp-tone-neutral-fg);
  background-color: var(--hsp-tone-neutral-bg);
  border-radius: var(--hsp-radius-pill, 999px);
}

.hsp-rates-option--saving .hsp-rates-option__change {
  color: var(--hsp-tone-success-fg);
  background-color: var(--hsp-tone-success-bg);
}

/* what it changes for this stay: the line guests compare at a glance */
.hsp-rates-option__diff {
  font-size: var(--hsp-fs-sm, 1.4rem);
  font-weight: var(--hsp-fw-semibold, 600);
  color: var(--hsp-color-text-strong);
  font-variant-numeric: tabular-nums;
}

.hsp-rates-option--saving .hsp-rates-option__diff {
  color: var(--hsp-tone-success-fg);
}

.hsp-rates-option.is-disabled :is(.hsp-rates-option__name, .hsp-rates-option__diff) {
  color: var(--hsp-color-text-disabled);
}

.hsp-rates-option__na {
  font-size: var(--hsp-fs-xs, 1.3rem);
  color: var(--hsp-color-text-secondary);
}

/* refundable or not: word + icon + tone, never colour alone */
.hsp-rates-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--hsp-space-1, 4px);
  padding: 0 var(--hsp-space-2, 8px);
  font-size: var(--hsp-fs-xs, 1.3rem);
  font-weight: var(--hsp-fw-medium, 500);
  line-height: 2.2rem;
  white-space: nowrap;
  border: var(--hsp-border-w, 1px) solid transparent;
  border-radius: var(--hsp-radius-pill, 999px);
}

.hsp-rates-badge--ok {
  color: var(--hsp-tone-success-fg);
  background-color: var(--hsp-tone-success-bg);
}

.hsp-rates-badge--warn {
  color: var(--hsp-tone-warning-fg);
  background-color: var(--hsp-tone-warning-bg);
  border-color: color-mix(in srgb, var(--hsp-tone-warning-solid) 35%, transparent);
}

.hsp-rates-choice__details {
  display: flex;
  flex-direction: column;
  gap: var(--hsp-space-1, 4px);
  margin-block-start: var(--hsp-space-2, 8px);
}

.hsp-rates-choice__note {
  margin: var(--hsp-space-2, 8px) 0 0;
  padding: var(--hsp-space-2, 8px) var(--hsp-space-3, 12px);
  font-size: var(--hsp-fs-sm, 1.4rem);
  color: var(--hsp-tone-info-fg);
  background-color: var(--hsp-tone-info-bg);
  border-radius: var(--hsp-radius-sm, 6px);
}

/* cancellation policy: a disclosure outside the labels (a <details> inside a <label> would toggle the radio) */
.hsp-rates-policy {
  font-size: var(--hsp-fs-sm, 1.4rem);
}

.hsp-rates-policy > summary {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--hsp-space-1, 4px);
  min-block-size: 4.4rem;
  font-weight: var(--hsp-fw-medium, 500);
  color: var(--hsp-color-text-link);
  cursor: pointer;
}

.hsp-rates-policy > summary:focus-visible {
  outline: 2px solid transparent;
  border-radius: var(--hsp-radius-xs, 4px);
  box-shadow: var(--hsp-focus-ring);
}

.hsp-rates-policy__name {
  color: var(--hsp-color-text-secondary);
}

.hsp-rates-policy > p {
  max-inline-size: 68ch;
  margin: 0 0 var(--hsp-space-2, 8px);
  color: var(--hsp-color-text);
  white-space: normal;
}

/* a single rate: one line, no choice to make */
.hsp-rates-single {
  padding: var(--hsp-space-3, 12px) var(--hsp-space-4, 16px);
  background-color: var(--hsp-color-surface);
  border: var(--hsp-border-w, 1px) solid var(--hsp-color-border-subtle);
  border-radius: var(--hsp-radius-md, 8px);
}

.hsp-rates-single__line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--hsp-space-1, 4px) var(--hsp-space-2, 8px);
  margin: 0;
}

.hsp-rates-single__label {
  font-size: var(--hsp-fs-sm, 1.4rem);
  color: var(--hsp-color-text-secondary);
}

.hsp-rates-single__name {
  font-weight: var(--hsp-fw-semibold, 600);
  color: var(--hsp-color-text-strong);
}

/* service charge of the hotel */
.hsp-rates-service {
  display: flex;
  align-items: flex-start;
  gap: var(--hsp-space-2, 8px);
  margin: 0;
  font-size: var(--hsp-fs-sm, 1.4rem);
  line-height: var(--hsp-lh-sm, 1.45);
  color: var(--hsp-color-text-secondary);
}

.hsp-rates-service > i {
  flex: none;
  margin-block-start: 0.2rem;
  color: var(--hsp-tone-info-solid);
}

/* ------------------------------------------------------------------ cart: meal plan and rate of a room group */

.hsp-rates-cart {
  margin: var(--hsp-space-3, 12px) 0 0;
  padding: var(--hsp-space-3, 12px) var(--hsp-space-4, 16px);
  background-color: var(--hsp-color-surface-sunken);
  border: var(--hsp-border-w, 1px) solid var(--hsp-color-border-subtle);
  border-radius: var(--hsp-radius-md, 8px);
}

.hsp-rates-cart__title {
  display: flex;
  align-items: center;
  gap: var(--hsp-space-2, 8px);
  margin: 0 0 var(--hsp-space-2, 8px);
  font-size: var(--hsp-fs-body, 1.6rem);
  font-weight: var(--hsp-fw-semibold, 600);
  color: var(--hsp-color-text-strong);
}

.hsp-rates-cart__title i {
  color: var(--hsp-color-action);
}

.hsp-rates-cart .hsp-rates-notice {
  margin-block-end: var(--hsp-space-2, 8px);
}

.hsp-rates-cart__facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--hsp-space-2, 8px) var(--hsp-space-6, 24px);
  margin: 0;
}

.hsp-rates-cart__fact {
  min-inline-size: 0;
}

.hsp-rates-cart__fact dt {
  font-size: var(--hsp-fs-xs, 1.3rem);
  font-weight: var(--hsp-fw-regular, 400);
  color: var(--hsp-color-text-secondary);
}

.hsp-rates-cart__fact dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--hsp-space-1, 4px) var(--hsp-space-2, 8px);
  margin: 0;
  font-weight: var(--hsp-fw-semibold, 600);
  color: var(--hsp-color-text-strong);
}

.hsp-rates-cart__rooms {
  display: grid;
  gap: var(--hsp-space-2, 8px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.hsp-rates-cart__rooms > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--hsp-space-1, 4px) var(--hsp-space-2, 8px);
}

.hsp-rates-cart__actions {
  margin: var(--hsp-space-2, 8px) 0 0;
}

.hsp-rates-cart .btn.hsp-rates-cart__change {
  display: inline-flex;
  align-items: center;
  gap: var(--hsp-space-2, 8px);
  min-block-size: 4.4rem;
  max-inline-size: 100%;
  white-space: normal;
  text-align: start;
}

.hsp-rates-cart__change[aria-expanded="true"] {
  border-color: var(--hsp-color-border-selected);
}

.hsp-rates-cart__editor {
  display: flex;
  flex-direction: column;
  gap: var(--hsp-space-3, 12px);
  margin-block-start: var(--hsp-space-3, 12px);
  padding-block-start: var(--hsp-space-3, 12px);
  border-block-start: var(--hsp-border-w, 1px) solid var(--hsp-color-border-subtle);
}

.hsp-rates-cart__set {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--hsp-space-2, 8px);
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.hsp-rates-cart__set > legend {
  float: none;
  inline-size: auto;
  margin: 0 0 var(--hsp-space-1, 4px);
  padding: 0;
  font-size: var(--hsp-fs-sm, 1.4rem);
  font-weight: var(--hsp-fw-semibold, 600);
  color: var(--hsp-color-text-strong);
  border: 0;
}

.hsp-rates-option--compact {
  padding: var(--hsp-space-2, 8px) var(--hsp-space-3, 12px);
}

.hsp-rates-option--compact .hsp-rates-option__name {
  font-size: var(--hsp-fs-sm, 1.4rem);
}

.hsp-rates-cart__total {
  margin: 0;
  font-size: var(--hsp-fs-body, 1.6rem);
  font-weight: var(--hsp-fw-semibold, 600);
  color: var(--hsp-color-text-strong);
  font-variant-numeric: tabular-nums;
}

.hsp-rates-cart__total:empty {
  display: none;
}

.hsp-rates-cart__error {
  margin: 0;
  padding: var(--hsp-space-2, 8px) var(--hsp-space-3, 12px);
  font-size: var(--hsp-fs-sm, 1.4rem);
  color: var(--hsp-tone-danger-fg);
  background-color: var(--hsp-tone-danger-bg);
  border-radius: var(--hsp-radius-sm, 6px);
}

.hsp-rates-cart__buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--hsp-space-2, 8px);
  margin: 0;
}

.hsp-rates-cart__buttons .btn {
  min-block-size: 4.4rem;
  white-space: normal;
}

.hsp-rates-cart__save[aria-busy="true"] {
  opacity: 0.7;
  cursor: progress;
}

/* ------------------------------------------------------------------ order detail and confirmation */

.hsp-rates-order {
  margin: var(--hsp-space-4, 16px) 0;
  padding: var(--hsp-space-4, 16px);
  background-color: var(--hsp-color-surface);
  border: var(--hsp-border-w, 1px) solid var(--hsp-color-border-subtle);
  border-radius: var(--hsp-radius-lg, 12px);
}

.hsp-rates-order__title {
  display: flex;
  align-items: center;
  gap: var(--hsp-space-2, 8px);
  margin: 0 0 var(--hsp-space-3, 12px);
  font-size: var(--hsp-fs-h4, 1.8rem);
  font-weight: var(--hsp-fw-semibold, 600);
  color: var(--hsp-color-text-strong);
}

.hsp-rates-order__title i {
  color: var(--hsp-color-action);
}

.hsp-rates-order__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hsp-rates-order__room {
  padding: var(--hsp-space-2, 8px) 0;
}

.hsp-rates-order__room + .hsp-rates-order__room {
  border-block-start: var(--hsp-border-w, 1px) solid var(--hsp-color-border-subtle);
}

.hsp-rates-order__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--hsp-space-2, 8px);
  margin: 0 0 var(--hsp-space-1, 4px);
}

.hsp-rates-order__name {
  font-weight: var(--hsp-fw-semibold, 600);
  color: var(--hsp-color-text-strong);
}

.hsp-rates-order__line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--hsp-space-1, 4px) var(--hsp-space-2, 8px);
  margin: 0;
  color: var(--hsp-color-text);
}

/* ------------------------------------------------------------------ Arabic, phones, motion, forced colours */

html[lang^="ar"] :is(.hsp-rates-badge, .hsp-rates-option__change, .hsp-rates-option__na, .hsp-board-option--meal .hsp-board-option__desc) {
  font-size: var(--hsp-fs-sm, 1.4rem);
}

@media (max-width: 479px) {
  .hsp-rates-option {
    padding-inline: var(--hsp-space-3, 12px);
  }

  .hsp-rates-cart {
    padding-inline: var(--hsp-space-3, 12px);
  }

  .hsp-rates-cart__buttons .btn,
  .hsp-rates-cart .btn.hsp-rates-cart__change {
    flex: 1 1 100%;
    justify-content: center;
    inline-size: 100%;
  }

  .hsp-rates-order {
    padding: var(--hsp-space-3, 12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hsp-rates-choice {
    transition: none;
  }
}

@media (forced-colors: active) {
  .hsp-rates-option,
  .hsp-rates-badge,
  .hsp-rates-option__change,
  .hsp-rates-notice,
  .hsp-rates-cart,
  .hsp-rates-single,
  .hsp-rates-order {
    border: 1px solid CanvasText;
  }

  .hsp-rates-option:has(input:checked) {
    border: 3px solid Highlight;
  }

  .hsp-rates-option.is-disabled {
    border-color: GrayText;
    color: GrayText;
  }
}

/* ------------------------------------------------------------------ compact booking card (coordinator review 2026-10-03)
   The booking card is narrow (about 260px): with four meal plans and two rates it grew to 1,800px and "Book now" fell
   far below. One row per option: the name and the price for the stay; the per-night prices and the description show
   for the selected option only. Screen readers still hear them: each radio points to them with aria-describedby,
   which reads referenced elements even when they are not displayed. */
/* the theme's ".product_wrapper label { display: block }" (0,1,1) beat the cards' own flex row (0,1,0) on the room page:
   the radio sat on its own line above the text. Two classes win and restore the row. */
.hsp-board-choice .hsp-board-option,
.hsp-rates-choice .hsp-rates-option {
  display: flex;
}

.hsp-board-choice--product .hsp-board-option,
.hsp-rates-book .hsp-rates-option {
  min-block-size: 4.4rem;
  padding: var(--hsp-space-2, 8px) var(--hsp-space-3, 12px);
}

.hsp-board-choice--product .hsp-board-option:has(.hsp-board-option__estimate):not(:has(input:checked)) .hsp-board-option__price,
.hsp-board-choice--product .hsp-board-option:not(:has(input:checked)) .hsp-board-option__desc {
  display: none;
}

/* name and price for the stay on one line when they fit (they do in Arabic); the selected option's details below */
.hsp-board-choice--product .hsp-board-option__body,
.hsp-rates-book .hsp-rates-option__body {
  flex-flow: row wrap;
  align-items: baseline;
  justify-content: space-between;
  column-gap: var(--hsp-space-2, 8px);
  row-gap: 0;
}

.hsp-board-choice--product .hsp-board-option__estimate {
  order: 1;
  font-weight: var(--hsp-fw-semibold, 600);
  color: var(--hsp-color-text);
}

.hsp-board-choice--product .hsp-board-option__price {
  flex-basis: 100%;
  order: 2;
}

.hsp-board-choice--product .hsp-board-option__desc {
  flex-basis: 100%;
  order: 3;
}
