.cw-modal,
.cw-modal * {
  box-sizing: border-box;
}

.cw-modal {
  --cw-green: #63AB45;
  --cw-dark: #10200C;
  --cw-deep-green: #315924;
  --cw-ink: #182814;
  --cw-muted: #4a5b44;
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 24px;
  font-family: Poppins, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Overlay ---------- */

.cw-modal__overlay {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(16, 32, 12, 0.55);
  cursor: default;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: cw-fade-in 220ms ease-out both;
}

/* ---------- Panel ---------- */

.cw-modal__panel {
  position: relative;
  z-index: 10 !important;
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  width: min(100%, 880px);
  min-height: min(50vh, 480px);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  border-radius: 20px;
  background: #ffffff;
  color: var(--cw-ink);
  box-shadow:
    0 40px 100px rgba(16, 32, 12, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  animation: cw-enter 320ms cubic-bezier(0.2, 0.9, 0.25, 1.15) both;
}

/* ---------- Botón cerrar ---------- */

.cw-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(49, 89, 36, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--cw-ink);
  cursor: pointer;
  transform: none !important;
  transition: none !important;
  animation: none !important;
}

.cw-modal__close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

/* Estática: igual en hover/focus (también evita estilos de botón del tema de WordPress). */
.cw-modal__close:hover,
.cw-modal__close:focus,
.cw-modal__close:focus-visible,
.cw-modal__close:active {
  border-color: rgba(49, 89, 36, 0.2) !important;
  background: rgba(255, 255, 255, 0.9) !important;
  color: var(--cw-ink) !important;
  box-shadow: none !important;
  outline: none;
  transform: none !important;
}

/* ---------- Lado del descuento ---------- */

.cw-modal__hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px 28px;
  overflow: hidden;
  background: var(--cw-green);
  color: #ffffff;
  text-align: center;
  isolation: isolate;
}

/* Cuadrícula "cyber" en perspectiva */
.cw-modal__grid {
  position: absolute;
  inset: -40% -20% -10%;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 34px 34px;
  transform: perspective(420px) rotateX(58deg) translateY(30%);
  transform-origin: bottom;
  mask-image: linear-gradient(to top, #000 10%, transparent 75%);
  -webkit-mask-image: linear-gradient(to top, #000 10%, transparent 75%);
  animation: cw-grid 6s linear infinite;
}

.cw-modal__glow {
  display: none;
}

.cw-modal__hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.cw-modal__pulse {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  animation: cw-pulse 1.8s ease-out infinite;
}

.cw-modal__discount {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.85;
}

.cw-modal__discount-value {
  position: relative;
  font-size: clamp(72px, 11vw, 128px);
  font-weight: 900;
  letter-spacing: -0.04em;
  color: #ffffff;
}

.cw-modal__discount-label {
  margin-top: 6px;
  font-size: clamp(30px, 4.4vw, 44px);
  font-weight: 800;
  letter-spacing: 0.32em;
  padding-left: 0.32em;
  color: #ffffff;
}

.cw-modal__dates {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  background: var(--cw-dark);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.cw-modal__dates svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Lado del contenido ---------- */

.cw-modal__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 40px 36px;
  overflow-y: auto;
}

.cw-modal__badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 14px;
  padding: 0 12px;
  border: 1px solid rgba(99, 171, 69, 0.34);
  border-radius: 999px;
  background: rgba(99, 171, 69, 0.13);
  color: var(--cw-deep-green);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cw-modal__title {
  margin: 0;
  color: var(--cw-ink);
  font-size: clamp(26px, 3.2vw, 34px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.cw-modal__description {
  margin: 12px 0 24px;
  color: var(--cw-muted);
  font-size: 15px;
  line-height: 1.6;
}

.cw-modal__code-caption {
  margin-bottom: 8px;
  color: var(--cw-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cw-modal__code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px;
  align-items: stretch;
  gap: 10px;
  width: 100%;
}

.cw-modal__code {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  margin: 0;
  padding: 12px 16px;
  border: 2px dashed rgba(49, 89, 36, 0.5);
  border-radius: 12px;
  background: rgba(99, 171, 69, 0.09);
  color: var(--cw-deep-green);
  font-family: inherit;
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  letter-spacing: 0.12em;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.cw-modal__code:hover,
.cw-modal__code:focus-visible {
  border-color: var(--cw-green) !important;
  background: rgba(99, 171, 69, 0.15);
  outline: none;
}

.cw-modal__copy {
  display: inline-grid;
  place-items: center;
  width: 56px;
  min-height: 60px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--cw-green) !important;
  color: #ffffff;
  cursor: pointer;
  transition: background-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.cw-modal__copy svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cw-modal__copy:hover,
.cw-modal__copy:focus-visible {
  background: #57993d !important;
  box-shadow: 0 10px 22px rgba(99, 171, 69, 0.32);
  outline: none;
  transform: translateY(-1px);
}

.cw-modal__copy--done {
  background: var(--cw-deep-green) !important;
  animation: cw-pop 280ms ease-out;
}

.cw-modal__copied {
  min-height: 20px;
  margin: 8px 0 14px;
  color: var(--cw-deep-green);
  font-size: 13px;
  font-weight: 600;
}

.cw-modal__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 0 24px;
  border-radius: 12px;
  background: var(--cw-dark);
  color: #ffffff !important;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none !important;
  box-shadow: 0 14px 30px rgba(16, 32, 12, 0.28);
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.cw-modal__cta svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 160ms ease;
}

.cw-modal__cta:hover,
.cw-modal__cta:focus-visible {
  background: var(--cw-deep-green);
  box-shadow: 0 18px 36px rgba(16, 32, 12, 0.34);
  outline: none;
  transform: translateY(-1px);
}

.cw-modal__cta:hover svg {
  transform: translateX(4px);
}

.cw-modal__dismiss {
  align-self: center;
  margin-top: 14px;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--cw-muted);
  font-family: inherit;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.cw-modal__dismiss:hover,
.cw-modal__dismiss:focus-visible {
  color: var(--cw-ink);
  outline: none;
}

/* ---------- Cierre ---------- */

.cw-modal--closing .cw-modal__overlay {
  animation: cw-fade-out 220ms ease-in both;
}

.cw-modal--closing .cw-modal__panel {
  animation: cw-leave 220ms ease-in both;
}

/* ---------- Animaciones ---------- */

@keyframes cw-enter {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cw-leave {
  to {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
}

@keyframes cw-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cw-fade-out {
  to { opacity: 0; }
}

@keyframes cw-grid {
  from { background-position: 0 0; }
  to { background-position: 0 34px; }
}

@keyframes cw-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
  80%, 100% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); }
}

@keyframes cw-pop {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .cw-modal *,
  .cw-modal *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .cw-modal {
    padding: 16px;
  }

  .cw-modal__panel {
    grid-template-columns: 1fr;
    min-height: 0;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    border-radius: 16px;
  }

  .cw-modal__hero {
    gap: 12px;
    padding: 32px 20px 26px;
  }

  .cw-modal__discount {
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
  }

  .cw-modal__discount-value {
    font-size: clamp(64px, 20vw, 88px);
  }

  .cw-modal__discount-label {
    margin-top: 0;
    font-size: clamp(26px, 8vw, 34px);
    letter-spacing: 0.12em;
    padding-left: 0;
  }

  .cw-modal__content {
    align-items: center;
    padding: 26px 20px 20px;
    overflow: visible;
    text-align: center;
  }

  .cw-modal__description {
    margin-bottom: 18px;
  }
}
