/* ========================================
   購物車頁面 — Cart Page Styles
   色彩設計對應設計稿（橘色主題）
   ======================================== */

:root {
  --cart-accent: #E25B2A;
  --cart-accent-deep: #D04E20;
  --cart-btn-bg: #5D311B;
  --cart-total-color: #E25B2A;
  --cart-success: #4CAF50;
}

/* ── 結帳步驟 ── */
.cart-steps {
  margin-top: var(--header-height);
  padding: 50px 0 30px;
  background: var(--color-white);
}

.cart-steps-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  max-width: 500px;
  margin: 0 auto;
}

.cart-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 2;
}

.cart-step-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-family: var(--font-primary);
  border: 1px solid #ccc;
  color: #888;
  background: transparent;
  transition: all 0.3s ease;
}

.cart-step.active .cart-step-num {
  background: var(--cart-accent);
  color: var(--color-white);
  border-color: var(--cart-accent);
}

.cart-step-label {
  font-size: 12px;
  color: #888;
  font-weight: 400;
}

.cart-step.active .cart-step-label {
  color: var(--cart-accent);
  font-weight: 700;
}

.cart-step-line {
  flex: 1;
  height: 1px;
  background: #ccc;
  min-width: 80px;
  margin: 0 10px;
  margin-bottom: 28px;
}

/* ── 頁面標題 ── */
.cart-title-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 30px;
}

.cart-page-title {
  font-family: var(--font-primary);
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text-primary);
  text-align: center;
}

.cart-title-underline {
  width: 200px;
  height: 2px;
  background: var(--cart-accent);
}

.cart-item-count {
  font-size: 14px;
  color: #888;
  text-align: center;
}

/* ── 主容器 ── */
.cart-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 50px 60px;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 40px;
  align-items: start;
}

/* ── 左側主欄 ── */
.cart-main {
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
}

/* ── 表頭 ── */
.cart-table-header {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1fr 60px;
  background: var(--cart-accent);
  padding: 12px 22px;
  align-items: center;
}

.cart-th {
  font-size: 14px;
  font-weight: 400;
  color: var(--color-white);
}

.cart-th-price,
.cart-th-qty,
.cart-th-subtotal,
.cart-th-action {
  text-align: center;
}

/* ── 商品列表 ── */
.cart-items {
  display: flex;
  flex-direction: column;
}

.cart-item {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1fr 60px;
  align-items: center;
  padding: 24px 22px;
  border: 1px solid #eee;
  border-top: none;
  transition: background 0.2s ease;
}

.cart-item:first-child {
  border-top: 1px solid #eee;
}

.cart-item:hover {
  background: #fafafa;
}

/* 商品資訊（圖片+名稱） */
.cart-item-product {
  display: flex;
  gap: 20px;
  align-items: center;
}

.cart-item-image {
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

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

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

.cart-item-name {
  font-size: 14px;
  font-weight: 700;
  color: #333;
}

.cart-item-spec {
  font-size: 12px;
  color: #888;
}

/* 單價 */
.cart-item-price {
  font-size: 14px;
  color: #000;
  text-align: center;
}

/* 數量控制 */
.cart-item-qty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.qty-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--color-white);
}

.qty-btn:hover {
  border-color: var(--cart-accent);
  color: var(--cart-accent);
}

.qty-value {
  width: 40px;
  height: 30px;
  border: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #333;
  background: var(--color-white);
}

/* 小計 */
.cart-item-subtotal {
  font-size: 14px;
  font-weight: 700;
  color: var(--cart-accent);
  text-align: center;
}

/* 刪除按鈕 */
.cart-item-delete {
  width: 24px;
  height: 24px;
  color: #888;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, transform 0.2s ease;
}

.cart-item-delete svg {
  width: 24px;
  height: 24px;
}

.cart-item-delete:hover {
  color: #d9534f;
  transform: scale(1.15);
}

/* 繼續購物 */
.cart-continue-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 36px;
  border: 1px solid var(--cart-accent);
  color: var(--cart-accent);
  font-size: 14px;
  margin-top: 20px;
  margin-bottom: 30px;
  transition: all 0.3s ease;
}

.cart-continue-btn:hover {
  background: var(--cart-accent);
  color: var(--color-white);
  opacity: 1;
}

/* ── 加購推薦區 ── */
.cart-upsell {
  margin-top: auto;
  border: 1px dashed var(--cart-accent);
  padding: 26px 29px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  background: #fffaf7;
  overflow: hidden;
}

.cart-upsell-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.cart-upsell-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--cart-accent);
}

.cart-upsell-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--cart-accent);
}

.cart-upsell-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.cart-upsell-grid::-webkit-scrollbar {
  height: 6px;
}

.cart-upsell-grid::-webkit-scrollbar-track {
  background: rgba(226, 91, 42, 0.08);
}

.cart-upsell-grid::-webkit-scrollbar-thumb {
  background: rgba(226, 91, 42, 0.45);
  border-radius: 999px;
}

.cart-upsell-card {
  flex: 0 0 250px;
  min-width: 0;
  border: 1px solid #eee;
  background: var(--color-white);
  display: flex;
  align-items: center;
  padding: 10px;
  gap: 8px;
  scroll-snap-align: start;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cart-upsell-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(226, 91, 42, 0.12);
}

.cart-upsell-card-image {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  overflow: hidden;
  background: #f5f5f5;
}

.cart-upsell-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-upsell-card-image a {
  display: block;
  width: 100%;
  height: 100%;
}

.cart-upsell-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.cart-upsell-card-name {
  font-size: 12px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-upsell-card-price {
  font-size: 12px;
  font-weight: 700;
  color: #000;
}

.cart-upsell-card-price del {
  color: #999;
  font-weight: 400;
  font-size: 11px;
  margin-right: 4px;
}

.cart-upsell-card-price ins {
  text-decoration: none;
  color: var(--cart-accent);
}

.cart-upsell-add-btn {
  margin-top: 4px;
  width: 100%;
  height: 22px;
  background: var(--cart-accent);
  color: var(--color-white);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;
}

.cart-upsell-add-btn:hover {
  background: var(--cart-accent-deep);
}

.cart-upsell-add-btn:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.cart-upsell-empty {
  flex: 1 0 100%;
  margin: 0;
  color: #777777;
  font-size: 13px;
}

/* ── 右側：訂單摘要 ── */
.cart-summary {
  position: sticky;
  top: calc(var(--header-height) + 20px);
  border: 1px solid var(--cart-accent);
  padding: 28px 24px;
  background: var(--color-white);
}

.cart-summary-title {
  font-size: 18px;
  font-weight: 700;
  color: #000;
  margin-bottom: 20px;
}

/* 優惠碼 */
.cart-coupon-section {
  margin-bottom: 10px;
}

.cart-coupon-label {
  font-size: 14px;
  color: #888;
  margin-bottom: 8px;
  display: block;
}

.cart-coupon-row {
  display: flex;
  gap: 0;
}

.cart-coupon-input {
  flex: 1;
  height: 36px;
  border: 1px solid #ddd;
  padding: 0 12px;
  font-size: 13px;
  font-family: var(--font-primary);
  outline: none;
  transition: border-color 0.2s ease;
}

.cart-coupon-input:focus {
  border-color: var(--cart-accent);
}

.cart-coupon-btn {
  height: 36px;
  padding: 0 20px;
  background: var(--cart-accent);
  color: var(--color-white);
  font-size: 13px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-primary);
  transition: background 0.2s ease;
}

.cart-coupon-btn:hover {
  background: var(--cart-accent-deep);
}

/* 已套用優惠 */
.cart-coupons-applied {
  margin-top: 10px;
}

.cart-coupon-applied {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFF8E8;
  border: 1px solid rgba(226, 91, 42, 0.4);
  border-radius: 0;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.cart-coupon-applied-text {
  font-size: 12px;
  color: var(--cart-accent);
}

.cart-coupon-remove {
  font-size: 14px;
  color: var(--cart-accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.2s ease;
}

.cart-coupon-remove:hover {
  color: #d9534f;
}

/* 分隔線 */
.cart-summary-divider {
  height: 1px;
  background: #eee;
  margin: 14px 0;
}

/* 金額明細 */
.cart-summary-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.cart-summary-label {
  font-size: 14px;
  color: #666;
}

.cart-summary-value {
  font-size: 14px;
  color: #333;
  text-align: right;
}

.cart-summary-row.success .cart-summary-label,
.cart-summary-row.success .cart-summary-value {
  color: var(--cart-success);
}

.cart-summary-row.coupon-row .cart-summary-label,
.cart-summary-row.coupon-row .cart-summary-value {
  color: var(--cart-accent);
}

/* 應付金額 */
.cart-summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.cart-summary-total-label {
  font-size: 16px;
  font-weight: 700;
  color: #000;
}

.cart-summary-total-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--cart-total-color);
}

/* 前往結帳按鈕 */
.cart-checkout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  background: var(--cart-btn-bg);
  color: var(--color-white);
  font-size: 16px;
  font-weight: 700;
  margin-top: 10px;
  transition: all 0.3s ease;
}

.cart-checkout-btn:hover {
  background: #4A2615;
  opacity: 1;
}

/* 信任標記 */
.cart-trust-badges {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 12px;
}

.cart-trust-badges span {
  font-size: 11px;
  color: #888;
}

.cart-trust-badges span:first-child::before {
  content: '🔒 ';
}

.cart-trust-badges span:last-child::before {
  content: '✓ ';
}

/* ========================================
   動畫效果
   ======================================== */

@keyframes cartItemFadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cart-item {
  animation: cartItemFadeIn 0.4s ease forwards;
}

.cart-item:nth-child(1) { animation-delay: 0.1s; }
.cart-item:nth-child(2) { animation-delay: 0.2s; }
.cart-item:nth-child(3) { animation-delay: 0.3s; }

.cart-item.removing {
  animation: cartItemRemove 0.35s ease forwards;
}

@keyframes cartItemRemove {
  to {
    opacity: 0;
    transform: translateX(40px);
    height: 0;
    padding: 0 22px;
    overflow: hidden;
  }
}

/* ========================================
   響應式 RWD
   ======================================== */
@media screen and (max-width: 992px) {
  .cart-container {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 30px 40px;
  }

  .cart-summary {
    position: static;
    order: 2;
    margin-top: 30px;
    margin-bottom: 0;
  }

  .cart-main {
    order: 1;
  }

  .cart-upsell-grid {
    display: flex;
    overflow-x: auto;
  }

  .cart-upsell-card {
    flex-basis: 240px;
  }

  /* 行動版訂單摘要 */
  .cart-summary {
    padding: 24px 20px 28px;
    border: 1px solid var(--cart-accent);
  }

  .cart-summary-title {
    text-align: center;
    font-size: 18px;
    margin-bottom: 22px;
  }

  .cart-coupon-section {
    margin-bottom: 0;
  }

  .cart-coupon-label {
    font-size: 14px;
    color: #888;
    margin-bottom: 10px;
  }

  .cart-coupon-input {
    height: 40px;
    font-size: 14px;
  }

  .cart-coupon-btn {
    height: 40px;
    min-width: 76px;
    font-size: 14px;
  }

  .cart-coupons-applied {
    margin-top: 12px;
  }

  .cart-coupon-applied {
    margin-bottom: 0;
  }

  .cart-summary-divider {
    margin: 18px 0;
  }

  .cart-summary-rows {
    gap: 14px;
  }

  .cart-summary-label,
  .cart-summary-value {
    font-size: 14px;
  }

  .cart-summary-total {
    padding: 10px 0 18px;
  }

  .cart-summary-total-label {
    font-size: 16px;
  }

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

  .cart-checkout-btn {
    height: 48px;
    font-size: 16px;
    margin-top: 0;
  }

  .cart-trust-badges {
    gap: 18px;
    margin-top: 14px;
  }

  .cart-trust-badges span {
    font-size: 11px;
  }
}

@media screen and (max-width: 768px) {
  .cart-title-section {
    gap: 6px;
    padding-bottom: 20px;
  }

  .cart-page-title {
    font-size: 22px;
    line-height: 1.25;
  }

  .cart-title-underline {
    width: 184px;
  }

  .cart-item-count {
    font-size: 14px;
    line-height: 20px;
  }

  .cart-container {
    padding: 0 7px 30px;
  }

  .cart-table-header {
    display: none;
  }

  .cart-items {
    gap: 10px;
  }

  .cart-item {
    display: grid;
    grid-template-columns: 90px minmax(96px, 1fr) auto 24px;
    grid-template-rows: 30px 28px 34px;
    column-gap: 15px;
    row-gap: 0;
    min-height: 119px;
    padding: 7px 13px 7px 7px;
    border: 1px solid #d6d6d6;
    margin-bottom: 0;
    position: static;
    align-items: center;
    background: #fff;
  }

  .cart-item:first-child {
    border-top: 1px solid #eee;
  }

  .cart-item:hover {
    background: var(--color-white);
  }

  .cart-item-product,
  .cart-item-info {
    display: contents;
  }

  .cart-item-image {
    grid-column: 1;
    grid-row: 1 / 4;
    width: 90px;
    height: 104px;
    align-self: center;
    background: #f5f5f5;
  }

  .cart-item-name {
    grid-column: 2 / 5;
    grid-row: 1;
    font-size: 16px;
    line-height: 22px;
    align-self: end;
    justify-self: start;
    text-align: left;
    padding-left: 0;
    margin-left: -4px;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
  }

  .cart-item-spec {
    grid-column: 2;
    grid-row: 2;
    font-size: 13px;
    line-height: 22px;
    align-self: center;
    justify-self: start;
    text-align: left;
    padding-left: 4px;
    margin-left: 0;
    color: #888;
    white-space: nowrap;
  }

  .cart-item-price {
    display: none;
  }

  .cart-item-qty {
    grid-column: 3;
    grid-row: 2;
    justify-content: flex-end;
    align-self: center;
    gap: 5px;
    transform: translateY(7px);
  }

  .qty-btn {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }

  .qty-value {
    width: 46px;
    height: 24px;
    font-size: 14px;
  }

  .cart-item-delete {
    grid-column: 4;
    grid-row: 2;
    position: static;
    margin: 0;
    align-self: center;
    justify-self: center;
    color: #333;
    width: 14px;
    height: 18px;
    transform: translateY(7px);
  }

  .cart-item-delete svg {
    width: 14px;
    height: 18px;
  }

  .cart-item-subtotal {
    grid-column: 2;
    grid-row: 3;
    text-align: left;
    font-size: 18px;
    line-height: 22px;
    font-weight: 700;
    color: var(--cart-accent);
    align-self: end;
    padding-top: 0;
    white-space: nowrap;
  }

  .cart-item-subtotal::before {
    content: none;
  }

  .cart-continue-btn {
    display: flex;
    width: 180px;
    height: 40px;
    margin: 24px auto 0;
    font-size: 14px;
  }

  .cart-upsell {
    margin-top: 24px;
    padding: 20px 16px;
    background: var(--color-white);
    gap: 16px;
    align-items: stretch;
  }

  .cart-upsell-header {
    justify-content: center;
    text-align: center;
  }

  .cart-upsell-text {
    font-size: 14px;
    line-height: 1.5;
  }

  .cart-upsell-grid {
    gap: 12px;
    padding-bottom: 8px;
  }

  .cart-upsell-card {
    flex: 0 0 178px;
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    gap: 8px;
    border: 1px solid rgba(226, 91, 42, 0.45);
  }

  .cart-upsell-card:hover {
    transform: none;
    box-shadow: none;
  }

  .cart-upsell-card-image {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .cart-upsell-card-info {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0;
    width: 100%;
  }

  .cart-upsell-card-name,
  .cart-upsell-card-price {
    display: inline;
    font-size: 13px;
    font-weight: 700;
    color: #333;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  .cart-upsell-add-btn {
    flex-basis: 100%;
    width: 100%;
    height: 30px;
    margin-top: 8px;
    font-size: 12px;
  }

  .cart-steps-inner {
    max-width: 320px;
  }

  .cart-step-line {
    min-width: 40px;
  }
}

@media screen and (max-width: 480px) {
  .cart-summary {
    padding: 22px 16px 26px;
  }

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

@media screen and (max-width: 380px) {
  .cart-container {
    padding-left: 6px;
    padding-right: 6px;
  }

  .cart-item {
    box-sizing: border-box;
    grid-template-columns: 90px minmax(70px, 1fr) auto 18px;
    column-gap: 6px;
    padding-right: 8px;
  }

  .cart-item-name,
  .cart-item-spec {
    grid-column-start: 2;
  }

  .cart-item-delete {
    justify-self: end;
    transform: translateY(7px);
  }

  .qty-btn {
    width: 22px;
  }

  .qty-value {
    width: 40px;
  }
}
