/* ======================================================================
   PATIENT PORTAL: PRESCRIPTION CARDS, ORDER BUTTON, CART BAR
   Markup: inc/frontend/shop/order-medication.php (article.ge-rx-card,
   .ge-rx-howto, #ge-cartbar). Behaviour: js/oma.js.
   Loaded after css/oma.css (handle ge-oma-order, kept out of SiteGround
   minify). The old sheet sizes cards as 32% floats and squeezes the order
   button to 10px text, so the rules below are scoped to .ge-rx-card and use
   !important where oma.css / the inline OOS rules already do.

   Colours are the site's own: header + cart green, the portal's light
   green, and the amber the order screens already use for "can order, but
   it will wait". All buttons use a 4px corner.
   ====================================================================== */

.pro-arch {
  --rx-green: #1a5c38;          /* header / mini-cart primary */
  --rx-green-dark: #144a2c;
  --rx-portal-green: #1a4731;   /* portal tabs (--ge-green) */
  --rx-soft: #f0fdf4;
  --rx-soft-line: rgba(26, 71, 49, .35);
  --rx-ok-ink: #15803d;
  --rx-amber: #d97706;
  --rx-amber-dark: #b45309;
  --rx-amber-soft: #fff7ed;
  --rx-amber-line: #fdba74;
  --rx-amber-ink: #9a3412;
  --rx-ink: #0f172a;
  --rx-muted: #6b7280;
  --rx-line: #e6e6e6;
  --rx-radius-btn: 4px;
}

/* ---- list layout: one column on phones, as many ~300px columns as fit above */
.pro-arch .pro-arch-grid { grid-template-columns: minmax(0, 1fr) !important; }
.pro-arch .pro-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

/* ---- "How to order" strip ---- */
.ge-rx-howto {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px 12px;
  list-style: none;
  background: #f0fdf4;
  border-radius: 6px;
  color: #1a4731;
}
.ge-rx-howto li { margin: 0; font-size: 13px; font-weight: 600; line-height: 1.3; }
.ge-rx-howto li span {
  display: block;
  margin-bottom: 2px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  opacity: .75;
}

/* ---- card ---- */
.pro-arch .pro-card.ge-rx-card {
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: auto !important;
  float: none !important;
  margin: 0 !important;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--rx-line);
  border-radius: 8px;
  color: var(--rx-ink);
  min-width: 0;
}
.ge-rx-card--stop .ge-rx-head,
.ge-rx-card--stop .ge-rx-facts,
.ge-rx-card--stop .ge-rx-price { opacity: .6; }

.ge-rx-head { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 12px; align-items: start; }
.ge-rx-head__text { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.ge-rx-card .ge-rx-title { margin: 2px 0 0; font-size: 16px; line-height: 1.3; font-weight: 700; color: var(--rx-ink); overflow-wrap: anywhere; }
.ge-rx-sub { font-size: 12.5px; color: var(--rx-muted); }
.ge-rx-card .pro-thumb-wrap { position: relative; width: 72px; }
.ge-rx-card .pro-thumb { width: 72px; height: 72px; padding: 4px; object-fit: contain; }
.ge-rx-card .ge-oos-ribbon { top: 6px; font-size: 9px; padding: 2px 6px 2px 5px; }

/* status label */
.ge-rx-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}
.ge-rx-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.ge-rx-chip--ok   { background: var(--rx-soft); color: var(--rx-ok-ink); }
.ge-rx-chip--wait { background: var(--rx-amber-soft); color: var(--rx-amber-dark); }
.ge-rx-chip--stop { background: #f3f4f6; color: #4b5563; }

/* qty / repeats / expiry */
.ge-rx-card .ge-rx-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: #f0f0f0;
  border-radius: 6px;
  overflow: hidden;
}
.ge-rx-facts > div { display: flex; flex-direction: column; padding: 6px 9px; background: #fafafa; min-width: 0; }
.ge-rx-facts dt { margin: 0; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--rx-muted); }
.ge-rx-facts dd { margin: 0; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

.ge-rx-price { margin: 0; }
/* cards in a row are the same height: keep the note + button at the bottom so buttons line up */
.pro-arch .ge-rx-card > .ge-rx-note,
.pro-arch .ge-rx-card > .ge-rx-actions { margin-top: auto !important; }
.pro-arch .ge-rx-card > .ge-rx-note + .ge-rx-actions { margin-top: 0 !important; }

.ge-rx-note {
  padding: 8px 10px;
  border-radius: 4px;
  background: var(--rx-amber-soft);
  border: 1px solid var(--rx-amber-line);
  color: var(--rx-amber-ink);
  font-size: 12.5px;
  line-height: 1.45;
}
.ge-rx-note b { color: #7c2d12; }

/* ---- the order button ---- */
.pro-arch .ge-rx-card .ge-rx-actions { display: block; width: 100%; margin: 0; text-align: center; }
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  margin: 0 !important;
  padding: 10px 14px !important;
  border: 0 !important;
  border-radius: var(--rx-radius-btn) !important;
  background: var(--rx-green) !important;
  color: #fff !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  text-align: center;
  text-transform: none !important;
  letter-spacing: 0 !important;
  text-decoration: none !important;
  box-shadow: none !important;
  opacity: 1 !important;
  cursor: pointer;
  transition: background-color .15s ease;
}
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn:hover,
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn:focus { background: var(--rx-green-dark) !important; color: #fff !important; }
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn:focus-visible { outline: 3px solid #46b266; outline-offset: 2px; }

/* cart icon on the plain "Order this script" button (CSS, so the JS label swaps keep it) */
.pro-arch .ge-rx-card .ge-rx-actions a.ge-rx-btn:not(.ge-btn-oos):not(.interval-blocked):not(.limit-blocked):not(.oma-in-cart):not(.oma-loading)::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4h2l2.4 11.2a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.5L21 8H6.2'/%3E%3Ccircle cx='10' cy='20.5' r='1.2'/%3E%3Ccircle cx='17' cy='20.5' r='1.2'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4h2l2.4 11.2a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.5L21 8H6.2'/%3E%3Ccircle cx='10' cy='20.5' r='1.2'/%3E%3Ccircle cx='17' cy='20.5' r='1.2'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* amber: can order, but it will wait (back order, not due yet, monthly limit) */
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn.ge-btn-oos,
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn.interval-blocked,
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn.limit-blocked { background: var(--rx-amber) !important; }
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn.ge-btn-oos:hover,
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn.interval-blocked:hover,
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn.limit-blocked:hover { background: var(--rx-amber-dark) !important; }

/* in the cart (js/oma.js sets .oma-in-cart and "✓ In your cart") */
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn.oma-in-cart,
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn.oma-in-cart:hover {
  background: var(--rx-soft) !important;
  color: var(--rx-portal-green) !important;
  border: 2px solid var(--rx-soft-line) !important;
  cursor: default;
}

/* can't be ordered */
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn.ge-rx-btn--off,
.pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn.ge-rx-btn--off:hover {
  background: #e5e7eb !important;
  color: #6b7280 !important;
  cursor: default;
  pointer-events: none;
}
.ge-rx-actions .ge-rx-note { margin-top: 8px; text-align: left; }

/* ---- secondary links ---- */
.ge-rx-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; }
.pro-arch .ge-rx-card .ge-rx-link,
.pro-arch .ge-rx-card button.viewrs.ge-rx-link {
  width: auto;
  margin: 0;
  padding: 4px 2px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--rx-portal-green);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.pro-arch .ge-rx-card .ge-rx-link:hover { color: var(--rx-green-dark); }
.pro-arch .ge-rx-card .ge-rx-link:focus-visible { outline: 2px solid #46b266; outline-offset: 2px; }

/* ---- monthly usage box: outline the type that is at its limit ---- */
.usage-item.ge-usage-at-limit { outline: 2px solid #fdba74; outline-offset: 4px; border-radius: 4px; }

/* ---- hold / limit pop-up: square the buttons to match ---- */
.oma-hold-box .oma-btn-continue,
.oma-hold-box .oma-btn-cancel { border-radius: 4px; min-height: 44px; }

/* ---- cart bar (phones and small tablets) ---- */
.ge-cartbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;                 /* under the header menu, mini cart and cookie banner */
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px max(14px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
  background: #fff;
  border-top: 1px solid #e7ebe9;
  box-shadow: 0 -8px 20px rgba(12, 24, 20, .10);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #0f172a;
  transform: translateY(110%);
  transition: transform .25s ease;
}
.ge-cartbar, .ge-cartbar * { box-sizing: border-box; }
.ge-cartbar[hidden] { display: none !important; }
.ge-cartbar.is-shown { transform: none; }
.ge-cartbar__sum { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; line-height: 1.25; }
.ge-cartbar__label { font-size: 12px; color: #6b7280; }
.ge-cartbar__total { font-size: 17px; font-variant-numeric: tabular-nums; }
.ge-cartbar a.ge-cartbar__go {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 4px;
  background: #1a5c38;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.ge-cartbar a.ge-cartbar__go:hover,
.ge-cartbar a.ge-cartbar__go:focus { background: #144a2c; color: #fff; }
body.ge-cartbar-open { padding-bottom: 76px; }

@media (min-width: 901px) {
  .ge-cartbar { display: none !important; }
  body.ge-cartbar-open { padding-bottom: 0; }
}

/* ---- phones ---- */
@media (max-width: 480px) {
  .ge-rx-howto { padding: 8px 10px; gap: 6px; }
  .ge-rx-howto li { font-size: 12px; }
  .pro-arch .pro-card.ge-rx-card { padding: 12px; }
  .ge-rx-head { grid-template-columns: minmax(0, 1fr) 60px; }
  .ge-rx-card .pro-thumb-wrap, .ge-rx-card .pro-thumb { width: 60px; }
  .ge-rx-card .pro-thumb { height: 60px; }
  .pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn { font-size: 15px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .ge-cartbar, .pro-arch .ge-rx-card .ge-rx-actions .ge-rx-btn { transition: none; }
}
