/*
 * USD 二手 3C 商城 — 商品頁響應式與規格描述兼容樣式
 * 嚴守 DESIGN.md 色票：#fd560f (Brand Primary) / #282828 (Heading Ink) / #f7f7f7 (Subtle Surface)
 */

/* ==========================================================================
   A. 新版語意範本樣式（全裝置適用，由 ProductSpecHtmlRenderer 輸出）
   ========================================================================== */
.usd-desc-shell {
  background: #f8f4ee;
  border-radius: 20px;
  padding: 24px;
}

.usd-desc-card {
  background: #fffdf9;
  border-radius: 16px;
  padding: 24px;
}

.usd-desc-title {
  text-align: center;
  font-size: 22px;
  margin-bottom: 16px;
  color: #282828;
}

.usd-spec-box {
  border: 1px solid #eadfd2;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  margin-bottom: 18px;
}

.usd-spec-heading {
  background: #f2e8dc;
  color: #3d332a;
  font-weight: 700;
  padding: 10px 16px;
  font-size: 16px;
}

.usd-spec-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.usd-spec-table th,
.usd-spec-table td {
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.55;
  border-bottom: 1px solid #efe7dc !important;
  vertical-align: top;
}

.usd-spec-table th {
  background: #faf6f0;
  color: #3d332a;
  font-weight: 600;
}

.usd-spec-table--4col th {
  width: 20%;
}

.usd-spec-table--4col td {
  width: 30%;
}

.usd-spec-table--2col th {
  width: 24%;
}

.usd-spec-table--2col td {
  width: 76%;
}

.usd-spec-note {
  background: #f7f1e8;
  border: 1px dashed #d8c7b4;
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.65;
  color: #3d332a;
}

.usd-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  scrollbar-width: thin;
  scrollbar-color: #d8c7b4 transparent;
}

.usd-table-scroll:focus-visible {
  outline: 2px solid #fd560f;
  outline-offset: 2px;
}

.usd-table-scroll table {
  display: table !important;
  width: max-content !important;
  min-width: 100% !important;
  max-width: none !important;
  table-layout: auto !important;
  border-collapse: collapse !important;
}

.usd-table-scroll th,
.usd-table-scroll td {
  white-space: nowrap !important;
}

/* ==========================================================================
   C. 附件一（主圖縮圖＋信任徽章）＋ Tab 導覽列 ＋ SKU 動態保固條（共用與桌機）
   ========================================================================== */
.product-image .left {
  flex: 0 0 80px;
  width: 80px;
}

.product-image .right {
  flex: 1 1 auto;
  min-width: 0;
}

@media (min-width: 992px) {
  .usd-trust-badges-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .usd-trust-badge-item {
    min-width: 0 !important;
  }
}

body.page-product .nav-tabs.nav-overflow {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

body.page-product .nav-tabs.nav-overflow::-webkit-scrollbar {
  display: none;
}

body.page-product .nav-tabs.nav-overflow .nav-link {
  flex: 0 0 auto;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  scroll-snap-align: start;
}

.usd-sku-warranty-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin-top: 4px;
}

.usd-sku-warranty-text {
  color: #282828;
  font-weight: 600;
  line-height: 1.5;
  padding-left: 8px;
  border-left: 3px solid #fd560f;
}

/* ==========================================================================
   B + C. 行動端響應式修復（限 <= 767.98px，桌機 1440px 完全保持原樣）
   ========================================================================== */
@media (max-width: 767.98px) {
  /* 新版語意範本手機收斂 */
  .usd-desc-shell {
    padding: 12px 10px;
    border-radius: 14px;
  }

  .usd-desc-card {
    padding: 14px 12px;
    border-radius: 12px;
  }

  .usd-desc-title {
    font-size: 18px;
  }

  /* 舊版 5 大商品描述變體與說明區塊外內距收斂 */
  body.page-product .rich-text-editor-content > div[style*="padding"],
  body.page-product #product-purchase-guide > div[style*="padding"],
  body.page-product #product-faq > div[style*="padding"] {
    padding: 12px 10px !important;
    border-radius: 14px !important;
  }

  body.page-product .rich-text-editor-content div[style*="padding:34px"],
  body.page-product .rich-text-editor-content div[style*="padding: 34px"],
  body.page-product .rich-text-editor-content div[style*="#fffdf9"],
  body.page-product .rich-text-editor-content div[style*="padding:24px"],
  body.page-product .rich-text-editor-content div[style*="padding: 24px"],
  body.page-product #product-purchase-guide div[style*="padding:34px"],
  body.page-product #product-purchase-guide div[style*="padding: 34px"],
  body.page-product #product-purchase-guide div[style*="#fffdf9"],
  body.page-product #product-purchase-guide div[style*="padding:24px"],
  body.page-product #product-purchase-guide div[style*="padding: 24px"],
  body.page-product #product-faq div[style*="padding:34px"],
  body.page-product #product-faq div[style*="padding: 34px"],
  body.page-product #product-faq div[style*="#fffdf9"],
  body.page-product #product-faq div[style*="padding:24px"],
  body.page-product #product-faq div[style*="padding: 24px"] {
    padding: 14px 12px !important;
    border-radius: 12px !important;
  }

  body.page-product .rich-text-editor-content h2 {
    font-size: 20px !important;
    margin-bottom: 14px !important;
  }

  body.page-product .rich-text-editor-content h3,
  body.page-product #product-purchase-guide h3,
  body.page-product #product-faq h3 {
    font-size: 18px !important;
  }

  /* 確保描述與購買須知正文最小可讀字級不縮到 13px */
  body.page-product #product-description,
  body.page-product #product-purchase-guide {
    font-size: 15px;
    line-height: 1.65;
  }

  body.page-product #product-description [style*="font-size:11px"],
  body.page-product #product-description [style*="font-size: 11px"],
  body.page-product #product-description [style*="font-size:12px"],
  body.page-product #product-description [style*="font-size: 12px"],
  body.page-product #product-description [style*="font-size:13px"],
  body.page-product #product-description [style*="font-size: 13px"],
  body.page-product #product-purchase-guide [style*="font-size:11px"],
  body.page-product #product-purchase-guide [style*="font-size: 11px"],
  body.page-product #product-purchase-guide [style*="font-size:12px"],
  body.page-product #product-purchase-guide [style*="font-size: 12px"],
  body.page-product #product-purchase-guide [style*="font-size:13px"],
  body.page-product #product-purchase-guide [style*="font-size: 13px"] {
    font-size: 14px !important;
    line-height: 1.6 !important;
  }

  /* 規格表（含舊版 2 欄 / 4 欄 / colspan="3" 與新版 .usd-spec-table）轉 2 欄易讀佈局；含寬表水平捲動還原 */
  body.page-product #product-description table,
  body.page-product #product-purchase-guide table,
  body.page-product #product-faq table,
  body.page-product .usd-spec-table,
  body.page-product #product-description table > tbody,
  body.page-product #product-purchase-guide table > tbody,
  body.page-product #product-faq table > tbody,
  body.page-product .usd-spec-table > tbody {
    display: block !important;
    width: 100% !important;
  }

  body.page-product #product-description table colgroup,
  body.page-product #product-purchase-guide table colgroup,
  body.page-product #product-faq table colgroup,
  body.page-product .usd-spec-table colgroup {
    display: none !important;
  }

  body.page-product #product-description table tr,
  body.page-product #product-purchase-guide table tr,
  body.page-product #product-faq table tr,
  body.page-product .usd-spec-table tr {
    display: grid !important;
    grid-template-columns: minmax(100px, 34%) minmax(0, 1fr) !important;
    width: 100% !important;
  }

  body.page-product #product-description table tr > th[colspan]:only-child,
  body.page-product #product-description table tr > td[colspan]:only-child,
  body.page-product #product-purchase-guide table tr > th[colspan]:only-child,
  body.page-product #product-purchase-guide table tr > td[colspan]:only-child {
    grid-column: 1 / -1 !important;
  }

  body.page-product #product-description table th,
  body.page-product #product-description table td,
  body.page-product #product-purchase-guide table th,
  body.page-product #product-purchase-guide table td,
  body.page-product #product-faq table th,
  body.page-product #product-faq table td,
  body.page-product .usd-spec-table th,
  body.page-product .usd-spec-table td {
    display: block !important;
    box-sizing: border-box !important;
    width: auto !important;
    min-width: 100% !important;
    max-width: 100% !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    text-align: left !important;
    border: 0 !important;
    border-bottom: 1px solid #efe7dc !important;
  }

  body.page-product #product-description table th,
  body.page-product #product-purchase-guide table th,
  body.page-product #product-faq table th,
  body.page-product .usd-spec-table th {
    background: #faf6f0 !important;
    color: #3d332a !important;
    font-weight: 600 !important;
  }

  body.page-product #product-description .usd-table-scroll table,
  body.page-product #product-purchase-guide .usd-table-scroll table,
  body.page-product #product-faq .usd-table-scroll table,
  body.page-product .rich-text-editor-content .usd-table-scroll table,
  body.page-product .usd-table-scroll table {
    display: table !important;
    width: max-content !important;
    min-width: 100% !important;
    max-width: none !important;
    table-layout: auto !important;
  }

  body.page-product #product-description .usd-table-scroll table > tbody,
  body.page-product #product-purchase-guide .usd-table-scroll table > tbody,
  body.page-product #product-faq .usd-table-scroll table > tbody,
  body.page-product .usd-table-scroll table > tbody {
    display: table-row-group !important;
    width: auto !important;
  }

  body.page-product #product-description .usd-table-scroll table colgroup,
  body.page-product #product-purchase-guide .usd-table-scroll table colgroup,
  body.page-product #product-faq .usd-table-scroll table colgroup,
  body.page-product .usd-table-scroll table colgroup {
    display: table-column-group !important;
  }

  body.page-product #product-description .usd-table-scroll table tr,
  body.page-product #product-purchase-guide .usd-table-scroll table tr,
  body.page-product #product-faq .usd-table-scroll table tr,
  body.page-product .usd-table-scroll table tr {
    display: table-row !important;
    width: auto !important;
  }

  body.page-product #product-description .usd-table-scroll table th,
  body.page-product #product-description .usd-table-scroll table td,
  body.page-product #product-purchase-guide .usd-table-scroll table th,
  body.page-product #product-purchase-guide .usd-table-scroll table td,
  body.page-product #product-faq .usd-table-scroll table th,
  body.page-product #product-faq .usd-table-scroll table td,
  body.page-product .usd-table-scroll table th,
  body.page-product .usd-table-scroll table td {
    display: table-cell !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    white-space: nowrap !important;
    border-bottom: 1px solid #efe7dc !important;
  }

  /* 變體 E（78 筆 Flex 偽表）與 iMCheck CTA 區 */
  body.page-product .rich-text-editor-content div[style*="flex:0 0 130px"],
  body.page-product .rich-text-editor-content div[style*="flex: 0 0 130px"] {
    flex: 0 0 88px !important;
    width: 88px !important;
    min-width: 88px !important;
    padding: 10px 8px !important;
    font-size: 14px !important;
  }

  body.page-product .rich-text-editor-content div[style*="flex:0 0 130px"] + div,
  body.page-product .rich-text-editor-content div[style*="flex: 0 0 130px"] + div {
    padding: 10px 12px !important;
    font-size: 14px !important;
    min-width: 0 !important;
    word-break: break-word !important;
  }

  body.page-product .rich-text-editor-content div[style*="flex:1 1 400px"],
  body.page-product .rich-text-editor-content div[style*="flex: 1 1 400px"] {
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }

  body.page-product .rich-text-editor-content img,
  body.page-product #product-purchase-guide img,
  body.page-product #product-faq img {
    max-width: 100% !important;
    height: auto !important;
    min-width: 0 !important;
  }

  body.page-product .rich-text-editor-content img[style*="width:82%"],
  body.page-product .rich-text-editor-content img[style*="width: 82%"] {
    width: 100% !important;
    min-width: 0 !important;
  }

  body.page-product .rich-text-editor-content img[style*="130px"] {
    width: 88px !important;
    height: 88px !important;
  }

  /* 主圖縮圖與信任徽章 3 卡 1+2 佈局 */
  .product-image {
    flex-direction: column-reverse !important;
    gap: 10px !important;
  }

  .product-image .left {
    width: 100% !important;
    flex: none !important;
    margin-right: 0 !important;
    max-height: none !important;
  }

  .product-image .left .swiper-wrapper {
    flex-direction: row !important;
    gap: 8px;
    overflow-x: auto;
  }

  .product-image .left .swiper-slide {
    width: 56px !important;
    height: 56px !important;
    flex: 0 0 56px !important;
  }

  .usd-trust-badges-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .usd-trust-badge-item--warranty,
  .usd-trust-badges-grid > .usd-trust-badge-item:first-child {
    grid-column: 1 / -1 !important;
  }

  .usd-trust-badge-item {
    min-width: 0 !important;
    padding: 10px 12px !important;
  }

  .usd-trust-badge-title,
  .usd-trust-badge-desc {
    display: block !important;
    white-space: normal !important;
    overflow: visible !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }

  .usd-trust-badge-title {
    font-size: 0.85rem !important;
    line-height: 1.35 !important;
  }

  .usd-trust-badge-desc {
    font-size: 0.75rem !important;
    line-height: 1.45 !important;
    color: #4b5563 !important;
  }
}

@media (max-width: 340px) {
  .usd-trust-badges-grid {
    grid-template-columns: 1fr !important;
  }
}
