/* ========== 购物车核心样式 ========== */
/* 购物车容器（首页下拉面板/购物车页面） */
.cart-container {
  position: relative;
  display: inline-block;
  margin-left: 20px;
}

/* 购物车按钮 */
.cart-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
}

.cart-btn:hover {
  filter: brightness(1.03);
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(37, 99, 235, 0.22);
}

.cart-btn::before {
  content: "🛒";
  font-size: 16px;
}

/* 购物车下拉面板 */
.cart-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 420px;
  background-color: rgba(255, 255, 255, 0.98);
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  box-shadow: 0 18px 50px rgba(2, 6, 23, 0.14);
  padding: 20px;
  z-index: 9999;
  display: none;
  max-height: 80vh;
  overflow-y: auto;
  box-sizing: border-box;
}

/* 鼠标悬停购物车按钮时显示下拉面板 */
.cart-container:hover .cart-dropdown {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* 购物车为空提示 */
.cart-empty {
  text-align: center;
  padding: 40px 20px;
  color: #7f8c8d;
  font-size: 14px;
}

/* 购物车商品项 */
.cart-item {
  display: flex;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid #f1f1f1;
  gap: 15px;
}

.cart-item:last-child {
  border-bottom: none;
}

/* 商品图片 */
.cart-item-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.12);
}

/* 商品信息 */
.cart-item-info {
  flex: 0 0 150px;
  max-width: 150px;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cart-item .product-name {
  font-size: 14px;
  font-weight: 500;
  color: #2c3e50;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  min-height: calc(1.35em * 2);
}

.cart-item .product-price {
  font-size: 13px;
  color: #e74c3c;
  font-weight: 600;
}

@media (max-width: 768px) {
  .cart-item-info {
    flex: 1 1 auto;
    max-width: none;
    min-width: 0;
  }
}

/* 数量控制区域 */
.quantity-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quantity-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.16);
  background-color: rgba(255, 255, 255, 0.98);
  color: #2c3e50;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.quantity-btn:hover {
  background-color: #f8f9fa;
  border-color: #2c3e50;
}

.quantity-input {
  width: 50px;
  height: 28px;
  text-align: center;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 10px;
  font-size: 14px;
  padding: 0;
  outline: none;
}

.quantity-input:focus {
  border-color: rgba(37, 99, 235, 0.60);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* 商品小计 */
.item-total {
  font-size: 14px;
  font-weight: 600;
  color: #2c3e50;
  min-width: 60px;
  text-align: right;
}

/* 删除按钮 */
.remove-btn {
  background-color: transparent;
  border: none;
  color: #95a5a6;
  cursor: pointer;
  font-size: 16px;
  transition: color 0.2s ease;
}

.remove-btn:hover {
  color: #e74c3c;
}

/* 购物车总计 */
.cart-total {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #f1f1f1;
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
  text-align: right;
}

/* 结算按钮 */
.cart-checkout-btn {
  width: 100%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  margin-top: 15px;
  transition: all 0.3s ease;
}

.cart-checkout-btn:hover {
  filter: brightness(1.03);
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(37, 99, 235, 0.20);
}

/* ========== 响应式适配（移动端） ========== */
@media (max-width: 768px) {
  .cart-dropdown {
    width: 320px;
    padding: 15px;
  }

  .cart-item {
    padding: 12px 0;
    gap: 10px;
  }

  .cart-item-img {
    width: 50px;
    height: 50px;
  }

  .product-name {
    font-size: 13px;
  }

  .product-price {
    font-size: 12px;
  }

  .quantity-controls {
    gap: 5px;
  }

  .quantity-btn {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }

  .quantity-input {
    width: 40px;
    height: 24px;
    font-size: 13px;
  }

  .item-total {
    font-size: 13px;
    min-width: 50px;
  }

  .cart-total {
    font-size: 15px;
  }

  .cart-checkout-btn {
    padding: 10px 0;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .cart-dropdown {
    width: calc(100vw - 40px);
    left: 0;
    right: auto;
  }

  .cart-btn {
    padding: 8px 15px;
    font-size: 13px;
  }
}

/* ========== 动画效果 ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

