/**
 * 移动端购物车布局修复样式
 * 1. 隐藏关闭按钮
 * 2. 隐藏WhatsApp咨询按钮
 * 3. 向下移动优惠券和总金额模态框
 */

/* 移动端适配 */
@media (max-width: 768px) {
  /* 隐藏购物车页面的关闭按钮 */
  .cart-header-top-row .close-cart {
    display: none !important;
  }

  /* 购物车页面中隐藏WhatsApp咨询按钮 */
  body.cart-open .whatsapp-float {
    display: none !important;
  }

  /* 调整地址选择器样式，使其占据整行 */
  .cart-address-selector {
    width: 100% !important;
    flex: 1 !important;
    padding: 12px 15px !important;
  }

  /* 增加购物车商品区域的高度，为底部留出更多空间 */
  .cart-items {
    padding-bottom: 200px !important; /* 增加底部内边距，为优惠券和总金额区域留出空间 */
    overflow-y: auto !important; /* 确保可以滚动 */
    -webkit-overflow-scrolling: touch !important; /* 增强iOS的滚动体验 */
  }

  /* 优惠券输入容器集成到cart-summary中 */
  .coupon-input-container {
    margin-bottom: 5px !important;
    width: 100% !important;
    background-color: transparent !important;
    padding: 0 !important;
    z-index: 10000 !important;
  }

  /* 向下移动总金额模态框 */
  .cart-summary {
    position: fixed !important;
    bottom: 70px !important; /* 为底部导航栏留出空间 */
    left: 0 !important;
    right: 0 !important;
    background-color: #fff !important;
    padding: 15px !important;
    z-index: 10001 !important;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* 调整优惠券区域样式 */
  .cart-coupon-section {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  /* 优化优惠券输入容器样式 */
  .coupon-input-container h4 {
    margin-top: 0 !important;
    margin-bottom: 8px !important;
    font-size: 14px !important;
  }

  /* 优化优惠券显示样式 */
  .applied-coupon-container {
    padding: 8px !important;
    margin-bottom: 0 !important;
  }

  /* 优化总金额区域样式 */
  .cart-subtotal,
  .cart-discount,
  .cart-total {
    display: flex !important;
    justify-content: space-between !important;
    margin-bottom: 5px !important;
    width: 100% !important;
    padding: 3px 0 !important;
  }

  .cart-total {
    font-weight: bold !important;
    margin-top: 5px !important;
    padding-top: 5px !important;
    border-top: 1px solid #eee !important;
    font-size: 16px !important;
  }

  .cart-discount {
    color: #e74c3c !important; /* 红色显示折扣 */
  }

  /* 简化结账信息区域 */
  .cart-summary {
    padding: 10px 15px !important;
  }

  /* 结账信息容器 */
  .checkout-info {
    background-color: #f9f9f9 !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    margin: 5px 0 !important;
    width: 100% !important;
  }

  /* 确保WhatsApp结账按钮样式正确 */
  .checkout-whatsapp-btn,
  .whatsapp-checkout-btn {
    width: 100% !important;
    margin-top: 10px !important;
    background-color: #25D366 !important; /* WhatsApp绿色 */
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 12px !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    position: relative !important;
    z-index: 10002 !important; /* 确保在最上层 */
  }

  /* 为iOS设备底部安全区域适配 */
  @supports (padding: env(safe-area-inset-bottom)) {
    .cart-summary {
      bottom: calc(70px + env(safe-area-inset-bottom)) !important;
      padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    }

    .cart-items {
      padding-bottom: calc(200px + env(safe-area-inset-bottom)) !important;
    }
  }
}
