/* Mini Cart Drawer - App-like full redesign (high-specificity, theme-proof) */

:root {
  --mc-bg: rgba(255,255,255,0.8);
  --mc-border: rgba(0,0,0,0.08);
  --mc-fg: #0f172a;
  --mc-muted: #475569;
  --mc-accent: #ad0000; /* brand */
  --mc-radius: 18px;
  --mc-shadow: 0 24px 50px rgba(0,0,0,0.25);
}

/* Respect prefers-color-scheme */
@media (prefers-color-scheme: dark) {
  :root {
    --mc-bg: rgba(20,22,24,0.82);
    --mc-border: rgba(255,255,255,0.12);
    --mc-fg: #e5e7eb;
    --mc-muted: #cbd5e1;
    --mc-shadow: 0 30px 60px rgba(0,0,0,0.6);
  }
}

/* Override with site's dark mode (via data-dracula-scheme or dark class) */
html.dark:root,
html[data-dracula-scheme="dark"]:root {
  --mc-bg: rgba(20,22,24,0.82);
  --mc-border: rgba(255,255,255,0.12);
  --mc-fg: #e5e7eb;
  --mc-muted: #cbd5e1;
  --mc-shadow: 0 30px 60px rgba(0,0,0,0.6);
}

/* Light mode override (explicitly light) */
html:not(.dark):root,
html:not([data-dracula-scheme="dark"]):root {
  --mc-bg: rgba(255,255,255,0.8);
  --mc-border: rgba(0,0,0,0.08);
  --mc-fg: #0f172a;
  --mc-muted: #475569;
  --mc-shadow: 0 24px 50px rgba(0,0,0,0.25);
}



/* overlay polish */
.mfp-bg { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 99999 !important;}

/* ===== Animation: slide up/down ===== */
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

/* ===== Mobile: bottom sheet ===== */
@media (max-width: 850px) {
  .category-page-row {
    padding-top: 10px !important;
  }
  div#cart-popup {
    background-color: white !important;
    border-bottom-right-radius: 0 !important;
    width: 90% !important;
    margin: 0 auto;
    /* min-height: 100%; */
  }
  html, body { overflow-x: hidden; }

  /* container */
  #cart-popup,
  .cart-popup,
  .off-canvas-cart,
  .off-canvas .cart-sidebar,
  .off-canvas .cart-panel {
    position: fixed !important;
    inset: auto 0 0 0 !important; /* left:0; right:0; bottom:0 */
    top: auto !important;
    width: 100vw !important;
    max-height: 82vh !important;
    box-sizing: border-box !important;
    background: var(--mc-bg) !important;
    backdrop-filter: blur(18px) saturate(130%) !important;
    -webkit-backdrop-filter: blur(18px) saturate(130%) !important;
    border-top-left-radius: var(--mc-radius) !important;
    border-top-right-radius: var(--mc-radius) !important;
    border: 1px solid var(--mc-border) !important;
    box-shadow: var(--mc-shadow) !important;
    overflow: hidden !important;
    z-index: 10020 !important;
    direction: rtl; text-align: right;
    
    /* Slide animation */
    animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    will-change: transform, opacity;
  }

  /* closing state animation */
  #cart-popup.is-closing,
  .cart-popup.is-closing,
  .off-canvas-cart.is-closing,
  .off-canvas.is-closing .cart-sidebar,
  .off-canvas.is-closing .cart-panel {
    animation: slideDown 0.3s cubic-bezier(0.7, 0, 0.84, 0) forwards !important;
  }

  /* header (if exists) */
  #cart-popup .off-canvas-header,
  .cart-popup .off-canvas-header,
  .off-canvas .off-canvas-header {
    display: flex !important; align-items: center !important; justify-content: center !important;
    gap: 8px; position: relative; padding: 12px 16px !important;
    border-bottom: 1px solid var(--mc-border) !important; color: var(--mc-fg) !important;
  }
  #cart-popup .off-canvas-header:after,
  .cart-popup .off-canvas-header:after,
  .off-canvas .off-canvas-header:after { content: ""; position: absolute; bottom: -1px; width: 88px; height: 3px; background: var(--mc-accent); border-radius: 8px; }

  /* close button */

  /* inner content area */
  #cart-popup .widget_shopping_cart_content,
  .cart-popup .widget_shopping_cart_content,
  .off-canvas .widget_shopping_cart_content {
    max-height: calc(82vh - 56px - env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: hidden !important;
    padding: 12px 14px 46px !important; /* leave room for sticky footer */
  }
  ul.product_list_widget li img {
    right: 10px !important;
    top: 7px !important;
  }
  .off-canvas-left.mfp-ready .mfp-content, .off-canvas-right.mfp-ready .mfp-content {
    background-color: transparent !important;
    border-bottom-right-radius: 0px !important;
  }
  #cart-popup span.heading-font.uppercase {
    font-size: 18px;
  }
  .widget_shopping_cart .total, .woocommerce-mini-cart__total {
    font-size: 16px !important;
  }
}

/* ===== Items layout (both viewports) ===== */
.widget_shopping_cart .woocommerce-mini-cart,
.woocommerce-mini-cart {
  list-style: none; margin: 0; padding: 0 !important;
  display: flex; flex-direction: column; gap: 10px;
}

.widget_shopping_cart .woocommerce-mini-cart li,
.woocommerce-mini-cart li {
  display: grid !important;
  grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center;
  padding: 10px !important; position: relative;
  border: 1px solid var(--mc-border) !important; border-radius: 14px !important;
  background: rgba(255,255,255,0.7) !important;
}

@media (prefers-color-scheme: dark) {
  .widget_shopping_cart .woocommerce-mini-cart li,
  .woocommerce-mini-cart li {
    background: rgba(255,255,255,0.06) !important;
  }
}

html.dark .widget_shopping_cart .woocommerce-mini-cart li,
html.dark .woocommerce-mini-cart li,
html[data-dracula-scheme="dark"] .widget_shopping_cart .woocommerce-mini-cart li,
html[data-dracula-scheme="dark"] .woocommerce-mini-cart li {
  background: rgba(255,255,255,0.06) !important;
}

html:not(.dark) .widget_shopping_cart .woocommerce-mini-cart li,
html:not(.dark) .woocommerce-mini-cart li,
html:not([data-dracula-scheme="dark"]) .widget_shopping_cart .woocommerce-mini-cart li,
html:not([data-dracula-scheme="dark"]) .woocommerce-mini-cart li {
  background: rgba(255,255,255,0.7) !important;
}

/* image */
.widget_shopping_cart .woocommerce-mini-cart img,
.woocommerce-mini-cart img {
  width: 64px !important; height: 64px !important; border-radius: 12px !important; object-fit: cover !important; flex-shrink: 0 !important;
}

/* title link */
.widget_shopping_cart .woocommerce-mini-cart li a:not(.remove),
.woocommerce-mini-cart li a:not(.remove) {
  color: var(--mc-fg) !important; font-weight: 700 !important; text-decoration: none !important;
  display: block !important; max-width: 100% !important; overflow: hidden !important; white-space: nowrap !important; text-overflow: ellipsis !important;
}

/* quantity/price */
.widget_shopping_cart .woocommerce-mini-cart li .quantity,
.woocommerce-mini-cart li .quantity { color: var(--mc-muted) !important; font-size: 12px !important; }

/* remove */
.widget_shopping_cart .woocommerce-mini-cart li .remove,
.woocommerce-mini-cart li .remove {
  color: #e11d48 !important; background: rgba(225,29,72,0.08) !important; border-radius: 10px !important;
  width: 28px !important; height: 28px !important; line-height: 28px !important; text-align: center !important;
}

/* ===== Footer (totals + buttons) ===== */
.widget_shopping_cart .total,
.woocommerce-mini-cart__total {
  background: transparent !important; color: var(--mc-fg) !important;
  display: flex !important; align-items: center !important; justify-content: space-between !important;
  padding: 10px 2px !important; margin-top: 8px !important; border-top: 1px dashed var(--mc-border) !important;
}

.widget_shopping_cart .buttons,
.woocommerce-mini-cart__buttons {
  position: sticky !important; bottom: 0 !important; z-index: 5 !important;
  display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 10px !important;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px)) !important;
  margin: 0 -14px -6px -14px !important; /* stretch to panel edges */
  background: linear-gradient(to top, rgba(255,255,255,0.96), rgba(255,255,255,0.5)) !important;
  backdrop-filter: blur(10px) !important; border-top: 1px solid var(--mc-border) !important;
}

@media (prefers-color-scheme: dark) {
  .widget_shopping_cart .buttons,
  .woocommerce-mini-cart__buttons {
    background: linear-gradient(to top, rgba(20,22,24,0.97), rgba(20,22,24,0.5)) !important;
  }
}

html.dark .widget_shopping_cart .buttons,
html.dark .woocommerce-mini-cart__buttons,
html[data-dracula-scheme="dark"] .widget_shopping_cart .buttons,
html[data-dracula-scheme="dark"] .woocommerce-mini-cart__buttons {
  background: linear-gradient(to top, rgba(20,22,24,0.97), rgba(20,22,24,0.5)) !important;
}

html:not(.dark) .widget_shopping_cart .buttons,
html:not(.dark) .woocommerce-mini-cart__buttons,
html:not([data-dracula-scheme="dark"]) .widget_shopping_cart .buttons,
html:not([data-dracula-scheme="dark"]) .woocommerce-mini-cart__buttons {
  background: linear-gradient(to top, rgba(255,255,255,0.96), rgba(255,255,255,0.5)) !important;
}

.widget_shopping_cart .buttons .button,
.woocommerce-mini-cart__buttons .button {
  border-radius: 12px !important; height: 46px !important; line-height: 46px !important;
  font-weight: 800 !important; text-align: center !important; border: 1px solid var(--mc-border) !important;
}

.widget_shopping_cart .buttons .button.checkout,
.woocommerce-mini-cart__buttons .button.checkout { background: var(--mc-accent) !important; color: #fff !important; border-color: var(--mc-accent) !important; font-size: 16px;}

.widget_shopping_cart .buttons .button:not(.checkout),
.woocommerce-mini-cart__buttons .button:not(.checkout) { background: rgba(0,0,0,0.06) !important; color: var(--mc-fg) !important; }

/* ===== Desktop side-panel polish ===== */
@media (min-width: 851px) {
  #cart-popup,
  .cart-popup,
  .off-canvas-cart,
  .off-canvas .cart-sidebar,
  .off-canvas .cart-panel {
    background: var(--mc-bg) !important;
    backdrop-filter: blur(12px) saturate(120%) !important;
    -webkit-backdrop-filter: blur(12px) saturate(120%) !important;
    border-left: 1px solid var(--mc-border) !important;
    height: 100%;
  }
}
