.mdms-inline-mini-cart-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 125000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 28px;
  background: #007cba;
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}
.mdms-inline-mini-cart-btn svg {
  display: block;
  width: 30px; /* basket icon slightly larger for clarity */
  height: 30px;
}
.mdms-inline-mini-cart-btn .mdms-cart-badge {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(
    50%,
    -30%
  ); /* push badge outward; overlaps ~half of its area */
  background: #ff4d4f;
  color: #fff;
  border-radius: 9999px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px; /* pill for 2–3 digits */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px #fff; /* subtle ring to separate from button */
}
.mdms-inline-mini-cart-panel {
  position: fixed;
  right: 20px;
  bottom: 84px;
  z-index: 110000;
  width: 360px;
  max-width: calc(100% - 40px);
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  display: none;
  transform: translateX(100%);
  transition: transform 260ms cubic-bezier(0.2, 0.9, 0.2, 1);
}
.mdms-inline-mini-cart-panel.mdms-open {
  display: block;
  transform: translateX(0);
  z-index: 130000;
  /* Ensure focus outline is visible against panel background */
  outline: none;
}
.mdms-mini-cart-header {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
  font-weight: 700;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mdms-mini-cart-header .mdms-mini-cart-close:focus {
  outline: 2px solid rgba(0, 124, 186, 0.4);
  outline-offset: 2px;
  border-radius: 4px;
}
.mdms-mini-cart-body {
  max-height: 320px;
  overflow: auto;
  padding: 10px;
}
.mdms-mini-cart-body ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.mdms-mini-cart-body li {
  padding: 10px 0;
  border-bottom: 1px solid #f5f5f5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: opacity 180ms ease;
}
/* Long message safety: allow toast-like content to wrap inside panel content */
.mdms-mini-cart-content,
.mdms-mini-cart-content * {
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.mdms-mini-cart-footer {
  padding: 10px;
  border-top: 1px solid #f0f0f0;
  text-align: right;
  background: #fff;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.mdms-mini-cart-footer a {
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
}
.mdms-mini-cart-footer .mdms-shop {
  background: #f5f5f5;
  color: #222;
}
.mdms-mini-cart-footer .mdms-view-cart {
  background: #f5f5f5;
  color: #222;
}
.mdms-mini-cart-footer .mdms-checkout {
  background: #007cba;
  color: #fff;
}
/* Aside fallback styles and make aside non-intrusive */
.mdms-inline-aside {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  width: 64px;
  z-index: 99999;
  pointer-events: none;
  background: transparent;
}
.mdms-inline-aside .mdms-inline-mini-cart-btn {
  position: absolute;
  right: -26px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;
}
/* When cart is empty we can dim the button */
.mdms-inline-mini-cart-btn.mdms-cart-empty {
  opacity: 0.85;
  background: #6c8ea6;
}
/* Distinct disabled state used on the Shop page when the cart is empty */
.mdms-inline-mini-cart-btn.mdms-disabled-on-shop {
  opacity: 0.55;
  background: #9aaebe; /* lighter/desaturated to distinguish from empty */
  cursor: not-allowed;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
/* Simple tooltip for the mini-cart button */
.mdms-mini-cart-tooltip {
  position: fixed;
  z-index: 110000;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.86);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.mdms-mini-cart-tooltip.mdms-show {
  opacity: 1;
  transform: translateY(0);
}

/* Backdrop that appears when the panel is open on mobile */
.mdms-mini-cart-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  z-index: 120000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
}
.mdms-mini-cart-backdrop.mdms-show {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile bottom-sheet styles (applies for narrow viewports) */
@media (max-width: 768px) {
  .mdms-inline-mini-cart-panel {
    /* make the panel a bottom-sheet */
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    height: 60vh;
    max-height: calc(100vh - 64px);
    border-radius: 12px 12px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    transform: translateY(100%);
    display: block;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    transition: transform 300ms cubic-bezier(0.2, 0.9, 0.2, 1);
  }
  .mdms-inline-mini-cart-panel.mdms-open {
    transform: translateY(0);
    z-index: 125000;
  }

  .mdms-mini-cart-header {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
  }

  /* Make body scrollable within the bottom-sheet with native momentum on iOS */
  .mdms-mini-cart-body {
    max-height: calc(60vh - 110px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Make footer sticky to bottom of sheet */
  .mdms-mini-cart-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    z-index: 2;
  }

  /* Ensure the floating button sits above sheet when closed */
  .mdms-inline-mini-cart-btn {
    right: 16px;
    bottom: 16px;
  }

  /* Larger badge spacing on mobile */
  .mdms-inline-mini-cart-btn .mdms-cart-badge {
    right: 0;
    top: 0;
    transform: translate(55%, -35%);
  }
}

/* class applied to <body> while sheet is open to lock scrolling */
.mdms-mini-cart-lock-scroll {
  overflow: hidden;
  height: 100%;
}

/* Remove button styling and spinner */
.mdms-cart-remove {
  border: none;
  background: transparent;
  color: #f05a5a;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mdms-cart-remove:hover {
  transform: scale(1.06);
  color: #d64545;
}
.mdms-cart-remove:focus {
  outline: 2px solid rgba(0, 124, 186, 0.15);
  outline-offset: 2px;
}
.mdms-cart-remove.is-loading {
  color: transparent;
  pointer-events: none;
}
.mdms-cart-remove.is-loading:after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-top-color: #007cba;
  display: inline-block;
  box-sizing: border-box;
  animation: mdms-spinner 800ms linear infinite;
}

@keyframes mdms-spinner {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Ensure fragment images stay constrained if fragment contains larger markup */
.mdms-mini-cart-content img {
  max-width: 48px;
  max-height: 48px;
  object-fit: cover;
}

/* Light polish: title emphasis and remove anchor alignment within our panel */
.mdms-inline-mini-cart-panel .mdms-mini-cart-content .mdms-cart-item-title {
  font-weight: 600;
  line-height: 1.3;
  color: #222;
}
.mdms-inline-mini-cart-panel .mdms-mini-cart-content a.remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #f05a5a;
  margin-right: 8px;
  text-decoration: none;
}
.mdms-inline-mini-cart-panel .mdms-mini-cart-content a.remove:hover {
  color: #d64545;
  transform: scale(1.06);
}
/* Spinner on Woo remove anchors reused in our panel */
.mdms-inline-mini-cart-panel .mdms-mini-cart-content a.remove.is-loading {
  color: transparent;
  pointer-events: none;
  position: relative;
}
.mdms-inline-mini-cart-panel .mdms-mini-cart-content a.remove.is-loading:after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-top-color: #007cba;
  display: inline-block;
  box-sizing: border-box;
  animation: mdms-spinner 800ms linear infinite;
}
/* Respect Woo/Theme removal state classes to create a subtle fade */
.mdms-mini-cart-body li.removing {
  opacity: 0;
}
.mdms-mini-cart-body li.loading {
  opacity: 0.5;
}

/* Toast stack and items (moved from inline styles in JS) */
#mdms-toast-stack {
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 2147483646; /* keep above most UI */
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none; /* allow clicks through gaps */
  width: var(--mdms-toast-width, 360px);
  max-width: calc(100vw - 40px);
}

/* React-Toastify inspired card with colored accent and left icon */
.mdms-toast-item {
  position: relative;
  pointer-events: auto; /* clickable */
  display: grid;
  grid-template-columns: 40px 1fr 28px; /* icon | text | close */
  align-items: center;
  gap: 12px;
  background: #fff;
  color: #222;
  border-radius: 10px;
  padding: 12px 10px 12px 10px; /* extra left padding pairs with accent bar */
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
  border-left: 6px solid var(--mdms-toast-accent, #3b82f6);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 200ms ease, transform 200ms ease, filter 160ms ease;
}
.mdms-toast-item:not(:first-child) {
  /* Dim older toasts without fighting inline opacity set by JS */
  filter: opacity(0.85);
}
.mdms-toast-item:hover,
.mdms-toast-item:focus-within {
  /* Restore full emphasis when interacted with (mouse or keyboard) */
  filter: none;
}
.mdms-toast-item .mdms-toast-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--mdms-toast-accent-bg, rgba(59, 130, 246, 0.12));
  color: var(--mdms-toast-accent, #3b82f6);
}
.mdms-toast-item .mdms-toast-content {
  display: flex;
  flex-direction: column;
}
.mdms-toast-item .mdms-toast-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
  margin: 0;
}
.mdms-toast-item .mdms-toast-text {
  font-size: 13px;
  color: #444;
  margin-top: 2px;
}
.mdms-toast-item .mdms-toast-close {
  border: none;
  background: transparent;
  color: #7a7a7a;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  justify-self: end;
}
.mdms-toast-item .mdms-toast-close:hover {
  color: #444;
}
.mdms-toast-item .mdms-toast-close:focus {
  outline: 2px solid rgba(0, 124, 186, 0.4);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Variants */
.mdms-toast--success {
  --mdms-toast-accent: #16a34a; /* green-600 */
  --mdms-toast-accent-bg: rgba(22, 163, 74, 0.12);
}
.mdms-toast--error {
  --mdms-toast-accent: #dc2626; /* red-600 */
  --mdms-toast-accent-bg: rgba(220, 38, 38, 0.12);
}
.mdms-toast--warning {
  --mdms-toast-accent: #d97706; /* amber-600 */
  --mdms-toast-accent-bg: rgba(217, 119, 6, 0.12);
}
.mdms-toast--info {
  --mdms-toast-accent: #0ea5e9; /* sky-600 */
  --mdms-toast-accent-bg: rgba(14, 165, 233, 0.12);
}
