/* ============================================================
   島牧拾草 - 購物車詳情頁樣式 cart.css
   色票：#FAFAFA / rgba(218,189,217,0.40) / #77796D / #20201F / #4E5B04
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700;900&display=swap');

/* ── Reset & Base ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  background: #FAFAFA;
  color: #20201F;
  min-height: 100vh;
}

/* ── Page Wrapper ──────────────────────────────────────────── */
.cart-page-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ── Breadcrumb ────────────────────────────────────────────── */
.cart-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #77796D;
  margin-bottom: 28px;
}

.cart-breadcrumb a {
  color: #77796D;
  text-decoration: none;
  transition: color 0.2s;
}

.cart-breadcrumb a:hover {
  color: #4E5B04;
}

.cart-breadcrumb .sep {
  opacity: 0.5;
}

.cart-breadcrumb .current {
  color: #20201F;
  font-weight: 600;
}

/* ── Page Title ────────────────────────────────────────────── */
.cart-page-title {
  font-size: 24px !important;
  font-weight: 700 !important;
  color: #20201F !important;
  margin-bottom: 24px;
  letter-spacing: 0.04em;
}

.cart-page-title span {
  font-size: 15px;
  font-weight: 500;
  color: #77796D;
  margin-left: 10px;
}

/* ── Layout：左（商品列表）+ 右（訂單摘要）─────────────────── */
.cart-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 860px) {
  .cart-layout {
    grid-template-columns: 1fr;
  }
}

/* ── 左側：商品列表卡片容器 ─────────────────────────────────── */
.cart-items-panel {
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(218, 219, 217, 0.35);
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.04);
}

/* ── 全選工具列 ────────────────────────────────────────────── */
.cart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(218, 219, 217, 0.30);
  background: #FAFAFA;
}

.cart-select-all-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.cart-select-all-wrap input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #4E5B04;
  cursor: pointer;
  flex-shrink: 0;
}

.cart-select-all-label {
  font-size: 14px;
  font-weight: 700;
  color: #20201F;
}

.cart-toolbar-count {
  font-size: 13px;
  color: #77796D;
  margin-left: 6px;
}

.cart-remove-selected-btn {
  font-size: 12px !important;
  font-weight: 400 !important;
  color: #77796D !important;
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  padding: 0 !important;
  border-radius: 0 !important;
  text-decoration: underline !important;
  text-decoration-color: #DADBD9 !important;
  text-underline-offset: 4px !important;
  transition: color 0.2s !important;
  box-shadow: none !important;
}

.cart-remove-selected-btn:hover {
  color: #8C3823 !important;
  background: transparent !important;
  text-decoration-color: #8C3823 !important;
}

/* ── 商品行 ─────────────────────────────────────────────────── */
.cart-item-list {
  list-style: none;
}

.cart-item-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(218, 219, 217, 0.30);
  transition: background 0.2s, opacity 0.2s;
  animation: cartItemFadeIn 0.35s ease forwards;
  opacity: 0;
}

.cart-item-row:last-child {
  border-bottom: none;
}

.cart-item-row:hover {
  background: rgba(218, 189, 217, 0.08);
}

@keyframes cartItemFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 刪除動畫 */
.cart-item-row.removing {
  animation: cartItemSlideOut 0.22s ease forwards;
}

@keyframes cartItemSlideOut {
  to {
    opacity: 0;
    transform: translateX(60px);
    max-height: 0;
    padding: 0 24px;
    margin: 0;
  }
}

/* ── 勾選框 ─────────────────────────────────────────────────── */
.cart-item-check {
  width: 18px;
  height: 18px;
  accent-color: #4E5B04;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── 商品小圖 ───────────────────────────────────────────────── */
.cart-item-img-wrap {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(218, 189, 217, 0.40);
  cursor: pointer;
  transition: transform 0.2s;
}

.cart-item-img-wrap:hover {
  transform: scale(1.04);
}

.cart-item-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── 商品資訊 ───────────────────────────────────────────────── */
.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-name {
  font-size: 15px;
  font-weight: 700;
  color: #20201F;
  text-decoration: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
  transition: color 0.2s;
}

.cart-item-name:hover {
  color: #4E5B04;
}

.cart-item-variant {
  font-size: 12px;
  color: #77796D;
  background: #FAFAFA;
  border: 1px solid rgba(218, 219, 217, 0.50);
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 10px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 數量控制 ───────────────────────────────────────────────── */
.cart-qty-ctrl {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 0 !important;
  border: 1px solid #DADBD9 !important;
  border-radius: 4px !important;
  overflow: hidden !important;
  width: 96px !important;
  height: 32px !important;
  background: #ffffff !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.cart-qty-btn {
  width: 28px !important;
  height: 100% !important;
  background: #ffffff !important;
  border: none !important;
  border-radius: 0 !important;
  cursor: pointer !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #77796D !important;
  transition: background 0.2s, color 0.2s, transform 0.1s !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.cart-qty-btn:hover:not(:disabled) {
  background: rgba(218, 219, 217, 0.20) !important;
  color: #20201F !important;
}

.cart-qty-btn:active:not(:disabled) {
  transform: scale(0.92) !important;
}

.cart-qty-btn:disabled {
  color: #E2E3E0 !important;
  cursor: not-allowed !important;
  background: #ffffff !important;
}

.cart-qty-display {
  width: 40px !important;
  height: 100% !important;
  text-align: center !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #20201F !important;
  border: none !important;
  border-left: 1px solid #DADBD9 !important;
  border-right: 1px solid #DADBD9 !important;
  border-radius: 0 !important;
  background: #ffffff !important;
  outline: none !important;
  box-shadow: none !important;
  -moz-appearance: textfield !important;
  padding: 0 !important;
  margin: 0 !important;
}

.cart-qty-display:focus {
  outline: none !important;
  box-shadow: none !important;
}

.cart-qty-display::-webkit-inner-spin-button,
.cart-qty-display::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ── 右側：價格 + 刪除 ──────────────────────────────────────── */
.cart-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.cart-item-subtotal {
  font-size: 16px;
  font-weight: 700;
  color: #20201F !important;
  white-space: nowrap;
}

.cart-item-delete-btn {
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  color: #A9AAA5 !important;
  padding: 4px !important;
  border-radius: 6px !important;
  transition: color 0.2s, background 0.2s !important;
  display: flex !important;
  align-items: center !important;
  box-shadow: none !important;
}

.cart-item-delete-btn:hover {
  color: #8C3823 !important;
  background: transparent !important;
}

.cart-item-delete-btn svg {
  width: 16px !important;
  height: 16px !important;
  stroke: currentColor !important;
}

/* ── 庫存/下架 警告標籤與提示文字樣式 ────────────────────────────── */
.cart-stock-warn {
  font-size: 13px;
  /* ⚠️ 該規格已達庫存上限 字級調整位置 */
  color: #8C3823;
  font-weight: 500;
  margin-top: 4px;
}

.cart-discontinued-hint {
  font-size: 13px;
  /* ⚠️ 此商品已下架或停售 字級調整位置 */
  color: #8C3823;
  margin-top: 4px;
  font-weight: 500;
}

.cart-discontinued-tag {
  font-size: 11px;
  /* [ 已下架 ] / [ 無庫存 ] 標籤字級調整位置 */
  color: #8C3823;
  font-weight: bold;
  border: 1px solid #8C3823;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: rgba(140, 56, 35, 0.05);
  display: inline-block;
}

/* ── 空購物車狀態 ───────────────────────────────────────────── */
.cart-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  gap: 16px;
  text-align: center;
}

.cart-empty-icon {
  font-size: 52px;
  opacity: 0.4;
}

.cart-empty-text {
  font-size: 18px;
  font-weight: 700;
  color: #77796D;
}

.cart-empty-sub {
  font-size: 14px;
  color: #77796D;
  opacity: 0.7;
}

.cart-empty-link {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 28px;
  background: #4E5B04;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 100px;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s;
}

.cart-empty-link:hover {
  background: #6F8200;
  transform: translateY(-1px);
}

/* ── 右側：訂單摘要面板 ─────────────────────────────────────── */
.cart-summary-panel {
  background: #FAFAFA;
  border-radius: 16px;
  border: 1px solid rgba(218, 219, 217, 0.40);
  padding: 28px 24px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.02);
  position: static !important;
  width: 100% !important;
  margin-top: 32px !important;
}

@media (min-width: 861px) {
  .cart-summary-panel {
    position: sticky !important;
    top: 96px !important;
    margin-top: 0 !important;
    width: auto !important;
  }
}

/* 訂單摘要文字 */
.cart-summary-title {
  font-size: 30px !important;
  font-weight: 900;
  color: #20201F;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(218, 219, 217, 0.30);
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.cart-summary-label {
  font-size: 14px;
  color: #77796D;
  font-weight: 500;
}

.cart-summary-value {
  font-size: 14px;
  color: #20201F;
  font-weight: 700;
}

.cart-summary-free-ship {
  font-size: 12px;
  color: #4E5B04;
  font-weight: 700;
}

/* 免運進度條 */
.cart-shipping-progress-wrap {
  margin: 12px 0 16px;
}

.cart-shipping-progress-bar {
  height: 6px;
  background: rgba(218, 189, 217, 0.40);
  border-radius: 100px;
  overflow: hidden;
}

.cart-shipping-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4E5B04, #8aab00);
  border-radius: 100px;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 100%;
}

.cart-shipping-hint {
  font-size: 12px;
  color: #4E5B04 !important;
  background-color: rgba(229, 233, 216, 0.50);
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 10px;
  text-align: center;
  font-weight: 700;
  display: block;
}

.cart-summary-divider {
  height: 1px;
  background: rgba(218, 219, 217, 0.30);
  margin: 14px 0;
}

/* 應付總計 */
.cart-summary-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.cart-summary-total-label {
  font-size: 15px;
  font-weight: 900;
  color: #20201F;
}

.cart-summary-total-value {
  font-size: 22px;
  font-weight: 900;
  color: #20201F;
  transition: opacity 0.15s ease;
}

/* 防閃爍：重算等待期間的 opacity 淡出 */
.cart-summary-total-value.recalculating {
  opacity: 0.4;
}

/* Skeleton Screen（骨架屏）佔位 */
.cart-skeleton-amount {
  display: inline-block;
  width: 90px;
  height: 24px;
  background: linear-gradient(90deg, #e8e5e0 25%, #f5f3ef 50%, #e8e5e0 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.4s infinite ease-in-out;
  border-radius: 6px;
  vertical-align: middle;
}

@keyframes skeletonPulse {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* 150ms text-fade-in 亮起 */
.cart-summary-total-value.fade-in-value {
  animation: totalFadeIn 0.15s ease forwards;
}

@keyframes totalFadeIn {
  from {
    opacity: 0.4;
  }

  to {
    opacity: 1;
  }
}

/* ── 結帳按鈕 ───────────────────────────────────────────────── */
.cart-checkout-btn {
  display: block;
  width: 100%;
  padding: 14px 0;
  background: #4E5B04 !important;
  color: #fff !important;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 0.15em;
  text-align: center;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.cart-checkout-btn:hover:not(:disabled) {
  background: #6F8200 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.cart-checkout-btn:active:not(:disabled) {
  transform: translateY(0);
}

.cart-checkout-btn:disabled {
  background: #ccc;
  color: #888;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ── 結帳身份攔截遮罩彈窗 ──────────────────────────────────── */
.cart-auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.40);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.cart-auth-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.cart-auth-modal {
  background: #fff;
  border-radius: 20px;
  padding: 40px 36px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  transform: scale(0.9);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

.cart-auth-overlay.show .cart-auth-modal {
  transform: scale(1);
  opacity: 1;
}

.cart-auth-modal-icon {
  font-size: 40px;
  margin-bottom: 14px;
}

.cart-auth-modal-title {
  font-size: 18px;
  font-weight: 900;
  color: #20201F;
  margin-bottom: 10px;
  line-height: 1.5;
}

.cart-auth-modal-sub {
  font-size: 13px;
  color: #77796D;
}

/* ── 全域 Toast（cart.js 動態建立，這裡補齊樣式）─────────────── */
#cart-toast-global {
  font-family: 'Noto Sans TC', sans-serif;
}

/* ── RWD：行動端調整 ────────────────────────────────────────── */
@media (max-width: 600px) {
  .cart-page-wrapper {
    padding: 20px 12px 60px;
  }

  .cart-item-row {
    padding: 16px 14px;
    gap: 10px;
  }

  .cart-item-img-wrap {
    width: 62px;
    height: 62px;
  }

  .cart-item-name {
    font-size: 13px;
  }

  .cart-item-subtotal {
    font-size: 14px;
  }

  .cart-summary-panel {
    padding: 20px 16px;
  }

  .cart-summary-total-value {
    font-size: 19px;
  }

  .cart-checkout-btn {
    font-size: 14px;
    padding: 12px 0;
  }
}