// Sub-sidebar (right side panel) — contextual content per active main section
// Provides quick actions, stats, recent items, and helpers relevant to each module.

function SubSidebar({ active, lang, onJumpTo, collapsed, onToggleCollapse }) {
  const T = (th, en) => lang === "th" ? th : en;

  // Find active nav item for title
  const navItem = (typeof NAV !== 'undefined') ? NAV.find(n => n.id === active) : null;
  const sectionTitle = navItem ? (lang === 'th' ? navItem.th : navItem.en) : '';

  // Map each active main section to its sub-content component
  const Content = {
    architecture: ArchSub,
    dashboard:    DashboardSub,
    boq:          BOQSub,
    contracts:    ContractsSub,
    procurement:  ProcurementSub,
    billing:      BillingSub,
    progress:     ProgressSub,
    inventory:    InventorySub,
    subcontractor: SubconSub,
    drawings:     DrawingsSub,
  }[active] || ArchSub;

  if (collapsed) {
    // Collapsed: thin vertical strip with expand button
    return (
      <aside style={{
        position: "sticky", top: 0,
        height: "100vh",
        background: "var(--glass)",
        borderLeft: "1px solid var(--line)",
        backdropFilter: "blur(24px) saturate(140%)",
        WebkitBackdropFilter: "blur(24px) saturate(140%)",
        padding: "12px 6px",
        display: "flex", flexDirection: "column", alignItems: "center", gap: 8,
        zIndex: 20,
      }}>
        <button onClick={onToggleCollapse} className="btn btn-ghost btn-sm"
          title={T("ขยายแถบขวา", "Expand")}
          style={{ width: 36, justifyContent: "center", padding: 0 }}>
          <I.chev dir="left" />
        </button>
        <div style={{
          writingMode: "vertical-rl", transform: "rotate(180deg)",
          fontSize: 11, fontWeight: 600, color: "var(--ink-soft)",
          letterSpacing: "0.1em", marginTop: 12, fontFamily: "var(--font-display)",
        }}>
          {sectionTitle}
        </div>
      </aside>
    );
  }

  return (
    <aside style={{
      position: "sticky", top: 0,
      height: "100vh", overflowY: "auto",
      background: "var(--glass)",
      borderLeft: "1px solid var(--line)",
      backdropFilter: "blur(24px) saturate(140%)",
      WebkitBackdropFilter: "blur(24px) saturate(140%)",
      padding: "16px 14px",
      display: "flex", flexDirection: "column", gap: 14,
      zIndex: 20,
    }}>
      {/* Header with collapse button */}
      <div style={{
        display: "flex", alignItems: "center", gap: 8,
        paddingBottom: 10, borderBottom: "1px solid var(--line)",
      }}>
        <div style={{ flex: 1, minWidth: 0 }}>
          <div style={{ fontSize: 9.5, color: "var(--ink-mute)", letterSpacing: "0.1em", textTransform: "uppercase", fontWeight: 600 }}>
            {T("รายละเอียด", "Details")}
          </div>
          <div style={{ fontSize: 13, fontWeight: 700, fontFamily: "var(--font-display)", color: "var(--ink)",
                         overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
            {sectionTitle}
          </div>
        </div>
        <button onClick={onToggleCollapse} className="btn btn-ghost btn-sm"
          title={T("หุบแถบขวา", "Collapse")}
          style={{ width: 30, justifyContent: "center", padding: 0, flexShrink: 0 }}>
          <I.chev dir="right" />
        </button>
      </div>

      <Content lang={lang} T={T} onJumpTo={onJumpTo} />
    </aside>
  );
}

// ── Reusable sub-sidebar primitives ──────────────────────────
function SubSection({ title, children, action }) {
  return (
    <div>
      <div style={{
        display: "flex", alignItems: "center", justifyContent: "space-between",
        marginBottom: 8, paddingBottom: 6, borderBottom: "1px solid var(--line)",
      }}>
        <div style={{ fontSize: 10.5, color: "var(--ink-mute)", letterSpacing: "0.1em",
                       textTransform: "uppercase", fontWeight: 700 }}>{title}</div>
        {action}
      </div>
      <div style={{ display: "flex", flexDirection: "column", gap: 6 }}>{children}</div>
    </div>
  );
}

function SubItem({ icon, label, value, color, onClick, sub }) {
  return (
    <div onClick={onClick}
      style={{
        display: "flex", alignItems: "center", gap: 8,
        padding: "8px 10px",
        background: "var(--glass-2)",
        border: "1px solid var(--line)",
        borderRadius: 8,
        cursor: onClick ? "pointer" : "default",
        transition: "all .15s",
      }}
      onMouseEnter={(e) => onClick && (e.currentTarget.style.background = "var(--glass-3)")}
      onMouseLeave={(e) => onClick && (e.currentTarget.style.background = "var(--glass-2)")}>
      {icon && <span style={{ fontSize: 16, lineHeight: 1, color: color || "var(--syk-blue-soft)" }}>{icon}</span>}
      <div style={{ flex: 1, minWidth: 0 }}>
        <div style={{ fontSize: 11.5, fontWeight: 500, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>{label}</div>
        {sub && <div style={{ fontSize: 10, color: "var(--ink-mute)", marginTop: 1 }}>{sub}</div>}
      </div>
      {value != null && (
        <span style={{ fontSize: 11, fontWeight: 700, fontFamily: "var(--font-mono)", color: color || "var(--ink)" }}>{value}</span>
      )}
    </div>
  );
}

function SubStat({ label, value, accent, hint }) {
  return (
    <div style={{
      padding: "10px 12px",
      background: `linear-gradient(135deg, ${accent || 'rgba(40,72,255,0.08)'}, transparent)`,
      border: "1px solid var(--line)",
      borderRadius: 10,
    }}>
      <div style={{ fontSize: 10, color: "var(--ink-mute)", letterSpacing: "0.06em", textTransform: "uppercase" }}>{label}</div>
      <div style={{ fontSize: 20, fontWeight: 700, fontFamily: "var(--font-display)", marginTop: 4,
                     color: accent ? "var(--ink)" : "var(--ink)", letterSpacing: "-0.01em" }}>{value}</div>
      {hint && <div style={{ fontSize: 10, color: "var(--ink-mute)", marginTop: 2 }}>{hint}</div>}
    </div>
  );
}

function SubButton({ icon, label, onClick, primary }) {
  return (
    <button onClick={onClick}
      className={"btn btn-sm " + (primary ? "btn-primary" : "")}
      style={{ width: "100%", justifyContent: "flex-start" }}>
      <span style={{ fontSize: 14 }}>{icon}</span>
      <span>{label}</span>
    </button>
  );
}

// ───────────────────────────────────────────────────────────────
// ARCHITECTURE — System docs & status
// ───────────────────────────────────────────────────────────────
function ArchSub({ lang, T }) {
  const [stats, setStats] = useState(null);
  useEffect(() => {
    (async () => {
      if (!window.electron) return;
      const [projects, drawings, boqs, contracts] = await Promise.all([
        window.electron.getProjects?.() || [],
        window.electron.getDrawings?.() || [],
        window.electron.getBOQs?.() || [],
        window.electron.getContracts?.() || [],
      ]);
      setStats({ projects: projects.length, drawings: drawings.length, boqs: boqs.length, contracts: contracts.length });
    })();
  }, []);

  return (
    <>
      <SubSection title={T("ภาพรวม", "Overview")}>
        {stats && (
          <>
            <SubStat label={T("โครงการทั้งหมด", "Projects")} value={stats.projects} accent="rgba(40,72,255,0.15)" />
            <SubStat label={T("BOQ", "BOQs")} value={stats.boqs} accent="rgba(74,222,128,0.12)" />
            <SubStat label={T("แบบก่อสร้าง", "Drawings")} value={stats.drawings} accent="rgba(246,201,124,0.12)" />
            <SubStat label={T("สัญญา", "Contracts")} value={stats.contracts} accent="rgba(255,107,138,0.12)" />
          </>
        )}
      </SubSection>

      <SubSection title={T("ระบบ", "System")}>
        <SubItem icon="🗄️" label={T("ฐานข้อมูล", "Database")} sub="SQLite WAL" value="✓" />
        <SubItem icon="☁️" label={T("Google Drive", "Drive sync")} sub={T("เชื่อมแล้ว", "connected")} value="●" color="var(--emerald)" />
        <SubItem icon="💾" label={T("Backup", "Backups")} sub={T("อัตโนมัติ", "auto")} value="●" color="var(--emerald)" />
      </SubSection>

      <SubSection title={T("Quick Actions", "Quick actions")}>
        <SubButton icon="💾" label={T("Backup ทันที", "Backup now")}
          onClick={async () => { await window.electron?.backupDatabase?.('manual'); alert(T("Backup สำเร็จ", "Backup done")); }} />
        <SubButton icon="📁" label={T("เปิดโฟลเดอร์ Backup", "Open backups")}
          onClick={() => window.electron?.backupOpenFolder?.()} />
        <SubButton icon="🔄" label={T("รีโหลดข้อมูล", "Reload data")}
          onClick={async () => { await window.loadRealData?.(); window.__triggerReload?.(); }} />
      </SubSection>
    </>
  );
}

// ───────────────────────────────────────────────────────────────
// DASHBOARD — Quick stats + notifications
// ───────────────────────────────────────────────────────────────
function DashboardSub({ lang, T }) {
  const [stats, setStats] = useState({ active: 0, total: 0 });
  useEffect(() => {
    (async () => {
      const projects = await window.electron?.getProjects?.() || [];
      setStats({
        active: projects.filter(p => p.status === 'active').length,
        total: projects.length,
      });
    })();
  }, []);

  return (
    <>
      <SubSection title={T("Quick stats", "Quick stats")}>
        <SubStat label={T("โครงการที่ดำเนินการ", "Active")} value={stats.active} hint={T(`/ ${stats.total} ทั้งหมด`, `/ ${stats.total} total`)} accent="rgba(74,222,128,0.12)" />
        <SubStat label={T("ยอดงานเดือนนี้", "This month")} value="—" accent="rgba(246,201,124,0.12)" />
        <SubStat label={T("รอเก็บเงิน", "Receivables")} value="—" accent="rgba(255,107,138,0.12)" />
      </SubSection>

      <SubSection title={T("วันนี้", "Today")}>
        <SubItem icon="📅" label={T("ไม่มีนัด", "No events")} sub={T("ตารางว่าง", "Clear schedule")} />
      </SubSection>

      <SubSection title={T("แจ้งเตือน", "Notifications")}>
        <SubItem icon="🔔" label={T("ไม่มีการแจ้งเตือน", "No notifications")} sub={T("เคลียร์หมด", "All clear")} />
      </SubSection>
    </>
  );
}

// ───────────────────────────────────────────────────────────────
// BOQ — Most useful sub-sidebar ⭐
// ───────────────────────────────────────────────────────────────
function BOQSub({ lang, T }) {
  const [recent, setRecent] = useState([]);
  const [priceStats, setPriceStats] = useState({ total: 0, learned: 0 });

  useEffect(() => {
    (async () => {
      if (!window.electron) return;
      const drafts = await window.electron.boqDraftList?.() || [];
      setRecent(drafts.slice(0, 5));

      // Get price DB stats
      const allPrices = await window.electron.boqPriceSearch?.('') || [];
      // Use a simple query via search
    })();
  }, []);

  return (
    <>
      <SubSection title={T("Price Database", "Price DB")}>
        <SubStat label={T("รายการอ้างอิง", "Price refs")} value="275+" hint={T("จากไฟล์ BOQ บ้าน", "from BOQ Excel")} accent="rgba(40,72,255,0.15)" />
        <SubButton icon="📋" label={T("จัดการ Price DB", "Manage Price DB")}
          onClick={() => alert(T("จะเปิดในเร็วๆนี้", "Coming soon"))} />
      </SubSection>

      <SubSection title={T("BOQ ล่าสุด", "Recent BOQs")}>
        {recent.length === 0
          ? <SubItem icon="📋" label={T("ยังไม่มี", "None yet")} />
          : recent.map(d => (
              <SubItem key={d.id} icon="📋"
                label={d.name || d.boq_number || `BOQ #${d.id}`}
                sub={d.project_name || '—'}
                value={d.status === 'draft' ? '✎' : d.status === 'finalized' ? '✓' : '→'}
                color={d.status === 'finalized' ? 'var(--emerald)' : 'var(--ink-soft)'} />
            ))}
      </SubSection>

      <SubSection title={T("Quantity Helpers", "Quantity helpers")}>
        <SubItem icon="📐" label={T("คำนวณพื้นที่พื้น", "Floor calculator")} sub="33 ห้องอ้างอิง" />
        <SubItem icon="🧱" label={T("คำนวณพื้นที่ผนัง", "Wall calculator")} sub="from Excel" />
        <SubItem icon="🎨" label={T("คำนวณงานสี", "Paint calculator")} sub="from Excel" />
      </SubSection>

      <SubSection title={T("Tips", "Tips")}>
        <div style={{ fontSize: 10.5, color: "var(--ink-soft)", lineHeight: 1.6, padding: 8, background: "rgba(40,72,255,0.05)", borderRadius: 6 }}>
          💡 {T(
            "พิมพ์ในช่อง 'รายการ' จะมี dropdown ขึ้นพร้อมราคา/หน่วย, ค่าวัสดุ, ค่าแรง จากไฟล์ Excel ต้นฉบับ",
            "Type in description for dropdown with unit prices from Excel master file"
          )}
        </div>
      </SubSection>
    </>
  );
}

// ───────────────────────────────────────────────────────────────
// CONTRACTS — Status overview
// ───────────────────────────────────────────────────────────────
function ContractsSub({ lang, T }) {
  const [contracts, setContracts] = useState([]);
  useEffect(() => {
    (async () => {
      const r = await window.electron?.getContracts?.() || [];
      setContracts(r);
    })();
  }, []);

  const active = contracts.filter(c => c.status === 'active').length;
  const expiringSoon = contracts.filter(c => {
    if (!c.end_date) return false;
    const days = (new Date(c.end_date) - new Date()) / 86400000;
    return days > 0 && days < 30;
  }).length;
  const totalValue = contracts.reduce((a, c) => a + (c.contract_value_thb || 0), 0);

  return (
    <>
      <SubSection title={T("สถานะสัญญา", "Status")}>
        <SubStat label={T("สัญญาที่ดำเนินการ", "Active")} value={active} accent="rgba(74,222,128,0.12)" />
        <SubStat label={T("ใกล้หมดอายุ (30 วัน)", "Expiring soon")} value={expiringSoon} accent="rgba(246,201,124,0.12)" />
        <SubStat label={T("มูลค่ารวม", "Total value")} value={totalValue ? (totalValue/1e6).toFixed(1) + "M" : "—"} hint="THB" accent="rgba(40,72,255,0.12)" />
      </SubSection>

      <SubSection title={T("Quick Actions", "Actions")}>
        <SubButton icon="📄" label={T("สร้างสัญญาใหม่", "New contract")} />
        <SubButton icon="📋" label={T("จาก BOQ ที่บันทึก", "From BOQ")} />
        <SubButton icon="📑" label={T("Template", "Template")} />
      </SubSection>

      <SubSection title={T("Recent", "Recent")}>
        {contracts.slice(0, 4).map(c => (
          <SubItem key={c.id || c.party} icon="📄"
            label={c.party || c.counterparty || '—'}
            sub={c.kind || c.contract_type}
            value={c.value || c.contract_value_thb ? ((c.value || c.contract_value_thb)/1e6).toFixed(1) + "M" : "—"} />
        ))}
      </SubSection>
    </>
  );
}

// ───────────────────────────────────────────────────────────────
// PROCUREMENT — PR/PO
// ───────────────────────────────────────────────────────────────
function ProcurementSub({ lang, T }) {
  return (
    <>
      <SubSection title={T("รออนุมัติ", "Pending approval")}>
        <SubStat label="PR" value={0} hint={T("รออนุมัติ", "pending")} accent="rgba(246,201,124,0.12)" />
        <SubStat label="PO" value={0} hint={T("รออนุมัติ", "pending")} accent="rgba(40,72,255,0.12)" />
      </SubSection>

      <SubSection title={T("Quick Actions", "Actions")}>
        <SubButton icon="🛒" label={T("สร้าง PR ใหม่", "New PR")} primary />
        <SubButton icon="📦" label={T("ออก PO", "Issue PO")} />
        <SubButton icon="📥" label={T("รับของ", "Receive goods")} />
      </SubSection>

      <SubSection title={T("Top Suppliers", "Top suppliers")}>
        <SubItem icon="🏭" label="SCG" sub={T("ยอด: —", "Total: —")} />
        <SubItem icon="🏭" label="TSC Steel" sub={T("ยอด: —", "Total: —")} />
        <SubItem icon="🏭" label="ตราเพชร" sub={T("ยอด: —", "Total: —")} />
      </SubSection>

      <SubSection title={T("เดือนนี้", "This month")}>
        <SubItem icon="💵" label={T("ยอดสั่งซื้อ", "Purchase total")} value="—" />
        <SubItem icon="📦" label={T("จำนวน PO", "PO count")} value="0" />
      </SubSection>
    </>
  );
}

// ───────────────────────────────────────────────────────────────
// BILLING & TAX
// ───────────────────────────────────────────────────────────────
function BillingSub({ lang, T }) {
  return (
    <>
      <SubSection title={T("สถานะใบกำกับ", "Invoice status")}>
        <SubStat label={T("ฉบับร่าง", "Draft")} value={0} accent="rgba(255,255,255,0.05)" />
        <SubStat label={T("ส่งแล้ว", "Sent")} value={0} accent="rgba(40,72,255,0.12)" />
        <SubStat label={T("ชำระแล้ว", "Paid")} value={0} accent="rgba(74,222,128,0.12)" />
      </SubSection>

      <SubSection title={T("Tax Calendar", "Tax calendar")}>
        <SubItem icon="📅" label={T("ยื่น ภพ.30", "VAT Submit")} sub={T("ภายในวันที่ 15", "by 15th")} value="!" color="var(--amber)" />
        <SubItem icon="📅" label={T("ยื่น ภงด.3/53", "WHT")} sub={T("ภายในวันที่ 7", "by 7th")} value="!" color="var(--amber)" />
      </SubSection>

      <SubSection title={T("Tax Calculator", "Calculator")}>
        <div style={{ fontSize: 10.5, color: "var(--ink-soft)", padding: 8, background: "var(--glass-2)", borderRadius: 6, lineHeight: 1.5 }}>
          VAT 7% · WHT 3% · Retention 5%
        </div>
        <SubButton icon="🧮" label={T("เปิดเครื่องคิดเลขภาษี", "Open calculator")} />
      </SubSection>

      <SubSection title={T("Quick Actions", "Actions")}>
        <SubButton icon="📋" label={T("ใบกำกับใหม่", "New invoice")} primary />
        <SubButton icon="📥" label={T("Export งวดนี้", "Export period")} />
      </SubSection>
    </>
  );
}

// ───────────────────────────────────────────────────────────────
// PROGRESS — milestones + retention
// ───────────────────────────────────────────────────────────────
function ProgressSub({ lang, T }) {
  return (
    <>
      <SubSection title={T("งวดงานปัจจุบัน", "Current period")}>
        <SubStat label={T("งวดที่กำลังทำ", "Active period")} value="—" accent="rgba(40,72,255,0.15)" />
        <SubStat label={T("ความคืบหน้ารวม", "Total progress")} value="—%" accent="rgba(74,222,128,0.12)" />
      </SubSection>

      <SubSection title={T("Retention", "Retention")}>
        <SubItem icon="💰" label={T("เงินประกันที่ค้าง", "Retained")} value="—" />
        <SubItem icon="✅" label={T("คืนเงินประกันได้", "Releasable")} value="—" color="var(--emerald)" />
      </SubSection>

      <SubSection title={T("กำหนดการ", "Timeline")}>
        <SubItem icon="📅" label={T("งวดถัดไป", "Next milestone")} sub="—" />
        <SubItem icon="⏰" label={T("วันส่งมอบ", "Delivery")} sub="—" />
      </SubSection>
    </>
  );
}

// ───────────────────────────────────────────────────────────────
// INVENTORY — stock alerts
// ───────────────────────────────────────────────────────────────
function InventorySub({ lang, T }) {
  return (
    <>
      <SubSection title={T("แจ้งเตือนสต๊อก", "Stock alerts")}>
        <SubStat label={T("ใกล้หมด", "Low stock")} value={0} accent="rgba(246,201,124,0.15)" />
        <SubStat label={T("หมด", "Out of stock")} value={0} accent="rgba(255,107,138,0.15)" />
      </SubSection>

      <SubSection title={T("วัสดุยอดนิยม", "Top materials")}>
        <SubItem icon="🧱" label={T("ปูนซีเมนต์", "Cement")} value="—" />
        <SubItem icon="🔧" label={T("เหล็กเส้น", "Steel rebar")} value="—" />
        <SubItem icon="🧱" label={T("อิฐมวลเบา", "Q-Con brick")} value="—" />
      </SubSection>

      <SubSection title={T("Quick Actions", "Actions")}>
        <SubButton icon="➕" label={T("เพิ่มวัสดุ", "Add material")} primary />
        <SubButton icon="📤" label={T("เบิกของ", "Issue goods")} />
        <SubButton icon="📥" label={T("รับเข้า", "Receive")} />
      </SubSection>
    </>
  );
}

// ───────────────────────────────────────────────────────────────
// SUBCONTRACTOR
// ───────────────────────────────────────────────────────────────
function SubconSub({ lang, T }) {
  const [subs, setSubs] = useState([]);
  useEffect(() => {
    (async () => {
      const r = await window.electron?.getSubcontractors?.() || [];
      setSubs(r);
    })();
  }, []);

  return (
    <>
      <SubSection title={T("สรุป", "Overview")}>
        <SubStat label={T("ทีมทั้งหมด", "Total teams")} value={subs.length} accent="rgba(40,72,255,0.15)" />
        <SubStat label={T("กำลังทำงาน", "Active")} value={subs.filter(s => (s.completion_pct || 0) > 0 && (s.completion_pct || 0) < 100).length} accent="rgba(74,222,128,0.12)" />
      </SubSection>

      <SubSection title={T("ทีมยอดนิยม", "Top rated")}>
        {subs.slice(0, 5).sort((a, b) => (b.rating_stars || 0) - (a.rating_stars || 0)).map(s => (
          <SubItem key={s.id || s.name_th} icon="👷"
            label={s.name_th || s.name || '—'}
            sub={s.type || ''}
            value={`⭐${(s.rating_stars || 0).toFixed(1)}`} />
        ))}
      </SubSection>

      <SubSection title={T("Quick Actions", "Actions")}>
        <SubButton icon="➕" label={T("เพิ่มผู้รับเหมา", "Add subcontractor")} primary />
        <SubButton icon="💸" label={T("จ่ายเงินงวด", "Make payment")} />
      </SubSection>
    </>
  );
}

// ───────────────────────────────────────────────────────────────
// DRAWINGS — folders + recent
// ───────────────────────────────────────────────────────────────
function DrawingsSub({ lang, T }) {
  const [folders, setFolders] = useState([]);
  const [drawings, setDrawings] = useState([]);
  useEffect(() => {
    (async () => {
      const [fl, dl] = await Promise.all([
        window.electron?.drawingFolderList?.() || [],
        window.electron?.getDrawings?.() || [],
      ]);
      setFolders(fl);
      setDrawings(dl);
    })();
  }, []);

  const byDiscipline = drawings.reduce((acc, d) => {
    const k = d.discipline || 'Other';
    acc[k] = (acc[k] || 0) + 1;
    return acc;
  }, {});

  return (
    <>
      <SubSection title={T("ภาพรวม", "Overview")}>
        <SubStat label={T("ไฟล์ทั้งหมด", "Total files")} value={drawings.length} accent="rgba(40,72,255,0.15)" />
        <SubStat label={T("โฟลเดอร์", "Folders")} value={folders.length} accent="rgba(74,222,128,0.12)" />
      </SubSection>

      <SubSection title={T("ตามสาขา", "By discipline")}>
        {Object.entries(byDiscipline).slice(0, 6).map(([disc, count]) => (
          <SubItem key={disc} icon={
            disc === 'Architecture' ? '🏛️' :
            disc === 'Structure' ? '🏗️' :
            disc === 'Electrical' ? '⚡' :
            disc === 'Plumbing' ? '💧' : '📐'
          } label={disc} value={count} />
        ))}
      </SubSection>

      <SubSection title={T("Quick Actions", "Actions")}>
        <SubButton icon="📁" label={T("สร้างโฟลเดอร์", "New folder")} primary />
        <SubButton icon="📥" label={T("Import จาก Drive", "Import from Drive")} />
        <SubButton icon="📤" label={T("Upload PDF", "Upload PDF")} />
      </SubSection>

      <SubSection title={T("Tip", "Tip")}>
        <div style={{ fontSize: 10.5, color: "var(--ink-soft)", lineHeight: 1.6, padding: 8, background: "rgba(40,72,255,0.05)", borderRadius: 6 }}>
          💡 {T("คลิกชื่อไฟล์เพื่อเปิด PDF ในโปรแกรม + เพิ่ม comment ได้", "Click filename to open PDF in-app")}
        </div>
      </SubSection>
    </>
  );
}

window.SubSidebar = SubSidebar;
