/* === Cart Modal Overlay === */
#cart-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  justify-content: center;
  align-items: center;
  padding: 20px;
  -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
  transition: all 0.3s ease-in-out;
}

/* Show modal */
#cart-modal[style*="display: flex"] {
  animation: fadeInOverlay 0.35s ease forwards;
}

@keyframes fadeInOverlay {
  from {opacity: 0;}
  to {opacity: 1;}
}

/* === Modal Content === */
#cart-modal .cart-modal-content {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 30px 40px 40px;
  width: 100%;
  max-width: 520px;
  color: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeInUp 0.4s ease forwards;
}

/* Header */
#cart-modal .cart-modal-content h3 {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 1px;
  margin: 0;
}

/* Close button */
#cart-modal .close {
  position: absolute;
  top: 18px;
  right: 22px;
  font-size: 1.7rem;
  cursor: pointer;
  color: #fff;
  transition: transform 0.2s ease, color 0.2s ease;
  user-select: none;
}

#cart-modal .close:hover {
  transform: scale(1.3);
  color: #ff5c5c;
}

#cart-modal {
 /* SET fixed max height */
  max-height: 100vh;

  /* enable vertical scrolling */
  overflow-y: auto;

  /* smooth scrolling on iOS */
  -webkit-overflow-scrolling: touch;

}
/* Cart list */
#cart-items {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.05);
}

/* Individual item */
#cart-items li {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 1rem;
  gap: 12px;
  transition: background-color 0.2s ease;
}

#cart-items li:last-child {
  border-bottom: none;
}

#cart-items li:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Item image */
#cart-items img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Item details */
#cart-items strong {
  flex: 1;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#cart-items li > div {
  font-size: 0.9rem;
  color: #ddd;
  white-space: nowrap;
}

/* Remove button */
#cart-items button {
  background: transparent;
  border: none;
  color: #ff6b6b;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  font-size: 0.9rem;
  user-select: none;
}

#cart-items button:hover {
  background-color: rgba(255, 107, 107, 0.25);
  color: #ff3b3b;
}

/* Empty cart message */
#empty-cart-msg {
  text-align: center;
  font-size: 1.1rem;
  color: #eee;
  margin: 15px 0;
}

/* User info form */
#cart-user-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#cart-user-form input,
#cart-user-form select {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  padding: 12px 16px;
  border-radius: 12px;
  color: #fff;
  font-size: 1rem;
  outline-offset: 2px;
  outline-color: transparent;
  transition: outline-color 0.3s ease;
}

#cart-user-form input::placeholder,
#cart-user-form select {
  color: rgba(255, 255, 255, 0.6);
}

#cart-user-form input:focus,
#cart-user-form select:focus {
  outline-color: #ffd700;
  background: rgba(255, 255, 255, 0.25);
}

#cart-state option {
  background-color: #181818;
  color: white;
  font-weight: bold;
  border-color: none;
}

/* Price summary */
#cart-summary {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 20px 25px;
  box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  user-select: none;
}

#cart-summary p {
  margin: 0;
  display: flex;
  justify-content: space-between;
  color: #fff;
}

#cart-summary p strong {
  color: #ffd700;
  font-weight: 700;
}

/* Payment buttons */
.cart-pay-btn {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  border-radius: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  border: none;
  margin-top: 10px;
  user-select: none;
}

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

/* Stripe button style */
.stripe-btn {
  background: linear-gradient(135deg, #6772e5, #5469d4);
  color: #fff;
  box-shadow: 0 4px 12px rgba(103, 114, 229, 0.5);
}

.stripe-btn:hover {
  box-shadow: 0 6px 20px rgba(103, 114, 229, 0.8);
  transform: scale(1.03);
}

/* PayPal button style */
.paypal-btn {
  background: linear-gradient(135deg, #003087, #0070ba);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 112, 186, 0.6);
}

.paypal-btn:hover {
  box-shadow: 0 6px 20px rgba(0, 112, 186, 0.9);
  transform: scale(1.03);
}

/* === Responsive Styling === */
@media (max-width: 650px) {
  #cart-modal .modal-content {
    max-width: 95%;
    padding: 25px 20px 30px;
    gap: 18px;
  }

  #cart-modal .cart-modal-content h3 {
    font-size: 1.6rem;
  }

  #cart-items li {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  #cart-items img {
    width: 44px;
    height: 44px;
  }

  #cart-summary {
    font-size: 1rem;
    padding: 16px 20px;
  }

  .cart-pay-btn {
    font-size: 1rem;
    padding: 12px;
  }

  #cart-user-form input,
  #cart-user-form select {
    font-size: 0.95rem;
    padding: 10px 14px;
  }
}

/* === Animations === */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
