/* จัดวางหน้าต่าง (dialog) ในหน้าจัดการกิจกรรมใหม่ (23 ต.ค. 2569 · taste-skill)
   เจ้าของระบบ: ใช้สีและเนื้อหาเดิม ปรับเฉพาะการจัดวาง
   - ปุ่มบันทึกของฟอร์มยาว (กิจกรรม · ผู้เข้าร่วม) ติดขอบล่างของหน้าต่าง ไม่ต้องเลื่อนลงไปหา
   - หน้าต่างแก้ไขกิจกรรม (จอกว้าง): กว้างขึ้น ช่องสั้นจับคู่กันสองคอลัมน์ ความยาวลดลงเกือบครึ่ง
   - QR: ปุ่มเลือก 4 แบบแถวเดียว · ผู้ลงนาม: ช่องกรอกแบบเดียวกับฟอร์มอื่น ป้ายบทบาทไม่ตัดบรรทัด */

/* ปุ่มบันทึกติดขอบล่าง: พื้นขาวรอบปุ่มบังเนื้อหาที่เลื่อนผ่าน (สีพื้นหน้าต่างเดิม ไม่ใช่เงา) */
#eventDialog #eventForm > button[type="submit"],
#participantDialog form > button[type="submit"],
#organizersDialog #organizersForm > button[type="submit"] {
  position: sticky; bottom: 0; z-index: 3;
  box-shadow: 0 0 0 14px #fff, 0 14px 0 14px #fff;
}

/* ฟอร์มเดิมตั้ง overflow-x:hidden ทำให้ฟอร์มเป็นกล่องเลื่อนเอง ปุ่มติดขอบไม่ทำงาน · ใช้ clip แทน (ตัดแนวนอนเหมือนเดิม แต่ไม่เป็นกล่องเลื่อน) */
#eventDialog #eventForm, #participantDialog form, #organizersDialog #organizersForm { overflow-x: clip !important; overflow-y: visible !important; }

/* แก้ไขกิจกรรม: จอกว้างใช้สองคอลัมน์ */
@media (min-width: 900px) {
  #eventDialog { width: min(900px, calc(100vw - 40px)) !important; max-width: min(900px, calc(100vw - 40px)) !important; }
  #eventDialog #eventForm { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
  #eventDialog #eventForm > * { grid-column: 1 / -1; }
  #eventDialog #eventForm > label:has(#eventName),
  #eventDialog #eventForm > label:has(#eventSlug),
  #eventDialog #eventForm > label:has(#eventLocation),
  #eventDialog #eventForm > label:has(#eventLocationUrl),
  #eventDialog #eventForm > fieldset.event-extra:has(#eventMediaGrid),
  #eventDialog #eventForm > fieldset.event-extra:has(#addEventLinkBtn) { grid-column: auto; }
  #eventDialog #eventForm > input[type="hidden"] { display: none; }
}

/* QR: สมัคร · Check-in · Finish · หน้าเว็บ แถวเดียว */
#qrDialog .qr-tabs { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 8px !important; }
#qrDialog .qr-tabs > * { width: 100% !important; min-width: 0 !important; padding-inline: 6px !important; white-space: nowrap; }
@media (max-width: 520px) { #qrDialog .qr-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }

/* ผู้ลงนามบนเกียรติบัตร */
.signers-dialog .team-role { white-space: nowrap; }
.signers-dialog .signer-row .admin-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.signers-dialog .signer-row label { display: grid; gap: 6px; font-weight: 700; font-size: .96rem; min-width: 0; }
.signers-dialog .signer-row :is(input[type="search"], label input) {
  width: 100%; min-width: 0; box-sizing: border-box; min-height: 52px; padding: 11px 13px;
  border: 1px solid transparent; border-radius: 16px; background: #f4f6f5; font: inherit; font-size: 17px; font-weight: 600;
}
@media (max-width: 600px) { .signers-dialog .signer-row .admin-form-grid { grid-template-columns: minmax(0, 1fr); } }

/* ทีมงาน: บทบาทกับปุ่มเพิ่มเต็มความกว้าง */
#teamDialog .team-add-row { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
#teamDialog .team-add-row > * { width: 100%; }

/* ผู้จัดกิจกรรม (ย้ายออกจากแก้ไขกิจกรรม 27 ต.ค. 2569): กว้างพอให้ชื่อ บทบาท และช่องลายเซ็นอยู่แถวเดียว */
@media (min-width: 900px) { #organizersDialog { width: min(760px, calc(100vw - 40px)) !important; max-width: min(760px, calc(100vw - 40px)) !important; } }
#organizersDialog .team-role { white-space: nowrap; }
#organizersDialog .team-rights li { grid-template-columns: 104px minmax(0, 1fr); }
#teamDialog .team-role { white-space: nowrap; }
#teamDialog .team-rights li { grid-template-columns: 96px minmax(0, 1fr); }
/* ไซส์เสื้อ (admin-shirts.js · 27 ต.ค. 2569): ตารางเส้นบาง ตัวเลขชิดขวา ไซส์ที่ยังไม่มีคนสั่งเป็นสีจาง */
@media (min-width: 900px) { #shirtDialog { width: min(680px, calc(100vw - 40px)) !important; max-width: min(680px, calc(100vw - 40px)) !important; } }
#shirtDialog .shirt-totals { margin: 4px 0 0; font-weight: 700; color: var(--health-ink, #203b35); }
#shirtDialog .shirt-table-wrap { overflow-x: auto; margin: 4px 0; }
#shirtDialog .shirt-table { width: 100%; border-collapse: collapse; font-size: .95rem; font-variant-numeric: tabular-nums; }
#shirtDialog .shirt-table th, #shirtDialog .shirt-table td { padding: 8px 10px; border-bottom: 1px solid var(--health-border, #d5e2dc); text-align: left; white-space: nowrap; }
#shirtDialog .shirt-table thead th { color: var(--health-muted, #5c716b); font-size: .82rem; font-weight: 600; }
#shirtDialog .shirt-table tbody th { font-weight: 700; }
#shirtDialog .shirt-table .num { text-align: right; }
#shirtDialog .shirt-table .shirt-measure { color: var(--health-muted, #5c716b); font-size: .85rem; }
#shirtDialog .shirt-table tr.is-zero td, #shirtDialog .shirt-table tr.is-zero th { color: #98a2b3; }
#shirtDialog .shirt-table tfoot th, #shirtDialog .shirt-table tfoot td { border-bottom: 0; border-top: 2px solid var(--health-ink, #203b35); font-weight: 800; }
#shirtDialog .shirt-table thead th { white-space: normal; vertical-align: bottom; }
@media (max-width: 560px) { #shirtDialog .shirt-table .shirt-measure { display: none; } #shirtDialog .shirt-table th, #shirtDialog .shirt-table td { padding: 8px 6px; } }
/* สิทธิ์ของแต่ละบทบาทอยู่ล่างสุดของหน้าต่างทีมงาน (เจ้าของระบบ 27 ต.ค. 2569): เส้นบางคั่นจากรายชื่อ/ช่องเพิ่ม */
#teamDialog .team-rights-foot { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--health-border, #d5e2dc); }
/* สิทธิ์ 2 บทบาทอยู่บรรทัดเดียว (เจ้าของระบบ 28 ต.ค. 2569) · จอแคบขึ้นบรรทัดใหม่ได้ */
#teamDialog .team-rights-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
#teamDialog .team-rights-foot li { display: inline-flex; align-items: center; gap: 8px; }
/* ช่องเพิ่มคนอยู่เหนือรายชื่อ (เจ้าของระบบ 27 ต.ค. 2569): เส้นคั่นย้ายไปด้านล่าง */
#teamDialog .team-add { margin: 4px 0 14px; padding: 0 0 14px; border-top: 0; border-bottom: 1px solid #e3e8e5; }
/* QR Check-in / Finish เปลี่ยนทุก 3 วินาที (admin.js startRotatingQr · 28 ต.ค. 2569): ไม่มีปุ่มคัดลอก/พิมพ์ */
.qr-actions[hidden]{display:none}
.qr-rotate-note{margin:0;padding:40px 12px;color:var(--muted);text-align:center}
