/* ============================================================================
   referral-embed.css — สไตล์โมดูล "บันทึกซัดทอดจากผู้เสพ" แบบฝังในฟอร์มอื่น
   ใช้กับ warroom.html (เพิ่มประวัติบุคคล) และ incident-report.html (แจ้งเหตุคนคลุ้มคลั่ง)

   หมายเหตุสำคัญ:
     ไฟล์นี้คัดเฉพาะกฎที่โมดูลต้องใช้มาจาก css/referral.css โดย "ตัด" กฎระดับเอกสาร
     (`*`, `body`, `.wr-main-content`, `.full-page-loader`, `.loader-*`) ออกทั้งหมด
     เพราะกฎเหล่านั้นจะไปทับสไตล์ของหน้าเจ้าบ้าน (host page) ที่ฝังโมดูลนี้เข้าไป

   คลาสทั้งหมดใช้ prefix `.rf-` / `.rff-` / `.rfe-` ซึ่งตรวจแล้วว่าไม่ชนกับคลาสเดิม
   ของทั้งสองหน้า จึงไม่ต้อง scope ซ้อนอีกชั้น (modal ถูกย้ายไปแขวนที่ body
   จึงอยู่นอก .rfe-root — การ scope ด้วย .rfe-root จะทำให้ modal ไม่ได้สไตล์)
   ============================================================================ */

/* ── ปุ่ม ── */
.rf-btn {
  display: inline-flex; align-items: center; gap: .35rem; border: 1px solid transparent;
  border-radius: .5rem; padding: .42rem .95rem; font-size: .8rem; font-weight: 700;
  cursor: pointer; text-decoration: none; transition: all .15s; font-family: inherit;
}
.rf-btn-sm { padding: .3rem .7rem; font-size: .75rem; }
.rf-btn-primary { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3); }
.rf-btn-primary:hover { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; }
.rf-btn-reset { background: #fff; border-color: #cbd5e1; color: #475569; }
.rf-btn-reset:hover { background: #f1f5f9; color: #1e293b; }
.rf-btn-ghost { background: #f1f5f9; border-color: #e2e8f0; color: #334155; }
.rf-btn-ghost:hover { background: #e2e8f0; color: #0f172a; }
.rf-btn-danger { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.rf-btn-danger:hover { background: #fee2e2; color: #991b1b; }
.rf-btn:disabled { opacity: .5; cursor: not-allowed; }

.rf-mini-btn {
  display: inline-flex; align-items: center; gap: .25rem;
  background: #fff; border: 1px solid #cbd5e1; border-radius: .4rem;
  padding: .2rem .5rem; font-size: .75rem; font-weight: 600; color: #475569;
  cursor: pointer; text-decoration: none; white-space: nowrap; font-family: inherit;
}
.rf-mini-btn:hover { background: #f1f5f9; border-color: #94a3b8; color: #1e293b; }

/* ── ช่องติ๊ก / ช่องค้นหา ── */
.rf-check { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; color: #334155; cursor: pointer; margin: 0; }
.rf-check input { width: 16px; height: 16px; accent-color: #2563eb; cursor: pointer; }
.rf-input-icon { position: relative; flex: 1; display: flex; }
.rf-input-icon i { position: absolute; left: .55rem; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: .8rem; }
.rf-input-icon input { padding-left: 1.9rem; width: 100%; }

/* ============================================================================
   กรอบโมดูลฝัง (.rfe-*) — ส่วนที่เพิ่มขึ้นมาจากหน้าฟอร์มเดิม
   ============================================================================ */
.rfe-root { display: flex; flex-direction: column; gap: .75rem; }

.rfe-bar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  background: linear-gradient(135deg, #0d1b4b, #1a3a7a); border-radius: .85rem;
  padding: .7rem 1rem; box-shadow: 0 2px 10px rgba(13,27,75,.2);
}
.rfe-bar-title { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.rfe-bar-title h3 { font-size: .9375rem; font-weight: 800; color: #fff; margin: 0; }
.rfe-bar-title span { font-size: .75rem; color: #a9bce0; }
.rfe-bar-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.rfe-note {
  font-size: .75rem; color: #475569; background: #f1f5fb;
  border: 1px solid #dbe4f0; border-left: 4px solid #0d1b4b; border-radius: .5rem;
  padding: .5rem .75rem; line-height: 1.5;
}
.rfe-note b { color: #0d1b4b; }

/* ป้ายสถานะ "โหมดแก้ไขบันทึกเดิม" */
.rfe-mode-badge {
  display: none; align-items: center; gap: .3rem;
  background: #fef3c7; color: #92400e; border: 1px solid #fde68a;
  border-radius: .4rem; padding: .15rem .5rem; font-size: .7rem; font-weight: 700;
}
.rfe-mode-badge.show { display: inline-flex; }

/* ============================================================================
   ฟอร์ม 17 ขั้นตอน (.rff-*) — คัดมาจาก css/referral.css
   ============================================================================ */
.rff-layout { display: grid; grid-template-columns: 300px 1fr; gap: .75rem; align-items: start; }

/* ── รายการขั้นตอนด้านซ้าย ── */
.rff-steps {
  background: #fff; border: 1px solid #e2e8f0; border-radius: .85rem; padding: .5rem;
  display: flex; flex-direction: column; gap: .2rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.04);
  max-height: 560px; overflow-y: auto; position: sticky; top: 12px;
}
.rff-step {
  display: flex; align-items: center; gap: .55rem; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: .6rem;
  padding: .5rem .6rem; font-size: .8rem; color: #475569; cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.rff-step:hover { background: #f1f5f9; color: #1e293b; }
.rff-step-icon {
  width: 30px; height: 30px; border-radius: .5rem; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #f1f5f9; color: #64748b; font-size: .85rem;
}
.rff-step-text { flex: 1; line-height: 1.25; }
.rff-step.active { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; font-weight: 700; }
.rff-step.active .rff-step-icon { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; }
.rff-step.done .rff-step-icon { background: #dcfce7; color: #16a34a; }
.rff-step.locked { opacity: .65; }
.rff-req { color: #dc2626; margin-left: .15rem; }

/* ── เนื้อหาขั้นตอน ── */
.rff-content { display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.rff-step-header { display: flex; align-items: center; gap: .55rem; }
.rff-step-header h2 { font-size: 1.05rem; font-weight: 800; color: #0f172a; margin: 0; }
.rff-step-badge {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem;
}

.rff-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: .85rem;
  padding: .85rem 1rem; box-shadow: 0 2px 12px rgba(0,0,0,.04);
  display: flex; flex-direction: column; gap: .65rem;
}
.rff-card--accent { border-color: #bfdbfe; background: linear-gradient(180deg, #f8fbff, #fff); }
.rff-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  font-size: .85rem; font-weight: 800; color: #1e293b;
  padding-bottom: .5rem; border-bottom: 1px solid #f1f5f9;
}
.rff-card--accent .rff-card-head { color: #1d4ed8; }
.rff-card-head i { color: #f59e0b; }
.rff-hint-line { font-size: .75rem; color: #64748b; margin-top: -.25rem; }

.rff-grid { display: grid; gap: .65rem; }
.rff-grid--2 { grid-template-columns: repeat(2, 1fr); }
.rff-grid--3 { grid-template-columns: repeat(3, 1fr); }
.rff-grid--4 { grid-template-columns: repeat(4, 1fr); }
.rff-grid--5 { grid-template-columns: repeat(5, 1fr); }

.rff-fld { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.rff-fld > label { font-size: .75rem; font-weight: 600; color: #475569; margin: 0; }
.rff-fld input, .rff-fld select, .rff-fld textarea {
  border: 1px solid #cbd5e1; border-radius: .45rem; padding: .38rem .6rem;
  font-size: .85rem; background: #fff; color: #1e293b; width: 100%; font-family: inherit;
}
.rff-fld input:focus, .rff-fld select:focus, .rff-fld textarea:focus {
  outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.rff-fld input:disabled { background: #f1f5f9; color: #94a3b8; }
.rff-fld textarea { resize: vertical; }
.rff-hint { font-size: .7rem; color: #94a3b8; min-height: .85rem; }
.rff-hint--ok { color: #16a34a; }
.rff-hint--warn { color: #d97706; }
.rff-radio-row { display: flex; gap: .85rem; padding-top: .3rem; }
.rff-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .35rem .75rem; }
.rff-check-lead { font-size: .85rem; font-weight: 700; color: #1e293b; }
.rff-disabled { opacity: .5; }
.rff-empty-line { font-size: .8rem; color: #94a3b8; padding: .5rem 0; }

/* ── ค้นหาบุคคล ── */
.rff-search-person { display: flex; gap: .45rem; position: relative; }
.rff-search-person--modal { margin-bottom: .9rem; }
.rff-search-person .rf-input-icon { flex: 1; }
.rff-search-person .rf-input-icon input {
  border: 1px solid #cbd5e1; border-radius: .45rem; padding: .38rem .6rem .38rem 1.9rem; font-size: .85rem; width: 100%;
}
.rff-suggest {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid #e2e8f0; border-radius: .6rem; box-shadow: 0 10px 30px rgba(0,0,0,.12);
  max-height: 320px; overflow-y: auto;
}
.rff-suggest.open { display: block; }
.rff-suggest-item {
  display: flex; flex-direction: column; gap: .1rem; width: 100%; text-align: left;
  background: none; border: none; border-bottom: 1px solid #f1f5f9; padding: .5rem .75rem; cursor: pointer;
}
.rff-suggest-item:hover { background: #eff6ff; }
.rff-suggest-name { font-size: .85rem; font-weight: 700; color: #1e293b; }
.rff-suggest-meta { font-size: .7rem; color: #64748b; }
.rff-suggest-src { font-size: .65rem; color: #2563eb; font-weight: 700; }
.rff-suggest-empty { padding: .75rem; font-size: .8rem; color: #94a3b8; text-align: center; }

/* ── รายการผู้ถูกซัดทอด ── */
.rff-dealer-list { display: flex; flex-direction: column; gap: .45rem; }
.rff-dealer-item {
  display: flex; align-items: center; gap: .65rem;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: .6rem; padding: .5rem .7rem;
}
.rff-dealer-no {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #dc2626, #991b1b); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 800;
}
.rff-dealer-body { flex: 1; min-width: 0; }
.rff-dealer-name { font-size: .85rem; font-weight: 700; color: #1e293b; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.rff-dealer-nick { font-weight: 500; color: #64748b; font-size: .8rem; }
.rff-dealer-meta { display: flex; gap: .75rem; flex-wrap: wrap; font-size: .75rem; color: #64748b; margin-top: .1rem; }
.rff-dealer-actions { display: flex; gap: .3rem; flex-shrink: 0; }
.rff-role-badge { font-size: .65rem; font-weight: 700; padding: .08rem .4rem; border-radius: .3rem; }
.rff-role-badge--src { background: #fef3c7; color: #92400e; }
.rff-role-badge--def { background: #e0e7ff; color: #3730a3; }

/* ── แถวซ้ำ (repeatable) ── */
.rff-repeat { display: flex; flex-direction: column; gap: .45rem; }
.rff-repeat-row {
  display: grid; grid-template-columns: 26px 1fr 1fr 1fr 1fr 30px; gap: .5rem; align-items: end;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: .6rem; padding: .5rem .6rem;
}
.rff-repeat-no { font-size: .75rem; font-weight: 800; color: #64748b; padding-bottom: .45rem; }
.rff-repeat-del {
  width: 28px; height: 28px; border-radius: .4rem; border: 1px solid #fecaca;
  background: #fef2f2; color: #dc2626; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; font-size: .8rem; padding: 0;
}
.rff-repeat-del:hover { background: #fee2e2; }

/* ── Modal รายละเอียดผู้ถูกซัดทอด ── */
.rff-modal { border-radius: 1rem; border: none; }
.rff-modal .modal-header { border-bottom: 1px solid #e2e8f0; padding: .85rem 1.25rem; }
.rff-modal .modal-title { font-size: .9375rem; font-weight: 800; color: #0f172a; }
.rff-modal .modal-body { padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .7rem; }
.rff-modal .modal-footer { border-top: 1px solid #e2e8f0; padding: .7rem 1.25rem; }
.rff-section-title {
  font-size: .85rem; font-weight: 800; color: #1e293b;
  background: #f1f5f9; border-left: 3px solid #2563eb; border-radius: .3rem;
  padding: .35rem .6rem; margin-top: .3rem;
}
.rff-contact-block { display: flex; flex-direction: column; gap: .35rem; }
.rff-contact-head { display: flex; align-items: center; justify-content: space-between; font-size: .8rem; font-weight: 700; color: #475569; }
.rff-contact-list { display: flex; flex-direction: column; gap: .35rem; }
.rff-contact-row { display: flex; gap: .4rem; align-items: center; }
.rff-contact-row input {
  flex: 1; border: 1px solid #cbd5e1; border-radius: .45rem; padding: .35rem .6rem; font-size: .8rem; font-family: inherit;
}
.rff-contact-row input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }

/* ── ตรวจสอบก่อนบันทึก ── */
.rff-review { display: flex; flex-direction: column; gap: .75rem; }
.rff-review-group { border: 1px solid #e2e8f0; border-radius: .6rem; overflow: hidden; }
.rff-review-title {
  background: #f1f5f9; padding: .4rem .7rem; font-size: .8rem; font-weight: 800; color: #1e293b;
  display: flex; align-items: center; gap: .35rem;
}
.rff-review-title i { color: #2563eb; }
.rff-review-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .35rem .7rem; border-top: 1px solid #f1f5f9; font-size: .8rem; color: #64748b;
}
.rff-review-row b { color: #1e293b; text-align: right; }
.rff-save-row { display: flex; gap: .5rem; justify-content: center; padding-top: .35rem; flex-wrap: wrap; }

/* ── แถบนำทางล่าง ── */
.rff-nav {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  background: #fff; border: 1px solid #e2e8f0; border-radius: .85rem; padding: .6rem .9rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.04);
}
.rff-progress-text { font-size: .8rem; color: #64748b; }
.rff-progress-text b { color: #2563eb; }

@media (max-width: 1100px) {
  .rff-layout { grid-template-columns: 1fr; }
  .rff-steps { position: static; max-height: none; flex-direction: row; overflow-x: auto; }
  .rff-step { min-width: 210px; }
  .rff-grid--4, .rff-grid--5 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .rff-grid--2, .rff-grid--3, .rff-grid--4, .rff-grid--5 { grid-template-columns: 1fr; }
  .rff-repeat-row { grid-template-columns: 1fr; }
  .rff-repeat-no { display: none; }
  .rfe-bar { flex-direction: column; align-items: stretch; }
}

/* โหมดมืดเดิมของไฟล์นี้ถูกถอดออก (ระบบเปลี่ยนเป็นธีมขาว-น้ำเงินแล้ว)
   กฎชุดนั้นเขียนสีเข้มไว้ตายตัวโดยไม่ผ่านโทเคน ชั้นผิว css/warroom-light.css
   จึงทับไม่ได้ทั้งหมด — สไตล์พื้นสว่างเดิมของไฟล์นี้ทำงานต่อได้เลย */
