/* ส่วนที่เขียนทับธีม CORK ให้เข้ากับงานนี้
   - ธีมเดิมใช้ Quicksand ซึ่งไม่มี glyph ภาษาไทย
   - letter-spacing ของธีมทำให้สระ/วรรณยุกต์ไทยดูหลุดจากพยัญชนะ
   ทั้งสองค่าถูกประกาศไว้บน body เท่านั้น ทับที่เดียวจึงพอ
   (Bootstrap 4 reboot ให้ input/button/select/textarea inherit ฟอนต์จาก body อยู่แล้ว) */

:root {
  --app-font: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  font-family: var(--app-font);
  letter-spacing: normal;
  line-height: 1.65;
}

code, pre, .mono {
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
}

/* ---------- การ์ดสถิติหน้าสรุป ---------- */

.stat-card {
  border-radius: 8px;
  padding: 18px 20px;
  color: #fff;
  height: 100%;
}
.stat-card .stat-value { font-size: 28px; font-weight: 600; line-height: 1.2; }
.stat-card .stat-label { font-size: 14px; opacity: .9; }
.stat-total   { background: linear-gradient(135deg, #4361ee, #3f37c9); }
.stat-success { background: linear-gradient(135deg, #1abc9c, #0f9b8e); }
.stat-failed  { background: linear-gradient(135deg, #e7515a, #c2313a); }
.stat-queued  { background: linear-gradient(135deg, #e2a03f, #c8862d); }

/* ---------- คลังคลิป ---------- */

.clip-thumb {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 6px;
  background: #e0e6ed;
  display: block;
}
.clip-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888ea8;
  font-size: 13px;
}
.clip-card .card-body { padding: 14px; }
.clip-meta { font-size: 12.5px; color: #888ea8; }

/* ---------- โพสต์ข่าว ---------- */

/* ติ๊กเลือกรูปด้วยการคลิกที่ตัวรูปเอง — checkbox จริงซ่อนอยู่หลัง label
   ใช้ :checked + .news-pick-box เพื่อไม่ต้องพึ่ง JS ในการวาดกรอบที่เลือก */
.news-pick { position: relative; }
.news-pick input { position: absolute; opacity: 0; pointer-events: none; }
.news-pick-box {
  display: block;
  border: 3px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #e0e6ed;
  transition: border-color .15s;
  margin: 0;
}
.news-pick-box img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}
.news-pick input:checked + .news-pick-box { border-color: #4361ee; }
.news-pick-tag {
  position: absolute;
  top: 10px; left: 10px;
  background: rgba(27, 85, 226, .92);
  color: #fff;
  font-size: 12px;
  border-radius: 20px;
  padding: 2px 10px;
  opacity: 0;
  transition: opacity .15s;
}
.news-pick input:checked ~ .news-pick-tag { opacity: 1; }
.news-pick-meta { font-size: 12px; color: #888ea8; padding-top: 4px; }

/* กล่องเทียบผลรีไรท์ — ซ้ายของเดิม ขวาของ AI ซ้อนกันเป็นแนวตั้งบนจอแคบ */
.ai-compare {
  border: 1px solid #e0e6ed;
  border-radius: 8px;
  padding: 14px;
  background: #fbfbfb;
}
.ai-compare-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 13.5px;
}
.ai-compare-head .ai-meta { font-size: 12px; }
.ai-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 767px) {
  .ai-compare-grid { grid-template-columns: 1fr; }
}
.ai-col-label {
  font-size: 12px;
  color: #888ea8;
  margin-bottom: 4px;
}
.ai-col-label-new { color: #4361ee; font-weight: 600; }
.ai-text {
  background: #fff;
  border: 1px solid #e0e6ed;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  margin: 0;
}
.ai-compare .ai-after { border-color: #4361ee; }
/* คำเตือนตัวเลขไม่ตรง — จุดที่ AI พลาดแล้วเสียหายที่สุดสำหรับเพจข่าว */
.ai-warn {
  background: #fff5e6;
  border-left: 3px solid #e2a03f;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 10px;
}

.news-preview {
  background: #f1f2f3;
  border-radius: 6px;
  padding: 14px;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
}

/* ---------- ทั่วไป ---------- */

.table td, .table th { vertical-align: middle; }
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.err-box {
  background: #fdeaee;
  color: #e7515a;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
}
.badge-pill-sm { font-size: 12px; padding: 3px 10px; }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }

/* ป้ายตัวเลขบนเมนู "ผู้ใช้" ตอนมีคนรออนุมัติ */
.nav-badge {
  background: #e7515a;
  color: #fff;
  border-radius: 99px;
  font-size: 11px;
  padding: 1px 7px;
  margin-left: 6px;
}

/* ปุ่มกากบาทเล็กในป้ายสิทธิ์ (ถอนสิทธิ์เพจ / ปลดการเชื่อม Telegram)
   ต้องเป็น <button> เพราะอยู่ในฟอร์ม POST — จัดให้ดูเหมือนลิงก์ตัวอักษร */
.btn-link-x {
  background: none;
  border: 0;
  padding: 0 0 0 4px;
  color: #e7515a;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.btn-link-x:hover { color: #a01a24; }

/* กล่องรหัสเชื่อม Telegram บนหน้า "บัญชีของฉัน" */
.link-code-box {
  background: #f1f2f3;
  border-radius: 8px;
  padding: 14px 18px;
  text-align: center;
}
.link-code {
  font-family: 'Sarabun', monospace;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 6px;
  color: #4361ee;
}

/* โลโก้มุมซ้ายบนของ rail — ใช้ตัวอักษรแทนไอคอน
   กล่อง .theme-logo กว้าง 43px (65 - margin 11 สองข้าง) และมี padding 7px
   จึงเหลือที่ว่างจริง 29px ตั้ง line-height ให้เท่าความสูงไอคอนเดิม (24px)
   ตัวอักษรจะได้อยู่กึ่งกลางพอดีเหมือนตอนเป็น SVG */
.sidebar-wrapper #compactSidebar .theme-logo a.logo-text {
  display: block;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
}
.sidebar-wrapper #compactSidebar .theme-logo a.logo-text:hover {
  color: #fff;
  text-decoration: none;
}

/* ─────────── หน้าคู่มือ (/help) ───────────
   เนื้อหามาจาก pandoc แปลง docs/*.md เป็น HTML fragment จึงเป็นแท็กดิบ ๆ
   (h1-h4, p, ul, ol, table, pre, code, blockquote) ต้องจัดสไตล์เองทั้งหมด
   เพราะธีม CORK ไม่ได้เตรียมสไตล์สำหรับเนื้อหาแบบบทความไว้ */
.help-doc {
  max-width: 860px;
  font-size: 15px;
  line-height: 1.75;
  color: #3b3f5c;
}
.help-doc h1 {
  font-size: 26px;
  font-weight: 700;
  color: #4361ee;
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e0e6ed;
}
.help-doc h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 38px 0 14px;
  scroll-margin-top: 80px;      /* header fixed 60px ทับหัวข้อตอนกดสารบัญ */
}
.help-doc h3 { font-size: 17px; font-weight: 600; margin: 26px 0 10px; }
.help-doc h4 { font-size: 15px; font-weight: 600; margin: 20px 0 8px; }
.help-doc p { margin-bottom: 14px; }
.help-doc ul, .help-doc ol { padding-left: 22px; margin-bottom: 16px; }
.help-doc li { margin-bottom: 7px; }
.help-doc li > p { margin-bottom: 6px; }
.help-doc a { color: #4361ee; text-decoration: underline; }
.help-doc hr { margin: 32px 0; border-color: #e0e6ed; }
.help-doc strong { color: #0e1726; }

.help-doc code {
  background: #f1f2f3;
  color: #e7515a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  word-break: break-word;
}
.help-doc pre {
  background: #0e1726;
  border-radius: 6px;
  padding: 14px 16px;
  overflow-x: auto;
  margin-bottom: 18px;
}
.help-doc pre code {
  background: none;
  color: #e0e6ed;
  padding: 0;
  font-size: 13px;
}

.help-doc blockquote {
  margin: 18px 0;
  padding: 12px 18px;
  background: #eef2ff;
  border-left: 4px solid #4361ee;
  border-radius: 0 6px 6px 0;
}
.help-doc blockquote > :last-child { margin-bottom: 0; }
.help-doc blockquote h3 { margin-top: 4px; font-size: 15px; }

/* ตารางในเอกสารมักกว้างกว่าจอมือถือ — ให้เลื่อนในกรอบตัวเองแทนที่จะดันทั้งหน้า */
.help-doc table {
  width: 100%;
  margin-bottom: 20px;
  border-collapse: collapse;
  font-size: 13.5px;
  display: block;
  overflow-x: auto;
}
.help-doc th, .help-doc td {
  border: 1px solid #e0e6ed;
  padding: 9px 12px;
  vertical-align: top;
}
.help-doc th { background: #f1f2f3; font-weight: 600; text-align: left; }
.help-doc tbody tr:nth-child(even) { background: #fafafa; }

/* สารบัญที่ JS สร้างจากหัวข้อ h2 */
.doc-toc {
  background: #f1f2f3;
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 26px;
  max-width: 860px;
}
.doc-toc-title { font-weight: 600; font-size: 13px; color: #888ea8; margin-bottom: 6px; }
.doc-toc ul { list-style: none; padding: 0; margin: 0; columns: 2; }
.doc-toc li { margin-bottom: 4px; break-inside: avoid; }
.doc-toc a { font-size: 13.5px; color: #4361ee; }

/* การ์ดรายการเอกสารในหน้า /help */
a.doc-card { display: block; height: 100%; color: inherit; transition: box-shadow .15s; }
a.doc-card:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
a.doc-card h6 { color: #4361ee; font-weight: 600; }

/* พิมพ์ออกกระดาษ: เอาเมนู/หัว/ท้าย/ปุ่มออก เหลือแต่เนื้อหา */
@media print {
  .header-container, .sidebar-wrapper, .footer-wrapper,
  .doc-toolbar, .doc-toc, .alert { display: none !important; }
  #content { margin-left: 0 !important; }
  .layout-px-spacing, .widget-content { padding: 0 !important; box-shadow: none !important; }
  .help-doc { max-width: none; font-size: 12pt; }
  .help-doc pre { background: #f1f2f3; }
  .help-doc pre code { color: #0e1726; }
  .help-doc a { text-decoration: none; color: #0e1726; }
}

/* ── กล่องยืนยัน (แทน confirm() ของเบราว์เซอร์) ─────────────────────────
   ธีม CORK ไม่มีสไตล์ modal แบบ "ถามก่อนทำ" มาให้ จึงจัดเองให้เข้าชุดกับการ์ด */
.confirm-modal .modal-content {
  border: none;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.confirm-modal .modal-body { padding: 32px 28px 20px; }
.confirm-modal .modal-footer { border-top: none; padding: 0 28px 26px; justify-content: center; }
.confirm-modal .modal-footer .btn { min-width: 110px; }
.confirm-modal h5 { font-weight: 600; color: #0e1726; }
.confirm-modal p { font-size: 13.5px; }

/* วงกลมสีส้มรอบไอคอนเตือน ให้สายตาไปหยุดตรงกลางกล่องก่อนอ่านข้อความ */
.confirm-modal-icon {
  width: 62px; height: 62px; margin: 0 auto;
  border-radius: 50%;
  background: #fff5e6;
  display: flex; align-items: center; justify-content: center;
}
.confirm-modal-icon svg { width: 30px; height: 30px; color: #e2a03f; stroke: #e2a03f; }
