/**
 * Template purchase modal — aligned with membership / site surface system.
 * Brand solid #1F2FF1 · radii sm9 / md12 / lg16 · frosted shell + blur mask
 */

.template-purchase-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--modal-backdrop, rgba(0, 0, 0, 0.48));
}

.template-purchase-modal {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: min(100%, 42rem);
  max-height: min(90vh, 640px);
  border: var(--vech-border-width, 1px) solid var(--modal-border);
  border-radius: var(--vech-radius-lg, 16px);
  background: var(--modal-bg, rgba(18, 21, 27, 0.72));
  box-shadow: var(--modal-shadow);
  font-family: var(--modal-font);
  color: var(--modal-text);
}

.template-purchase-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.75rem 0.85rem 1.15rem;
  border-bottom: 1px solid var(--modal-border, rgba(255, 255, 255, 0.08));
  background: transparent;
}

.template-purchase-header__title {
  margin: 0;
  min-width: 0;
  font-family: var(--vech-font-ui, inherit);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--modal-text, #e7eef8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button.template-purchase-close {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--vech-radius-sm, 9px);
  background: transparent;
  color: var(--modal-text, #e7eef8);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.72;
  transition: opacity 0.16s ease, background-color 0.16s ease;
}

button.template-purchase-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.template-purchase-close svg {
  width: 16px;
  height: 16px;
  display: block;
}

.template-purchase-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 1.5rem 1.35rem 1.35rem;
}

.template-purchase-plans {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.template-purchase-plan {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 0;
  min-height: 100%;
  padding: 1.35rem 1.25rem 1.2rem;
  border: 1px solid var(--modal-border);
  border-radius: var(--vech-radius-md, 12px);
  background: var(--modal-bg-elevated, rgba(26, 31, 40, 0.88));
}

.template-purchase-plan--featured {
  border-color: rgba(31, 47, 241, 0.55);
  background: var(--brand, #1f2ff1);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.14),
    0 12px 28px rgba(31, 47, 241, 0.28);
}

.template-purchase-plan--featured .template-purchase-plan__title,
.template-purchase-plan--featured .template-purchase-plan__currency,
.template-purchase-plan--featured .template-purchase-plan__amount {
  color: #fff;
}

.template-purchase-plan--featured .template-purchase-plan__badge {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.template-purchase-plan--featured .template-purchase-plan__desc,
.template-purchase-plan--featured .template-purchase-plan__feature-text {
  color: rgba(255, 255, 255, 0.82);
}

.template-purchase-plan--featured .template-purchase-plan__feature-icon {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.template-purchase-plan--active:not(.template-purchase-plan--featured) {
  border-color: rgba(31, 47, 241, 0.55);
  box-shadow: 0 0 0 1px rgba(31, 47, 241, 0.28);
}

.template-purchase-plan__header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  min-height: 1.5rem;
}

.template-purchase-plan__badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0.22rem 0.5rem;
  border-radius: var(--vech-radius-sm, 9px);
  background: var(--brand, #1f2ff1);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
}

.template-purchase-plan__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--modal-text);
}

.template-purchase-plan__desc {
  margin: 0.65rem 0 0;
  min-height: 2.4rem;
  font-size: 12px;
  line-height: 1.45;
  color: var(--modal-text-muted);
}

.template-purchase-plan__price {
  display: flex;
  align-items: baseline;
  gap: 0.12rem;
  margin-top: 1.1rem;
  min-height: 2.75rem;
}

.template-purchase-plan__currency {
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  color: var(--modal-text);
}

.template-purchase-plan__amount {
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--modal-text);
}

.template-purchase-plan__features {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.template-purchase-plan__feature {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.375rem;
}

.template-purchase-plan__feature-icon {
  flex: none;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--vech-radius-full, 999px);
  background: rgba(255, 255, 255, 0.08);
  color: var(--modal-text-soft, rgba(231, 238, 248, 0.72));
  line-height: 0;
}

.template-purchase-plan__feature-icon svg {
  display: block;
  width: 11px;
  height: 11px;
}

.template-purchase-plan__feature-text {
  min-width: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--modal-text-muted);
}

button.template-purchase-plan__cta {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 38px;
  margin-top: 1.25rem;
  border: 1px solid var(--modal-border-strong, rgba(255, 255, 255, 0.14));
  border-radius: var(--vech-radius-sm, 9px);
  background: rgba(255, 255, 255, 0.06);
  color: var(--modal-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    opacity 0.16s ease;
}

button.template-purchase-plan__cta:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
}

button.template-purchase-plan__cta:disabled {
  opacity: 0.72;
  cursor: wait;
}

.template-purchase-plan--featured button.template-purchase-plan__cta {
  background: #fff;
  border-color: #fff;
  color: var(--brand, #1f2ff1);
}

.template-purchase-plan--featured button.template-purchase-plan__cta:hover:not(:disabled) {
  background: #f4f6ff;
  border-color: #f4f6ff;
}

.template-purchase-backdrop--pay {
  z-index: 10002;
}

.template-purchase-modal--pay {
  width: min(100%, 22.5rem);
  max-height: min(86vh, 520px);
}

.template-purchase-body--pay {
  padding: 1.25rem 1.25rem 1.125rem;
}

.template-purchase-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.template-purchase-qr--modal {
  padding: 0.15rem 0 0;
}

.template-purchase-qr__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--modal-text);
}

.template-purchase-qr__plan {
  margin: 0.4rem 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--modal-text-muted);
}

.template-purchase-qr__price {
  margin: 0.65rem 0 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--modal-text);
}

.template-purchase-qr__wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
}

.template-purchase-qr__image {
  display: block;
  width: 168px;
  height: 168px;
  border-radius: var(--vech-radius-sm, 9px);
  background: #fff !important;
  background-color: #fff !important;
}

.template-purchase-qr__hint {
  margin: 0.75rem 0 0;
  width: 100%;
  flex: none;
  font-size: 12px;
  line-height: 1.45;
  color: #3dd68c;
}

.template-purchase-qr__order {
  margin: 0.45rem 0 0;
  width: 100%;
  flex: none;
  font-size: 11px;
  line-height: 1.4;
  color: var(--modal-text-muted);
  word-break: break-all;
}

.template-purchase-qr__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 11rem;
  color: var(--modal-text-muted);
  font-size: 12px;
}

.template-purchase-qr__spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--modal-border);
  border-top-color: var(--brand, #1f2ff1);
  border-radius: 50%;
  animation: template-purchase-spin 0.8s linear infinite;
}

.template-purchase-jsapi {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin-top: 1rem;
}

.template-purchase-jsapi .template-purchase-primary {
  min-width: 9.5rem;
}

@keyframes template-purchase-spin {
  to {
    transform: rotate(360deg);
  }
}

.template-purchase-success {
  padding: 1.25rem 0 0.25rem;
  text-align: center;
}

.template-purchase-success__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #3dd68c;
}

.template-purchase-success__desc {
  margin: 0.45rem 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--modal-text-muted);
}

.template-purchase-success__order {
  margin: 0.55rem 0 0;
  font-size: 11px;
  color: var(--modal-text-muted);
}

button.template-purchase-primary {
  appearance: none;
  -webkit-appearance: none;
  margin: 1.125rem auto 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 14rem;
  height: 36px;
  border: 1px solid rgba(31, 47, 241, 0.72);
  border-radius: var(--vech-radius-sm, 9px);
  background: var(--brand, #1f2ff1);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.16s ease;
}

button.template-purchase-primary:hover:not(:disabled) {
  background: var(--brand-hover, #1826d4);
}

.template-purchase-error {
  margin: 0.85rem 0 0;
  padding: 0.65rem 0.75rem;
  border-radius: var(--vech-radius-sm, 9px);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.22);
  color: #f87171;
  font-size: 12px;
  text-align: center;
}

.template-purchase-footer-note {
  margin: 0.9rem 0 0;
  text-align: center;
  font-size: 11px;
  line-height: 1.45;
  color: var(--modal-text-muted);
}

@media only screen and (max-width: 680px) {
  .template-purchase-backdrop {
    padding: 12px;
  }

  .template-purchase-modal {
    width: 100%;
    max-height: min(92dvh, 100%);
  }

  .template-purchase-body {
    padding: 1rem 0.95rem 0.95rem;
  }

  .template-purchase-plans {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .template-purchase-plan {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "header price"
      "desc price"
      "features features"
      "cta cta";
    column-gap: 0.75rem;
    row-gap: 0;
    align-items: center;
    padding: 0.95rem;
  }

  .template-purchase-plan__header {
    grid-area: header;
    min-height: 0;
  }

  .template-purchase-plan__desc {
    grid-area: desc;
    margin: 0.3rem 0 0;
    min-height: 0;
  }

  .template-purchase-plan__price {
    grid-area: price;
    align-self: center;
    justify-content: flex-end;
    margin-top: 0;
    min-height: 0;
    white-space: nowrap;
  }

  .template-purchase-plan__currency {
    font-size: 16px;
  }

  .template-purchase-plan__amount {
    font-size: 32px;
  }

  .template-purchase-plan__features {
    grid-area: features;
    margin-top: 0.65rem;
  }

  button.template-purchase-plan__cta {
    grid-area: cta;
    margin-top: 0.75rem;
  }

  .template-purchase-modal--pay {
    width: 100%;
    max-width: 22.5rem;
  }
}
