/* ==========================================================================
   Recent Purchase Popup (v2 unified stylesheet) + Storefront Button Active States
   ========================================================================== */

/* Keep legacy duplicate popup nodes hidden if cached HTML ever injects them */
#rpp-box,
#rpp-toast,
#real_time_order {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#rpp-box-custom.rppc-pop {
  position: fixed;
  z-index: 50000;
  left: var(--rpp-mx, 16px);
  right: auto;
  bottom: var(--rpp-my, 90px);
  top: auto;
  width: calc(100vw - var(--rpp-mx, 16px) - var(--rpp-sr, 120px));
  max-width: var(--rpp-max-w, 420px);
  min-width: min(var(--rpp-min-w, 260px), calc(100vw - 84px));
  border-radius: 12px;
  background: #ffffff;
  color: #222222;
  border: 0;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.35;
  box-sizing: border-box;
}

#rpp-box-custom.rppc-pop.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* 4-Corner Positioning */
#rpp-box-custom.rppc-pop[data-rpp-pos="br"] {
  left: auto;
  right: var(--rpp-mx, 16px);
  bottom: var(--rpp-desk-bottom, var(--rpp-my, 90px));
  top: auto;
}
#rpp-box-custom.rppc-pop[data-rpp-pos="tl"] {
  left: var(--rpp-mx, 16px);
  right: auto;
  top: var(--rpp-my, 24px);
  bottom: auto;
}
#rpp-box-custom.rppc-pop[data-rpp-pos="tr"] {
  left: auto;
  right: var(--rpp-mx, 16px);
  top: var(--rpp-my, 24px);
  bottom: auto;
}

/* Optional Visual Themes */
#rpp-box-custom.rppc-pop[data-rpp-theme="dark"] {
  background: #18181b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.36);
}
#rpp-box-custom.rppc-pop[data-rpp-theme="red"] {
  background: #fffafa;
  border-left: 4px solid #dc2626;
}
#rpp-box-custom.rppc-pop[data-rpp-theme="green"] {
  background: #f7fdfa;
  border-left: 4px solid #059669;
}

/* Inner Card Structure (Original Card + Centered Stamp + Single-Line Product + 44x44 Anti-Misclick Close) */
#rpp-box-custom .rppc-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  text-decoration: none !important;
  color: #222222 !important;
}
#rpp-box-custom.rppc-pop[data-rpp-theme="dark"] .rppc-link {
  color: #f8fafc !important;
}

#rpp-box-custom .rppc-img {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 0;
  border: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  box-sizing: border-box;
}
#rpp-box-custom.rppc-pop[data-rpp-theme="dark"] .rppc-img {
  background: transparent;
}
#rpp-box-custom .rppc-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

#rpp-box-custom .rppc-link,
#rpp-box-custom .rppc-title,
#rpp-box-custom .rppc-product,
#rpp-box-custom .rppc-time {
  font-family: inherit;
}

#rpp-box-custom .rppc-body {
  flex: 1 1 auto;
  min-width: 0;
}

#rpp-box-custom .rppc-title {
  margin: 0 0 4px 0;
  padding-right: 18px;
  font-size: var(--rpp-title-size, 13.5px) !important;
  font-weight: var(--rpp-title-weight, 500) !important;
  line-height: 1.35;
  letter-spacing: 0.1px;
  word-break: break-word;
}
#rpp-box-custom .rppc-title strong {
  font-weight: 600;
}

#rpp-box-custom .rppc-product {
  display: block !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--rpp-product-color, #147bff) !important;
  text-decoration-line: var(--rpp-product-underline, none) !important;
  text-decoration-color: var(--rpp-product-color, #147bff) !important;
  text-underline-offset: 2px;
}

#rpp-box-custom .rppc-time {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.65;
}

/* Close Button: original clean look at top-right with 44x44px thumb hit target */
#rpp-box-custom .rppc-close {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 8px 11px 0 0;
  border: 0;
  border-radius: 0 12px 0 12px;
  background: transparent;
  color: #5a5e60;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.62;
  touch-action: manipulation;
  z-index: 3;
}
#rpp-box-custom.rppc-pop[data-rpp-theme="dark"] .rppc-close {
  color: #f8fafc;
}
#rpp-box-custom .rppc-close:hover,
#rpp-box-custom .rppc-close:focus-visible {
  opacity: 1;
}
#rpp-box-custom .rppc-close:focus-visible,
#rpp-box-custom .rppc-img:focus-visible,
#rpp-box-custom .rppc-product:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Top-corner mobile guard only; bottom-left preserves original left pocket (safe_right=120px) so it never collides with right help widget */
@media (max-width: 767px) {
  #rpp-box-custom.rppc-pop[data-rpp-pos="tl"],
  #rpp-box-custom.rppc-pop[data-rpp-pos="tr"] {
    left: 12px;
    right: auto;
    top: 12px;
    bottom: auto;
    width: calc(100vw - 24px);
    max-width: min(var(--rpp-max-w, 366px), calc(100vw - 24px));
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #rpp-box-custom.rppc-pop {
    transition: none !important;
    transform: none !important;
  }
}

/* Preserved Storefront Primary / Checkout Button Active & Focus Rules */
.btn-primary.btn:active:not(#_):not(#__),
.btn-primary.btn:focus:not(#_):not(#__),
.btn-primary.btn:active:focus:not(#_):not(#__),
.btn-primary.btn:focus-within:not(#_):not(#__),
.btn-primary.btn:focus-visible:not(#_):not(#__),
.btn-checkout.btn:active:not(#_):not(#__),
.btn-checkout.btn:focus:not(#_):not(#__),
.btn-checkout.btn:active:focus:not(#_):not(#__),
.btn-checkout.btn:focus-within:not(#_):not(#__),
.btn-checkout.btn:focus-visible:not(#_):not(#__) {
  background: #fff !important;
  background-color: #fff !important;
  color: #031021 !important;
  border: 1px solid #000 !important;
}
.btn-primary.btn:active:not(#_) > span, .btn-primary.btn:focus:not(#_) > span,
.btn-checkout.btn:active:not(#_) > span, .btn-checkout.btn:focus:not(#_) > span {
  color: #031021 !important;
}
