/* KME TAKE LEAVE — In-app attachment viewer (lightbox)
 * เปิดไฟล์แนบ (image/PDF) ในแอป มีปุ่มปิด/ย้อนกลับ
 * แก้ปัญหา PWA standalone (iOS) เปิดไฟล์แล้วไม่มี browser chrome ให้กดออก
 */
.att-viewer {
  position: fixed;
  inset: 0;
  z-index: 2000; /* เหนือ navbar + toast */
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.92);
}
.att-viewer[hidden] {
  display: none;
}

.att-viewer__bar {
  display: flex;
  align-items: center;
  justify-content: flex-end; /* ปุ่ม (เปิดแท็บใหม่ + ปิด) ชิดขวา */
  gap: 8px;
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(0, 0, 0, 0.55);
}
.att-viewer__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 15px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
.att-viewer__btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.att-viewer__body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding-bottom: env(safe-area-inset-bottom);
}
.att-viewer__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.att-viewer__frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
/* PDF render ในแอป (iOS, pdf.js) — เต็มความสูง scroll ภายใน คงปุ่มปิดบน bar ไว้ */
.att-viewer__pdf {
  align-self: stretch; /* override align-items:center ของ body → ไม่ตัดบนตอน scroll */
  width: 100%;
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 8px 24px;
}
.att-viewer__page {
  display: block;
  width: 100%;
  height: auto;
  max-width: 920px;
  margin: 0 auto 10px;
  background: #fff;
  border-radius: 2px;
}
.att-viewer__fallback {
  color: #fff;
  text-align: center;
  padding: 24px;
  line-height: 1.8;
}
.att-viewer__fallback a {
  color: #9ec5ff;
}

.att-viewer__img[hidden],
.att-viewer__frame[hidden],
.att-viewer__pdf[hidden] {
  display: none;
}

.att-viewer--loading .att-viewer__body::after {
  content: "กำลังโหลด…";
  color: #fff;
  font-size: 15px;
}

body.att-viewer-open {
  overflow: hidden; /* ล็อก scroll หน้าหลังขณะเปิด viewer */
}
