/* Cart Badge */
.cart-button-container {
  position: relative;
  display: inline-block;
}

.cart-count-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: #d42e2e;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  animation: bounceIn 0.3s ease;
}

@keyframes bounceIn {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Cart Popup */
.cart-popup {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 10px;
  width: 380px;
  max-height: 500px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  overflow: hidden;
}

.cart-popup-empty {
  padding: 40px 20px;
  text-align: center;
  color: #666;
}

.cart-popup-items {
  max-height: 350px;
  overflow-y: auto;
  padding: 10px;
  scroll-behavior: smooth;
  /* Đảm bảo scroll events không bị chặn */
  pointer-events: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on mobile */
}

.cart-popup-items::-webkit-scrollbar {
  width: 6px;
}

.cart-popup-items::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.cart-popup-items::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.cart-popup-items::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.cart-popup-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s;
}

.cart-popup-item:hover {
  background-color: #f9f9f9;
}

.cart-popup-item img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
}

.cart-popup-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cart-popup-item-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  line-height: 1.3;
}

.cart-popup-item-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #666;
}

.cart-popup-item-price {
  color: #d42e2e;
  font-weight: 600;
}

.cart-popup-footer {
  padding: 15px;
  border-top: 2px solid #f0f0f0;
  background-color: #fafafa;
}

.cart-popup-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
}

.cart-popup-total-price {
  color: #d42e2e;
  font-size: 18px;
}

.cart-popup-button {
  display: block;
  width: 100%;
  padding: 12px;
  background-color: #536fbd;
  color: white;
  text-align: center;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  transition: background-color 0.3s;
  cursor: pointer;
  /* Đảm bảo click events hoạt động */
  pointer-events: auto;
  position: relative;
  z-index: 1001;
}

.cart-popup-button:hover {
  background-color: #3d5aa8;
}

.cart-popup-button:active {
  transform: translateY(1px);
}

/* Cart Detail Page */
.cart-detail-container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
}

.cart-detail-title {
  font-size: 28px;
  font-weight: 600;
  color: #333;
  margin-bottom: 30px;
  padding-bottom: 15px;
  border-bottom: 2px solid #536fbd;
}

.cart-detail-content {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 30px;
}

.cart-items-section {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cart-table {
  width: 100%;
  border-collapse: collapse;
}

.cart-table thead {
  background-color: #f5f5f5;
  border-bottom: 2px solid #e0e0e0;
}

.cart-table th {
  padding: 15px 10px;
  text-align: left;
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.cart-table td {
  padding: 20px 10px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.cart-item-product {
  display: flex;
  gap: 15px;
  align-items: center;
}

.cart-item-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
}

.cart-item-name {
  font-size: 15px;
  font-weight: 500;
  color: #333;
  line-height: 1.4;
}

.cart-item-type {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

.cart-item-price {
  font-size: 16px;
  font-weight: 600;
  color: #d42e2e;
}

.quantity-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.quantity-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.quantity-btn:hover {
  background-color: #536fbd;
  color: white;
  border-color: #536fbd;
}

.quantity-input {
  width: 50px;
  text-align: center;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px;
  font-size: 14px;
}

.remove-btn {
  background: none;
  border: none;
  color: #d42e2e;
  cursor: pointer;
  font-size: 20px;
  padding: 5px 10px;
  transition: color 0.2s;
}

.remove-btn:hover {
  color: #a02020;
}

/* Order Summary */
.order-summary {
  background: white;
  border-radius: 8px;
  padding: 25px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  height: fit-content;
  position: sticky;
  top: 20px;
}

.order-summary-title {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #f0f0f0;
}

.order-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  font-size: 15px;
  color: #666;
}

.order-summary-row.total {
  border-top: 2px solid #f0f0f0;
  margin-top: 10px;
  padding-top: 15px;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.order-total-price {
  color: #d42e2e;
  font-size: 22px;
}

.checkout-btn {
  width: 100%;
  padding: 15px;
  background-color: #d42e2e;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 20px;
  transition: background-color 0.3s;
}

.checkout-btn:hover {
  background-color: #b02525;
}

/* Empty Cart */
.empty-cart {
  text-align: center;
  padding: 80px 20px;
}

.empty-cart-icon {
  font-size: 80px;
  color: #ddd;
  margin-bottom: 20px;
}

.empty-cart-title {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

.empty-cart-text {
  font-size: 16px;
  color: #666;
  margin-bottom: 30px;
}

.continue-shopping-btn {
  display: inline-block;
  padding: 12px 30px;
  background-color: #536fbd;
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  transition: background-color 0.3s;
}

.continue-shopping-btn:hover {
  background-color: #3d5aa8;
}

/* Notification */
.cart-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 15px 25px;
  background-color: white;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s ease;
}

.cart-notification.show {
  opacity: 1;
  transform: translateX(0);
}

.cart-notification.success {
  border-left: 4px solid #4caf50;
}

.cart-notification.error {
  border-left: 4px solid #d42e2e;
}

/* Responsive */
@media (max-width: 1024px) {
  .cart-detail-content {
    grid-template-columns: 1fr;
  }

  .order-summary {
    position: static;
  }
}

@media (max-width: 768px) {
  .cart-popup {
    width: 320px;
    right: -20px;
  }

  .cart-table {
    font-size: 13px;
  }

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

  .cart-table th,
  .cart-table td {
    padding: 10px 5px;
  }

  .cart-detail-title {
    font-size: 22px;
  }
}
