/* รอบ 28: ปรับหน้าแบบหน้าเดียว (fit-catalog)
   หน้า: สินค้า, โปรโมชัน, แบนเนอร์หน้าร้าน, ลูกค้าหน้าร้าน, สต็อกสาขา
   ใช้ร่วมกับ fit.css — คลาสของไฟล์นี้ขึ้นต้นด้วย fitc- */

@media screen {

/* ---------- แถบชิปตัวกรอง ---------- */
.fitc-bar { display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.fitc-chips {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; min-width: 0;
  overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px;
}
.fitc-chips::-webkit-scrollbar { display: none; }
.fitc-chips-end { flex: none; }
.fitc-chips .chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px;
  font: inherit; font-size: .86rem; cursor: pointer; transition: border-color .12s, background-color .12s;
}
.fitc-chips .chip:hover:not(.on) { border-color: var(--brand); }
.fitc-chips .chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.fitc-n { font-size: .74rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.fitc-chips .chip.on .fitc-n { color: inherit; opacity: .7; }
.fitc-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; padding: 0; border: 0; flex: none; }
.fitc-chips .fitc-dot { background: currentColor; }
.fitc-chips .chip.on .fitc-dot { box-shadow: 0 0 0 2px var(--surface); }
.fitc-chip-clear { border-style: dashed; color: var(--muted); }
.fitc-hint { margin: 0; flex: 0 1 auto; min-width: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ปุ่มไอคอน+ข้อความ (มือถือเหลือไอคอน) */
.fitc-ico-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.fitc-ico-btn svg { flex: none; }

/* ช่องค้นหาที่มีปุ่มกด (ลูกค้า: ค้นหาที่เซิร์ฟเวอร์) */
.fitc-search-form { padding-right: 5px; width: 320px; }
.fitc-search-go { flex: none; min-height: 32px; padding: 4px 12px; }

/* .fit-stat.hl ชนกับ .brand ของแถบเมนู (app.css: จัดกลาง/ตัวหนา/สีขาว) → คืนค่า */
.fitc-stats .fit-stat.hl { align-items: stretch; font-weight: inherit; color: var(--ink); }

/* ตาราง: แถวเตี้ยลงเล็กน้อยบนจอคอม ให้เห็นหลายแถว */
.fit .fit-scroll > .table td { padding-top: 8px; padding-bottom: 8px; }

/* ---------- สินค้า ---------- */
.fitc-prod-table .product-cell img, .fitc-prod-table .thumb-empty { flex: none; }
.fitc-import-links { display: flex; flex-wrap: wrap; gap: 8px; }
.fitc-import .muted.small { margin: 0; }
.fitc-import code { overflow-wrap: anywhere; }

/* ---------- แบนเนอร์ ---------- */
.fit .bn-intro { margin: 0; font-size: .9rem; min-width: 0; }
.fitc-pills { display: flex; flex-wrap: wrap; gap: 6px; flex: none; }
.fitc-pills .status-pill b { font-weight: 700; margin-left: 2px; }
.fitc-bn-list { align-content: start; }
.fitc-bn-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 180px; padding: 16px; border: 2px dashed var(--line); border-radius: var(--radius-lg);
  background: transparent; color: var(--ink); font: inherit; cursor: pointer; transition: border-color .12s, background-color .12s;
}
.fitc-bn-add:hover { border-color: var(--brand); background: var(--brand-soft); }
.fitc-bn-add:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.fitc-bn-add-ico {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); font-size: 1.6rem; line-height: 1; margin-bottom: 4px;
}

/* ---------- การ์ดสรุปที่กดกรองได้ (สต็อก) ---------- */
.fitc-stat-btn {
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  border: 1px solid transparent; transition: border-color .12s, box-shadow .12s;
}
.fitc-stat-btn:hover { border-color: var(--line); }
.fitc-stat-btn.on { border-color: var(--brand); box-shadow: var(--shadow), 0 0 0 3px var(--brand-soft); }
.fitc-stat-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.fitc-stat-warn strong { color: var(--warn-text, #8a5a00); }
.fitc-stat-danger strong { color: var(--danger); }
.fitc-note { margin: 0; }

/* ---------- จอคอม ---------- */
@media (min-width: 1025px) {
  .fitc-bn-list { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
  .fitc-stats .fit-stat { padding: 10px 16px; }
}
@media (min-width: 1600px) {
  .fitc-bn-list { grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); }
}

/* ---------- จอกว้างกว่ามือถือ: ชิปขึ้นบรรทัดใหม่ได้ (เห็นครบทุกตัว) ---------- */
@media (min-width: 761px) {
  .fitc-bar { flex-wrap: wrap; align-items: flex-start; }
  .fitc-chips { flex-wrap: wrap; overflow: visible; }
  .fitc-chips-end { max-width: none; margin-left: auto; }
  /* ตารางโปรโมชัน: ปุ่ม/สถานะไม่ตัดบรรทัด */
  .fitc-promos .promo-actions { flex-wrap: nowrap; }
  :is(.fitc-custs, .fitc-stock, .fitc-promos) .fit-scroll > .table td.num { white-space: nowrap; }
  :is(.fitc-custs, .fitc-products) .fit-scroll > .table .status-pill { white-space: nowrap; }
  .fitc-promos .promo-table .status-pill, .fitc-promos .promo-code-tag { white-space: nowrap; }
  .fitc-promos .promo-table td:first-child { min-width: 180px; }
  .fitc-promos .promo-table td:nth-child(3), .fitc-promos .promo-table td:nth-child(4) { white-space: nowrap; }
}
@media (max-width: 1180px) {
  .fitc-hint { text-align: left; white-space: normal; flex-basis: 100%; }
}

/* ---------- มือถือ ---------- */
@media (max-width: 760px) {
  .fitc-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .fitc-chips { margin: -2px -16px; padding: 2px 16px; }
  .fitc-chips .chip { min-height: 36px; }
  /* สองกลุ่มชิป (หมวด/ประเภท + สถานะ) รวมเป็นแถวเดียวที่เลื่อนข้างได้ ประหยัดความสูง */
  .fitc-bar:has(> .fitc-chips-end) {
    flex-direction: row; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none;
    margin: -2px -16px; padding: 2px 16px;
  }
  .fitc-bar:has(> .fitc-chips-end)::-webkit-scrollbar { display: none; }
  .fitc-bar:has(> .fitc-chips-end) > .fitc-chips { flex: none; overflow: visible; margin: 0; padding: 0; max-width: none; }
  .fitc-bar:has(> .fitc-chips-end) > .fitc-chips-end { padding-left: 10px; border-left: 1px solid var(--line); }
  .fitc-ico-btn { padding-left: 12px; padding-right: 12px; }
  .fitc-ico-btn span { display: none; }
  .fitc-search-form { width: auto; }
  /* ให้ช่องค้นหาหดได้ ปุ่มด้านขวาไม่ล้นจอ */
  :is(.fitc-products, .fitc-promos, .fitc-custs, .fitc-stock) .fit-tools .fit-search { min-width: 0; }
  :is(.fitc-products, .fitc-promos, .fitc-custs, .fitc-stock) .fit-tools .fit-search input { width: 100%; }
  .fitc-bn-bar { gap: 6px; }
  .fitc-banners .fit-tools > .btn { flex: 1 1 auto; }
  .fitc-bn-add { min-height: 120px; }
  .fitc-hint { font-size: .8rem; }
  .fitc-stats .fit-stat.hl { grid-column: 1 / -1; order: 10; }
  /* ลูกค้า: การ์ดสรุปเป็นแถบเดียวเลื่อนข้าง (ไม่กินความสูง) */
  .fitc-custs .fitc-stats { display: flex; overflow-x: auto; scrollbar-width: none; margin: -4px -16px; padding: 4px 16px; }
  .fitc-custs .fitc-stats::-webkit-scrollbar { display: none; }
  .fitc-custs .fitc-stats > .fit-stat { flex: 0 0 auto; min-width: 128px; }
  .fitc-custs .fitc-stats > .fit-stat.hl { order: 0; }
  .fitc-stock .fitc-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fitc-stock .fitc-stats .fit-stat span { font-size: .74rem; }
}

}

/* =====================================================================
   รอบ 104: สต็อก — ชื่อสินค้ากดได้ + ลิ้นชักประวัติความเคลื่อนไหว (prefix stkh-)
   ===================================================================== */
@media screen {
  .stkh-name {
    background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; text-align: left; cursor: pointer;
    text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; overflow-wrap: anywhere;
  }
  .stkh-name:hover, .stkh-name:focus-visible { color: var(--brand-text, var(--brand)); text-decoration-color: currentColor; }
  .stkh-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stkh-note { margin: 0 0 10px; }
  .stkh-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
  .stkh-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: start;
    padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: var(--radius-sm); background: var(--surface);
  }
  .stkh-row.out { border-left-color: var(--danger); }
  .stkh-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .stkh-main strong { font-size: .92rem; }
  .stkh-main small { overflow-wrap: anywhere; }
  .stkh-qty { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; white-space: nowrap; }
  .stkh-qty strong { font-size: .95rem; }
}

/* =====================================================================
   รอบ 110: สต็อก — คอลัมน์ "≈ หมดใน" (คาดการณ์จากการใช้จริง · prefix stk-ro)
   ===================================================================== */
@media screen {
  .stk-ro { white-space: nowrap; }
  .stk-ro .muted { font-size: .85rem; }
  .stk-ro-th a { color: inherit; text-decoration: underline dashed; text-decoration-color: var(--line); text-underline-offset: 3px; }
  .stk-ro-th a:hover, .stk-ro-th a:focus-visible { color: var(--brand-text, var(--brand)); }
  .tag.stk-ro-out { background: var(--danger-soft); color: var(--danger); }
}
