{% extends "ewoooc_base.html" %}

{% block title %}市場情報｜EwoooC{% endblock %}

{% block extra_css %}
<style>
  .market-intel-page {
    display: grid;
    gap: 1rem;
    min-width: 0;
  }

  .market-intel-hero,
  .market-intel-panel {
    background:
      radial-gradient(circle at 1px 1px, rgba(120, 83, 44, 0.14) 1px, transparent 1.35px),
      var(--momo-bg-paper, #faf7f0);
    background-size: 10px 10px, auto;
    border: 1px solid var(--momo-border, #d8c8aa);
    border-radius: 8px;
    box-shadow: var(--momo-shadow-sm, 0 8px 18px rgba(72, 49, 28, 0.08));
    min-width: 0;
  }

  .market-intel-hero {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: clamp(1rem, 2vw, 1.35rem);
  }

  .market-intel-kicker,
  .market-intel-label {
    color: var(--momo-accent, #a76a2d);
    font-family: var(--momo-font-mono, "JetBrains Mono", monospace);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0;
    text-transform: uppercase;
  }

  .market-intel-title {
    color: var(--momo-text-title, #2a2520);
    font-family: var(--momo-font-display, "Noto Sans TC", sans-serif);
    font-size: clamp(1.45rem, 3vw, 2rem);
    font-weight: 900;
    letter-spacing: 0;
    line-height: 1.15;
    margin: 0.35rem 0 0;
  }

  .market-intel-copy {
    color: var(--momo-text-muted, #756a5b);
    line-height: 1.65;
    margin: 0.6rem 0 0;
    max-width: 58rem;
  }

  .market-intel-status-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
    min-width: 0;
  }

  .market-intel-status-card {
    background: rgba(255, 250, 241, 0.82);
    border: 1px solid rgba(120, 83, 44, 0.16);
    border-left: 3px solid var(--momo-accent, #a76a2d);
    border-radius: 8px;
    min-width: 0;
    padding: 0.8rem 0.9rem;
  }

  .market-intel-status-card strong {
    color: var(--momo-text-title, #2a2520);
    display: block;
    font-family: var(--momo-font-mono, "JetBrains Mono", monospace);
    font-size: 1rem;
    margin-top: 0.25rem;
  }

  .market-intel-panel {
    padding: clamp(1rem, 2vw, 1.2rem);
  }

  .market-intel-flow {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    margin-top: 0.9rem;
    min-width: 0;
  }

  .market-intel-flow-item {
    background: rgba(255, 250, 241, 0.78);
    border: 1px solid rgba(120, 83, 44, 0.14);
    border-radius: 8px;
    min-width: 0;
    padding: 0.85rem;
  }

  .market-intel-flow-item h3 {
    color: var(--momo-text-title, #2a2520);
    font-size: 1rem;
    font-weight: 900;
    margin: 0;
  }

  .market-intel-flow-item p {
    color: var(--momo-text-muted, #756a5b);
    line-height: 1.55;
    margin: 0.45rem 0 0;
  }

  .market-intel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.9rem;
  }

  .market-intel-action {
    align-items: center;
    background: var(--momo-bg-paper, #faf7f0);
    border: 1px solid rgba(120, 83, 44, 0.22);
    border-radius: 8px;
    color: var(--momo-text-title, #2a2520);
    display: inline-flex;
    font-weight: 800;
    gap: 0.45rem;
    min-height: 2.35rem;
    padding: 0.45rem 0.7rem;
    text-decoration: none;
  }

  .market-intel-action:hover {
    background: rgba(201, 117, 45, 0.12);
    color: var(--momo-accent-dark, #8f4530);
  }

  @media (max-width: 640px) {
    .market-intel-hero {
      grid-template-columns: 1fr;
    }

  }
</style>

{% endblock %}

{% block ewooo_content %}
<section class="market-intel-page">
  <header class="market-intel-hero">
    <div>
      <p class="market-intel-kicker">市場情報</p>
      <h1 class="market-intel-title">市場情報入口</h1>
      <p class="market-intel-copy">
        市場情報尚未進入正式決策；先用比價覆核、PChome 商品監控與 AI 觀測台守住商品判斷。
      </p>
    </div>
  </header>

  <section class="market-intel-panel" aria-labelledby="market-intel-status-title">
    <p class="market-intel-label">資料狀態</p>
    <h2 id="market-intel-status-title" class="market-intel-title">資料狀態</h2>
    <div class="market-intel-status-grid">
      <div class="market-intel-status-card">
        <span class="market-intel-label">情報入口</span>
        <strong>{{ '已啟用' if status.enabled else '未啟用' }}</strong>
      </div>
      <div class="market-intel-status-card">
        <span class="market-intel-label">資料擷取</span>
        <strong>{{ '已啟用' if status.crawler_enabled else '未啟用' }}</strong>
      </div>
      <div class="market-intel-status-card">
        <span class="market-intel-label">寫入</span>
        <strong>{{ '已啟用' if status.write_enabled else '未啟用' }}</strong>
      </div>
      <div class="market-intel-status-card">
        <span class="market-intel-label">排程</span>
        <strong>{{ '已啟用' if status.scheduler_attached else '未啟用' }}</strong>
      </div>
      <div class="market-intel-status-card">
        <span class="market-intel-label">來源規格</span>
        <strong>{{ adapter_count|default(0) }}</strong>
      </div>
      <div class="market-intel-status-card">
        <span class="market-intel-label">手動整理</span>
        <strong>{{ '已啟用' if manual_fetch_allowed|default(false) else '未啟用' }}</strong>
      </div>
    </div>
  </section>

  <section class="market-intel-panel" aria-labelledby="market-intel-flow-title">
    <p class="market-intel-label">操作入口</p>
    <h2 id="market-intel-flow-title" class="market-intel-title">正式操作入口</h2>
    <div class="market-intel-flow">
      <article class="market-intel-flow-item">
        <h3>PChome 比價覆核</h3>
        <p>先處理候選同款、單位價與低信心候選。</p>
      </article>
      <article class="market-intel-flow-item">
        <h3>PChome 商品監控</h3>
        <p>先檢查搜尋、候選取得與資料新鮮度。</p>
      </article>
      <article class="market-intel-flow-item">
        <h3>AI 觀測台</h3>
        <p>監看 AI 呼叫、主機健康、RAG 命中與 PPT 產線。</p>
      </article>
    </div>
    <div class="market-intel-actions">
      <a class="market-intel-action" href="/?filter=pchome_review&review_status=all&sort_by=pchome_review&order=desc">
        <i class="fas fa-scale-balanced" aria-hidden="true"></i>
        <span>比價覆核</span>
      </a>
      <a class="market-intel-action" href="/pchome_crawler">
        <i class="fas fa-magnifying-glass-chart" aria-hidden="true"></i>
        <span>PChome 商品監控</span>
      </a>
      <a class="market-intel-action" href="/observability/overview">
        <i class="fas fa-satellite-dish" aria-hidden="true"></i>
        <span>AI 觀測台</span>
      </a>
    </div>
  </section>
</section>
{% endblock %}
