/**
 * PX Booking — date picker popup (datepicker.js). Colours come from the --pxb-* variables (the popup carries the
 * .pxb class, so a template's .pxb { --pxb-*: … } map applies); --pxb-dp-* tune the popup itself.
 */
.pxb-dp {
  --pxb-dp-bg: var(--pxb-page, #fff);
  --pxb-dp-text: var(--bs-body-color, #212529);
  --pxb-dp-muted: var(--bs-secondary-color, #6c757d);
  --pxb-dp-range: color-mix(in srgb, var(--pxb-primary, #0d6efd) 10%, var(--pxb-dp-bg));
  --pxb-dp-shadow: 0 1.25rem 2.5rem -0.75rem rgba(0, 0, 0, 0.28), 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
  --pxb-dp-day: 2.5rem;
  position: absolute;
  z-index: 1080;
  width: max-content;
  max-width: calc(100vw - 16px);
  padding: 1rem 1.125rem 0.875rem;
  border: 1px solid var(--pxb-border, #dee2e6);
  border-radius: var(--pxb-radius, 0.375rem);
  background: var(--pxb-dp-bg);
  color: var(--pxb-dp-text);
  box-shadow: var(--pxb-dp-shadow);
  font-variant-numeric: tabular-nums;
}

.pxb-dp[hidden] {
  display: none;
}

.pxb-dp__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.pxb-dp__heading {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pxb-dp-muted);
}

.pxb-dp__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--pxb-border, #dee2e6);
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.pxb-dp__nav:hover:not(:disabled) {
  border-color: var(--pxb-primary, #0d6efd);
  background: var(--pxb-primary, #0d6efd);
  color: var(--pxb-on-primary, #fff);
}

.pxb-dp__nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.pxb-dp__months {
  display: flex;
  gap: 1.75rem;
}

.pxb-dp__title {
  margin: 0 0 0.5rem;
  font-weight: 600;
  text-align: center;
}

.pxb-dp__grid {
  border-collapse: collapse;
}

.pxb-dp__grid th {
  width: var(--pxb-dp-day);
  padding: 0 0 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  color: var(--pxb-dp-muted);
}

.pxb-dp__grid td {
  padding: 1px 0;
  text-align: center;
}

/* The stay as one band: the cells between arrival and departure, and the inner half of both ends. */
.pxb-dp__cell--between {
  background: var(--pxb-dp-range);
}

.pxb-dp__cell--start {
  background: linear-gradient(to right, transparent 50%, var(--pxb-dp-range) 50%);
}

.pxb-dp__cell--end {
  background: linear-gradient(to left, transparent 50%, var(--pxb-dp-range) 50%);
}

[dir="rtl"] .pxb-dp__cell--start {
  background: linear-gradient(to left, transparent 50%, var(--pxb-dp-range) 50%);
}

[dir="rtl"] .pxb-dp__cell--end {
  background: linear-gradient(to right, transparent 50%, var(--pxb-dp-range) 50%);
}

.pxb-dp__day {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--pxb-dp-day);
  height: var(--pxb-dp-day);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--pxb-radius, 0.375rem);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
}

.pxb-dp__day:hover:not([aria-disabled="true"]) {
  border-color: var(--pxb-primary, #0d6efd);
}

.pxb-dp__day--today::after {
  content: "";
  position: absolute;
  bottom: 0.3rem;
  left: 50%;
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 50%;
  background: currentColor;
  transform: translateX(-50%);
}

.pxb-dp__day--selected {
  border-color: var(--pxb-primary, #0d6efd);
  background: var(--pxb-primary, #0d6efd);
  color: var(--pxb-on-primary, #fff);
  font-weight: 600;
}

.pxb-dp__day[aria-disabled="true"] {
  color: var(--pxb-dp-muted);
  opacity: 0.45;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  cursor: default;
}

/* The arrival stays marked while the departure is picked, although it can no longer be chosen. */
.pxb-dp__day--selected[aria-disabled="true"] {
  color: var(--pxb-on-primary, #fff);
  opacity: 1;
  text-decoration: none;
}

.pxb-dp__day:focus-visible,
.pxb-dp__nav:focus-visible,
.pxb-dp__done:focus-visible {
  outline: 2px solid var(--pxb-focus-ring, #0d6efd);
  outline-offset: 2px;
}

.pxb-dp__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--pxb-border, #dee2e6);
}

.pxb-dp__summary {
  margin: 0;
  font-size: 0.875rem;
  color: var(--pxb-dp-muted);
}

.pxb-dp__done {
  padding: 0.5rem 1.125rem;
  border: 0;
  border-radius: var(--pxb-radius, 0.375rem);
  background: var(--pxb-primary, #0d6efd);
  color: var(--pxb-on-primary, #fff);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

/* Trigger: the button that replaces the date input keeps the input's classes; read like a field, not a button. */
.pxb-dp__trigger {
  display: block;
  width: 100%;
  text-align: start;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pxb-dp__trigger--empty {
  color: var(--bs-secondary-color, #6c757d);
}

/* Phones: a bottom sheet, one month. */
.pxb-dp--sheet {
  position: fixed;
  inset: auto 0 0;
  width: auto;
  max-width: none;
  padding-bottom: calc(0.875rem + env(safe-area-inset-bottom, 0px));
  border-radius: var(--pxb-radius, 0.375rem) var(--pxb-radius, 0.375rem) 0 0;
}

.pxb-dp--sheet .pxb-dp__months {
  justify-content: center;
}

.pxb-dp--sheet .pxb-dp__grid th,
.pxb-dp--sheet .pxb-dp__day {
  --pxb-dp-day: min(2.75rem, calc((100vw - 3rem) / 7));
}

@media (prefers-reduced-motion: no-preference) {
  .pxb-dp__day,
  .pxb-dp__nav {
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }
}
