/* =========================================================
   Cart Drawer
   Compact + readable single source of truth
   ========================================================= */

/* Overlay + drawer shell */
.cart-drawer-overlay {
  position: fixed;
  inset: 0;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99990;
  opacity: 0;
  visibility: hidden;
  cursor: pointer;
  pointer-events: none;
  backdrop-filter: blur(2px);
  will-change: opacity;
  transition: opacity 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), visibility 0.35s ease;
}

.cart-drawer-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.cart-drawer {
  /* Reset design tokens to base theme defaults so the Site Customizer
     :root:root overrides don't leak into the cart drawer. */
  --nm-primary-color: #595e73;
  --nm-primary-hover: #464a5c;
  --nm-white: #ffffff;
  --nm-body-bg: #ffffff;
  --nm-text-primary: #333;
  --nm-gray-100: #f8f8f8;
  --nm-gray-200: #e3e3e3;
  --nm-gray-700: #464a4f;
  --nm-border-color: #dee2e6;

  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  width: 400px;
  max-width: 85vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--nm-white, #fff) !important;
  color: #333 !important;
  box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
  transform: translateX(-100%);
  visibility: hidden;
  touch-action: pan-y;
  will-change: transform;
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 99991;
}

[dir="rtl"] .cart-drawer,
html[lang="ar"] .cart-drawer {
  left: 0;
  right: auto;
  transform: translateX(-100%);
}

.cart-drawer.open {
  transform: translateX(0);
  visibility: visible;
}


/* Header */
.cart-drawer-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  color: #fff;
  background: linear-gradient(135deg, var(--nm-primary-color, #667eea), #764ba2);
  flex-shrink: 0;
}

.cart-drawer-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
}

.cart-drawer-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.cart-drawer-title svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.cart-drawer-count {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.25);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  margin-inline-start: 8px;
}

.cart-drawer-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cart-drawer-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.cart-drawer-close svg { width: 20px; height: 20px; }

/* Shipping */


/* Items container + empty state */
.cart-drawer-items {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}


.cart-drawer-empty {
  height: 100%;
  padding: 60px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.cart-drawer-empty svg {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  color: #ddd;
}

.cart-drawer-empty-text { margin-bottom: 8px; font-size: 18px; font-weight: 600; color: #333; }
.cart-drawer-empty-subtext { margin-bottom: 24px; font-size: 14px; color: #888; }

.cart-drawer-shop-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border: 0;
  border-radius: 30px;
  background: linear-gradient(135deg, var(--nm-primary-color) 0%, var(--nm-primary-hover) 100%);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
}


/* Item row */
.cart-drawer-item {
  position: relative;
  display: flex;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--nm-gray-100);
  transition: background 0.2s ease;
}


.cart-drawer-item:last-child { border-bottom: 0; }

.cart-drawer-item-image {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--nm-gray-100);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cart-drawer-item-image img { width: 100%; height: 100%; object-fit: cover; }


.cart-drawer-item-details {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cart-drawer-item-image-link,
.cart-drawer-item-name-link {
  display: block;
  color: inherit;
  text-decoration: none;
}


.cart-drawer-item-name {
  margin: 0;
  color: #1a1a2e;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.2s ease;
}


.cart-drawer-item-price { color: var(--nm-primary-color, #667eea); font-size: 16px; font-weight: 700; }

.cart-drawer-item-discount {
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.cart-drawer-item-original-price { color: #999; text-decoration: line-through; }
.cart-drawer-item-savings {
  color: #2e7d32;
  background: #e8f5e9;
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 600;
}

/* Quantity + remove */
.cart-drawer-item-quantity {
  margin-top: 8px;
  display: flex;
  align-items: center;
  direction: ltr;
}

[dir="rtl"] .cart-drawer-item-quantity,
html[lang="ar"] .cart-drawer-item-quantity {
  margin-left: auto;
  margin-right: 0;
}

.cart-drawer-qty-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--nm-gray-200);
  background: #fff;
  color: #333;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cart-drawer-qty-btn:first-child { border-radius: 6px 0 0 6px; }
.cart-drawer-qty-btn:last-child { border-radius: 0 6px 6px 0; }


.cart-drawer-qty-value {
  width: 40px;
  height: 28px;
  border-top: 1px solid var(--nm-gray-200);
  border-bottom: 1px solid var(--nm-gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #333;
  font-size: 14px;
  font-weight: 600;
}

.cart-drawer-item-remove {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.1);
  color: var(--nm-danger-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

[dir="rtl"] .cart-drawer-item-remove,
html[lang="ar"] .cart-drawer-item-remove {
  right: auto;
  left: 16px;
}


.cart-drawer-item-remove svg { width: 16px; height: 16px; }

/* Footer + actions */
.cart-drawer-footer {
  flex-shrink: 0;
  padding: 20px 24px;
  background: #fff;
  border-top: 1px solid var(--nm-gray-100);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

.cart-drawer-subtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--nm-gray-200);
}

.cart-drawer-subtotal-label { color: #666; font-size: 14px; }
.cart-drawer-subtotal-value { color: var(--nm-primary-color, #667eea); font-size: 22px; font-weight: 700; }

.cart-drawer-discount {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  border: 1px solid #a5d6a7;
  border-radius: 8px;
}

.cart-drawer-discount-label { color: #2e7d32; font-size: 14px; font-weight: 600; }
.cart-drawer-discount-value { color: #1b5e20; font-size: 16px; font-weight: 700; }


.cart-drawer-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cart-drawer-checkout-btn,
.cart-drawer-view-cart-btn {
  width: 100%;
  border: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.3s ease;
}

.cart-drawer-checkout-btn {
  gap: 10px;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--nm-primary-color, #667eea) 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}


.cart-drawer-view-cart-btn {
  gap: 8px;
  padding: 14px 24px;
  background: #f5f5f5;
  color: #666;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}


.cart-drawer-view-cart-btn svg { width: 18px; height: 18px; }

/* Loading + stock errors */

/* Stock/availability error block in cart drawer */
.cart-drawer-stock-error {
  margin: 0 0 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #fff8f0 0%, #ffefe6 100%);
  border: 1px solid #f5c6a8;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(220, 120, 60, 0.08);
}

.cart-drawer-stock-error .stock-error-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.cart-drawer-stock-error .stock-error-header svg {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-top: 2px;
  color: #c2410c;
  stroke: #c2410c;
}

.cart-drawer-stock-error .stock-error-header span {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: #9a3412;
  line-height: 1.45;
}

.cart-drawer-stock-error .stock-error-list {
  margin: 0 0 16px;
  padding: 0 0 0 20px;
  list-style: none;
}

[dir="rtl"] .cart-drawer-stock-error .stock-error-list,
html[lang="ar"] .cart-drawer-stock-error .stock-error-list {
  padding: 0 20px 0 0;
}

.cart-drawer-stock-error .stock-error-list li {
  margin-bottom: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  border-left: 3px solid #ea580c;
  font-size: 13px;
  line-height: 1.5;
}

[dir="rtl"] .cart-drawer-stock-error .stock-error-list li,
html[lang="ar"] .cart-drawer-stock-error .stock-error-list li {
  border-left: 0;
  border-right: 3px solid #ea580c;
}

.cart-drawer-stock-error .stock-error-list li:last-child {
  margin-bottom: 0;
}

.cart-drawer-stock-error .stock-error-list strong {
  display: block;
  color: #1a1a2e;
  font-size: 13px;
  margin-bottom: 4px;
}

.cart-drawer-stock-error .stock-error-detail {
  display: block;
  font-size: 12px;
  color: #b45309;
  font-weight: 500;
}

.cart-drawer-stock-error .stock-error-close {
  display: block;
  width: 100%;
  padding: 12px 20px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.15s ease;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.3);
}

.cart-drawer-stock-error .stock-error-close:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.cart-drawer-stock-error .stock-error-close:active {
  transform: translateY(0);
}

/* Highlight item row when it has a stock error */
.cart-drawer-item.stock-error-item {
  background: #fffbf7;
  border-color: #f5c6a8;
}

.cart-drawer-qty-value.stock-error-qty {
  color: #c2410c;
  font-weight: 700;
  border-color: #f5c6a8;
  background: #fff8f0;
}

.cart-drawer-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(102, 126, 234, 0.2);
  border-top-color: var(--nm-primary-color);
  border-radius: 50%;
  animation: cart-spinner 0.8s linear infinite;
}


.cart-drawer-items.fade-in { animation: fade-in-content 0.3s ease forwards; }
.cart-drawer-items.fade-in .cart-drawer-item { animation: slide-in-item 0.3s ease forwards; }
.cart-drawer-item:nth-child(1) { animation-delay: 0.05s; }


/* Full-page loading overlay */
.cart-drawer-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.cart-drawer-loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.cart-drawer-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 48px;
  background: var(--nm-white, #fff);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: loading-bounce-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cart-drawer-loading-content .cart-drawer-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--nm-gray-200, #e5e7eb);
  border-top-color: var(--nm-primary, #000);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.cart-drawer-loading-content span {
  color: var(--nm-text-primary, #111);
  font-size: 15px;
  font-weight: 500;
}

/* Keep old dropdown hidden + lock page interactions */
.cart-block--contents,
.cart-block--contents.bg-primary,
.cart-block--contents__expanded,
.cart-block--contents.cart-block--contents__expanded {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body.cart-drawer-open { overflow: hidden !important; }

body.cart-drawer-open > *:not(.cart-drawer):not(.cart-drawer-overlay) {
  pointer-events: none !important;
}

body.cart-drawer-open .cart-drawer,
body.cart-drawer-open .cart-drawer-overlay {
  pointer-events: auto !important;
}

/* Responsive */
@media screen and (max-width: 768px) {
  .cart-drawer {
    width: 320px;
    max-width: 85vw;
  }
}

@media screen and (max-width: 480px) {
  .cart-drawer {
    width: 280px;
    max-width: 80vw;
  }

  .cart-drawer-header,
  .cart-drawer-footer { padding: 14px 16px; }

  .cart-drawer-title { font-size: 16px; }
  .cart-drawer-count { font-size: 12px; padding: 3px 10px; }
  .cart-drawer-item { padding: 12px 16px; gap: 10px; }
  .cart-drawer-item-image { width: 60px; height: 60px; }
  .cart-drawer-item-name { font-size: 12px; }
  .cart-drawer-item-price { font-size: 13px; }
  .cart-drawer-subtotal-value { font-size: 18px; }
  .cart-drawer-checkout-btn { padding: 12px 16px; font-size: 14px; }
  .cart-drawer-qty-btn { width: 26px; height: 26px; font-size: 14px; }
  .cart-drawer-qty-value { width: 35px; height: 26px; font-size: 13px; }
}

/* Keyframes */


