/* ---------- สิ่งที่ส่งมาด้วย ---------- */
/* ไฟล์ Word ราชการที่ใช้ฟอนต์ TH SarabunIT๙ แสดงถูกแม้เครื่องผู้อ่านไม่มีฟอนต์ (เลขไทยตามฟอนต์จริง)
   ไม่ผูก TH SarabunPSK กับไฟล์นี้ เพราะฟอนต์ IT๙ เปลี่ยนเลขอารบิกเป็นเลขไทย ตัวเลขในเอกสารจะผิดไป */
@font-face { font-family: "TH SarabunIT๙"; src: local("TH SarabunIT๙"), url("../assets/fonts/THSarabunIT9.ttf") format("truetype"); font-weight: 400; }
@font-face { font-family: "TH SarabunIT๙"; src: local("TH SarabunIT๙ Bold"), url("../assets/fonts/THSarabunIT9-Bold.ttf") format("truetype"); font-weight: 700; }

.icon-btn {
  width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text-2); font-size: 18px; cursor: pointer; transition: background .2s, color .2s, transform .2s var(--spring);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-btn:active:not(:disabled) { transform: scale(.92); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-bg); border-color: transparent; }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }

.att-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.att-item {
  display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 4px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); animation: rise .35s var(--ease) both; transition: border-color .2s, box-shadow .2s;
}
.att-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.att-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border: 0; background: none; border-radius: 9px;
  color: inherit; text-align: left; font: inherit; text-decoration: none; cursor: pointer;
}
div.att-main { cursor: default; }
.att-main:focus-visible { outline: none; box-shadow: var(--ring); }
.att-txt { min-width: 0; display: grid; }
.att-txt b { font-weight: 500; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-txt small { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-go { margin-left: auto; color: var(--text-3); }
.att-ic { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; font-size: 20px; color: #fff; }
.att-ic.big { width: 72px; height: 72px; font-size: 38px; border-radius: 18px; }
.att-ic.k-pdf { background: #dc2626; }
.att-ic.k-doc { background: #2563eb; }
.att-ic.k-xls { background: #15803d; }
.att-ic.k-ppt { background: #ea580c; }
.att-ic.k-img { background: #9333ea; }
.att-ic.k-zip { background: #a16207; }
.att-ic.k-txt { background: #64748b; }
.att-ic.k-link { background: #0891b2; }
.att-item.is-wait .att-ic { opacity: .55; }
.att-item.is-up .att-ic i { animation: spin 1s linear infinite; }
.att-item.is-ok .att-ic { background: var(--success); }
.att-item.is-fail .att-ic { background: var(--danger); }
.att-item.is-ok { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.att-item.is-fail { border-color: var(--danger); background: var(--danger-bg); }
@keyframes spin { to { transform: rotate(360deg); } }

.att-body { display: grid; gap: 12px; }
.att-text { margin: 0; display: flex; gap: 8px; align-items: flex-start; color: var(--text-2); font-size: 14px; }
.att-text i { color: var(--text-3); margin-top: 3px; }
.att-tools { gap: 8px; }
.att-tools label { cursor: pointer; }
.att-uploading { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--info); background: var(--info-bg); padding: 8px 12px; border-radius: 10px; }
.att-uploading i { animation: spin 1s linear infinite; }

/* หน้าลงรับ: พื้นที่วางไฟล์แนบ */
.drop.drop-sm .drop-empty { padding: 20px 14px; }
.drop.drop-sm .drop-empty > i { font-size: 30px; color: var(--orange-500); }
.att-pick-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.att-pick-tools .muted { font-size: 13px; }

/* หน้าเกษียน: รายการแบบย่อ */
.att-mini .att-list { margin-top: 8px; }
.att-mini .att-item { background: var(--surface); }

/* ---------- หน้าต่างเปิดไฟล์ ---------- */
dialog.viewer {
  border: 0; padding: 0; margin: auto; width: min(1100px, calc(100vw - 24px)); height: calc(100dvh - 24px); max-height: none;
  max-width: none; border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
dialog.viewer:not([open]) { display: none; }
dialog.viewer[open] { animation: modal-in .3s var(--ease); }
dialog.viewer::backdrop { background: rgba(6, 15, 43, .65); backdrop-filter: blur(4px); }
.viewer-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--border); }
.viewer-title { flex: 1; min-width: 0; display: grid; }
.viewer-title b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title small { color: var(--text-3); font-size: 12.5px; }
.viewer-head .toolbar { gap: 4px; flex-wrap: nowrap; }
.viewer-body { flex: 1; min-height: 0; overflow: auto; background: var(--surface-2); }
.viewer-body .pdf-view { padding: 12px; max-width: 900px; margin: 0 auto; }
.viewer-note { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 13px; color: var(--text-2); border-top: 1px solid var(--border); background: var(--surface); }
.img-view { min-height: 100%; display: grid; place-items: center; padding: 12px; }
.img-view img { max-width: 100%; height: auto; border-radius: 8px; box-shadow: var(--shadow); background: #fff; }
.txt-view { margin: 0; padding: 18px; white-space: pre-wrap; word-break: break-word; font: 14px/1.7 var(--font); }
.no-preview { min-height: 100%; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 32px 20px; text-align: center; }
.no-preview p { margin: 0; max-width: 360px; }

/* Word: หน้ากระดาษจาก docx-preview */
.docx-host { padding: 8px 0; }
.docx-host .docx-wrapper { background: transparent !important; padding: 16px !important; }
.docx-host section.docx { box-shadow: 0 6px 24px -10px rgba(15, 39, 102, .45) !important; margin-bottom: 16px !important; color: #111; }

/* Excel: ตาราง */
.sheet-view { display: flex; flex-direction: column; height: 100%; }
.sheet-tabs { display: flex; gap: 4px; padding: 8px 10px 0; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); flex: none; }
.sheet-tabs button {
  border: 1px solid var(--border); border-bottom: 0; background: var(--surface-2); color: var(--text-2); padding: 7px 14px; border-radius: 10px 10px 0 0;
  font: inherit; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.sheet-tabs button.on { background: #fff; color: #15803d; font-weight: 600; box-shadow: inset 0 3px 0 #15803d; }
.sheet-table { flex: 1; overflow: auto; background: #fff; }
table.xls { border-collapse: collapse; font-size: 13.5px; color: #111; font-family: var(--font); }
table.xls th, table.xls td { border: 1px solid #dfe3ea; padding: 4px 8px; white-space: pre-wrap; vertical-align: top; max-width: 420px; min-width: 48px; }
table.xls thead th { position: sticky; top: 0; background: #f1f4f8; color: #4a5470; font-weight: 500; z-index: 1; text-align: center; }
table.xls tbody th { position: sticky; left: 0; background: #f1f4f8; color: #7b85a0; font-weight: 400; text-align: right; min-width: 40px; }
table.xls thead th:first-child { left: 0; z-index: 2; }

@media (max-width: 640px) {
  dialog.viewer { width: 100vw; height: 100dvh; border-radius: 0; }
  .hide-sm { display: none; }
  .viewer-head { padding: 8px; gap: 8px; }
  .viewer-head .att-ic { display: none; }
}

.jump-att { border: 0; font: inherit; font-size: 12.5px; cursor: pointer; }
.jump-att:hover { filter: brightness(1.08); }
#att-slot { scroll-margin-top: 80px; }
.att-mini summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.att-mini summary::-webkit-details-marker { display: none; }
.att-mini summary::after { content: "แสดง"; font-size: 12.5px; color: var(--blue-600); }
.att-mini[open] summary::after { content: "ซ่อน"; }
