/* ==========================================================================
   MJ / WooCommerce Cart (Classic cart.php table)
   Clean version:
   - 移除重覆 selector 與互相打架的規則（尤其 notices）
   - 保留：兩欄布局、左側商品卡片、右側 totals 撐滿、紫金按鈕
   ========================================================================== */

/* 基礎容器：避免 cart 內容莫名被推到很右邊 */
body.woocommerce-cart .site-main,
body.woocommerce-cart .site-main .mj-container,
body.woocommerce-cart .site-main .woocommerce {
  max-width: 1260px;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* WooCommerce 主容器兩欄 */
body.woocommerce-cart .woocommerce {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 28px;
  padding-left: 18px;
  padding-right: 18px;
  flex-wrap: wrap; /* 重要：允許 notices 佔滿一列，不破壞兩欄 */
}

/* notices：必須獨立一列全寬，且不參與左右欄擠壓 */
body.woocommerce-cart .woocommerce > .woocommerce-notices-wrapper,
body.woocommerce-cart .mj-container .woocommerce-notices-wrapper,
body.woocommerce-cart .woocommerce-notices-wrapper {
  width: 100% !important;
  max-width: none !important;
  margin: 0 0 18px 0 !important;

  /* 父層是 flex：佔滿一列並排到最上方 */
  flex: 0 0 100% !important;
  order: -1 !important;
  align-self: stretch !important;

  /* 若未來父層改成 grid 也可跨滿 */
  grid-column: 1 / -1 !important;

  clear: both !important;
  position: relative !important;
  z-index: 2 !important;
}

/* notice 本體：紫金風格 + 不影響版面 */
body.woocommerce-cart .woocommerce-message,
body.woocommerce-cart .woocommerce-info,
body.woocommerce-cart .woocommerce-error {
  border-radius: 16px !important;
  border: 1px solid rgba(210, 170, 255, 0.18) !important;
  background: rgba(15, 12, 20, 0.88) !important;
  color: rgba(255,255,255,0.88) !important;
  box-shadow: 0 12px 36px rgba(0,0,0,0.35) !important;
}

body.woocommerce-cart .woocommerce-message a,
body.woocommerce-cart .woocommerce-info a,
body.woocommerce-cart .woocommerce-error a {
  color: rgba(255, 215, 170, 0.92) !important;
  text-decoration: underline;
}

/* 左欄：cart form */
body.woocommerce-cart .woocommerce-cart-form {
  flex: 1 1 auto;
  min-width: 0;
}

/* 右欄：cart totals（紅框寬度在這裡調整） */
body.woocommerce-cart .cart-collaterals {
  flex: 0 0 420px; /* 原本 360 太窄就調大：420 / 440 都可 */
  width: 420px;
  max-width: 420px;
}

/* 右欄內所有直接子層不要自帶奇怪寬度 */
body.woocommerce-cart .cart-collaterals > * {
  width: 100% !important;
  max-width: 100% !important;
}

/* totals 卡片：務必撐滿右欄（擠壓的核心修正） */
body.woocommerce-cart .cart_totals {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  box-sizing: border-box;

  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  padding: 18px 18px 16px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

body.woocommerce-cart .cart_totals h2 {
  margin: 0 0 14px 0;
  font-weight: 800;
}

/* totals 內部表格撐滿 */
body.woocommerce-cart .cart_totals table.shop_table {
  width: 100% !important;
  border-collapse: collapse;
}

/* totals 兩欄：標籤/值 */
body.woocommerce-cart .cart_totals table.shop_table th {
  width: 34%;
  text-align: left;
  opacity: 0.9;
  padding: 12px 10px 12px 0;
  vertical-align: top;
}
body.woocommerce-cart .cart_totals table.shop_table td {
  width: 66%;
  text-align: right;
  padding: 12px 0 12px 10px;
  vertical-align: top;
}

/* Shipping 區塊：radio + 文字 */
body.woocommerce-cart .cart_totals .woocommerce-shipping-methods {
  margin: 0;
  padding: 0;
  list-style: none;
}
body.woocommerce-cart .cart_totals .woocommerce-shipping-methods li {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: start;
  gap: 10px;
  margin: 10px 0;
}
body.woocommerce-cart .cart_totals .woocommerce-shipping-methods input[type="radio"] {
  margin-top: 3px;
}

/* 地址區域靠左避免被硬切 */
body.woocommerce-cart .cart_totals .woocommerce-shipping-destination,
body.woocommerce-cart .cart_totals .shipping-calculator-button,
body.woocommerce-cart .cart_totals .woocommerce-shipping-calculator {
  text-align: left;
}

/* 結帳按鈕 */
body.woocommerce-cart .wc-proceed-to-checkout a.checkout-button {
  border-radius: 14px;
  background: rgba(123, 70, 190, 0.70);
  border: 1px solid rgba(210, 170, 255, 0.30);
  font-weight: 800;
}
body.woocommerce-cart .wc-proceed-to-checkout a.checkout-button:hover {
  background: rgba(123, 70, 190, 0.86);
}

/* -------------------------------------------
   表格（左側商品列表）
   ------------------------------------------- */
body.woocommerce-cart table.shop_table {
  width: 100% !important;
  border-collapse: separate;
  border-spacing: 0 16px;
}

body.woocommerce-cart table.shop_table thead th {
  text-align: center;
  font-weight: 600;
  opacity: 0.9;
}

body.woocommerce-cart table.shop_table tbody tr.cart_item td {
  background: rgba(255,255,255,0.04);
  border-top: 1px solid rgba(255,255,255,0.08);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  vertical-align: middle;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

body.woocommerce-cart table.shop_table tbody tr.cart_item td:first-child {
  border-left: 1px solid rgba(255,255,255,0.08);
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
}
body.woocommerce-cart table.shop_table tbody tr.cart_item td:last-child {
  border-right: 1px solid rgba(255,255,255,0.08);
  border-top-right-radius: 14px;
  border-bottom-right-radius: 14px;
}

/* product-remove 不可撐爆 */
body.woocommerce-cart td.product-remove {
  width: 52px !important;
  min-width: 52px !important;
  max-width: 52px !important;
  padding: 0 !important;
  text-align: center !important;
}

body.woocommerce-cart td.product-remove a.remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0 auto;
  border-radius: 999px;
  border: 1px solid rgba(255, 75, 75, 0.55);
  color: rgba(255, 75, 75, 0.95) !important;
  background: rgba(0,0,0,0.25);
  line-height: 1;
  font-size: 20px;
  text-decoration: none !important;
}
body.woocommerce-cart td.product-remove a.remove:hover {
  background: rgba(255, 75, 75, 0.12);
}

/* 縮圖固定 */
body.woocommerce-cart td.product-thumbnail {
  width: 92px;
  min-width: 92px;
  padding: 10px 10px 10px 6px;
}

body.woocommerce-cart td.product-thumbnail img {
  width: 72px !important;
  height: 72px !important;
  object-fit: cover;
  border-radius: 14px;
  display: block;
  border: 1px solid rgba(255,255,255,0.08);
}

body.woocommerce-cart td.product-name a {
  color: rgba(255, 215, 170, 0.95);
  text-decoration: none;
}

body.woocommerce-cart td.product-price,
body.woocommerce-cart td.product-subtotal {
  white-space: nowrap;
  font-weight: 600;
}

body.woocommerce-cart td.product-quantity .qty {
  width: 74px;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.92);
  border-radius: 10px;
  padding: 8px 10px;
}

/* Actions row：折價券 + 更新購物車 */
body.woocommerce-cart td.actions {
  background: transparent !important;
  border: 0 !important;
  padding: 12px 0 0 0 !important;
}

body.woocommerce-cart td.actions .coupon {
  display: flex;
  align-items: center;
  gap: 12px;
}

body.woocommerce-cart td.actions .coupon input#coupon_code {
  flex: 1 1 auto;
  min-width: 220px;
  height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.92);
}

body.woocommerce-cart td.actions .coupon button[name="apply_coupon"] {
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid rgba(210, 170, 255, 0.35);
  background: rgba(123, 70, 190, 0.35);
  color: rgba(255,255,255,0.95);
  font-weight: 700;
}
body.woocommerce-cart td.actions .coupon button[name="apply_coupon"]:hover {
  background: rgba(123, 70, 190, 0.52);
}

/* Update Cart 按鈕：基礎樣式 */
body.woocommerce-cart button[name="update_cart"] {
  height: 44px;
  margin-left: 14px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.92) !important;
  font-weight: 700;
  opacity: 1 !important;
}
body.woocommerce-cart button[name="update_cart"]:hover {
  background: rgba(255,255,255,0.16);
}
body.woocommerce-cart button[name="update_cart"][disabled] {
  opacity: 0.55 !important;
  cursor: not-allowed;
}

/* Update Cart 狀態：disabled（低調但可讀） */
body.woocommerce-cart button[name="update_cart"]:disabled,
body.woocommerce-cart button[name="update_cart"].disabled,
body.woocommerce-cart button[name="update_cart"][aria-disabled="true"] {
  opacity: 0.45 !important;
  background: rgba(255,255,255,0.10) !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  color: rgba(255,255,255,0.70) !important;
  filter: none !important;
  box-shadow: none !important;
}

/* 已變更待更新（enabled）：紫金強提醒 */
body.woocommerce-cart form.woocommerce-cart-form.mj-cart-dirty button[name="update_cart"]:not(:disabled),
body.woocommerce-cart button[name="update_cart"].mj-needs-update:not(:disabled) {
  opacity: 1 !important;
  color: rgba(255,255,255,0.96) !important;
  background: rgba(123, 70, 190, 0.72) !important;
  border: 1px solid rgba(210, 170, 255, 0.38) !important;
  box-shadow: 0 0 0 1px rgba(210,170,255,0.20), 0 14px 38px rgba(0,0,0,0.30) !important;
  transform: translateY(-1px);
}
body.woocommerce-cart form.woocommerce-cart-form.mj-cart-dirty button[name="update_cart"]:not(:disabled):hover,
body.woocommerce-cart button[name="update_cart"].mj-needs-update:not(:disabled):hover {
  background: rgba(123, 70, 190, 0.86) !important;
  box-shadow: 0 0 0 1px rgba(210,170,255,0.26), 0 18px 44px rgba(0,0,0,0.35) !important;
}

/* 提交中：避免連點 */
body.woocommerce-cart form.woocommerce-cart-form.mj-cart-submitting button[name="update_cart"] {
  transform: none !important;
  opacity: 0.75 !important;
}

/* 提示條：dirty 才顯示 */
body.woocommerce-cart .mj-cart-update-hint {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(210, 170, 255, 0.22);
  background: rgba(123, 70, 190, 0.10);
  color: rgba(255,255,255,0.86);
  display: none;
  line-height: 1.5;
}
body.woocommerce-cart .mj-cart-update-hint.is-visible {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
body.woocommerce-cart .mj-cart-update-hint .mj-hint-title {
  flex: 0 0 auto;
  font-weight: 800;
  color: rgba(255, 215, 170, 0.92);
}
body.woocommerce-cart .mj-cart-update-hint .mj-hint-text {
  flex: 1 1 auto;
  opacity: 0.92;
}

/* RWD：手機改單欄 */
@media (max-width: 980px) {
  body.woocommerce-cart .woocommerce {
    flex-direction: column;
    gap: 18px;
    padding-left: 14px;
    padding-right: 14px;
  }

  body.woocommerce-cart .cart-collaterals {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 auto;
  }

  body.woocommerce-cart td.actions .coupon {
    flex-direction: column;
    align-items: stretch;
  }

  body.woocommerce-cart button[name="update_cart"] {
    margin-left: 0;
    margin-top: 12px;
    width: 100%;
  }

  body.woocommerce-cart .cart_totals table.shop_table th,
  body.woocommerce-cart .cart_totals table.shop_table td {
    text-align: left;
    width: auto;
    display: block;
    padding: 8px 0;
  }
}

/* =========================================================
   MJ MOBILE INPUT SIZE FIX (Cart) v1.0
   Goal: Prevent iOS Safari auto-zoom & enlarge tap targets
   Scope: mobile only; no layout changes
========================================================= */
@media (max-width: 980px) {

  body.woocommerce-cart .woocommerce input[type="text"],
  body.woocommerce-cart .woocommerce input[type="email"],
  body.woocommerce-cart .woocommerce input[type="tel"],
  body.woocommerce-cart .woocommerce input[type="number"],
  body.woocommerce-cart .woocommerce input[type="search"],
  body.woocommerce-cart .woocommerce input[type="password"],
  body.woocommerce-cart .woocommerce select,
  body.woocommerce-cart .woocommerce textarea {
    font-size: 16px !important; /* iOS Safari: <16px triggers zoom */
    line-height: 1.35;
    min-height: 48px;           /* better tap target */
    padding-top: 12px;
    padding-bottom: 12px;
  }

  /* Qty input (common culprit) */
  body.woocommerce-cart .woocommerce .quantity .qty {
    font-size: 16px !important;
    min-height: 48px;
  }

  /* Select2 (if used anywhere in cart / shipping calculator) */
  body.woocommerce-cart .select2-container .select2-selection--single {
    min-height: 48px;
  }
  body.woocommerce-cart .select2-container .select2-selection--single .select2-selection__rendered {
    font-size: 16px !important;
    line-height: 48px;
  }
  body.woocommerce-cart .select2-container .select2-selection--single .select2-selection__arrow {
    height: 48px;
  }

  /* Textarea should not become too short */
  body.woocommerce-cart .woocommerce textarea {
    min-height: 120px;
    resize: vertical;
  }
}
