/* ========================================
   CART DRAWER - Slide-in Sidebar Cart
   Modern design similar to filter sidebar
   ======================================== */

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

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

.cart-drawer-overlay.dragging {
  transition: none !important;
}

/* Cart Drawer Container - Always on the left for all languages */
.cart-drawer {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: auto !important;
  width: 400px !important;
  max-width: 85vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  background: #fff !important;
  z-index: 999999 !important;
  overflow: hidden !important;
  box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15) !important;
  transform: translateX(-100%) !important;
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
  visibility: hidden !important;
  touch-action: pan-y;
  will-change: transform;
  display: flex !important;
  flex-direction: column;
  font-family: "Cairo", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Keep drawer on left for RTL too */
[dir="rtl"] .cart-drawer,
html[lang="ar"] .cart-drawer {
  left: 0 !important;
  right: auto !important;
  transform: translateX(-100%) !important;
  box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15) !important;
}

/* Open state */
.cart-drawer.open,
[dir="rtl"] .cart-drawer.open,
html[lang="ar"] .cart-drawer.open {
  transform: translateX(0) !important;
  visibility: visible !important;
}

.cart-drawer.dragging {
  transition: none !important;
}

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

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

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

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

.cart-drawer-count {
  background: rgba(255,255,255,0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

.cart-drawer-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  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;
}

/* Free Shipping Progress Bar */
.cart-drawer-shipping-progress {
  padding: 16px 24px;
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
  border-bottom: 1px solid rgba(102, 126, 234, 0.1);
  flex-shrink: 0;
}

.shipping-progress-text {
  font-size: 13px;
  color: #333;
  margin-bottom: 10px;
  text-align: center;
}

.shipping-progress-text strong {
  color: #667eea;
}

.shipping-progress-bar {
  height: 8px;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.shipping-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 10px;
  transition: width 0.5s ease;
  position: relative;
}

.shipping-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.shipping-progress-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.shipping-progress-icon svg {
  width: 28px;
  height: 28px;
  color: #667eea;
}

.shipping-success {
  color: #10b981 !important;
  font-weight: 600;
}

.shipping-success svg {
  color: #10b981;
}

/* Cart Items Container */
.cart-drawer-items {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar */
.cart-drawer-items::-webkit-scrollbar {
  width: 6px;
}

.cart-drawer-items::-webkit-scrollbar-track {
  background: #f5f5f5;
}

.cart-drawer-items::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
  border-radius: 10px;
}

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

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

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

.cart-drawer-empty-subtext {
  font-size: 14px;
  color: #888;
  margin-bottom: 24px;
}

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

.cart-drawer-shop-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
  color: #fff;
}

/* Cart Item */
.cart-drawer-item {
  display: flex;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid #f0f0f0;
  position: relative;
  transition: background 0.2s ease;
}

.cart-drawer-item:hover {
  background: #fafafa;
}

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

/* Item Image */
.cart-drawer-item-image {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #f5f5f5;
  position: relative;
}

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

.cart-drawer-item-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
}

.cart-drawer-item-image-placeholder svg {
  width: 32px;
  height: 32px;
  color: #ccc;
}

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

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

.cart-drawer-item-variant {
  font-size: 12px;
  color: #888;
}

.cart-drawer-item-price {
  font-size: 15px;
  font-weight: 700;
  color: #667eea;
}

/* Quantity Controls */
.cart-drawer-item-quantity {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  margin-top: 8px;
  direction: ltr; /* Force LTR direction for quantity controls */
}

/* RTL - Shift quantity input to the right */
[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 #e0e0e0;
  background: #fff;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  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-btn:hover {
  background: #667eea;
  border-color: #667eea;
  color: #fff;
}

.cart-drawer-qty-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

/* Remove Button */
.cart-drawer-item-remove {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: #ccc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border-radius: 50%;
}

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

.cart-drawer-item-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

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

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

/* Subtotal */
.cart-drawer-subtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px dashed #e0e0e0;
}

.cart-drawer-subtotal-label {
  font-size: 14px;
  color: #666;
}

.cart-drawer-subtotal-value {
  font-size: 20px;
  font-weight: 700;
  color: #333;
}

/* Terms Checkbox */
.cart-drawer-terms {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #666;
}

.cart-drawer-terms input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: #667eea;
  cursor: pointer;
}

.cart-drawer-terms a {
  color: #667eea;
  text-decoration: underline;
}

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

.cart-drawer-checkout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s ease;
}

.cart-drawer-checkout-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.35);
  color: #fff;
}

.cart-drawer-checkout-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.cart-drawer-view-cart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: transparent;
  color: #333;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.cart-drawer-view-cart-btn:hover {
  border-color: #667eea;
  color: #667eea;
  background: rgba(102, 126, 234, 0.05);
}

/* Hide old cart dropdown completely */
.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;
}

/* Ensure cart drawer is always on top */
.cart-drawer {
  z-index: 999999 !important;
}

.cart-drawer-overlay {
  z-index: 999998 !important;
}

/* Body scroll lock when drawer is open */
body.cart-drawer-open {
  overflow: hidden !important;
}

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

/* Mobile Responsive - Small screens */
@media screen and (max-width: 480px) {
  .cart-drawer {
    width: 280px !important;
    max-width: 80vw !important;
  }
  
  .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-header {
    padding: 14px 16px;
  }
  
  .cart-drawer-title {
    font-size: 16px;
  }
  
  .cart-drawer-count {
    font-size: 12px;
    padding: 3px 10px;
  }
  
  .cart-drawer-footer {
    padding: 14px 16px;
  }
  
  .cart-drawer-checkout-btn {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  .cart-drawer-subtotal-value {
    font-size: 18px;
  }
  
  .cart-drawer-qty-btn {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }
  
  .cart-drawer-qty-value {
    width: 35px;
    height: 26px;
    font-size: 13px;
  }
}

/* Animations */
@keyframes slideInItem {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.cart-drawer-item {
  animation: slideInItem 0.3s ease forwards;
}

.cart-drawer-item:nth-child(1) { animation-delay: 0.05s; }
.cart-drawer-item:nth-child(2) { animation-delay: 0.1s; }
.cart-drawer-item:nth-child(3) { animation-delay: 0.15s; }
.cart-drawer-item:nth-child(4) { animation-delay: 0.2s; }
.cart-drawer-item:nth-child(5) { animation-delay: 0.25s; }

/* RTL - same animation since drawer is on left */
[dir="rtl"] .cart-drawer-item,
html[lang="ar"] .cart-drawer-item {
  animation-name: slideInItem;
}

/* ========================================
   STOCK VALIDATION ERROR STYLES
   ======================================== */

/* Stock error message container */
.cart-drawer-stock-error {
  background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
  border: 1px solid #fc8181;
  border-radius: 12px;
  margin: 16px;
  padding: 16px;
  animation: shakeError 0.5s ease;
}

@keyframes shakeError {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.stock-error-header {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #c53030;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
}

.stock-error-header svg {
  flex-shrink: 0;
  color: #e53e3e;
}

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

.stock-error-list li {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  color: #2d3748;
}

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

.stock-error-list li strong {
  color: #1a202c;
  display: block;
  margin-bottom: 4px;
}

.stock-error-detail {
  color: #718096;
  font-size: 12px;
}

.stock-error-close {
  width: 100%;
  padding: 10px 16px;
  background: #e53e3e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stock-error-close:hover {
  background: #c53030;
}

/* Highlight items with stock errors */
.cart-drawer-item.stock-error-item {
  background: #fff5f5 !important;
  border: 1px solid #fc8181 !important;
  border-radius: 12px;
  animation: pulseError 1s ease infinite;
}

@keyframes pulseError {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(229, 62, 62, 0); }
}

.cart-drawer-qty-value.stock-error-qty {
  color: #e53e3e !important;
  font-weight: 700 !important;
}

/* Checkout button loading state */
.cart-drawer-checkout-btn.loading {
  pointer-events: none;
  opacity: 0.8;
}

.cart-drawer-checkout-btn .spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

[dir="rtl"] .cart-drawer-checkout-btn .spinner,
html[lang="ar"] .cart-drawer-checkout-btn .spinner {
  margin-right: 0;
  margin-left: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

