/* report.css — 智析港股 AI 數據解讀報告樣式（demo + 真 report 共用） */

body { background: var(--bg); color: var(--text); font-family: 'Noto Sans TC', 'IBM Plex Sans', sans-serif; margin: 0; }
    .report-wrap { max-width: 820px; margin: 0 auto; padding: 20px 16px 60px; }
    .back { display: inline-block; margin-bottom: 14px; font-size: 13px; color: var(--accent); text-decoration: none; }
    .back:hover { text-decoration: underline; }
    /* 樣本/報告可自由閱讀、複製、列印 */
    @media print { body { display: block !important; } }
    body { -webkit-user-select: text; user-select: text; }

    /* ===== PDF 分頁效果（A4 比例） ===== */
    .report-page {
      background: var(--card-bg);
      border: 1px solid var(--border);
      border-radius: 4px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.08);
      padding: 96px 96px 96px;
      margin: 0 auto 22px;
      position: relative;
      width: 100%;
      max-width: 793px;            /* A4 @96dpi 寬 */
      aspect-ratio: 210 / 297;     /* A4 高度比例 */
      page-break-after: always;
      display: flex;
      flex-direction: column;
      box-sizing: border-box;
    }
    /* 內容過長時唔好爆出頁面，靠 footer 撐住底部 */
    .report-page .page-body { flex: 1 1 auto; overflow: hidden; display: flex; flex-direction: column; }
    /* 水印（屏幕：淡色；列印：固定重複） */
    .report-page::after {
      content: "智析港股 · SAMPLE REPORT";
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: clamp(20px, 6vw, 56px);
      font-weight: 800;
      letter-spacing: 2px;
      color: var(--accent);
      opacity: 0.07;
      pointer-events: none;
      transform: rotate(-28deg);
      z-index: 10;      /* 水印放最上層，覆蓋內容 */
      white-space: nowrap;
      overflow: hidden;
      max-width: 100%;
      padding: 0 8px;
      box-sizing: border-box;
      text-align: center;
    }
    .report-page > * { position: relative; z-index: 1; }

    /* 收費／精裝版報告（report.html）：水印改用品牌 logo */
    #reportContent .report-page::after {
      content: "";
      background-image: url(/assets/images/logo-light.png);
      background-repeat: no-repeat;
      background-position: center;
      background-size: 70% auto;
      color: transparent;
      font-size: 0;
      letter-spacing: 0;
      padding: 0;
      opacity: 0.06;
    }
    [data-theme="dark"] #reportContent .report-page::after {
      background-image: url(/assets/images/logo-dark.png);
    }

    /* 封面頁 */
    .report-cover { justify-content: center; text-align: center; align-items: center; gap: 12px; padding-bottom: 170px; }
    .report-cover .tag { display: inline-block; background: rgba(59,130,196,0.15); color: var(--accent); border: 1px solid var(--accent); border-radius: 20px; padding: 4px 16px; font-size: clamp(11px, 1.5vw, 12px); font-weight: 600; }
    .report-cover h1 { font-size: clamp(22px, 4.5vw, 34px); margin: 10px 0 4px; }
    .report-cover .symbol { font-size: clamp(15px, 2.4vw, 18px); color: var(--muted); }
    .report-cover .meta { font-size: clamp(12px, 1.7vw, 13px); color: var(--muted); line-height: 2; margin-top: 20px; }
    /* 報告品牌 logo（雙主題） */
    .report-logo { display: inline-flex; align-items: center; justify-content: center; }
    .report-logo .logo-img { height: 26px; width: auto; display: block; }
    .report-logo .logo-img-dark { display: none; }
    [data-theme="dark"] .report-logo .logo-img-light { display: none; }
    [data-theme="dark"] .report-logo .logo-img-dark { display: block; }
    .report-cover .report-logo { margin-bottom: 4px; }
    /* 樣本報告版本說明（同免責一齊釘喺 footer 上方） */
    .report-cover .sample-tier-note {
      position: absolute;
      left: 96px;
      right: 96px;
      bottom: 148px;
      margin: 0 auto;
      max-width: 460px;
      background: rgba(59,130,196,0.08);
      border: 1px solid rgba(59,130,196,0.25);
      border-radius: 8px;
      padding: 10px 14px;
      font-size: clamp(10px, 1.4vw, 11px);
      color: var(--text-secondary);
      line-height: 1.6;
      text-align: center;
    }
    /* 免責固定喺頁底（footer 底線上），唔再隨置中排列浮動而重疊 footer */
    .report-cover .disclaimer-line {
      position: absolute;
      left: 96px;
      right: 96px;
      bottom: 96px;
      margin: 0;
      max-width: 460px;
      margin-left: auto;
      margin-right: auto;
      font-size: clamp(10px, 1.4vw, 11px);
      color: var(--muted);
      line-height: 1.6;
      text-align: center;
    }

    /* 數據過時提示（sync 空窗期服務舊報告） */
    .report-stale-banner {
      margin: 18px auto 0;
      max-width: 430px;
      background: rgba(214,124,6,0.10);
      border: 1px solid rgba(214,124,6,0.35);
      border-radius: 8px;
      padding: 10px 14px;
      font-size: clamp(11px, 1.5vw, 12.5px);
      color: var(--text-secondary);
      line-height: 1.7;
    }

    /* 目錄頁（14 節時要慳位，避免免責 note 頂到 footer） */
    .report-toc { justify-content: flex-start; }
    .report-toc h2 { margin-bottom: 18px; }
    .toc-list { list-style: none; padding: 0; margin: 0; }
    .toc-list li { display: flex; align-items: baseline; gap: 14px; padding: clamp(9px, 1.4vw, 13px) 0; border-bottom: 1px dashed var(--border); font-size: clamp(12.5px, 1.7vw, 14px); }
    .toc-list li:last-child { border-bottom: none; }
    .toc-no { flex: 0 0 26px; font-weight: 700; color: var(--accent); }
    .toc-title { font-weight: 500; }
    .toc-note { margin-top: 22px; font-size: clamp(10.5px, 1.5vw, 12px); color: var(--muted); line-height: 1.7; }

    /* 頁腳 + 頁碼（貼頁底） */
    .page-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 14px 0 0;
      border-top: 1px solid var(--border);
      font-size: clamp(10px, 1.4vw, 11px);
      color: var(--muted);
      position: absolute;
      left: 96px;
      right: 96px;
      bottom: clamp(16px, 4vw, 28px);
      margin-top: 0;
    }
    .page-num::before { content: attr(data-page) " · 共 " attr(data-total) " 頁"; }

    .report-page h2 { font-size: clamp(16px, 2.2vw, 19px); border-left: 4px solid var(--accent); padding-left: 12px; margin: 0 0 20px; }
    .report-page h3 { font-size: clamp(14px, 1.9vw, 15px); margin: 22px 0 10px; }
    .report-page p { line-height: 1.75; margin: 14px 0; font-size: clamp(13px, 1.8vw, 15px); }
    .obs { background: var(--hover-bg); border: 1px solid var(--border); border-radius: 10px; padding: clamp(12px, 2.5vw, 18px) clamp(14px, 3vw, 22px); margin: 18px 0; }
    .obs li { margin: 12px 0; line-height: 1.7; font-size: clamp(13px, 1.8vw, 15px); }
    table { width: 100%; border-collapse: collapse; font-size: clamp(12px, 1.7vw, 13.5px); margin: 16px 0; }
    /* 數字唔可以折行會令表格 min-content 闊過容器而溢出（右邊線出界），容許 cell 內任意折行 */
    th, td { border: 1px solid var(--border); padding: clamp(8px, 1.5vw, 12px) clamp(8px, 1.8vw, 14px); text-align: left; word-break: break-all; overflow-wrap: anywhere; }
    th { background: var(--hover-bg); font-weight: 600; }
    .num { text-align: right; font-variant-numeric: tabular-nums; }
    .value-box { display: flex; gap: 16px; flex-wrap: wrap; margin: 18px 0; }
    .value-box .v { flex: 1 1 170px; background: var(--hover-bg); border: 1px solid var(--border); border-radius: 8px; padding: clamp(12px, 2.2vw, 16px) clamp(14px, 2.5vw, 18px); }
    .value-box .v .k { font-size: clamp(10px, 1.4vw, 11px); color: var(--muted); }
    .value-box .v .val { font-size: clamp(16px, 2.3vw, 18px); font-weight: 700; margin-top: 6px; }

    /* Executive Summary（Premium/Enterprise） */
    .exec-summary {
      background: linear-gradient(135deg, rgba(74,144,217,0.10), rgba(74,144,217,0.03));
      border: 1px solid rgba(74,144,217,0.35);
      border-left: 5px solid #4a90d9;
      border-radius: 10px;
      padding: clamp(14px, 2.5vw, 20px) clamp(16px, 3vw, 22px);
      margin: 18px 0;
      line-height: 1.9;
      font-size: clamp(12.5px, 1.8vw, 14px);
    }
    .exec-title {
      font-size: clamp(11px, 1.6vw, 13px);
      font-weight: 700;
      letter-spacing: 1px;
      color: #4a90d9;
      margin-bottom: 10px;
      border-bottom: 1px dashed rgba(74,144,217,0.3);
      padding-bottom: 6px;
    }
    .exec-summary p { margin: 6px 0; }

    /* Key Takeaways（Enterprise） */
    .take-box {
      background: linear-gradient(135deg, rgba(123,92,201,0.10), rgba(123,92,201,0.03));
      border: 1px solid rgba(123,92,201,0.35);
      border-left: 5px solid #7a5cc9;
      border-radius: 10px;
      padding: clamp(14px, 2.5vw, 20px) clamp(16px, 3vw, 22px);
      margin: 18px 0;
    }
    .take-title {
      font-size: clamp(11px, 1.6vw, 13px);
      font-weight: 700;
      letter-spacing: 1px;
      color: #7a5cc9;
      margin-bottom: 10px;
      border-bottom: 1px dashed rgba(123,92,201,0.3);
      padding-bottom: 6px;
    }
    .take-item { font-size: clamp(12.5px, 1.8vw, 14px); line-height: 1.9; color: var(--text-secondary); }

    /* 結論結構化列表（支持/風險/追蹤指標 bullets） */
    #reportContent .page-body ul {
      margin: 8px 0 14px;
      padding-left: 22px;
    }
    #reportContent .page-body li {
      margin: 7px 0;
      line-height: 1.75;
      font-size: clamp(13px, 1.8vw, 14.5px);
    }
    #reportContent .page-body li::marker {
      color: var(--accent);
    }
    .report-page h3 { margin-top: 16px; }
    .warn { background: rgba(214,124,6,0.08); border: 1px solid rgba(214,124,6,0.3); border-radius: 8px; padding: clamp(12px, 2vw, 14px) clamp(14px, 2.2vw, 16px); font-size: clamp(12px, 1.6vw, 12.5px); color: var(--text-secondary); line-height: 1.7; margin: 18px 0; }
    .locked-box { border: 1px dashed var(--border); border-radius: 10px; padding: clamp(14px, 2.5vw, 20px) clamp(16px, 3vw, 22px); background: var(--hover-bg); margin: 18px 0; }
    .locked-box .blur { opacity: 0.55; filter: blur(3px); pointer-events: none; user-select: none; }
    .locked-box .blur li,
    .locked-box .blur p,
    .locked-box .blur .value-box { max-width: 100%; overflow: hidden; }
    .locked-box .blur li { white-space: nowrap; text-overflow: clip; }
    .locked-note { font-size: clamp(11px, 1.6vw, 12.5px); color: var(--muted); margin: 14px 0 0; }
    .locked-note strong { color: var(--accent); }


    @media print {
      /* 強制打印 CSS 背景色（Heatmap 顏色），不受瀏覽器「背景圖形」選項影響 */
      * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
      /* A4 完美對齊：關閉瀏覽器預設打印邊距，頁面精確 210×297mm，同網站顯示一致 */
      @page { size: A4; margin: 0; }
      body { margin: 0; }
      /* container 嘅 bottom padding 會溢出落最後一頁之後，造成空白頁（要用足 specificity 壓過 learn/style.css 嘅 body.room .container） */
      body.room .container { padding: 0 !important; max-width: none !important; }
      #reportWrap { padding: 0; }
      #reportStatus { display: none !important; }
      .report-wrap { max-width: none; padding: 0; }
      .report-page {
        width: 210mm;
        height: 297mm;
        max-width: none;
        margin: 0;
        page-break-after: always;
      }
      #reportContent .page-body { overflow: visible; display: block; }
      /* 最後一頁之後唔好再強制斷頁，避免多出一張空白頁（footer 頁數先啱） */
      .report-page:last-child { page-break-after: auto; break-after: auto; }
    }

    @media (max-width: 600px) {
      .report-page {
        padding: 24px 16px 22px;
        aspect-ratio: auto !important;  /* 手機上唔用 A4 固定高度，隨內容增長 */
        min-height: 0;
        max-width: 100%;
        height: auto !important;        /* 確保高度由內容決定，唔截斷 */
        display: block !important;      /* 手機上用普通 block，高度由內容決定 */
      }
      .report-page .page-body { overflow: visible; display: block; }
      .value-box { gap: 10px; }
      .value-box .v { flex: 1 1 100%; }
    }

/* ===== 精裝版報告（quick）：fact-sheet 緊湊 A4 排版 ===== */
#reportContent.quick-report .report-page {
  padding: 44px 50px 46px;
}
#reportContent.quick-report .page-body {
  font-size: 13px;
  line-height: 1.6;
  gap: 4px;
}
#reportContent.quick-report .page-body h2 {
  font-size: 14.5px;
  margin: 12px 0 6px;
}
#reportContent.quick-report .page-body p {
  font-size: 12.5px;
  line-height: 1.55;
  margin: 3px 0;
}
#reportContent.quick-report .page-body table {
  font-size: 12px;
}

/* 精裝版：跟 site var() token（日/夜自動），teal 做 accent */
#reportContent.quick-report .report-page {
  background: var(--card-bg);
  color: var(--text-secondary);
}
#reportContent.quick-report .page-body h2 {
  color: var(--text);
  border-left: 3px solid #0b6e6a;
  background: transparent;
}
#reportContent.quick-report .page-body a { color: var(--blue); }

/* 夜間：淨係 4 個 section 標題變深灰卡（頁底保持 theme） */
[data-theme="dark"] #reportContent.quick-report .page-body h2 {
  background: #262c36;
  border-radius: 6px;
  padding: 5px 10px;
}
