/* ============================================
   Change Plan Modal (cpm-) — Scoped Styles
   ============================================ */

.cpm-overlay {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  z-index: 9999999;
  overflow-y: auto;
  font-family: "Poppins", sans-serif;

  /* borrowed from the Ghost popup, adapted */
  background: linear-gradient(315deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.1) 100%);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transform: translate3d(0, 0, 0);
}

.cpm-overlay.cpm-is-open {
  display: flex;
  animation: fadein 0.2s;
}

/* Popup entrance for the modal content (mirrors Ghost's popup animation) */
.cpm-overlay.cpm-is-open .cpm-modal {
  animation: popup 0.25s ease-in-out;
}

@keyframes fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes popup {
  0% {
    transform: translateY(-30px);
    opacity: 0;
  }
  1% {
    transform: translateY(30px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.cpm-modal {
  background: #fff;
  border-radius: 12px;
  max-width: 1300px;
  width: 100%;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  position: relative;
}

/* Header */
.cpm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.cpm-title {
  font-family: var(--primary-font);
  font-weight: 400;
  font-size: 32px;
  line-height: 40px;
  letter-spacing: -4%;
  color: var(--black);
  margin: 0;
  flex: 1;
  text-align: center;
}

.cpm-back-btn,
.cpm-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #555;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s;
}

/* .cpm-back-btn:hover,
.cpm-close-btn:hover {
  background: #f2f2f2;
} */

/* Toggle */
.cpm-toggle-wrap {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-size: 14px;
  color: #666;
}

.cpm-toggle-label--active {
  color: var(--black);
  font-weight: 500;
}

.cpm-toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}

.cpm-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.cpm-slider {
  position: absolute;
  inset: 0;
  /* background: var(--black); */
  border-radius: 22px;
  transition: 0.3s;
  cursor: pointer;
  border: 1px solid var(--black);
}

.cpm-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  top: 2px;
  background: var(--black);
  border-radius: 50%;
  transition: 0.3s;
}

.cpm-toggle-switch input:checked + .cpm-slider::before {
  transform: translateX(20px);
}

/* Plans Grid */
.cpm-plans-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

/* Hide whichever plan view (individual/team) is not active */
.cpm-plans-grid[hidden] {
  display: none;
}

/* Team view: two cards, centered */
.cpm-plans-grid--team {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

.cpm-plan-card {
  display: flex;
  flex-direction: column;
  padding: 4px;
}

.cpm-plan-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}

.cpm-plan-name {
  font-family: var(--primary-font);
  font-weight: 400;
  font-size: 32px;
  line-height: 40px;
  letter-spacing: -4%;
  color: var(--black);
  margin: 0 0 8px 0;
}

.cpm-plan-desc {
  font-size: 16px;
  color: #666;
  margin: 0;
  line-height: 1.4;
}

.cpm-plan-badge {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

/* Pricing */
.cpm-price-wrap {
  display: flex;
  align-items: self-end;
  gap: 6px;
  margin-bottom: 6px;
}

.cpm-price {
  font-family: var(--primary-font);
  font-weight: 400;
  font-size: 42px;
  line-height: 40px;
  letter-spacing: -4%;
  color: var(--black);
  margin-top: 0;
  margin-bottom: 0;
}

.cpm-price-period {
  font-size: 14px;
  color: #888;
  line-height: 1.3;
}

.cpm-price-total {
  font-size: 14px;
  color: #999;
  margin: 0 0 20px 0;
}

/* Features */
.cpm-features-intro {
  font-size: 13px;
  color: var(--black);
  margin: 0 0 12px 0;
}

.cpm-features-list {
  list-style: none;
  padding: 0;
  margin-top: 0;
  margin-bottom: 0;
  flex: 1;
}

.cpm-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 16px;
  font-weight: 300;
  color: var(--black);
  margin-bottom: 10px;
  line-height: 24px;
}

.cpm-feature-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  /* margin-top: 1px; */
  background: url("https://pma-assets-external.ams3.cdn.digitaloceanspaces.com/Janrey-test/bullet-point.svg") no-repeat center center;
  background-size: contain;
  /* hide the ✓ fallback glyph */
  font-size: 0;
  line-height: 0;
  color: transparent;
}

.cpm-more-text {
  font-size: 13px;
  color: #888;
  margin: 0 0 16px 0;
}

/* Buttons */
.cpm-select-btn {
  width: 100%;
  padding: 12px;
  background: var(--black);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 12px;
  transition: background 0.2s;
  text-align: center;
  text-decoration: none;
  line-height: 17px;
  box-sizing: border-box;
}

.cpm-select-btn:hover {
  background: var(--brand);
}

/* Current plan — disabled, non-clickable */
.cpm-select-btn--current,
.cpm-select-btn--current:hover {
  background: #e0e0e0;
  color: #888;
  cursor: default;
  pointer-events: none;
}

.cpm-learn-link {
  display: block;
  text-align: center;
  font-size: 14px;
  color: var(--black);
  text-decoration: underline;
}

/* Footer */
.cpm-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  /* background: #f7f7f7; */
  border-radius: 8px;
  margin-top: 16px;
  border: 1px solid #c5d2d9;
}

.cpm-footer-text {
  font-size: 14px;
  color: #6C6C6C;
  line-height:22px;
  margin: 0;
  display: block;
}

.cpm-footer-date {
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  color: var(--black);
  margin: 0;
}

.cpm-cancel-btn {
  background: none;
  border: none;
  color: #ff5252;
  font-size: 14px;
  cursor: pointer;
  font-weight: 400;
}

/* Renew subscription — shown when cancel_at_period_end is true */
.cpm-renew-btn {
  background: #ff5252;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 28px;
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 17px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.cpm-renew-btn:hover {
  background: #09100f;
  color: #f9f8f5;
}

.cpm-renew-btn[hidden] {
  display: none;
}

#ghost-portal-root .account-plan {
  display: none;
}

/* Scheduled plan change notice — pending downgrade that applies at renewal */
.cpm-scheduled-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  border: 1px solid #f0c36d;
  background: #fff8e6;
  border-radius: 8px;
}

.cpm-scheduled-notice[hidden] {
  display: none;
}

.cpm-scheduled-notice__icon {
  display: inline-flex;
  flex-shrink: 0;
  color: #b7791f;
}

.cpm-scheduled-notice__body {
  flex: 1;
}

.cpm-scheduled-notice__text {
  margin: 0;
  font-size: 14px;
  line-height: 21px;
  color: #6b5418;
}

.cpm-scheduled-notice__cancel {
  flex-shrink: 0;
  background: none;
  border: 1px solid #b7791f;
  color: #b7791f;
  border-radius: 8px;
  padding: 8px 16px;
  font-family: "Poppins", sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.cpm-scheduled-notice__cancel:hover {
  background: #b7791f;
  color: #fff;
}

/* Responsive */
@media (max-width: 768px) {
  .cpm-plans-grid {
    grid-template-columns: 1fr;
  }
  .cpm-modal {
    padding: 20px;
  }
  .cpm-footer {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .cpm-scheduled-notice {
    flex-direction: column;
    align-items: flex-start;
  }
}
/* Loading indicator for select-plan buttons (in-place plan switch) */
.cpm-select-btn.is-loading,
.cpm-renew-btn.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: progress;
}

.cpm-select-btn .checkout-spinner,
.cpm-renew-btn .checkout-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: checkout-spin 0.6s linear infinite;
  vertical-align: middle;
  flex: 0 0 auto;
  margin-right: 8px;
}

@keyframes checkout-spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   Change Plan Confirmation (cpm-confirm-)
   ============================================ */
.cpm-confirm-overlay {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 99999999; /* above the change-plan modal */
  font-family: "Poppins", sans-serif;
  background: linear-gradient(315deg, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0.35) 100%);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transform: translate3d(0, 0, 0);
}

.cpm-confirm-overlay.cpm-is-open {
  display: flex;
  animation: fadein 0.2s;
}

.cpm-confirm-overlay.cpm-is-open .cpm-confirm-modal {
  animation: popup 0.25s ease-in-out;
}

.cpm-confirm-modal {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: 588px;
  max-width: 100%;
  height: auto;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.cpm-confirm-x {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  padding: 4px;
  line-height: 0;
}

.cpm-confirm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-bottom: 20px;
}

.cpm-confirm-title {
  font-family: var(--primary-font);
  font-weight: 400;
  font-size: 28px;
  line-height: 36px;
  letter-spacing: -4%;
  color: var(--black);
  margin: 0 0 12px 0;
}

.cpm-confirm-text {
  font-size: 14px;
  font-weight: 300;
  line-height: 22px;
  color: #6C6C6C;
  margin: 0 0 28px 0;
}

.cpm-confirm-breakdown {
  border: 1px solid #E5E5E5;
  border-radius: 8px;
  padding: 16px;
  margin: 0 0 28px 0;
}

.cpm-confirm-breakdown__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  line-height: 22px;
  color: #6C6C6C;
}

.cpm-confirm-breakdown__row + .cpm-confirm-breakdown__row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #F0F0F0;
}

.cpm-confirm-breakdown__row strong {
  font-weight: 500;
  color: var(--black);
  white-space: nowrap;
}

.cpm-confirm-breakdown__note {
  font-size: 12px;
  font-weight: 300;
  line-height: 18px;
  color: #9A9A9A;
  margin: 12px 0 0 0;
}

.cpm-confirm-proceed {
  width: 100%;
  padding: 12px;
  background: var(--black);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 12px;
  transition: background 0.2s;
  line-height: 17px;
  box-sizing: border-box;
}

.cpm-confirm-proceed:hover {
  background: var(--brand);
}

.cpm-confirm-cancel {
  display: block;
  width: 100%;
  background: none;
  border: none;
  text-align: center;
  font-size: 14px;
  color: var(--black);
  cursor: pointer;
}
