/* css/boq-summary.css — ย้ายมาจาก pages/shared-pages.css (2026-08-16)
   ตอนรวม BOQ Summary เข้ามาเป็นแท็บใน contistant.html
   กฎที่ shell มีอยู่แล้ว (:root, .fp-*, .rh-table, .ov-table, .modal-*) ถูกตัดทิ้ง
   ไม่ได้ย้ายมา — ดู tests/css-no-shell-collision.test.js */

/* .mc-mono ไม่ใช่ของ shell (ไม่มีใน css/*.css เลย) แต่ก็ไม่ใช่ของ BOQ Summary
   ล้วน ๆ เหมือนกัน — js/boq/boq-summary.js และ js/boq/boq-preset-ui.js ใช้จริง
   (ตัวเลขคอลัมน์ราคา/qty) เดิมอยู่ในบรรทัด 31 ของ shared-pages.css รวมกับ
   .ov-num/td.ov-num/.ov-kpi-value ซึ่งสามส่วนหลังนั้นซ้ำกับของ shell อยู่แล้ว
   (feature-panels.css: `.ov-table td.ov-num` มี font-family เดียวกัน,
   `.ov-kpi-value` ไม่ได้ถูกใช้ในหน้านี้เลย) เลยตัดสามตัวนั้นทิ้ง เหลือแต่ .mc-mono
   ซึ่งไม่มีที่ไปอื่นนอกจากประกาศซ้ำในทั้งสองไฟล์ (ไม่ชนกันเอง เพราะ test เช็คแค่
   การชนกับ shell ไม่เช็คระหว่างสองไฟล์นี้) */
.mc-mono { font-family: 'IBM Plex Mono', 'JetBrains Mono', monospace; }

/* ─── ส่วนต่างจาก shell ที่ตรวจพบและต้องคงไว้ (ดู task-3-report.md สำหรับรายละเอียด) ─── */

/* price-source-badge: feature-panels.css มีสีให้แค่ cgd_2569/cgd_2026/catalog/
   project_override/manual/missing — ไม่มี bq_standard_2567 กับ upload ที่
   renderPriceSourceBadge() ใน boq-summary.js ยังคืนค่าจริง (unit_price_source
   ทั้งสองค่านี้ยังถูกเขียนจริงใน js/boq/boq-import.js) เติมสีที่ขาด scope ไว้ใต้
   #panel-boq เท่านั้น ไม่ให้ทับ badge ของแท็บอื่น */
#panel-boq .price-source-badge.bq_standard_2567 { background: #cffafe; color: #155e75; }
#panel-boq .price-source-badge.upload { background: #ede9fe; color: #5b21b6; }

/* .ov-table th/td ของ shell (feature-panels.css) ไม่มี vertical-align:middle
   (shared-pages.css เดิมมี) และไม่มี th.ov-num เลย (มีแต่ td.ov-num) — แต่ BOQ
   ใช้ <th class="ov-num"> จริงหลายจุด (boq-summary.js, boq-preset-ui.js) จึงต้อง
   เติมกลับ scope ไว้ใต้ #panel-boq */
#panel-boq .ov-table th, #panel-boq .ov-table td { vertical-align: middle; }
#panel-boq .ov-table th.ov-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── BOQ Summary specific ─── */
.boq-project-header {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.boq-project-header__title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: var(--color-text-primary);
  transition: color 0.2s;
  border-bottom: 1px solid var(--color-border-default);
}
.boq-project-header__title:hover {
  color: var(--color-primary);
}
.boq-project-header__toggle {
  display: inline-block;
  width: 16px;
  text-align: center;
  transition: transform 0.3s ease;
  font-size: 12px;
}
.boq-project-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  margin-top: 12px;
  padding-bottom: 8px;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
  }
  to {
    opacity: 1;
    max-height: 500px;
  }
}
.boq-label { color: var(--color-text-secondary); font-weight: 600; margin-right: 6px; }
.boq-no-price { color: #d97706; font-size: 12px; font-weight: 600; white-space: nowrap; }
.boq-source-tag { font-size: 10px; color: var(--color-text-secondary); }
.boq-group { margin-bottom: 18px; }
.boq-group:last-child { margin-bottom: 0; }
.boq-group-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 2px solid var(--color-border-default); margin-bottom: 8px;
}
.boq-group-head h3 { margin: 0; font-size: 15px; }
.boq-subgroup { margin: 10px 0 16px 12px; }
.boq-subgroup-head { font-size: 13px; font-weight: 700; color: var(--color-text-secondary); margin-bottom: 6px; }
.boq-export-controls .mc-toolbar-actions { flex-wrap: wrap; }

/* ─── Print stylesheet (Export as PDF) ─── the original combined print rule
   (shared-pages.css lines 431-438) hid .pg-topbar/.boq-export-controls/.mc-tabs/
   .mc-sidebar/.mc-toolbar-actions together and reset .pg-content — brief routes
   that whole block to material-catalog.css (it hosts the .fp-card/body reset
   that's shared print behavior), but .boq-export-controls is BOQ-owned and
   .pg-topbar/.pg-content are dead chrome (dropped, same as elsewhere in this
   file) — so BOQ Summary's own print-hide rule for its export controls lives
   here instead of being silently lost. ─── */
@media print {
  .boq-export-controls { display: none !important; }
}

/* ─── BOQ Summary deep-link highlight (Material Catalog v2 Task 4) -- lives here, not
   feature-panels.css, because the standalone page never loaded feature-panels.css;
   now that both load from the same shell, kept here since it's BOQ-Summary-owned. ─── */
.boq-subgroup--highlighted {
  animation: boq-subgroup-flash 2.5s ease-out;
}
@keyframes boq-subgroup-flash {
  0% { background-color: color-mix(in srgb, var(--color-primary) 15%, transparent); }
  100% { background-color: transparent; }
}

/* ปุ่มที่หน้าตาเหมือนลิงก์ — ใช้แทน <a href="material-catalog.html"> เดิมที่กลายเป็นการสลับแท็บ */
.boqw-linkbtn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
}

/* เครื่องมือนำเข้าราคา — เดิมอยู่บนสุดของ pages/boq-summary.html บังตาราง BOQ
   ย้ายมาไว้ล่างตาราง และพับเก็บไว้ เพราะเป็นงานของผู้ดูแลข้อมูล ไม่ใช่งานประจำวัน */
.boq-import-tools { margin-top: 24px; border-top: 1px solid var(--color-border-default); padding-top: 16px; }
.boq-import-tools > summary { cursor: pointer; font-weight: 600; color: var(--color-text-secondary); }
.boq-import-tools__group { margin-top: 16px; }
.boq-import-tools__row { display: flex; gap: 12px; align-items: center; }
.boq-import-tools__row input[type="file"] { flex: 1; }
.boq-import-tools__status { margin-top: 8px; font-size: 12px; color: var(--color-text-secondary); }
.boq-import-tools__scroll { max-height: 300px; overflow-y: auto; border: 1px solid var(--color-border-default); border-radius: 4px; }
.boq-import-tools__actions { margin-top: 12px; display: flex; gap: 8px; }
.boq-import-tools__note { font-size: 11px; color: var(--color-text-secondary); margin-top: 8px; }

/* ── 2026-08-19 full-width (spec §5): BOQ เลิกใช้ cap 960px แบบเดียวกับ Planner ── */
#panel-boq { align-items: stretch !important; }
#panel-boq .app-panel { width: 100%; max-width: none; }
/* การ์ดค่าขนส่งเรียงเป็น grid ใช้ความกว้างที่ได้มา แทนกองแนวตั้ง */
#panel-boq .boqw-dv { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }

/* ── ธง "ควรตรวจสอบ" (2026-08-28) ─────────────────────────────────────────────
   BOQItem.status/review_reason ถูกเขียนโดย pipeline มานานแล้วแต่ไม่เคยมีพื้นผิวไหน
   ในแอปแสดงมันเลย — ธงที่ไม่มีใครเห็นเท่ากับไม่ได้ติด ตัวที่ทำให้จำเป็นคือสูตรกำหนดเอง
   ซึ่งเปลี่ยนตัวเลขจริง คนที่มาอ่าน BOQ ทีหลังต้องรู้ว่าแถวไหนไม่ได้ใช้สูตรมาตรฐาน */
#panel-boq .boqw-flag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: middle;
  cursor: help;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}
#panel-boq .boqw-flag--strong {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}
#panel-boq .boqw-reviewbar {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.7;
  background: #fffbeb;
  color: #78350f;
  border: 1px solid #fcd34d;
}
/* ── 2026-08-23 (Task 9, freight-lead-time-engine): truck switcher / ส่งฟรี badge /
   RMC warnings / lead-time ETA on the delivery cards ── feature-panels.css already
   owns .boqw-dv-card/.boqw-dv-math/.boqw-trips/.boqw-eta (base card shell); this repo
   has no --color-success/--color-warning tokens (checked css/shell.css — only
   --color-primary/-pressed/-active and greyscale text/border tokens exist), so these
   match the plain hex the rest of the app already uses for the same semantics
   (#16a34a = boqw-diff-dn/boqw-chip-ok green, #ea580c = the existing warning-orange at
   feature-panels.css:657) rather than inventing new tokens. */
#panel-boq .boqw-dv-free { display: inline-block; margin-left: 8px; color: #16a34a; font-size: 12px; font-weight: 600; }
#panel-boq .boqw-dv-warn { color: #ea580c; font-size: 12px; margin-top: 4px; line-height: 1.5; }
#panel-boq .boqw-dv-unweighed { margin-top: 4px; }
#panel-boq .boqw-truck-select { font-size: 13px; padding: 3px 6px; border: 1px solid var(--color-border-default); border-radius: 4px; background: #fff; }
#panel-boq .boqw-truck-fixed { font-size: 13px; color: var(--color-text-secondary); }

/* ── เงินสามช่องของแถว BOQ (2026-08-28) ─────────────────────────────────────
   ค่าวัสดุ + ค่าแรง = รวม · ช่อง "รวม" เน้นกว่าเพราะเป็นตัวเลขที่คนอ่านหาก่อน
   และเป็นช่องที่ต้องบวกตามได้ด้วยตาจากสองช่องซ้ายมือ */
#panel-boq .boqw-amount { font-weight: 600; }

/* แถบสรุปความสมเหตุสมผล — สรุปอย่างเดียว รายละเอียดอยู่ที่การ์ดสูตร (2026-08-29)
   แยกสีจาก .boqw-reviewbar (ธง needs_review) เพราะเป็นคนละเรื่อง:
   reviewbar = "ระบบไม่มีสูตรให้/ผู้ใช้แก้สูตรเอง", แถบนี้ = "ตัวเลขที่ได้ดูแปลก" */
.boqw-plausbar {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-left: 3px solid #a86a00;
  background: #fdf9f1;
  border-radius: 4px;
  font-size: 13px;
  color: #6b4a06;
}
.boqw-plausbar--fail {
  border-left-color: #b4232a;
  background: #fdf4f4;
  color: #8c1c22;
}
.boqw-plauslink {
  margin-left: 8px;
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}
