/* =========================================================================
   Digibouz Checkout — slide-out cart drawer.

   Ported from the qlimatix theme's header.css, where these rules lived under
   `#lohdr-root` (the theme's header wrapper). Rescoped to `.dbck-drawer-root`,
   which this plugin renders itself, and repointed at the `--dbck-*` tokens.

   THE SCROLL LAYOUT IS NOT COSMETIC. WooCommerce replaces `#dbckDrawerBody`
   wholesale on every fragment refresh, so that wrapper sits between the drawer's
   flex column and its children. Left alone it breaks the intended
   "scrolling body + pinned CTA": on a phone the items and upsell push the
   checkout button below the fold with nothing scrollable, i.e. a cart you
   cannot check out from. So the BODY is the single internal scroll area, the
   item list does not scroll, and the footer is sticky.
   ========================================================================= */

.dbck-drawer-root {
  font-family: var(--dbck-font, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
}

/* ---------- shell ---------- */
.dbck-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 42, 71, 0.46);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
  z-index: 100000;
}
.dbck-drawer-backdrop.is-open { opacity: 1; visibility: visible; }

.dbck-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 420px;
  max-width: 100vw;
  background: #fff;
  display: flex;
  flex-direction: column;
  z-index: 100001;
  visibility: hidden;
  transform: translateX(100%);
  transition: transform 0.34s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.34s;
  color: var(--dbck-text);
  box-shadow: -8px 0 40px rgba(13, 42, 71, 0.12);
}
.dbck-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.34s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0s;
}
@media (max-width: 480px) {
  .dbck-drawer { width: 100vw; }
}

/* The fragment-swapped wrapper IS the scroll area — see the header note. */
.dbck-drawer #dbckDrawerBody {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ---------- head ---------- */
.dbck-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--dbck-border);
  flex: none;
}
.dbck-drawer__title { display: flex; align-items: center; gap: 9px; font-size: 18px; font-weight: 600; }
.dbck-drawer__qty {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--dbck-accent);
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dbck-drawer__close {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--dbck-field-border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--dbck-text);
  flex: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.dbck-drawer__close:hover { background: var(--dbck-navy); border-color: var(--dbck-navy); color: #fff; }
.dbck-drawer__close svg { width: 15px; height: 15px; }

/* ---------- free shipping bar ---------- */
.dbck-drawer-ship { padding: 14px 22px; border-bottom: 1px solid var(--dbck-border); flex: none; }
.dbck-drawer-ship__msg { font-size: 13px; line-height: 1.4; margin: 0 0 9px; color: var(--dbck-muted); }
.dbck-drawer-ship__msg b { color: var(--dbck-text); font-weight: 600; }
.dbck-drawer-ship__msg .is-done { color: var(--dbck-green); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.dbck-drawer-ship__track { height: 7px; border-radius: 4px; background: var(--dbck-border-soft); overflow: hidden; }
.dbck-drawer-ship__fill { height: 100%; border-radius: 4px; background: var(--dbck-green); width: 0; transition: width 0.5s ease; }

/* ---------- items ---------- */
.dbck-drawer-items { flex: 0 0 auto; overflow: visible; padding: 6px 22px; }
.dbck-drawer-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 14px;
  padding: 18px 0;
  border-bottom: 1px solid var(--dbck-border);
  position: relative;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.dbck-drawer-item:last-child { border-bottom: 0; }
.dbck-drawer-item.is-removing { opacity: 0; transform: translateX(20px); }
.dbck-drawer-item.is-loading { opacity: 0.55; pointer-events: none; }

.dbck-drawer-item__media {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--dbck-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.dbck-drawer-item__media img { max-width: 84%; max-height: 84%; object-fit: contain; }

/* WooCommerce wraps the thumbnail in a link to the product. That anchor is the
   flex item, so the centring lands on IT — and it stretches to the full width,
   leaving the inline <img> inside it against the left edge. Making the anchor a
   centred box that fills the frame is what actually centres the image. */
.dbck-drawer-item__media > a,
.dbck-drawer-up__media > a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.dbck-drawer-item__main { min-width: 0; display: flex; flex-direction: column; }
.dbck-drawer-item__name { font-size: 14px; font-weight: 600; line-height: 1.32; margin: 0 0 8px; padding-right: 22px; color: var(--dbck-text); }
.dbck-drawer-item__unit { font-size: 13px; color: var(--dbck-muted-2); margin: 0 0 auto; }
.dbck-drawer-item__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.dbck-drawer-item__price { font-size: 15px; font-weight: 700; color: var(--dbck-text); white-space: nowrap; }

.dbck-drawer-item__remove {
  position: absolute;
  top: 18px;
  right: 0;
  width: 22px;
  height: 22px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--dbck-muted-2);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.15s ease, background 0.15s ease;
}
.dbck-drawer-item__remove:hover { color: var(--dbck-danger); background: #fbeaea; }
.dbck-drawer-item__remove svg { width: 13px; height: 13px; }

/* ---------- quantity ---------- */
.dbck-drawer-qtybox {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--dbck-field-border);
  border-radius: 999px;
  height: 34px;
  overflow: hidden;
}
.dbck-drawer-qtybox button {
  width: 34px;
  height: 34px;
  border: 0;
  background: #fff;
  cursor: pointer;
  color: var(--dbck-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.dbck-drawer-qtybox button:hover:not(:disabled) { background: var(--dbck-navy); color: #fff; }
.dbck-drawer-qtybox button:disabled { color: #c2cbd4; cursor: not-allowed; background: #fff; }
.dbck-drawer-qty-val { min-width: 30px; text-align: center; font-size: 14px; font-weight: 600; }
.dbck-drawer-qty-static { font-size: 13px; color: var(--dbck-muted); }

/* ---------- empty ---------- */
.dbck-drawer-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 30px;
  gap: 14px;
}
.dbck-drawer-empty svg { width: 56px; height: 56px; color: #c8d1da; }
.dbck-drawer-empty__title { margin: 0; font-size: 17px; font-weight: 600; }
.dbck-drawer-empty p { margin: 0; font-size: 14px; color: var(--dbck-muted-2); }

/* ---------- upsell ---------- */
.dbck-drawer-upsell {
  margin: 18px 22px 16px;
  background: var(--dbck-summary-bg);
  border-radius: 16px;
  padding: 16px 18px 18px;
}
.dbck-drawer-upsell__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dbck-drawer-upsell__title { font-size: 16px; font-weight: 600; color: var(--dbck-text); }
.dbck-drawer-upsell__sub { margin: 0 0 14px; font-size: 13px; line-height: 1.45; color: var(--dbck-muted); }
.dbck-drawer-upsell__list { display: flex; flex-direction: column; gap: 10px; }

.dbck-drawer-up {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.dbck-drawer-up.is-adding { opacity: 0; transform: scale(0.96); }
.dbck-drawer-up__media {
  width: 54px;
  height: 54px;
  border-radius: 9px;
  background: #fff;
  border: 1px solid var(--dbck-border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dbck-drawer-up__media img { max-width: 84%; max-height: 84%; object-fit: contain; }
.dbck-drawer-up__main { min-width: 0; }
.dbck-drawer-up__name { margin: 0 0 5px; font-size: 13.5px; font-weight: 600; line-height: 1.3; color: var(--dbck-text); }
.dbck-drawer-up__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dbck-drawer-up__price { font-size: 13px; color: var(--dbck-text); }
.dbck-drawer-up__price s { color: var(--dbck-muted-2); margin-right: 5px; font-weight: 400; }
.dbck-drawer-up__add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--dbck-accent);
  background: #fff;
  color: var(--dbck-accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.dbck-drawer-up__add:hover { background: var(--dbck-accent); color: #fff; }
.dbck-drawer-up__add svg { width: 13px; height: 13px; }

/* ---------- foot ---------- */
.dbck-drawer-foot {
  flex: none;
  position: sticky;
  bottom: 0;
  z-index: 1;
  border-top: 1px solid var(--dbck-border);
  padding: 18px 22px 22px;
  background: #fff;
}
.dbck-drawer-subtotal { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 2px; }
.dbck-drawer-subtotal span:first-child { font-size: 16px; font-weight: 600; }
.dbck-drawer-subtotal span:last-child { font-size: 20px; font-weight: 700; }
.dbck-drawer-vat { font-size: 12px; color: var(--dbck-muted-2); text-align: right; margin: 0 0 14px; }

.dbck-drawer-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 52px;
  background: var(--dbck-accent);
  color: #fff;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.dbck-drawer-cta:hover { background: var(--dbck-accent-hover-deep); box-shadow: 0 10px 22px rgba(13, 42, 71, 0.32); }
.dbck-drawer-cta svg { width: 17px; height: 17px; }

.dbck-drawer-edit {
  display: block;
  text-align: center;
  margin-top: 13px;
  font-size: 14px;
  color: var(--dbck-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}
.dbck-drawer-edit:hover { color: var(--dbck-accent); }

.dbck-drawer-pay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--dbck-border);
  flex-wrap: wrap;
}
/* The label spans the row; the paychips must NOT. `> span` matched the chips
   too — they are spans as well — so every logo took a full-width line and they
   stacked vertically instead of sitting side by side. */
.dbck-drawer-pay > span:not(.dbck-paychip) {
  font-size: 11.5px;
  color: var(--dbck-muted-2);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  justify-content: center;
  margin-bottom: 2px;
}
.dbck-drawer-pay .dbck-paychip {
  display: inline-flex;
  align-items: center;
  width: auto;
  flex: 0 0 auto;
}
.dbck-drawer-pay .dbck-paychip img { height: 20px; width: auto; max-width: 40px; object-fit: contain; border-radius: 3px; display: block; }

@media (prefers-reduced-motion: reduce) {
  .dbck-drawer,
  .dbck-drawer-backdrop,
  .dbck-drawer-ship__fill { transition: none; }
}

/* ---------------------------------------------------------------------------
   Takeover: hide the theme's own cart panel.

   Page builders ship their own mini-cart off-canvas. Left in place a site ends
   up with two cart panels that can disagree about what is in the cart — and on
   Bricks the theme's panel is still in the DOM even when ours opens. The body
   class is only present when the takeover setting is on, so a site that wants
   to keep its own panel simply switches it off.
   ------------------------------------------------------------------------ */

body.dbck-drawer-takeover .cart-detail.off-canvas,
body.dbck-drawer-takeover .brxe-woocommerce-mini-cart .cart-detail,
body.dbck-drawer-takeover .bricks-mini-cart,
body.dbck-drawer-takeover .wc-block-mini-cart__drawer,
body.dbck-drawer-takeover .widget_shopping_cart_content {
  display: none !important;
}

/* The toggle itself stays visible and clickable — it now opens our drawer. */
body.dbck-drawer-takeover .bricks-woo-toggle,
body.dbck-drawer-takeover .mini-cart-link { cursor: pointer; }
