/* =====================================================================
   หน้าโปรโมชัน (พนักงาน) — โหลดหลัง app.css / shop.css
   ทุกกฎขึ้นต้นด้วย .promo- เพื่อไม่กระทบหน้าอื่น
   ===================================================================== */

/* การ์ดเลือกประเภทโปร */
/* มือถือ: 2 คอลัมน์ การ์ดสุดท้ายที่เหลือเดี่ยวกินเต็มแถว
   จอใหญ่: grid 6 ช่อง — แถวแรก 3 การ์ด (โปรระดับสินค้า) แถวสอง 2 การ์ด (ท้ายบิล/คูปอง) กว้างครึ่งแถว */
.promo-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.promo-types > .promo-type:last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (min-width: 761px) {
  .promo-types { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .promo-types > .promo-type { grid-column: span 2; }
  .promo-types > .promo-type:nth-child(3n+1):nth-last-child(2),
  .promo-types > .promo-type:nth-child(3n+2):last-child { grid-column: span 3; }
  .promo-types > .promo-type:nth-child(3n+1):last-child { grid-column: 1 / -1; }
}
.promo-type {
  font: inherit; color: var(--ink); text-align: left; cursor: pointer; min-width: 0;
  display: flex; flex-direction: column; gap: 4px; padding: 12px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.promo-type:hover { border-color: rgba(var(--brand-rgb), .5); }
.promo-type:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.promo-type.on { border-color: var(--brand); background: var(--brand-tint); box-shadow: 0 0 0 1px var(--brand) inset; }
.promo-type strong { font-size: .95rem; line-height: 1.3; overflow-wrap: anywhere; }
.promo-type small { font-size: .8rem; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.promo-type-ico {
  display: inline-flex; align-items: center; justify-content: center; align-self: flex-start;
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: 10px;
  background: var(--chip); color: var(--ink); font-weight: 700; font-size: .9rem;
}
.promo-type.on .promo-type-ico { background: var(--brand); color: var(--brand-ink); }

/* ตัวอย่าง ซื้อ X แถม Y */
.promo-example { margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--ok-soft); color: var(--ok); font-weight: 600; font-size: .9rem; }

/* โค้ดคูปอง */
.promo-code-row { display: flex; gap: 8px; min-width: 0; }
.promo-code-row input { flex: 1 1 auto; min-width: 0; }
.promo-code-row .btn { flex: none; }
.promo-code { text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.promo-code-tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px; border: 1px dashed var(--brand);
  color: var(--brand); background: var(--brand-tint); font-weight: 700; letter-spacing: .04em; font-size: .85rem;
}

/* ขอบเขตสินค้า */
.promo-scope legend { padding: 0 6px; font-size: .9rem; color: var(--muted); }
.segmented.promo-seg3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented.promo-seg3 button { overflow-wrap: anywhere; }

.promo-picker { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.promo-picker-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.promo-picker-head .search { flex: 1 1 220px; min-width: 0; }
.promo-picked { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; color: var(--brand); }
.promo-picker-list {
  max-height: 280px; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.promo-pick { padding: 8px 12px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.promo-pick:last-child { border-bottom: 0; }
.promo-pick.on { background: var(--brand-tint); }
.promo-pick input { flex: none; margin-top: 2px; }
.promo-pick-name { min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.promo-picker-empty { margin: 0; padding: 12px; }

/* ซื้อ A แถม B */
.promo-scope.promo-bo { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.promo-scope.promo-bo legend { font-weight: 700; color: var(--ink); }
.promo-bo-sub { font-size: .85rem; color: var(--muted); }
.promo-bo-qty { max-width: 220px; }
.promo-picked.promo-bo-picked, .promo-picked.promo-bo-none { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.promo-picked.promo-bo-none { color: var(--muted); font-weight: 500; }
.promo-bo-hint { display: block; margin-top: -4px; line-height: 1.4; }

/* สรุปโปร */
.promo-preview {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 14px;
  border-radius: var(--radius-sm); background: var(--chip); color: var(--ink); font-size: .9rem; overflow-wrap: anywhere;
}
.promo-preview-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* สถานะในรายการ */
.promo-st-live { background: var(--ok-soft); color: var(--ok); }
.promo-st-scheduled { background: var(--warn-soft); color: #7a5300; }
.promo-st-ended, .promo-st-usedup { background: var(--danger-soft); color: var(--danger); }
.promo-st-off { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.promo-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.promo-del { color: var(--danger); }
.promo-gives { min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .promo-type { padding: 10px; }
  .promo-bo-qty { max-width: none; }
  .promo-table td[data-label] > * { text-align: right; }
  .promo-table td.actions-cell { flex-wrap: wrap; }
  .promo-actions .btn { min-height: 40px; }
}
