/* ==============================================
   CART DROPDOWN — Desktop hover popover (Blibli-style)
   ============================================== */

.cart-menu {
  position: relative;
  display: inline-flex;
}

.cart-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  max-width: min(380px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.14);
  z-index: 10050;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.cart-dropdown:not([hidden]) {
  display: flex !important;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.cart-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}

.cart-dropdown-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #1f2937;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cart-panel-icon {
  color: #6b7280;
  flex-shrink: 0;
  display: block;
}

.cart-dropdown-body {
  max-height: min(420px, 55vh);
  overflow-y: auto;
  padding: 4px 0;
  min-height: 120px;
}

.cart-dropdown-footer {
  border-top: 1px solid #e5e7eb;
  padding: 12px 16px 14px;
  background: #fff;
  flex-shrink: 0;
}

/* Hide dropdown on mobile — bottom sheet instead */
@media (max-width: 768px) {
  .cart-dropdown {
    display: none !important;
  }
}

/* ==============================================
   SKELETON loading
   ============================================== */

.cart-skel {
  padding: 8px 0 4px;
}
.cart-skel-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
}
.cart-skel-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: cart-skel-shine 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
.cart-skel-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}
.cart-skel-line {
  display: block;
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: cart-skel-shine 1.2s ease-in-out infinite;
}
.cart-skel-line.w40 { width: 40%; }
.cart-skel-line.w50 { width: 50%; }
.cart-skel-line.w55 { width: 55%; }
.cart-skel-line.w70 { width: 70%; }
.cart-skel-line.w80 { width: 80%; }
.cart-skel-line.w90 { width: 90%; }

@keyframes cart-skel-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cart-skel-thumb,
  .cart-skel-line,
  .cart-dropdown {
    animation: none;
    transition: none;
  }
}

/* ==============================================
   CART PREVIEW — shared list / empty / actions
   ============================================== */

.cart-preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cart-preview-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
}
.cart-preview-item:last-child {
  border-bottom: none;
}
.cart-preview-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  flex-shrink: 0;
  background: #f9fafb;
}
.cart-preview-img-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  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-variant {
  font-size: 11px;
  color: #4f46e5;
  font-weight: 600;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.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-more {
  display: block;
  text-align: center;
  padding: 10px 16px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #F28C1A;
  text-decoration: none;
}
.cart-preview-more:hover {
  text-decoration: underline;
}

.cart-preview-empty {
  text-align: center;
  padding: 28px 20px 32px;
  color: #9ca3af;
}
.cart-preview-empty-img {
  display: block;
  width: 140px;
  height: auto;
  margin: 0 auto 14px;
  object-fit: contain;
}
.cart-preview-empty-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}
.cart-preview-empty-sub {
  margin: 0 auto 14px;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
  max-width: 260px;
}
.cart-preview-empty-cta {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 10px;
  background: #F28C1A;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.cart-preview-empty-cta:hover {
  background: #d97809;
}

.cart-preview-loading,
.cart-preview-error {
  text-align: center;
  padding: 32px 24px;
  color: #6b7280;
  font-size: 14px;
}

.cart-preview-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  color: #374151;
}
.cart-preview-total strong {
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
}
.cart-preview-actions {
  display: flex;
  gap: 8px;
}
.cart-preview-actions .btn-cart-page {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  border-radius: 10px;
  font-size: 13px;
  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: 10px 8px;
  text-align: center;
  border-radius: 10px;
  font-size: 13px;
  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-preview-actions .btn-checkout.is-disabled,
.cart-preview-actions .btn-checkout[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  background: #9ca3af;
}

/* ==============================================
   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;
  display: flex;
  align-items: center;
  gap: 8px;
}
.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;
}

@media (min-width: 769px) {
  .cart-sheet {
    display: none !important;
  }
}
