/* =============================================================================
   Feedback Dashboard — CSS เฉพาะระบบ (prefix fb-) โหลดหลัง ds-ui.css
   ใช้สีจาก token var(--ds-*) เท่านั้น (template/AI-UI-GUIDE.md §3.5)
   ========================================================================== */

/* ---------- ข้อความ / บล็อกเล็ก ---------- */
.fb-strong{ font-weight:var(--ds-fw-medium, 500); }
.fb-break{ overflow-wrap:anywhere; }
.fb-subhead{
  margin:0 0 8px;
  font-size:13px;
  font-weight:500;
  color:var(--ds-ink-2);
}
.fb-comment{
  padding:12px 14px;
  border-radius:var(--ds-r-md);
  background:var(--ds-surface-2);
  color:var(--ds-ink);
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  line-height:1.7;
}
.fb-comment-cell{ max-width:360px; color:var(--ds-ink-2); }
.fb-modal-body{ display:flex; flex-direction:column; gap:var(--ds-gap); }
.fb-apex{ min-height:280px; }

/* checkbox ในแถบตัวกรอง: สูงเท่า ds-input เพื่อให้แนวตรงกัน */
.fb-check-lg{ min-height:39px; display:inline-flex; align-items:center; }

/* Top 10: ชื่อระบบยาว → ชื่อเต็มอยู่บรรทัดบน แท่งกับตัวเลขอยู่บรรทัดล่าง */
.fb-top-bars .ds-bar{ grid-template-columns:1fr auto; row-gap:4px; }
.fb-top-bars .ds-bar__label{ grid-column:1 / -1; white-space:normal; overflow:visible; line-height:1.4; }
.fb-top-bars .ds-bar__value{ min-width:28px; }

/* หน้าลิงก์แบบสำรวจ */
.fb-links-search{ width:260px; max-width:100%; }
.fb-links-table .fb-link-url{ word-break:break-all; font-size:13px; }
.fb-links-table td{ vertical-align:middle; }
.fb-links-table .ds-pill{ margin-left:6px; }
.fb-link-actions{ display:flex; gap:6px; justify-content:flex-end; white-space:nowrap; }
.fb-links-empty{ padding:16px 0 4px; text-align:center; }
.fb-steps{ margin:8px 0 12px; padding-left:22px; line-height:1.8; }
.fb-code{ margin:6px 0; padding:10px 12px; border-radius:var(--ds-r-sm); background:var(--ds-surface-2); border:1px solid var(--ds-line); font-size:13px; overflow-x:auto; }
/* QR: พื้นขาวเสมอ เพื่อให้สแกนได้ในโหมดมืด */
.fb-qr{ width:240px; max-width:100%; margin:8px auto 4px; padding:8px; background:#fff; border-radius:var(--ds-r-md); }
.fb-qr svg{ display:block; width:100%; height:auto; }
.fb-qr-url{ text-align:center; font-size:12px; word-break:break-all; margin:0 0 8px; }

/* legend แนวนอนใต้กราฟ Top 10 */
.ds-legend.fb-legend-inline{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:4px 16px;
  margin-top:10px;
}

/* ---------- ไฟล์แนบ ---------- */
.fb-files{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(150px, 1fr));
  gap:8px;
}
.fb-file{
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width:0;
  padding:6px;
  border:1px solid var(--ds-line);
  border-radius:var(--ds-r-md);
  background:var(--ds-surface);
  color:var(--ds-ink);
  text-decoration:none;
  transition:border-color var(--ds-dur-fast);
}
.fb-file:hover{ border-color:var(--ds-link); text-decoration:none; }
.fb-file__thumb{
  width:100%;
  height:110px;
  object-fit:cover;
  border-radius:calc(var(--ds-r-md) - 2px);
  background:var(--ds-surface-2);
}
.fb-file__icon{
  display:flex;
  align-items:center;
  justify-content:center;
  height:110px;
  border-radius:calc(var(--ds-r-md) - 2px);
  background:var(--ds-cancel-bg);
  color:var(--ds-cancel-ink);
}
.fb-file__name{ font-size:13px; font-weight:500; }

/* ---------- DataTables (ไม่โหลด CSS theme ของ DataTables) ---------- */
.fb-dt-bar{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:8px 16px;
  padding:6px 0;
  color:var(--ds-ink-2);
  font-size:13px;
}
.fb-dt .dataTables_wrapper{ position:relative; }
.fb-dt .dataTables_length label,
.fb-dt .dataTables_filter label{ display:inline-flex; align-items:center; gap:6px; margin:0; }
.fb-dt .dataTables_filter input{ min-width:200px; }
.fb-dt .dataTables_processing{
  position:absolute;
  top:48px;
  left:50%;
  transform:translateX(-50%);
  z-index:2;
  padding:6px 14px;
  border-radius:var(--ds-r-pill);
  background:var(--ds-surface);
  box-shadow:var(--ds-shadow-pop);
  color:var(--ds-ink-2);
}
.fb-dt .dataTables_processing > div{ display:none; } /* จุดเคลื่อนไหวของ DataTables */
.fb-dt .dataTables_paginate{ display:flex; flex-wrap:wrap; gap:4px; }
.fb-dt .dataTables_paginate > span{ display:inline-flex; gap:4px; }
.fb-dt .paginate_button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:32px;
  height:32px;
  padding:0 8px;
  border:1px solid var(--ds-line);
  border-radius:var(--ds-r-md);
  background:var(--ds-surface);
  color:var(--ds-ink);
  cursor:pointer;
  text-decoration:none;
  user-select:none;
}
.fb-dt .paginate_button:hover{ background:var(--ds-surface-2); text-decoration:none; color:var(--ds-ink); }
.fb-dt .paginate_button.current{
  border-color:var(--ds-primary);
  background:var(--ds-primary);
  color:var(--ds-on-color);
}
.fb-dt .paginate_button.disabled{ opacity:.45; cursor:default; pointer-events:none; }
.fb-dt .paginate_button:focus-visible{ outline:2px solid var(--ds-focus); outline-offset:2px; }
.fb-dt .ellipsis{ padding:0 4px; color:var(--ds-ink-3); }

/* ลูกศรเรียงคอลัมน์ */
.fb-dt table.dataTable thead th.sorting,
.fb-dt table.dataTable thead th.sorting_asc,
.fb-dt table.dataTable thead th.sorting_desc{ cursor:pointer; white-space:nowrap; }
.fb-dt table.dataTable thead th.sorting::after,
.fb-dt table.dataTable thead th.sorting_asc::after,
.fb-dt table.dataTable thead th.sorting_desc::after{
  margin-left:6px;
  font-size:11px;
  color:var(--ds-ink-3);
}
.fb-dt table.dataTable thead th.sorting::after{ content:"\2195"; }
.fb-dt table.dataTable thead th.sorting_asc::after{ content:"\25B2"; color:var(--ds-link); }
.fb-dt table.dataTable thead th.sorting_desc::after{ content:"\25BC"; color:var(--ds-link); }
.fb-dt table.dataTable td.dataTables_empty{ padding:24px; text-align:center; color:var(--ds-ink-3); }

/* ---------- Tom Select (เลือกหลายระบบ) ---------- */
.ts-wrapper.ds-select{ padding:0; border:0; background:none; height:auto; }
.ts-wrapper .ts-control{
  min-height:39px;
  padding:4px 8px;
  border:1px solid var(--ds-line-strong);
  border-radius:var(--ds-r-md);
  background:var(--ds-surface-2);
  color:var(--ds-ink);
  font:inherit;
  font-size:14px;
  box-shadow:none;
}
.ts-wrapper.focus .ts-control{
  border-color:var(--ds-focus);
  box-shadow:0 0 0 3px color-mix(in srgb, var(--ds-focus) 20%, transparent);
}
.ts-wrapper .ts-control input{ color:var(--ds-ink); font:inherit; }
.ts-wrapper .ts-control input::placeholder{ color:var(--ds-ink-3); }
.ts-wrapper.multi .ts-control > .item{
  margin:2px;
  padding:1px 6px;
  border:1px solid transparent;
  border-radius:var(--ds-r-sm);
  background:var(--ds-progress-bg);
  color:var(--ds-progress-ink);
  font-size:13px;
}
.ts-wrapper.plugin-remove_button .item .remove{ border-left-color:var(--ds-line); color:inherit; }
.ts-dropdown{
  margin-top:4px;
  border:1px solid var(--ds-line);
  border-radius:var(--ds-r-md);
  background:var(--ds-surface);
  color:var(--ds-ink);
  box-shadow:var(--ds-shadow-pop);
  z-index:var(--ds-z-dropdown);
}
.ts-dropdown .option,
.ts-dropdown .no-results{ padding:6px 10px; }
.ts-dropdown .active{ background:var(--ds-surface-2); color:var(--ds-ink); }
.ts-dropdown .no-results{ color:var(--ds-ink-3); }
.ts-dropdown .optgroup-header{
  padding:6px 10px 2px;
  background:var(--ds-surface);
  color:var(--ds-ink-3);
  font-size:12px;
  font-weight:500;
}
.ts-dropdown .optgroup + .optgroup{ border-top:1px solid var(--ds-line); }

/* ---------- หน้าแบบสำรวจสาธารณะ (submit.php) ไม่มี shell ---------- */
.fb-public{
  width:100%;
  max-width:880px;
  margin:0 auto;
  padding:24px 16px 48px;
}
.fb-public__head{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:var(--ds-gap);
}
.fb-public__logo{ flex:none; }
.fb-public__titles{ flex:1; min-width:0; }
.fb-public__title{ margin:0; font-size:22px; font-weight:600; color:var(--ds-ink); }
.fb-public__sub{ margin:2px 0 0; color:var(--ds-ink-2); font-size:14px; }
.fb-public__ref{ display:block; max-width:100%; color:var(--ds-ink-2); font-size:13px; }

.fb-rates-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(320px, 1fr));
  gap:4px 24px;
}
.fb-rate{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:4px 12px;
  min-width:0;
  margin:0;
  padding:8px 0;
  border:0;
  border-bottom:1px solid var(--ds-line);
}
.fb-rate__label{ float:left; padding:0; color:var(--ds-ink); font-size:14px; }
.fb-rate__control{ display:inline-flex; align-items:center; gap:8px; }
.fb-rate__val{ min-width:28px; color:var(--ds-ink-2); font-size:13px; }

/* ดาว: input เรียง 5→1 แล้วกลับด้านด้วย row-reverse เพื่อใช้ ~ ระบายดาวทางซ้าย */
.fb-stars{ display:inline-flex; flex-direction:row-reverse; }
.fb-stars input{ position:absolute; opacity:0; width:1px; height:1px; pointer-events:none; }
.fb-stars label{
  padding:0 2px;
  font-size:26px;
  line-height:1;
  color:var(--ds-line-strong);
  cursor:pointer;
  transition:color var(--ds-dur-fast), transform var(--ds-dur-fast);
}
.fb-stars input:checked ~ label,
.fb-stars label:hover,
.fb-stars label:hover ~ label{ color:var(--ds-orange); }
.fb-stars label:hover{ transform:scale(1.12); }
.fb-stars input:focus-visible + label{
  outline:2px solid var(--ds-focus);
  outline-offset:1px;
  border-radius:var(--ds-r-sm);
}

.fb-form-3{ grid-template-columns:repeat(auto-fit, minmax(200px, 1fr)); }

.fb-thanks{ padding-block:40px; }
.fb-thanks__icon{ color:var(--ds-done-ink); }

@media (max-width:480px){
  .fb-public{ padding-top:16px; }
  .fb-public__title{ font-size:19px; }
  .fb-rates-grid{ grid-template-columns:1fr; }
  .fb-stars label{ font-size:30px; padding:0 3px; }
}

/* ---------- ApexCharts tooltip ตามธีม ---------- */
.fb-apex .apexcharts-tooltip,
.fb-apex .apexcharts-xaxistooltip{ font-family:var(--ds-font); }
