/**
 * Whop WooCommerce Gateway Frontend Styles
 *
 * @package    Whop_WooCommerce
 * @version    3.12.22
 */

/* Reset container */
#payment div.payment_box.payment_method_whop,
.woocommerce-checkout #payment div.payment_box.payment_method_whop {
  background: #ffffff !important;
  border: 1px solid #e4e4e7 !important;
  border-radius: 8px !important;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05) !important;
  padding: 12px 16px !important;
  margin: 10px 0 !important;
  color: #27272a !important;
  font-size: 13px !important;
}

/* Hide pointer */
#payment div.payment_box.payment_method_whop::before,
#payment div.payment_box.payment_method_whop::after,
.woocommerce-checkout #payment div.payment_box.payment_method_whop::before,
.woocommerce-checkout #payment div.payment_box.payment_method_whop::after {
  display: none !important;
  content: none !important;
  border: none !important;
}

/* Styling */
.whop-payment-card {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
}

.whop-payment-card .whop-card-title {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #0f172a !important;
  margin: 0 0 2px 0 !important;
  line-height: 1.4 !important;
}

.whop-payment-card .whop-card-description {
  font-size: 12px !important;
  color: #64748b !important;
  margin: 0 !important;
  line-height: 1.5 !important;
}

/* Badge */
.whop-payment-card .whop-sandbox-badge {
  display: inline-flex !important;
  align-self: flex-start !important;
  align-items: center !important;
  background: #fef3c7 !important;
  color: #92400e !important;
  border: 1px solid #fde68a !important;
  border-radius: 4px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  padding: 2px 8px !important;
  margin-top: 6px !important;
}

/* Checkout Block payment-method description. It inherits the store theme's
   text colour, matching the classic checkout card without forcing a surface. */
.wc-whop-blocks-description {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 2px;
  color: inherit;
  font-size: 13px;
  line-height: 1.45;
}

.wc-whop-blocks-icon {
  display: inline-flex;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(127, 127, 127, 0.3);
  border-radius: 9px;
}

.wc-whop-blocks-icon svg {
  width: 16px;
  height: 16px;
}

.wc-whop-blocks-copy {
  opacity: 0.72;
}

/* Embed on Checkout inside the Block checkout. The block already prints the
   gateway title beside its radio, so only the merchant's own copy appears here
   — matching the classic checkout. */
.wc-whop-blocks-direct-copy {
  margin: 8px 0 10px;
  font-size: 13px;
  line-height: 1.5;
  color: inherit;
  opacity: 0.72;
}

.wc-whop-blocks-direct .whop-direct-checkout {
  margin-top: 8px;
  padding-top: 0;
  border-top: 0;
}

/* The block checkout renders the payment panel inside its own bordered card,
   so the progress panel needs a little breathing room beneath the form. */
.wc-whop-blocks-direct .whop-direct-progress {
  margin-top: 14px;
  margin-bottom: 4px;
}

/* Success Checkmark */
.whop-checkmark-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-width: 2;
  stroke-miterlimit: 10;
  stroke: #22c55e;
  fill: none;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.whop-checkmark {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: block;
  stroke-width: 2;
  stroke: #fff;
  stroke-miterlimit: 10;
  box-shadow: inset 0px 0px 0px #22c55e;
  animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s forwards;
}

.whop-checkmark-check {
  transform-origin: 50% 50%;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
  100% {
    stroke-dashoffset: 0;
  }
}
@keyframes scale {
  0%, 100% {
    transform: none;
  }
  50% {
    transform: scale3d(1.1, 1.1, 1);
  }
}
@keyframes fill {
  100% {
    box-shadow: inset 0px 0px 0px 40px #22c55e;
  }
}


/* ── Inline Embedded Checkout mode ── */
#whop-inline-embed-container {
  margin-top: 14px;
  border-top: 1px solid #f1f5f9;
  padding-top: 14px;
}

.whop-inline-skeleton {
  padding: 24px 0;
  text-align: center;
}

.whop-inline-skeleton-bar {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: whop-skeleton-shimmer 1.4s ease infinite;
  margin: 0 auto 10px;
  max-width: 320px;
}

.whop-inline-skeleton-bar.short {
  max-width: 200px;
}

.whop-inline-skeleton p {
  font-size: 12px;
  color: #94a3b8;
  margin: 12px 0 0;
}

@keyframes whop-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.whop-inline-paid-notice {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* ── Embed on Checkout mode ──
   The Whop form sits inside the payment method box, directly under the method
   description, and WooCommerce's Place Order button submits it. */
.whop-direct-checkout {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(127, 127, 127, 0.22);
  border-top: 1px solid color-mix(in srgb, currentColor 16%, transparent);
}

/* With the duplicate title gone, the form is the first thing in the box — no
   divider to sit under and no gap to leave above it. */
.whop-payment-card-direct {
  gap: 0 !important;
}

.whop-payment-card-direct .whop-direct-checkout:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.whop-payment-card-direct .whop-card-description {
  margin: 0 0 10px !important;
}

/* Narrated wait. Sits under the payment form, never over it, so Whop's own
   verification steps stay reachable while this is on screen. */
.whop-direct-progress {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 11px 13px;
  border: 1px solid rgba(127, 127, 127, 0.26);
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 10px;
  background: rgba(127, 127, 127, 0.06);
  background: color-mix(in srgb, currentColor 5%, transparent);
  font-size: 13px;
  line-height: 1.45;
  color: inherit;
}

.whop-direct-spinner {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid rgba(127, 127, 127, 0.3);
  border-top-color: #ff6423;
  animation: whop-direct-spin 0.8s linear infinite;
}

@keyframes whop-direct-spin {
  to { transform: rotate(360deg); }
}

.whop-direct-progress-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.whop-direct-progress-step {
  font-weight: 650;
}

.whop-direct-progress-note {
  opacity: 0.72;
  font-size: 12.5px;
}

.whop-direct-progress-done .whop-direct-spinner {
  border-color: rgba(34, 197, 94, 0.3);
  border-top-color: #22c55e;
}

@media (prefers-reduced-motion: reduce) {
  .whop-direct-spinner { animation-duration: 2.4s; }
}

.whop-direct-sandbox {
  margin: 8px 0 0 !important;
  font-size: 11.5px !important;
  line-height: 1.4 !important;
  color: inherit !important;
  opacity: 0.6;
  text-align: center;
}

.whop-direct-mount {
  min-height: 0;
}

.whop-direct-mount iframe {
  width: 100% !important;
  /* See the modal mount: never floor the frame itself. */
  min-height: 0;
  border: none;
  display: block;
  color-scheme: normal;
}

.whop-direct-mount:empty {
  display: none;
}

.whop-direct-status {
  margin: 0;
}

.whop-direct-status .whop-inline-skeleton {
  padding: 18px 0;
}

.whop-direct-status p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.whop-direct-status-error p {
  color: #b91c1c;
}

.whop-direct-status-info p {
  color: inherit;
  opacity: 0.75;
}

/* While the payment is being taken, the rest of the checkout is locked but the
   Whop form must stay interactive — 3-D Secure, wallet confirmations and Whop's
   own inline errors all render inside that iframe. */
form.checkout.whop-direct-busy {
  pointer-events: none;
}

form.checkout.whop-direct-busy .whop-direct-checkout,
form.checkout.whop-direct-busy .whop-direct-checkout * {
  pointer-events: auto;
}

form.checkout.whop-direct-busy .woocommerce-billing-fields,
form.checkout.whop-direct-busy .woocommerce-shipping-fields,
form.checkout.whop-direct-busy .woocommerce-additional-fields,
form.checkout.whop-direct-busy #order_review_heading {
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

/* ── Embedded Modal checkout ── */
body.whop-modal-open {
  overflow: hidden;
}

.whop-embed-modal-mode {
  position: fixed;
  inset: 0;
  background: rgba(9, 12, 20, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.whop-embed-modal-card {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 32px 80px rgba(0, 0, 0, 0.45);
  animation: whop-modal-in 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes whop-modal-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.whop-embed-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.whop-embed-modal-heading {
  display: flex;
  align-items: center;
}

.whop-embed-modal-title {
  font-size: 14px;
  font-weight: 650;
  color: #0f172a;
  letter-spacing: 0;
}

#whop-embed-modal-close {
  background: transparent;
  border: 0;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  padding: 0;
}

#whop-embed-modal-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

#whop-embed-modal-close:active {
  transform: scale(0.94);
}

#whop-embed-modal-close:disabled {
  cursor: wait;
  opacity: 0.45;
}

.whop-embed-modal-body {
  max-height: min(680px, calc(100dvh - 100px));
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  flex: 0 1 auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#whop-embed-modal-mount:empty {
  min-height: 520px;
}

#whop-embed-modal-mount iframe {
  width: 100% !important;
  /* No min-height. A floor here clamps the frame's rendered box, which hides
     the height change Whop makes when it draws its validation errors — the one
     signal this plugin has that a submit was refused. The floor lives on the
     empty mount above so the modal still has a size before the frame loads. */
  min-height: 0;
  border: none;
  border-radius: 0;
  display: block;
}

.whop-inline-submit-controls {
  --whop-submit-background: #000000;
  --whop-submit-text-color: #FFFFFF;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 13px;
  border-top: 1px solid #e5e7eb;
  background: rgba(255, 255, 255, 0.96);
}

.whop-inline-submit-button {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border: 1px solid var(--whop-submit-background, #000000);
  border-radius: 10px;
  background: var(--whop-submit-background, #000000);
  color: var(--whop-submit-text-color, #FFFFFF);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

.whop-inline-submit-button:hover:not(:disabled) {
  filter: brightness(0.94);
}

.whop-inline-submit-button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.whop-inline-submit-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.whop-inline-submit-align-full .whop-inline-submit-button {
  width: 100%;
}

.whop-inline-submit-align-left .whop-inline-submit-button {
  width: auto;
  align-self: flex-start;
}

.whop-inline-submit-align-center .whop-inline-submit-button {
  width: auto;
  align-self: center;
}

.whop-inline-submit-align-right .whop-inline-submit-button {
  width: auto;
  align-self: flex-end;
}

/* ── Success confirmation ── */
.whop-embed-modal-success {
  padding: 42px 28px 38px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(circle at 50% 0, rgba(34, 197, 94, 0.08), transparent 42%),
    #ffffff;
}

.whop-success-ring {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #22c55e;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 12px 30px rgba(34, 197, 94, 0.23);
}

.whop-success-ring .whop-checkmark {
  width: 48px;
  height: 48px;
}

.whop-embed-modal-success .whop-success-eyebrow {
  display: inline-flex;
  align-items: center;
  color: #15803d !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.08em !important;
  line-height: 1.2 !important;
  margin: 0 0 8px !important;
  text-transform: uppercase;
}

.whop-embed-modal-success h3 {
  font-size: 24px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  line-height: 1.2 !important;
  margin: 0 0 8px !important;
  letter-spacing: -0.025em !important;
}

.whop-embed-modal-success p {
  font-size: 13px !important;
  color: #64748b !important;
  margin: 0 0 24px !important;
  line-height: 1.5 !important;
}

.whop-success-progress {
  width: 120px;
  height: 3px;
  border-radius: 99px;
  background: #f1f5f9;
  overflow: hidden;
}

.whop-success-progress span {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #16a34a, #4ade80);
  transform-origin: left;
  animation: whop-progress-fill 1.9s ease forwards;
}

@keyframes whop-progress-fill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@media (max-width: 520px) {
  .whop-embed-modal-mode { padding: 0; }
  .whop-embed-modal-card {
    max-width: 100%;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
  }
  #whop-embed-modal-mount:empty { min-height: 60vh; }
}
