/* ============================================================
   萃見 UI（cj-ui.css）— rex/crm-v2 業務員端質感改版的共用層
   ------------------------------------------------------------
   用法（每張 crm-v2 頁）：
     <meta name="rex-theme" content="native">          ← 開機碼之前
     <link rel="stylesheet" href="/assets/cj/cj-ui.css"> ← 頁面自己的 <style> 之前
     <script src="/assets/cj/cj-ui.js" defer></script>    ← 要用 CJ.empty()/CJ.ic() 時
   頁面自己的 :root 變數改指向下面的 --cj-* 語意 token，深色就自動跟著切；
   不要在頁面裡寫死 hex 底色/字色（狀態色可用 --cj-ok/warn/bad 系列）。

   深色來源：全站開機碼寫 <html data-rex-theme="dark">（rex-topbar-unify 規格）。
   本檔只認這個屬性，不用 prefers-color-scheme（launcher 會接管 media query）。
   ============================================================ */

:root {
  /* ---- 萃見品牌色（固定，不隨明暗變） ---- */
  --cj-navy: #0a2334;
  --cj-navy-2: #0f2e44;
  --cj-navy-3: #163a54;
  --cj-ink-brand: #173e49;
  --cj-teal: #17727d;
  --cj-teal-2: #1d8b97;
  --cj-teal-soft: #e3f0f1;
  --cj-ivory: #f6f2ea;
  --cj-ivory-2: #fbf9f4;
  --cj-gold: #e8bd76;
  --cj-gold-2: #d9a456;
  --cj-gold-ink: #94692a;       /* 金色「文字」在淺底要夠對比 */

  /* ---- 語意 token（淺色） ---- */
  --cj-bg: #f5f3ee;
  --cj-surface: #ffffff;
  --cj-surface-2: #faf8f3;
  --cj-surface-3: #f1eee6;
  --cj-line: #e6e1d6;
  --cj-line-2: #efebe2;
  --cj-text: #14232e;
  --cj-text-2: #51606b;
  --cj-text-3: #84909a;
  --cj-acc: #17727d;            /* 主要動作 */
  --cj-acc-hover: #12606a;
  --cj-acc-ink: #ffffff;        /* 主要按鈕上的字 */
  --cj-acc-soft: #e3f0f1;
  --cj-focus: rgba(23, 114, 125, .35);
  --cj-ok: #1f7a4d;   --cj-ok-soft: #e4f3ea;
  --cj-warn: #a3620b; --cj-warn-soft: #fbf0dc;
  --cj-bad: #b3261e;  --cj-bad-soft: #fbe9e7;
  --cj-info: #1d6fa5; --cj-info-soft: #e5f0f8;
  --cj-shadow: 0 1px 2px rgba(10, 35, 52, .05), 0 8px 24px rgba(10, 35, 52, .06);
  --cj-shadow-lg: 0 12px 36px rgba(10, 35, 52, .12);
  --cj-r: 14px;
  --cj-r-lg: 20px;
  --cj-font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  --cj-font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  color-scheme: light;
}

html[data-rex-theme="dark"] {
  --cj-bg: #0b1a26;
  --cj-surface: #112636;
  --cj-surface-2: #142d40;
  --cj-surface-3: #19354b;
  --cj-line: #23425a;
  --cj-line-2: #1b374d;
  --cj-text: #e9eef2;
  --cj-text-2: #a9b7c2;
  --cj-text-3: #7d8d99;
  --cj-acc: #4fb3bd;
  --cj-acc-hover: #6cc3cc;
  --cj-acc-ink: #06202a;
  --cj-acc-soft: rgba(79, 179, 189, .14);
  --cj-focus: rgba(79, 179, 189, .4);
  --cj-gold-ink: #e8bd76;
  --cj-teal-soft: rgba(79, 179, 189, .14);
  --cj-ok: #5ccf94;   --cj-ok-soft: rgba(92, 207, 148, .13);
  --cj-warn: #f0b860; --cj-warn-soft: rgba(240, 184, 96, .13);
  --cj-bad: #f2857d;  --cj-bad-soft: rgba(242, 133, 125, .13);
  --cj-info: #7cb8e6; --cj-info-soft: rgba(124, 184, 230, .13);
  --cj-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --cj-shadow-lg: 0 12px 36px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ---- 頁面骨架 ---- */
html.cj, html.cj body { background: var(--cj-bg); color: var(--cj-text); }
html.cj body { font-family: var(--cj-font); -webkit-font-smoothing: antialiased; }
html.cj :focus-visible { outline: 2px solid var(--cj-acc); outline-offset: 2px; }

/* ---- 頁頂主視覺（深藍底＋右側插圖；字在左） ----
   <section class="cj-hero"><div class="cj-hero-tx"><h1>…</h1><p>…</p></div>
     <img class="cj-hero-art" src="/assets/cj/crm-home-hero.webp" alt="" width="2000" height="750"></section> */
.cj-hero {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--cj-navy); color: #f3efe6;
  border-radius: var(--cj-r-lg); padding: 26px 28px; min-height: 132px;
  display: flex; align-items: center; box-shadow: var(--cj-shadow);
}
.cj-hero-art {
  position: absolute; inset: 0 0 0 auto; height: 100%; width: auto; max-width: none;
  object-fit: cover; object-position: right center; z-index: -1; pointer-events: none;
}
.cj-hero::after {   /* 左側漸層讓字永遠可讀 */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, var(--cj-navy) 0%, rgba(10, 35, 52, .92) 38%, rgba(10, 35, 52, 0) 72%);
}
.cj-hero-tx { position: relative; max-width: 560px; }
.cj-hero h1, .cj-hero .cj-hero-t { margin: 0 0 6px; font-size: 24px; font-weight: 800; letter-spacing: .01em; color: #fff; }
.cj-hero p, .cj-hero .cj-hero-s { margin: 0; font-size: 14px; color: rgba(243, 239, 230, .78); line-height: 1.6; }
.cj-hero .cj-kicker { display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .12em; color: var(--cj-gold); margin-bottom: 8px; }

/* ---- 工具頁頁頂底紋帶（較矮，給雷達、戰情室、看板等） ---- */
.cj-band {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--cj-navy); color: #f3efe6;
  border-radius: var(--cj-r-lg); padding: 18px 22px; min-height: 84px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.cj-band > img.cj-band-art {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center;
  z-index: -1; opacity: .95; pointer-events: none;
}
.cj-band h1, .cj-band .cj-band-t { margin: 0; font-size: 20px; font-weight: 800; color: #fff; }
.cj-band p, .cj-band .cj-band-s { margin: 2px 0 0; font-size: 13px; color: rgba(243, 239, 230, .75); }
.cj-band .cj-ic { filter: none; }
.cj-band a, .cj-hero a { color: var(--cj-gold); }
/* 深藍帶上的深色線條圖示看不見 → 自動墊象牙白小底座（已在 .cj-icb 裡的不重複墊） */
.cj-band :not(.cj-icb) > img.cj-ic, .cj-hero :not(.cj-icb) > img.cj-ic,
.cj-band > img.cj-ic, .cj-hero > img.cj-ic {
  background: var(--cj-ivory); border-radius: 7px; padding: 3px; box-sizing: content-box;
  box-shadow: 0 0 0 1px rgba(232, 189, 118, .45);
}

/* 右上角「個資遮罩」小膠囊（demo-mask #dm-fab，固定在功能膠囊正下方）會浮在頁頂帶右側：
   桌機時頁頂帶右邊讓出它的寬度，避免壓到帶內右側的連結與按鈕 */
@media (min-width: 641px) {
  .cj-band { padding-right: 172px; }
  .cj-hero { padding-right: 172px; }
}

/* ---- 插圖空狀態 ----
   CJ.empty({art:'em-no-clients', title:'…', text:'…', actions:'<button…>'}) 會產生： */
.cj-empty { text-align: center; padding: 28px 16px 32px; color: var(--cj-text-2); }
.cj-empty-art { display: block; margin: 0 auto 14px; width: min(260px, 70%); height: auto; aspect-ratio: 3 / 2; object-fit: contain; }
.cj-empty.sm .cj-empty-art { width: min(150px, 50%); margin-bottom: 8px; }
.cj-empty.lg .cj-empty-art { width: min(340px, 80%); }
.cj-empty-t { margin: 0 0 6px; font-size: 16px; font-weight: 800; color: var(--cj-text); }
.cj-empty.sm .cj-empty-t { font-size: 14px; }
.cj-empty-s { margin: 0 auto; max-width: 420px; font-size: 13.5px; line-height: 1.65; }
.cj-empty-act { margin-top: 14px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---- 圖示（取代 emoji） ---- */
.cj-ic { display: inline-block; width: 20px; height: 20px; vertical-align: -4px; object-fit: contain; flex: 0 0 auto; }
.cj-ic.s16 { width: 16px; height: 16px; vertical-align: -3px; }
.cj-ic.s24 { width: 24px; height: 24px; vertical-align: -6px; }
.cj-ic.s32 { width: 32px; height: 32px; }
.cj-ic.s40 { width: 40px; height: 40px; }
.cj-ic.s48 { width: 48px; height: 48px; }
/* 圖示底座：深色模式下把深藍線條圖示墊在淺圓上，避免看不見 */
.cj-icb { display: inline-flex; align-items: center; justify-content: center; border-radius: 12px;
  background: var(--cj-ivory); border: 1px solid var(--cj-line-2); flex: 0 0 auto; }
.cj-icb > .cj-ic { width: 62%; height: 62%; vertical-align: 0; }
.cj-icb.s32 { width: 32px; height: 32px; border-radius: 9px; }
.cj-icb.s40 { width: 40px; height: 40px; }
.cj-icb.s48 { width: 48px; height: 48px; border-radius: 14px; }
.cj-icb.s56 { width: 56px; height: 56px; border-radius: 16px; }
html[data-rex-theme="dark"] .cj-icb { background: #f1ece1; border-color: transparent; }

/* ---- 卡片／區塊（頁面可直接用，或把自己的 .sec/.card 指到這些 token） ---- */
.cj-card { background: var(--cj-surface); border: 1px solid var(--cj-line); border-radius: var(--cj-r); box-shadow: var(--cj-shadow); }
.cj-sec-t { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 16px; font-weight: 800; color: var(--cj-text); }
.cj-sec-t .cj-sub { font-size: 12.5px; font-weight: 500; color: var(--cj-text-3); }
.cj-gold-rule { height: 2px; border: 0; margin: 0; background: linear-gradient(90deg, var(--cj-gold), rgba(232, 189, 118, 0)); }

/* ---- 按鈕（給頁面對齊用） ---- */
.cj-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--cj-line); background: var(--cj-surface); color: var(--cj-text);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none; }
.cj-btn:hover { border-color: var(--cj-acc); color: var(--cj-acc); }
.cj-btn.pri { background: var(--cj-acc); border-color: var(--cj-acc); color: var(--cj-acc-ink); }
.cj-btn.pri:hover { background: var(--cj-acc-hover); color: var(--cj-acc-ink); }
.cj-btn.gold { background: var(--cj-gold); border-color: var(--cj-gold); color: var(--cj-navy); }

/* ---- 載入中插圖 ---- */
.cj-loading { text-align: center; padding: 28px 16px; color: var(--cj-text-2); font-size: 13.5px; }
.cj-loading .cj-empty-art { width: min(180px, 55%); animation: cjFloat 2.4s ease-in-out infinite; }
@keyframes cjFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .cj-loading .cj-empty-art { animation: none; } }

/* ---- 列印抬頭（健診／建議書）：<img class="cj-print-head" src="/assets/cj/print-checkup.webp" alt=""> ---- */
.cj-print-head { display: none; width: 100%; height: auto; max-height: 34mm; object-fit: cover; object-position: right center; border-radius: 6px; }
@media print {
  .cj-print-head { display: block; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cj-hero, .cj-band { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cj-noprint { display: none !important; }
  html.cj, html.cj body { background: #fff !important; }   /* 列印一律白紙，不印象牙白頁底 */
}

/* ---- 手機 ---- */
@media (max-width: 640px) {
  .cj-hero { padding: 20px 18px 112px; min-height: 0; align-items: flex-start; border-radius: 16px; }
  .cj-hero-art { inset: auto 0 0 0; width: 100%; height: 120px; object-position: 70% center; }
  .cj-hero::after { background: linear-gradient(180deg, var(--cj-navy) 0%, rgba(10, 35, 52, .9) 45%, rgba(10, 35, 52, .15) 100%); }
  .cj-hero h1, .cj-hero .cj-hero-t { font-size: 20px; }
  .cj-band { padding: 14px 16px; border-radius: 14px; }
  .cj-band h1, .cj-band .cj-band-t { font-size: 17px; }
  .cj-empty-art { width: min(220px, 72%); }
}
