/* ==============================================
   CART DRAWER - Desktop Side Panel
   ============================================== */

.cart-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.cart-drawer-overlay:not([hidden]) {
  opacity: 1;
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.cart-drawer.open {
  right: 0;
}

/* Hide drawer on mobile — use bottom sheet instead */
@media (max-width: 768px) {
  .cart-drawer,
  .cart-drawer-overlay {
    display: none !important;
  }
}

.cart-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}
.cart-drawer-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cart-drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  color: #9ca3af;
  padding: 2px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.cart-drawer-close:hover {
  background: #e5e7eb;
  color: #374151;
}

.cart-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.cart-drawer-footer {
  border-top: 1px solid #e5e7eb;
  padding: 16px 20px;
  background: #fff;
  flex-shrink: 0;
}

/* ==============================================
   CART PREVIEW — shared between drawer & sheet
   ============================================== */

.cart-preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cart-preview-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid #f3f4f6;
}
.cart-preview-item:last-child {
  border-bottom: none;
}
.cart-preview-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  flex-shrink: 0;
  background: #f9fafb;
}
.cart-preview-img-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.cart-preview-info {
  flex: 1;
  min-width: 0;
}
.cart-preview-name {
  font-size: 13px;
  font-weight: 500;
  color: #1f2937;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cart-preview-meta {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}
.cart-preview-subtotal {
  font-size: 13px;
  font-weight: 600;
  color: #e07b00;
  flex-shrink: 0;
  white-space: nowrap;
}
.cart-preview-empty {
  text-align: center;
  padding: 48px 24px;
  color: #9ca3af;
}
.cart-preview-empty span {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}
.cart-preview-empty p {
  margin: 0;
  font-size: 14px;
}
.cart-preview-loading,
.cart-preview-error {
  text-align: center;
  padding: 32px 24px;
  color: #6b7280;
  font-size: 14px;
}
.cart-preview-loading::before {
  content: '⏳ ';
}

/* Footer: total row + action buttons */
.cart-preview-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 14px;
  color: #374151;
}
.cart-preview-total strong {
  font-size: 17px;
  font-weight: 700;
  color: #1f2937;
}
.cart-preview-actions {
  display: flex;
  gap: 8px;
}
.cart-preview-actions .btn-cart-page {
  flex: 1;
  padding: 11px 10px;
  text-align: center;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: 1.5px solid #d1d5db;
  color: #374151;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  display: block;
}
.cart-preview-actions .btn-cart-page:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}
.cart-preview-actions .btn-checkout {
  flex: 1;
  padding: 11px 10px;
  text-align: center;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  background: linear-gradient(135deg, #FF8C00, #e07b00);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
  display: block;
}
.cart-preview-actions .btn-checkout:hover {
  opacity: 0.9;
}

/* ==============================================
   CART BOTTOM SHEET — Mobile
   ============================================== */

.cart-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  pointer-events: none;
}
.cart-sheet:not([hidden]) {
  pointer-events: auto;
}
.cart-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease-out;
}
.cart-sheet.active .cart-sheet-backdrop {
  opacity: 1;
}
.cart-sheet-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 20px 20px 0 0;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.cart-sheet.active .cart-sheet-content {
  transform: translateY(0);
}
.cart-sheet-handle {
  width: 40px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}
.cart-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 14px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.cart-sheet-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}
.cart-sheet-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  color: #9ca3af;
  padding: 2px 8px;
  border-radius: 6px;
  line-height: 1;
}
.cart-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  min-height: 0;
}
.cart-sheet-footer {
  border-top: 1px solid #e5e7eb;
  padding: 14px 20px;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
  flex-shrink: 0;
}

/* Hide bottom sheet on desktop — drawer is used instead */
@media (min-width: 769px) {
  .cart-sheet {
    display: none !important;
  }
}
