/* SimpleBox overlay chrome (see simple-box.js). Generic, content-agnostic - popup-specific
   styling belongs in the fetched content itself, not here. */
.simplebox-overlay {
  position: fixed;
  inset: 0;
  inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  /* use dynamic viewport where supported for mobile resize/address-bar */
  height: 100dvh;
}
.simplebox-overlay[hidden] {
  display: none;
}
.simplebox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.simplebox-box {
  position: relative;
  box-sizing: border-box;
  max-width: 460px;
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh; /* better on mobile dynamic viewport (address bar etc) */
  overflow: auto;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.25);
}
@media (max-width: 863px) {
  .simplebox-box {
    max-height: 95dvh;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}
/* Full override, not just color/background - the site has a global button{} reset (red pill with
   its own height/border-radius/box-shadow, plus a button:hover{background:#c00} darken-on-hover)
   that otherwise bleeds into any plain <button>, same issue as the cart's Remove button earlier. */
.simplebox-close {
  position: absolute;
  top: 6px;
  right: 10px;
  background: none;
  border: none;
  box-shadow: none;
  border-radius: 0;
  height: auto;
  padding: 4px;
  font-size: 28px;
  line-height: 1;
  color: #888;
  cursor: pointer;
  z-index: 1;
}
.simplebox-close:hover {
  background: none;
  box-shadow: none;
  color: #333;
}
/* .simplebox-content carries "fancybox-inner" + "fancybox-content" (plus id="fancybox-inner")
   so the vast body of legacy popup CSS (rules like #fancybox-inner .update-rx,
   .fancybox-content.update-rx, body.fluid .fancybox-content... etc. from the generated
   shopping-cart.css / submit-order.css) applies to content loaded via SimpleBox. */
#fancybox-inner.simplebox-content,
.simplebox-content.fancybox-inner,
.simplebox-content.fancybox-content {
  height: auto;
  overflow: visible;
  overflow-y: visible !important;
  position: static;
  width: 100% !important;
}
/* Classic content commonly combines width:100% with its own padding (content-box sizing adds
   padding on top of that 100%, overflowing the container by exactly the padding amount). Real
   fancybox has other chrome that happens to absorb this; we don't, so force border-box on
   whatever gets fetched in here instead of chasing exact pixel dimensions per popup. */
.simplebox-content,
.simplebox-content * {
  box-sizing: border-box;
}

/* Outer wrapper padding for Update Rx (30px around the content) */
.simplebox-content.update-rx,
#fancybox-inner.update-rx {
  padding: 30px;
}

/* Bring back pre-merge padding and column widths for Update Rx .lens-variations table
    (merge changed popups.css / generated values; reduced td padding to fix spread) */
.simplebox-content .update-rx #prescription .lens-variations th,
.simplebox-content .update-rx #prescription .lens-variations td,
#fancybox-inner .update-rx #prescription .lens-variations th,
#fancybox-inner .update-rx #prescription .lens-variations td {
  padding: 0 4px !important;
  vertical-align: middle !important;
}
.simplebox-content .update-rx #prescription .lens-variations thead th,
#fancybox-inner .update-rx #prescription .lens-variations thead th {
  padding: 0 5px !important;
  line-height: 20px !important;
  text-align: center !important;
}
.simplebox-content .update-rx #prescription .lens-variations tbody td,
#fancybox-inner .update-rx #prescription .lens-variations tbody td {
  padding: 5px !important;
  text-align: center !important;
}
.simplebox-content .update-rx #prescription .lens-variations tbody th.eye,
#fancybox-inner .update-rx #prescription .lens-variations tbody th.eye {
  min-width: 110px !important;
  width: 105px !important;
  text-align: right !important;
  padding: 5px 5px 5px 0 !important;
}
.simplebox-content .update-rx #prescription .lens-variations tbody th,
#fancybox-inner .update-rx #prescription .lens-variations tbody th {
  padding: 2px 2px !important;
  text-align: left !important;
}
/* Ensure quantity and variation label columns have reasonable widths (was driven by .price before) */
.simplebox-content .update-rx #prescription .lens-variations th.quantity,
.simplebox-content .update-rx #prescription .lens-variations th.label,
#fancybox-inner .update-rx #prescription .lens-variations th.quantity,
#fancybox-inner .update-rx #prescription .lens-variations th.label {
  width: 80px !important;
}
/* blank header should match the eye column width for alignment */
.simplebox-content .update-rx #prescription .lens-variations th.blank,
#fancybox-inner .update-rx #prescription .lens-variations th.blank {
  width: 105px !important;
}

/* Popup content that classic sized against fancybox's own chrome. Real fancybox gave
   .fancybox-content a generous padding of its own, so the page stylesheets only ever set padding
   at the small-screen breakpoint (see .after_rebate_info in shopping-cart.css: padding appears
   only inside its max-width:480px block). We don't load fancybox's CSS, so without this the box
   hugs its content on desktop - noticeably tighter top and bottom than classic.

   Deliberately not a blanket .simplebox-content rule: that element also carries .fancybox-content
   itself, and some popups (Update Rx) already bring their own padding.

   #total_price_info is matched via [id=...] on purpose. As an id selector it would outrank the
   page stylesheets (.fancybox-content#total_price_info) and, because simple-box.css loads after
   them on some sites, would also beat their max-width:480px override and break the tighter mobile
   padding. The attribute form has class-level specificity, so this only fills in where a page
   stylesheet says nothing - which is exactly the fancybox-shaped hole we're patching. */
.simplebox-content .after_rebate_info,
.simplebox-content [id="total_price_info"] {
  padding: 30px;
}

/* Mobile viewport resize can cause .simplebox-box (max-height:90vh + overflow:auto) to become scrollable
   when UpdateRx (or other tall content) is injected. On touch devices this interferes with click/tap
   delivery to child interactive elements (e.g. the Update button's inline onclick + form submit listener,
   cancel links) because the UA prioritizes scroll gesture detection. The desktop case (no scroll) works.
   Fix ensures consistent event handling by allowing immediate click recognition. */
.simplebox-box {
  -webkit-overflow-scrolling: touch;
}
.simplebox-box a,
.simplebox-box button,
.simplebox-box .btn,
.simplebox-content.update-rx a,
.simplebox-content.update-rx .btn,
.simplebox-content.update-rx select {
  touch-action: manipulation;
}
