/* หน่วยงานทดสอบ AI - Dashboard page (Figma node 121:2569 "dashboard") */

/* ===== Layout shell ===== */
.workspace-body {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px;
  width: 100%;
}

.card,
.hero-card,
.kpi-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 16px;
}
/* admin.css stacks adjacent cards vertically; on this page cards sit side by side
   inside flex rows, so neutralise that shared rule here (page-scoped override). */
.card + .card { margin-top: 0; }

/* shared icon sizing */
.icon-16 { width: 16px; height: 16px; display: block; }
.icon-14 { width: 14px; height: 14px; display: block; }
.dot-8   { width: 8px;  height: 8px;  display: block; }
.icon-container {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ===== Hero summary card ===== */
.hero-card { padding: 28px; }
.summary-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}
.title-block { display: flex; flex-direction: column; gap: 8px; }
.hero-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-01);
  line-height: normal;
}
.hero-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-500);
  line-height: normal;
}

.hero-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  flex-shrink: 0;
}
.controls { display: flex; align-items: center; gap: 12px; }

/* ===== Export buttons (TOR 5.5.2) ===== */
.export-group { display: flex; align-items: center; gap: 8px; }
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 8px;
  font-family: var(--font-thai);
  font-size: 13px;
  font-weight: 600;
  line-height: normal;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease;
}
.btn-export svg { width: 15px; height: 15px; display: block; flex-shrink: 0; }
.btn-export--xlsx { background: var(--color-01); color: #fff; }
.btn-export--xlsx:hover { background: #1d3a80; }
.btn-export--csv {
  background: var(--bg-white);
  color: var(--color-01);
  border-color: var(--border-active);
}
.btn-export--csv:hover { background: var(--bg-active); }

.date-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-chip);
  border-radius: 8px;
}
.date-tabs .tab {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-500);
  line-height: normal;
  background: transparent;
  transition: background .15s ease, color .15s ease;
  white-space: nowrap;
}
.date-tabs .tab:hover { color: var(--color-01); }
.date-tabs .tab.is-active {
  background: var(--bg-white);
  color: var(--color-01);
  font-weight: 700;
}

.date-picker { position: relative; }
.date-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-900);
  line-height: normal;
  white-space: nowrap;
}
.date-btn:hover { border-color: var(--border-active); background: var(--bg-active); }
.date-btn[aria-expanded="true"] img { transform: rotate(180deg); }
.date-btn img { transition: transform .15s ease; }

.date-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: 148px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .1);
}
.date-menu[hidden] { display: none; }
.date-menu button {
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-700);
}
.date-menu button:hover { background: var(--bg-active); color: var(--color-01); }

/* ===== KPI cards (5 ใบ) ===== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
  width: 100%;
}
.kpi-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}
.kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-500);
  line-height: normal;
}
.icon-bg {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-bg--navy   { background: #f0f5ff; }
.icon-bg--orange { background: #ffe2d7; }
.icon-bg--purple { background: #faf5ff; }
.icon-bg--green  { background: #def7ec; }
.icon-bg--teal   { background: #ccfbf1; }

.kpi-metric { line-height: normal; white-space: nowrap; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: normal; }
.kpi-value--navy   { color: var(--color-01); }
.kpi-value--orange { color: var(--color-02); }
.kpi-value--purple { color: #7c3aed; }
.kpi-value--green  { color: var(--success-600); }
.kpi-value--teal   { color: #0d9488; }
.kpi-unit { font-size: 13px; font-weight: 500; color: var(--text-500); }
.kpi-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-500);
  line-height: normal;
  margin-top: -4px;
}

/* ===== Charts row ===== */
.charts-row { display: flex; gap: 16px; align-items: stretch; width: 100%; }

.card-title { display: flex; flex-direction: column; gap: 4px; }
.card-title h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-01);
  line-height: normal;
}
.card-title p {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-500);
  line-height: normal;
}

.query-volume-card {
  flex: 1 0 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-item p { font-size: 12px; font-weight: 400; color: var(--text-500); line-height: normal; }

.chart-body { display: flex; flex-direction: column; gap: 16px; width: 100%; }

.plot {
  position: relative;
  height: 180px;
  width: 100%;
  overflow: hidden;
}
.grid-back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.grid-back i {
  display: block;
  height: 1px;
  width: 100%;
  background: #f1f5f9;
}
.plot-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 213.913px;
  display: block;
}

.x-axis {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
}
.x-axis p {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-500);
  line-height: normal;
  white-space: nowrap;
}

.chart-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.chart-note { display: flex; align-items: center; gap: 4px; }
.chart-note p { font-size: 12px; font-weight: 400; color: var(--text-500); line-height: normal; }
.chart-avg { font-size: 12px; font-weight: 600; color: var(--color-02); line-height: normal; }

/* ===== Topic distribution ===== */
.topic-distribution-card {
  width: 420px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
}
.bars-list { display: flex; flex-direction: column; gap: 16px; width: 100%; }
.bar-item { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.label-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  font-size: 13px;
  line-height: normal;
}
.bar-name  { font-weight: 600; color: var(--text-900); }
.bar-value { font-weight: 700; color: var(--color-01); white-space: nowrap; }
.progress {
  height: 8px;
  width: 100%;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  background: var(--color-02);
  border-radius: 4px;
}

/* ===== Bottom row ===== */
.bottom-row { display: flex; gap: 16px; align-items: stretch; width: 100%; }

.top-topics-card {
  flex: 1 0 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
}
.card-header-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.rows-list { display: flex; flex-direction: column; width: 100%; }
.topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s ease;
}
.topic-row.is-last { border-bottom: none; }
.topic-row:hover { background: var(--bg-active); }
.rank-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.num {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--bg-chip);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-500);
  line-height: normal;
}
.topic-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-900);
  line-height: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topic-metric {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-500);
  line-height: normal;
  white-space: nowrap;
}

/* ===== Reported issues ===== */
.issues-list { display: flex; flex-direction: column; gap: 10px; width: 100%; }

/* ประเด็นที่ผู้ใช้แจ้ง - แถบรองในการ์ดความคิดเห็นและการแจ้งปัญหาจากผู้ใช้ */
.issues-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.issues-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.issues-head h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-900);
  line-height: normal;
}
.issues-head p {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-500);
  line-height: normal;
}
.issues-block .issues-list {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}
.issues-block .issue-item {
  width: auto;
  flex: 0 1 auto;
  padding: 7px 12px;
  border-radius: 999px;
}
.issues-block .issue-left { gap: 8px; }
.issues-block .issue-left p { font-size: 12.5px; font-weight: 500; }
.issue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px;
  background: #fff9f5;
  border: 1px solid #fee2e2;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.issue-item:hover { background: #fff3ea; border-color: #fbcfcf; }
.issue-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.issue-left p {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-900);
  line-height: normal;
}

.status-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.status-left { font-size: 12px; font-weight: 400; color: var(--text-500); line-height: normal; }

.standard-compliance { display: flex; align-items: center; gap: 6px; }
.standard-compliance p {
  font-size: 12px;
  font-weight: 600;
  color: var(--success-700);
  line-height: normal;
  white-space: nowrap;
}

/* ===== คำตอบที่ถูกแจ้งว่าไม่ถูกต้อง (คิวคำตอบถูกแจ้งผิด) ===== */
.flagged-row { display: flex; width: 100%; }
.flagged-card {
  flex: 1 0 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
}
.link-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-02);
  white-space: nowrap;
}
.link-more svg { width: 13px; height: 13px; display: block; }
.link-more:hover { text-decoration: underline; }

.flagged-tbl { width: 100%; border-collapse: collapse; }
.flagged-tbl th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-500);
  padding: 9px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  line-height: normal;
  white-space: nowrap;
}
.flagged-tbl th:first-child { border-radius: 8px 0 0 0; }
.flagged-tbl th:last-child  { border-radius: 0 8px 0 0; }
.flagged-tbl td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-700);
  vertical-align: middle;
  line-height: normal;
}
.flagged-tbl tbody tr:last-child td { border-bottom: none; }
.flagged-tbl tbody tr:hover td { background: #fbfcfe; }
.flagged-tbl .col-q { width: 46%; min-width: 0; }
.flagged-tbl .q-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-900);
}
.flagged-tbl .col-by { white-space: nowrap; }
.flagged-tbl th.col-date { text-align: right; }
.flagged-tbl .col-date {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  color: var(--text-500);
  font-weight: 500;
}
.flagged-tbl .col-status { width: 110px; }
.flagged-tbl .col-owner  { width: 190px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-thai);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter .15s ease;
}
.chip::before {
  content: "";
  width: 6px; height: 6px; border-radius: 3px;
  background: currentColor;
}
.chip:hover { filter: brightness(.96); }
.chip-new    { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.chip-fixing { background: var(--warn-bg); color: var(--warn-700); border-color: #fde68a; }
.chip-done   { background: var(--success-bg); color: var(--success-700); border-color: #a7f3d0; }

.owner-select {
  width: 100%;
  font-family: var(--font-thai);
  font-size: 12px;
  color: var(--text-700);
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
}
.owner-select:hover { border-color: var(--border-active); }
.owner-select:focus { outline: 2px solid var(--border-active); border-color: var(--border-active); }

/* ===== Toast (shell.js) ===== */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--color-01); color: #fff; font-size: 13px; font-weight: 500;
  padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: all .2s ease; z-index: 200; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== responsive: KPI grid + main columns ===== */
@media (max-width: 1360px) {
  .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
