/* ============================================================
   DONA FULANA — Cart Drawer Styles
   Slide-out cart with WhatsApp checkout
   ============================================================ */

/* ============================================================
   1. CART OVERLAY (#cart-overlay)
   ============================================================ */
#cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#cart-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ============================================================
   2. CART DRAWER (#cart-drawer)
   ============================================================ */
#cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: 420px;
  max-width: 90vw;
  background: var(--white);
  z-index: 2000;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
}

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

/* ============================================================
   3. CART HEADER (.cart-header)
   ============================================================ */
.cart-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--cream-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cart-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--burgundy);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cart-title .cart-count {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-light);
}

.cart-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
  line-height: 1;
}

.cart-close-btn:hover {
  color: var(--burgundy);
  background: var(--cream);
}

.cart-close-btn:active {
  transform: scale(0.92);
}

/* ============================================================
   4. CART ITEMS LIST (#cart-items-list)
   ============================================================ */
#cart-items-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  overscroll-behavior: contain;
}

/* Custom scrollbar for cart */
#cart-items-list::-webkit-scrollbar {
  width: 5px;
}

#cart-items-list::-webkit-scrollbar-track {
  background: transparent;
}

#cart-items-list::-webkit-scrollbar-thumb {
  background: rgba(var(--burgundy-rgb), 0.15);
  border-radius: 3px;
}

#cart-items-list::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--burgundy-rgb), 0.30);
}

/* ============================================================
   5. CART ITEM (.cart-item)
   ============================================================ */
.cart-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--cream-dark);
  position: relative;
  animation: cartItemFadeIn 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

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

/* ── Image ── */
.cart-item-image {
  width: 70px;
  height: 70px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--cream-dark);
}

/* ── Details ── */
.cart-item-details {
  flex: 1;
  min-width: 0;
  padding-right: 1.5rem;
}

.cart-item-name {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.cart-item-price {
  color: var(--burgundy);
  font-weight: 600;
  font-size: 0.95rem;
}

/* ── Quantity Controls ── */
.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--cream-dark);
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--text-medium);
  transition: var(--transition);
  line-height: 1;
  padding: 0;
}

.qty-btn:hover {
  border-color: var(--burgundy);
  color: var(--burgundy);
  background: rgba(var(--burgundy-rgb), 0.04);
}

.qty-btn:active {
  transform: scale(0.90);
}

.qty-value {
  min-width: 28px;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-dark);
  user-select: none;
}

/* ── Remove Button ── */
.cart-item-remove {
  position: absolute;
  top: 1rem;
  right: 0;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
  padding: 0.25rem;
  border-radius: 4px;
  line-height: 1;
  opacity: 0.6;
}

.cart-item-remove:hover {
  color: #EF4444;
  opacity: 1;
  background: rgba(239, 68, 68, 0.06);
}

/* ── Removing Animation ── */
.cart-item.removing {
  animation: cartItemFadeOutRight 0.3s ease forwards;
  pointer-events: none;
}

/* ============================================================
   6. CART EMPTY STATE (#cart-empty-message)
   ============================================================ */
#cart-empty-message {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
  filter: grayscale(30%);
}

.empty-text {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-medium);
  margin-bottom: 0.35rem;
}

.empty-subtext {
  font-size: 0.85rem;
  color: var(--text-light);
}

/* ============================================================
   7. CART FOOTER (.cart-footer)
   ============================================================ */
.cart-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--cream-dark);
  background: var(--white);
  flex-shrink: 0;
}

/* ─── Cart Customer Form ─── */
.cart-customer-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px dashed var(--cream-dark);
}

.cart-customer-form input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-dark);
  transition: var(--transition);
}

.cart-customer-form input:focus {
  border-color: var(--burgundy);
  outline: none;
  box-shadow: 0 0 0 3px rgba(107, 28, 58, 0.1);
}

.cart-customer-form input::placeholder {
  color: var(--text-light);
}

.cart-subtotal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-medium);
}

.cart-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--burgundy);
  margin-bottom: 1.5rem;
  padding-top: 0.75rem;
  border-top: 2px solid var(--cream-dark);
}

.cart-total .total-label {
  font-size: 1rem;
  font-weight: 600;
}

.cart-total .total-value {
  color: var(--burgundy-dark);
  font-family: var(--font-body);
}

/* ── WhatsApp Checkout Button ── */
#checkout-whatsapp-btn {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--burgundy) 0%, var(--burgundy-dark) 100%);
  color: var(--white);
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: var(--transition);
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}

#checkout-whatsapp-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--burgundy-light) 0%, var(--burgundy) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#checkout-whatsapp-btn:hover::before {
  opacity: 1;
}

#checkout-whatsapp-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(var(--burgundy-rgb), 0.35);
}

#checkout-whatsapp-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(var(--burgundy-rgb), 0.25);
}

#checkout-whatsapp-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#checkout-whatsapp-btn:disabled::before {
  display: none;
}

.whatsapp-btn-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.whatsapp-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ============================================================
   8. CART ANIMATIONS
   ============================================================ */
@keyframes cartItemFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cartItemFadeOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
    max-height: 120px;
  }
  to {
    opacity: 0;
    transform: translateX(60px);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border-bottom-width: 0;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   9. MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
  #cart-drawer {
    width: 100vw;
    max-width: 100vw;
  }

  .cart-header {
    padding: 1.25rem;
  }

  .cart-title {
    font-size: 1.15rem;
  }

  #cart-items-list {
    padding: 0.75rem 1.25rem;
  }

  .cart-item-image {
    width: 60px;
    height: 60px;
  }

  .cart-footer {
    padding: 1.25rem;
  }

  .cart-total {
    font-size: 1.15rem;
    margin-bottom: 1.25rem;
  }

  #checkout-whatsapp-btn {
    padding: 0.9rem;
    font-size: 0.95rem;
  }
}

@media (max-width: 768px) {
  #cart-drawer {
    width: 100vw;
    max-width: 100vw;
  }
}

/* ============================================================
   10. CART ITEM SUBTOTAL (per-item line total)
   ============================================================ */
.cart-item-subtotal {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.25rem;
  font-weight: 400;
}

/* ============================================================
   11. CART SHIMMER / LOADING STATE
   ============================================================ */
.cart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-light);
  gap: 0.75rem;
}

.cart-loading .spinner-small {
  width: 20px;
  height: 20px;
  border: 2px solid var(--cream-dark);
  border-top-color: var(--burgundy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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