/* AI 房地產助手（ai.html）—— 對照 Android activity_deepseek_search.xml
   顏色／尺寸逐項由 app 抄：頂欄 logo_blue #0056B3、chat 背景 #F5F6F7、
   右邊氣泡 #9EDCEF（bg_chat_right）、圓角 8（右下 0）、內文 12sp、時間 10sp #999999。 */

.ai-page { background: #F5F6F7; display: flex; flex-direction: column; min-height: 100vh; }

.ai-header { padding-right: 4px; }
.ai-export { background: none; border: 0; padding: 6px 8px; cursor: pointer; display: flex; align-items: center; }
.ai-export svg { width: 22px; height: 22px; display: block; }

/* 每日額度：tvQuota 10sp，喺頂欄下面一行 */
.ai-quota {
  font-size: 10px; color: #666666; background: #fff;
  padding: 4px 12px; border-bottom: 1px solid var(--divider, #E5E5E5);
}

/* 對話區 */
.ai-chat { flex: 1; overflow-y: auto; padding: 8px 0 12px; display: flex; flex-direction: column; gap: 10px; }

.ai-row { display: flex; padding: 0 8px; }
.ai-row.user { justify-content: flex-end; }

.ai-bubble {
  max-width: 84%; background: #fff; border-radius: 8px 8px 8px 0;
  padding: 10px 12px; font-size: 12px; line-height: 1.7; color: #111;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); word-break: break-word;
}
.ai-row.user .ai-bubble {
  background: #9EDCEF; border-radius: 8px 8px 0 8px; color: #111;
}
.ai-who { font-size: 12px; color: var(--brand-blue, #0056B3); margin-bottom: 4px; }
.ai-time { font-size: 10px; color: #999999; margin-top: 4px; text-align: right; }
.ai-row.user .ai-time { color: #666; }

/* AI 答案入面嘅 markdown：粗體／表格／引用 */
.ai-bubble p { margin: 0 0 6px; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble strong { font-weight: 700; }
.ai-bubble table { border-collapse: collapse; width: 100%; margin: 6px 0; font-size: 11.5px; }
.ai-bubble th, .ai-bubble td { border: 1px solid #E0E0E0; padding: 4px 6px; text-align: left; vertical-align: top; }
.ai-bubble th { background: #F2F6FB; font-weight: 700; white-space: nowrap; }
.ai-bubble p.ai-foot { font-size: 10.5px; color: #8A94A6; margin-top: 3px; }
.ai-bubble blockquote { margin: 6px 0 0; padding: 6px 10px; background: #FFF7E8; border-left: 3px solid var(--brand-orange, #FF8000); color: #6b4a00; font-size: 11.5px; }

/* 樓盤卡片（item_chat_property_card.xml：卡闊 220dp、相高 140dp、圓角 8、內文 padding 8） */
.ai-cards { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.ai-card {
  width: 220px; max-width: 100%; background: #fff; border: 1px solid #E5E5E5; border-radius: 8px;
  overflow: hidden; text-decoration: none; color: inherit; display: block;
}
.ai-card-img { width: 100%; height: 140px; background: #EEF1F4; object-fit: cover; display: block; position: relative; }
.ai-card-img img { width: 100%; height: 140px; object-fit: cover; display: block; }
.ai-card-count {
  position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.55); color: #fff;
  font-size: 10px; padding: 2px 8px; border-radius: 10px;
}
.ai-card-body { padding: 8px; }
.ai-card-name { font-size: 16px; font-weight: 700; color: #000; }
.ai-card-detail { font-size: 12px; color: #666666; margin-top: 2px; }
.ai-card-line { display: flex; justify-content: space-between; font-size: 12px; color: #666666; margin-top: 2px; }
.ai-card-price { font-size: 16px; font-weight: 700; color: var(--brand-orange, #FF8000); margin-top: 6px; }

/* 查詢項目 chips（activity_deepseek_search chipGroupKeywords：11sp、白底） */
.ai-chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px; background: #fff;
  border-top: 1px solid #E5E5E5; scrollbar-width: none;
}
.ai-chips::-webkit-scrollbar { display: none; }
.ai-chip {
  flex: none; font-size: 11px; padding: 6px 12px; border-radius: 16px;
  border: 1px solid #DDDDDD; background: #fff; color: #444; cursor: pointer;
}
.ai-chip[aria-pressed="true"] {
  border-color: var(--brand-blue, #0056B3); color: var(--brand-blue, #0056B3);
  background: #EBF2FA; font-weight: 700;
}

/* 輸入列（bg_chat_input 圓角；輸入字 13sp；送出 = paper plane） */
.ai-input {
  position: relative; display: flex; align-items: center; gap: 6px;
  background: #fff; padding: 8px 10px 10px; border-top: 1px solid #E5E5E5;
}
.ai-input input {
  flex: 1; height: 38px; border: 1px solid #DDDDDD; border-radius: 19px;
  padding: 0 14px; font-size: 13px; color: #111; background: #fff; outline: none;
}
.ai-input input:focus { border-color: var(--brand-blue, #0056B3); }
.ai-send {
  width: 38px; height: 38px; border: 0; background: none; color: var(--brand-blue, #0056B3);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.ai-send svg { width: 22px; height: 22px; }
.ai-send:disabled { color: #B9C2CC; cursor: default; }

/* 屋苑建議清單（同 app EstateSearchDropdown 一樣：撳一行即刻填入） */
.ai-suggest {
  position: absolute; left: 10px; right: 10px; bottom: 56px; max-height: 260px; overflow-y: auto;
  background: #fff; border: 1px solid #E0E0E0; border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,.16); z-index: 20;
}
.ai-suggest-row { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #F0F0F0; }
.ai-suggest-row:last-child { border-bottom: 0; }
.ai-suggest-row:hover { background: #F5F8FC; }
.ai-suggest-name { font-size: 16px; color: #111; }
.ai-suggest-name b { color: var(--brand-blue, #0056B3); }
.ai-suggest-sub { font-size: 12px; color: #999999; margin-top: 1px; }

.ai-empty { text-align: center; color: #999; font-size: 12px; padding: 24px 0; }

/* 桌面：唔好拉到成個螢幕闊 */
@media (min-width: 720px) {
  .ai-page { max-width: 720px; margin: 0 auto; min-height: 100vh; box-shadow: 0 0 24px rgba(0,0,0,.06); }
  .ai-input { position: sticky; bottom: 0; }
  .ai-page { height: 100vh; min-height: 0; }
}

/* AI 表格（10 行成交表喺 430px 手機）—— 太窄就容許橫向捲，唔好夾到每格斷行 */
.ai-bubble .tbl { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 6px 0; }
.ai-bubble .tbl table { min-width: 420px; margin: 0; }

/* ==========================================================================
   桌面寬版（≥961px，2026-11-22 Alan「用盡屏幕、唔好置中」規則）
   手機 ≤960px 完全唔變：仍然係 720px 單欄、chips 橫向一行、輸入框貼底。
   桌面：聊天區食盡左邊（上限 920px 保持易讀），查詢項目 chips 變右邊直向欄。
   ========================================================================== */
@media (min-width: 961px) {
  .ai-page {
    max-width: none;
    margin: 0;
    height: 100vh;
    min-height: 0;
    padding: 0 24px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "hdr hdr"
      "quota chips"
      "chat chips"
      "input chips";
    column-gap: 28px;
  }
  .ai-header { grid-area: hdr; margin: 0 -24px; }
  .ai-quota { grid-area: quota; margin: 10px 0 0; }
  .ai-chat { grid-area: chat; max-width: 920px; padding: 12px 0 16px; }
  .ai-input { grid-area: input; max-width: 920px; margin: 0 0 20px; }

  /* 右欄：查詢項目變直向清單（原本貼底橫掃，桌面用唔到） */
  .ai-chips {
    grid-area: chips;
    flex-direction: column;
    align-items: stretch;
    overflow: visible;
    padding: 16px 0 24px;
    gap: 8px;
    border-top: 0;
  }
  .ai-chips::before {
    content: "查詢項目";
    display: block;
    margin-bottom: 2px;
    font-size: 12px;
    letter-spacing: .4px;
    color: #8A94A0;
  }
  .ai-chip {
    width: 100%;
    height: 44px;
    justify-content: flex-start;
    padding: 0 14px;
    border-radius: 10px;
    text-align: left;
    font-size: 14px;
  }
  .ai-bubble { max-width: 88%; }
}

/* ---------------- 屋苑價格分析卡（AI 助手；數字由 estate-analysis.js 直出） ---------------- */
.ai-bubble-wide { max-width: 100% !important; width: 100%; }
.ai-an {
  margin-top: 8px;
  background: #fff;
  border: 1px solid #E1E6ED;
  border-radius: 10px;
  padding: 10px 10px 8px;
}
.ai-an-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ai-an-head b { font-size: 14px; color: #111; }
.ai-an-head span { font-size: 11px; color: #6B7686; }
.ai-an-chart { display: block; width: 100%; height: auto; margin: 6px 0 0; }
.ai-an-legend { display: flex; gap: 14px; margin-top: 2px; font-size: 10.5px; color: #6B7686; }
.ai-an-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: 1px; }
.ai-an-legend i.b { background: rgba(0, 86, 179, .75); }
.ai-an-legend i.l { background: #FF8000; border-radius: 50%; }
.ai-an-kv {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 8px;
  padding: 6px 0;
  border-top: 1px solid #F0F2F5;
  font-size: 12px;
  color: #4A5464;
}
.ai-an-kv:first-of-type { border-top: 0; }
.ai-an-kv b { font-size: 14px; color: #0056B3; }
.ai-an-kv i { grid-column: 1 / -1; font-style: normal; font-size: 11px; color: #8A94A6; }
.ai-an-sub { margin: 8px 0 4px; font-size: 12px; font-weight: 700; color: #111; }
.ai-an-note { margin: 8px 0 2px; font-size: 11.5px; line-height: 1.5; color: #6B7686; }
.ai-an-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  padding: 7px 8px;
  margin-top: 6px;
  border: 1px solid #EDEFF3;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  background: #FBFCFE;
}
.ai-an-row:active { background: #F2F6FB; }
.ai-an-row-main { flex: 1 1 55%; min-width: 0; display: flex; flex-direction: column; }
.ai-an-row-main b { font-size: 13px; color: #111; }
.ai-an-row-main i { font-style: normal; font-size: 11px; color: #7A8595; }
.ai-an-row-right { flex: 0 0 auto; text-align: right; display: flex; flex-direction: column; }
.ai-an-row-right b { font-size: 13px; color: #111; }
.ai-an-row-right i { font-style: normal; font-size: 11px; color: #E06D00; }
.ai-an-tag {
  flex: 0 0 100%;
  display: inline-block;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  color: #0F8A4D;
  background: #E8F6EE;
  border-radius: 999px;
  padding: 2px 8px;
}
.ai-an-tag.warn { color: #B26A00; background: #FFF4E0; }
.ai-an-foot { margin-top: 8px; font-size: 10.5px; line-height: 1.5; color: #8A94A6; }
.ai-an-foot a { color: #0056B3; text-decoration: none; white-space: nowrap; }

@media (min-width: 961px) {
  /* 桌面氣泡闊，圖表要封頂，否則 340×132 的 viewBox 會被拉到 900px 闊、字變大、比例過扁 */
  .ai-an-chart { max-width: 620px; }
}

/* 2026-11-24 Alan：「bold and highlight key figure and %」——重點數字用色底 pill，
   百分比（荀盤標籤）加粗加大，價錢用 800 字重。 */
.ai-an-kv b.hl {
  font-size: 15px;
  font-weight: 800;
  color: #00468F;
  background: #EAF2FB;
  border-radius: 6px;
  padding: 1px 7px;
}
.ai-an-kv b.hl-g {
  font-size: 15px;
  font-weight: 800;
  color: #0B7A44;
  background: #E8F6EE;
  border-radius: 6px;
  padding: 1px 7px;
}
.ai-an-tag { font-size: 12px; font-weight: 800; }
.ai-an-row-right b { font-size: 14px; font-weight: 800; }
.ai-an-row-right i { font-weight: 700; }

/* ---------------- 會員限定閘（2026-11-30）----------------
   Alan：AI 助手只限已註冊會員使用。未登入者見鎖卡，唔會見到輸入框／對話。 */
.ai-gate { display: none; }
body.ai-locked .ai-gate { display: block; }
body.ai-locked .ai-chat,
body.ai-locked .ai-chips,
body.ai-locked .ai-input,
body.ai-locked .ai-quota,
body.ai-locked .ai-export { display: none !important; }

.ai-gate-card {
  margin: 28px 16px 0;
  background: #fff;
  border: 1px solid var(--divider, #E5E5E5);
  border-radius: 16px;
  padding: 28px 22px 24px;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 86, 179, .08);
}
.ai-gate-ico {
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 50%; background: #EBF2FA;
  display: flex; align-items: center; justify-content: center;
}
.ai-gate-ico svg { width: 32px; height: 32px; }
.ai-gate-card h2 {
  font-size: 18px; font-weight: 700; color: var(--text-primary, #111); margin: 0 0 8px;
}
.ai-gate-card p {
  font-size: 13.5px; line-height: 1.7; color: var(--text-secondary, #666); margin: 0 0 18px;
}
.ai-gate-btns { display: flex; gap: 10px; }
.ai-gate-btns a {
  flex: 1; height: 44px; line-height: 44px; border-radius: 10px;
  font-size: 15px; font-weight: 700; text-decoration: none;
}
.ai-gate-btns .btn-login { background: var(--brand-blue, #0056B3); color: #fff; }
.ai-gate-btns .btn-signup {
  background: #fff; color: var(--brand-blue, #0056B3);
  border: 1px solid var(--brand-blue, #0056B3);
}
.ai-gate-note {
  margin: 14px 0 0 !important; font-size: 12px !important; color: var(--text-secondary, #999) !important;
}
@media (min-width: 720px) {
  .ai-gate-card { max-width: 440px; margin: 48px auto 0; }
}

/* ---- AI 追問建議（Alan 2026-12-02；跟 HomeDash「你可能想問」，內容由本地數據砌） ---- */
.ai-bubble-wide { max-width: 100%; }
.fd-follow { margin: 0; }
.fd-follow-t { font-size: 12px; color: #5a6a85; margin: 0 0 6px; letter-spacing: .02em; }
.fd-follow-list { display: flex; flex-direction: column; gap: 8px; }
.fd-follow-btn {
  display: flex; align-items: flex-start; gap: 8px; width: 100%;
  text-align: left; background: #f7fbff; border: 1px solid #e3e9f1; color: #00002a;
  border-radius: 12px; padding: 11px 13px; font-size: 13px; line-height: 1.5;
  cursor: pointer; font-family: inherit; transition: background .15s, border-color .15s;
}
.fd-follow-btn:hover { background: #eaf1f8; border-color: #c9d9ea; }
.fd-follow-btn:disabled { opacity: .55; cursor: default; }
.fd-follow-btn.picked { background: var(--brand-blue, #0056B3); border-color: var(--brand-blue, #0056B3); color: #fff; }
.fd-follow-btn > span:first-child { flex: 1 1 auto; min-width: 0; }
.fd-follow-go { margin-left: auto; color: var(--brand-blue, #0056B3); font-weight: 700; flex: none; }
.fd-follow-btn.picked .fd-follow-go { color: #fff; }

/* 版本印記（Alan 2026-12-02：報「冇變」時一眼分到新舊版；純診斷，唔影響閱讀） */
.ai-header .ai-build { font-size: 10px; color: rgba(255,255,255,.72); letter-spacing: .05em; margin-right: 6px; align-self: center; }

/* ---- 樓盤卡（HomeDash 版式，2026-12-02）--------------------------------- */
.hd-sec { font-size: 15px; font-weight: 700; color: #00005a; margin: 2px 0 2px; }
.hd-cards { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 10px; }
@media (min-width: 720px) { .hd-cards { grid-template-columns: 1fr 1fr; gap: 12px; } }
.hd-card { display: flex; flex-direction: column; background: #fff; border: 1px solid #dfdfe4; border-radius: 12px; overflow: hidden; text-decoration: none; color: inherit; transition: box-shadow .15s; }
.hd-card:hover { box-shadow: 0 6px 20px -6px rgba(0,0,90,.16); }
.hd-reason { background: #f7fbff; border-bottom: 1px solid #e7ecf3; padding: 8px 11px 7px; }
.hd-reason-h { font-size: 11px; font-weight: 700; color: #00005a; margin-bottom: 2px; }
.hd-reason p { margin: 0; font-size: 12.5px; line-height: 1.5; color: #00002a; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.hd-prov { margin-top: 5px; padding-top: 4px; border-top: 1px solid #e3e9f1; font-size: 10px; color: #5a6a85; }
.hd-photo { position: relative; aspect-ratio: 4 / 3; background: #eaf1f8; }
.hd-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hd-tag { position: absolute; right: 8px; top: 8px; background: #ffb102; color: #fff; font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.hd-count { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,42,.55); color: #fff; font-size: 10px; padding: 2px 8px; border-radius: 999px; }
.hd-badge { position: absolute; left: 8px; top: 8px; font-size: 11px; font-weight: 600; color: #fff; background: #22c55e; padding: 2px 9px; border-radius: 999px; box-shadow: 0 2px 8px -2px rgba(0,0,40,.25); }
.hd-badge.owner { background: var(--brand-blue, #0056B3); }
.hd-body { padding: 10px 12px 12px; }
.hd-name { font-size: 15px; font-weight: 600; color: #00002a; line-height: 1.3; }
.hd-meta { font-size: 12.5px; color: #40405f; margin-top: 2px; }
.hd-price { font-size: 17px; font-weight: 700; color: #00002a; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hd-price span { font-size: 12px; font-weight: 400; color: #808094; }

.hd-more { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--brand-blue, #0056B3); text-decoration: none; }
.hd-more:hover { text-decoration: underline; }
.hd-note { margin-top: 8px; font-size: 11.5px; color: #808094; }
