/* ==========================================================================
   catalog.css — 產品選配目錄（catalog.html，會員專屬）
   色彩一律走 style.css 的 :root 變數，跟著全站墨綠主題
   ========================================================================== */

/* ---------- 未登入 / 載入中 ---------- */
.cat-gate { text-align: center; padding: 46px 26px; }
.cat-gate-icon { font-size: 2rem; line-height: 1; margin-bottom: 10px; }
.cat-gate h3 { margin-bottom: 8px; }
.cat-gate p { max-width: 520px; margin: 0 auto 18px; }
.cat-gate-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.cat-loading { text-align: center; padding: 46px 26px; }
.cat-spinner {
  width: 26px; height: 26px; margin: 0 auto 12px;
  border: 3px solid var(--brand-soft);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: cat-spin .9s linear infinite;
}
@keyframes cat-spin { to { transform: rotate(360deg); } }

/* ---------- 台灣報價授權狀態列 ---------- */
.cat-price-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border: 1px solid rgba(47, 74, 55, .18);
  border-left: 4px solid var(--brand);
  background: var(--bg-alt);
  border-radius: 12px;
  padding: 12px 16px; margin-bottom: 16px;
}
.cat-price-info { display: flex; flex-direction: column; gap: 2px; margin-right: auto; min-width: 0; }
.cat-price-info b { font-size: .95rem; color: var(--ink); }
.cat-price-text { font-size: .84rem; color: #5d6b62; line-height: 1.5; }
.cat-price-bar.is-ok { border-left-color: var(--brand); background: var(--brand-soft); }
.cat-price-bar.is-wait { border-left-color: #b8860b; background: #fdf7e6; }
.cat-price-bar.is-no { border-left-color: #a3423a; background: #fbf1f0; }
.cat-price-bar .btn { flex: none; }

/* ---------- 上方工具列 ---------- */
.cat-bar {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.cat-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-tab {
  border: 1px solid rgba(47, 74, 55, .22);
  background: #fff; color: var(--ink);
  border-radius: 999px; padding: 9px 18px;
  font: inherit; font-size: .95rem; cursor: pointer;
  transition: background .16s, border-color .16s, color .16s;
}
.cat-tab:hover { border-color: var(--brand); }
.cat-tab.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.cat-tab small { display: block; font-size: .74rem; opacity: .78; }

.cat-searchbox { display: flex; gap: 8px; align-items: center; margin-left: auto; flex: 1 1 280px; max-width: 420px; }
.cat-searchbox .input { flex: 1; }

/* ---------- 版面：左目錄 / 右產品 ---------- */
.cat-layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 22px; align-items: start; }

.cat-side {
  background: var(--bg-alt);
  border: 1px solid rgba(47, 74, 55, .12);
  border-radius: 14px;
  padding: 14px;
  max-height: 74vh;
  display: flex; flex-direction: column;
}
.cat-side-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-weight: 700; font-size: .92rem; padding: 2px 4px 10px;
  border-bottom: 1px solid rgba(47, 74, 55, .12);
}
.cat-side-count { font-weight: 500; font-size: .82rem; color: #6b7a6f; }
/* flex:1 + min-height:0 讓分類清單在 74vh 內部正常捲動，不被裁切 */
.cat-tree { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-top: 8px; padding-right: 4px; -webkit-overflow-scrolling: touch; }

.cat-node {
  display: flex; width: 100%; justify-content: space-between; gap: 8px;
  background: none; border: 0; border-radius: 8px;
  padding: 8px 10px; margin-bottom: 2px;
  font: inherit; font-size: .88rem; color: var(--ink);
  text-align: left; cursor: pointer; line-height: 1.35;
}
.cat-node:hover { background: #fff; }
.cat-node.is-active { background: #fff; color: var(--brand); font-weight: 700; box-shadow: inset 3px 0 0 var(--brand); }
.cat-node span.n { flex: none; color: #85937f; font-size: .78rem; }

/* ---------- 產品區 ---------- */
.cat-main { min-width: 0; }
.cat-meta { font-size: .9rem; color: #5d6b62; margin-bottom: 12px; min-height: 20px; }
.cat-meta b { color: var(--ink); }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; }

.cat-card {
  background: #fff;
  border: 1px solid rgba(47, 74, 55, .12);
  border-radius: 12px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.cat-thumb {
  aspect-ratio: 1 / 1;
  background: #f6f8f5;
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-in; overflow: hidden;
}
.cat-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.cat-thumb.noimg { cursor: default; color: #9aa89b; font-size: .76rem; }

.cat-body { padding: 10px 12px 12px; display: flex; flex-direction: column; flex: 1; }
.cat-name {
  font-size: .88rem; font-weight: 700; line-height: 1.4; margin: 0 0 6px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.cat-line { font-size: .78rem; color: #63715f; line-height: 1.5; margin: 0 0 2px; word-break: break-all; }
.cat-line b { font-weight: 600; color: #48543f; }

.cat-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: auto; padding-top: 9px; border-top: 1px dashed rgba(47, 74, 55, .16);
}
.cat-unit { font-size: .76rem; color: #7d8b78; }
.cat-price { font-size: .82rem; font-weight: 700; color: var(--brand); }
/* 核准後的實際單價：字級大一階，跟「請洽詢」明顯區分 */
.cat-price.is-on { font-size: .95rem; letter-spacing: .2px; }

.cat-add {
  border: 1px solid var(--brand); background: #fff; color: var(--brand);
  border-radius: 8px; padding: 5px 10px; font: inherit; font-size: .78rem;
  cursor: pointer; flex: none;
}
.cat-add:hover { background: var(--brand); color: #fff; }
.cat-add.is-on { background: var(--brand); color: #fff; }

.cat-empty { padding: 40px 10px; text-align: center; color: #6b7a6f; }
.cat-foot-note { margin-top: 26px; }
.cat-foot-note a { color: var(--brand); }

/* ---------- 已選清單 ---------- */
.cat-pick {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-top: 1px solid rgba(47, 74, 55, .18);
  box-shadow: 0 -6px 20px rgba(24, 33, 27, .10);
  padding: 10px 16px 12px;
}
.cat-pick-head { display: flex; align-items: center; gap: 10px; max-width: 1200px; margin: 0 auto; }
.cat-pick-head b { margin-right: auto; font-size: .9rem; }
.cat-pick-list {
  max-width: 1200px; margin: 8px auto 0; max-height: 116px; overflow-y: auto;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-soft); border-radius: 999px;
  padding: 4px 6px 4px 10px; font-size: .78rem; max-width: 320px;
}
.cat-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-chip i { font-style: normal; font-weight: 700; color: var(--brand); flex: none; }
.cat-chip button { border: 0; background: none; cursor: pointer; color: #5d6b62; font-size: .95rem; line-height: 1; padding: 0 2px; }

.cat-pick-sum {
  max-width: 1200px; margin: 8px auto 0;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-size: .84rem; color: #5d6b62;
}
.cat-pick-sum b { font-size: 1rem; color: var(--brand); }
.cat-pick-warn { color: #a3423a; }
.cat-pick-tip { font-size: .76rem; color: #7d8b78; }

/* ---------- 看大圖 ---------- */
.cat-lightbox {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(18, 26, 20, .88);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 26px;
}
.cat-lightbox img { max-width: min(88vw, 760px); max-height: 74vh; background: #fff; border-radius: 10px; padding: 12px; }
.cat-light-cap { color: #eef2ec; font-size: .88rem; margin-top: 12px; text-align: center; max-width: 700px; }
.cat-light-close {
  position: absolute; top: 16px; right: 20px;
  background: none; border: 0; color: #fff; font-size: 2rem; line-height: 1; cursor: pointer;
}

/* ---------- 響應式 ---------- */
@media (max-width: 900px) {
  .cat-layout { grid-template-columns: minmax(0, 1fr); }
  .cat-side { max-height: none; }
  /* 手機／平板：分類改成橫向捲動的晶片列，不佔滿整個畫面高度。
     ⚠️ width:auto 必須寫：桌面版 .cat-node 有 width:100%，flex:none 不會覆蓋它，
     會讓每顆晶片都佔滿整列寬，其他分類全部被推進滑動區（iPad 上看起來像分類消失）。 */
  .cat-tree { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .cat-node { flex: none; width: auto; border: 1px solid rgba(47, 74, 55, .16); border-radius: 999px; padding: 7px 13px; margin: 0; white-space: nowrap; }
  .cat-node.is-active { box-shadow: none; }
  .cat-node span.n { margin-left: 4px; }
  .cat-searchbox { margin-left: 0; max-width: none; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .cat-price-bar { padding: 11px 13px; gap: 10px; }
  .cat-price-bar .btn { width: 100%; }
  .cat-pick-list { max-height: 92px; }
}

/* ===== 申請查看台灣報價：填一點個人資料，後台才認得出人是誰 =====
   ⚠️ 欄位用 grid 排，手機斷點一定要改成單欄 —— 用 3 欄寫死會把手機撐破。 */
.cat-apply { margin-top: 14px; }
.cat-apply-in {
  padding: 16px 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
}
.cat-apply-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.cat-apply-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cat-apply .form-note.is-err { color: var(--danger); }
@media (max-width: 760px) {
  .cat-apply-in { padding: 14px 14px; }
  .cat-apply-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .cat-apply-actions .btn { flex: 1 1 auto; }
}
