/* Payment banner + schedule + pay dialog (template-parts/payment-schedule.php, assets/js/payment-schedule.js).
   The block adapts to the width of ITS OWN container (container queries), not the viewport: stacked layout below
   ~360px, title and description in one row with the actions on the right from ~560px. */

.rpr-pay {
  container-type: inline-size;
  container-name: pay;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0 4px;
  width: 100%;
}

/* ---- One status chip: fixed size, 4 variants. The words carry the meaning, colour only supports it. ---- */
.rpr-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.rpr-chip.is-paid {
  background: #e3f6e9;
  border-color: #b7e4c7;
  color: #0b5d34;
}

.rpr-chip.is-due {
  background: #fff4d6;
  border-color: #f2d27a;
  color: #7a5200;
}

.rpr-chip.is-upcoming {
  background: #eef1f6;
  border-color: #d5dbe6;
  color: #3d4a5e;
}

.rpr-chip.is-processing {
  background: #e6f0fb;
  border-color: #b9d3f0;
  color: #17457a;
}

.rpr-chip.is-overdue {
  background: #fde8e6;
  border-color: #f2b8b2;
  color: #a4180e;
}

/* ---- Banner: ONE primary call to action for the next payment ---- */
.rpr-pay-banner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--rpr-radius-md);
  border: 1px solid var(--rpr-border-strong);
  background: var(--rpr-bg-hover-3);
  color: var(--rpr-text);
}

.rpr-pay-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 14px;
  line-height: 1.4;
}

.rpr-pay-banner-text span {
  color: var(--rpr-text-secondary);
  font-size: 13px;
}

.rpr-pay-banner .rpr-btn-primary {
  width: 100%;
  padding: 11px 18px;
  font-size: 14px;
}

.rpr-pay-banner.is-processing {
  background: #eef5fd;
  border-color: #b9d3f0;
}

.rpr-pay-banner.is-overdue {
  background: #fef3f2;
  border-color: #f4b4ae;
}

.rpr-pay-banner.is-overdue .rpr-pay-banner-text strong {
  color: #a4180e;
}

.rpr-pay-banner.is-overdue .rpr-btn-primary {
  background: #c8281a;
}

/* ---- Schedule ---- */
.rpr-pay-card {
  border: 1px solid var(--rpr-border);
  border-radius: var(--rpr-radius-md);
  background: #fff;
  overflow: hidden;
}

.rpr-pay-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  font-size: 14px;
}

.rpr-pay-card-head::-webkit-details-marker {
  display: none;
}

.rpr-pay-card-title {
  font-weight: 600;
  color: var(--rpr-text);
}

.rpr-pay-card-sub {
  color: var(--rpr-text-secondary);
  font-variant-numeric: tabular-nums;
}

.rpr-pay-card-head:focus-visible,
.rpr-pay-early:focus-visible,
.rpr-pay-invoices a:focus-visible,
.rpr-pay-banner .rpr-btn-primary:focus-visible {
  outline: 2px solid var(--rpr-blue);
  outline-offset: 2px;
}

.rpr-pay-list {
  list-style: none;
  margin: 0;
  padding: 0 16px;
}

/* An item = two lines: title + amount, then description + chip (+ a small "Pay early" for later items). */
.rpr-pay-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-top: 1px solid var(--rpr-border);
}

.rpr-pay-item-line1,
.rpr-pay-item-line2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  min-width: 0;
}

.rpr-pay-item-line2 {
  flex-wrap: wrap;
}

.rpr-pay-item-title {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--rpr-text);
}

.rpr-pay-item-amount {
  white-space: nowrap;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--rpr-text);
}

.rpr-pay-item-sub {
  flex: 1 1 140px;
  min-width: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--rpr-text-secondary);
}

.rpr-pay-item-tail {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.rpr-pay-early {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--rpr-blue);
  text-decoration: underline;
  cursor: pointer;
}

.rpr-pay-early:hover {
  color: var(--rpr-navy);
}

.rpr-pay-item.is-paid .rpr-pay-item-amount {
  color: var(--rpr-text-secondary);
}

/* Wide container: title and description share one row, the chip / link sit on the right. */
@container pay (min-width: 560px) {
  .rpr-pay-item {
    display: grid;
    grid-template-columns: minmax(150px, 0.9fr) minmax(0, 1.4fr) auto auto;
    align-items: center;
    column-gap: 16px;
  }

  .rpr-pay-item-line1,
  .rpr-pay-item-line2 {
    display: contents;
  }

  .rpr-pay-item-title {
    order: 1;
  }

  .rpr-pay-item-sub {
    order: 2;
    flex: none;
  }

  .rpr-pay-item-tail {
    order: 3;
    margin-left: 0;
  }

  .rpr-pay-item-amount {
    order: 4;
    min-width: 96px;
  }
}

@container pay (min-width: 360px) {
  .rpr-pay-banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .rpr-pay-banner .rpr-btn-primary {
    width: auto;
    white-space: nowrap;
  }
}

/* ---- Summary: Total / Paid / Balance share one number format ---- */
.rpr-pay-summary {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--rpr-border);
  background: var(--rpr-bg-hover-3);
  font-size: 14px;
}

.rpr-pay-summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.rpr-pay-summary dt {
  color: var(--rpr-text-secondary);
}

.rpr-pay-summary dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--rpr-text);
}

.rpr-pay-summary .is-balance dd {
  font-weight: 700;
}

.rpr-pay-item-deposit {
  order: 5; /* below the title / description / chip / amount, spanning the whole row in the wide grid layout */
  grid-column: 1 / -1;
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--rpr-text-secondary);
}

.rpr-pay-fineprint {
  margin: 0;
  padding: 8px 16px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--rpr-text-faint);
  background: var(--rpr-bg-hover-3);
}

/* ---- Invoices: "RPR-2026-0007 · Nov 16 · $1,500.00" ---- */
.rpr-pay-invoices {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--rpr-border);
}

.rpr-pay-invoices-title {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--rpr-text-faint);
}

.rpr-pay-invoices ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rpr-pay-invoices li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 3px 0;
  font-size: 13px;
  color: var(--rpr-text-secondary);
}

.rpr-pay-invoices a {
  font-weight: 600;
  color: var(--rpr-blue);
}

.rpr-pay-inv-amount {
  font-variant-numeric: tabular-nums;
}

/* ---- Pay dialog ---- */
.rpr-paymodal[hidden] {
  display: none;
}

.rpr-paymodal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.rpr-paymodal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 40, 0.5);
}

.rpr-paymodal-box {
  position: relative;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  background: #fff;
  border-radius: var(--rpr-radius-lg) var(--rpr-radius-lg) 0 0;
  padding: 22px 18px 18px;
  box-shadow: var(--rpr-shadow-modal);
}

.rpr-paymodal-x {
  position: absolute;
  top: 10px;
  right: 14px;
  border: 0;
  background: none;
  font-size: 26px;
  line-height: 1;
  color: var(--rpr-text-secondary);
  cursor: pointer;
}

.rpr-paymodal-title {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--rpr-navy);
}

.rpr-paymodal-sub {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--rpr-text-secondary);
}

.rpr-paymodal-element {
  min-height: 80px;
}

.rpr-paymodal-error {
  margin-top: 12px;
  font-size: 13px;
  color: var(--rpr-error);
}

.rpr-paymodal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 16px;
}

.rpr-paymodal-actions .rpr-btn-primary[disabled] {
  opacity: 0.6;
  cursor: default;
}

@media (min-width: 640px) {
  .rpr-paymodal {
    align-items: center;
  }

  .rpr-paymodal-box {
    max-width: 460px;
    border-radius: var(--rpr-radius-lg);
  }
}
