/* 첨부파일 공통 스타일 -- attachments.js (목록, 전체 화면 보기, 안내 문구) */

/* ---------- 목록: 파일명 칩 + 다운로드 [+ 삭제] ---------- */
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.attachment-chip .att-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip .att-icon {
  flex: none;
  min-width: 30px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}
.attachment-chip .att-icon-pdf { background: #fee2e2; color: #b91c1c; }
.attachment-chip .att-icon-other { background: #e2e8f0; color: #475569; }
.attachment-download.is-busy { opacity: .75; cursor: progress; }
@media (max-width: 768px) {
  /* 손가락으로 누르기 편하게 */
  .attachment-chip, .attachment-download, .attachment-remove { min-height: 36px; }
}

/* ---------- 전체 화면 보기 ---------- */
html.av-open { overflow: hidden; }
dialog.av-viewer {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #0b1220;
  color: #e2e8f0;
  overflow: hidden;
}
dialog.av-viewer[open] { display: flex; flex-direction: column; }
dialog.av-viewer::backdrop { background: #0b1220; }

.av-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 8px 12px calc(8px) 16px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: rgba(15, 23, 42, .96);
  border-bottom: 1px solid rgba(148, 163, 184, .22);
}
.av-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
}
.av-tools { flex: none; display: flex; align-items: center; gap: 6px; }
.av-pages, .av-zoomtools { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: #cbd5e1; }
.av-pages[hidden], .av-zoomtools[hidden] { display: none; }
.av-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(148, 163, 184, .35);
  border-radius: 10px;
  background: rgba(30, 41, 59, .9);
  color: #f1f5f9;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.av-btn:hover { background: rgba(51, 65, 85, .95); }
.av-btn:focus-visible { outline: 2px solid #60a5fa; outline-offset: 2px; }
.av-btn:disabled { opacity: .7; cursor: progress; }
.av-zoomval { min-width: 64px; font-size: 13px; }
.av-btn-download { background: #2563eb; border-color: #2563eb; font-size: 14px; }
.av-btn-download:hover { background: #1d4ed8; }
.av-btn-primary { background: #2563eb; border-color: #2563eb; font-size: 16px; padding: 0 28px; height: 48px; }
.av-btn-primary:hover { background: #1d4ed8; }
.av-btn-close { font-size: 18px; }

.av-scroller {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: #0b1220;
  outline: none;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;        /* 화면 전체 확대는 막고, 이동은 기본 스크롤로 */
  cursor: grab;
}
.av-scroller.is-panning { cursor: grabbing; user-select: none; }
.av-stage {
  display: flex;
  width: max-content;               /* 확대하면 가로로도 늘어나 스크롤이 생긴다 */
  min-width: 100%;
  min-height: 100%;
  box-sizing: border-box;
  padding: 12px;
}
.av-stage > * { margin: auto; }     /* 작을 땐 가운데, 커지면 가장자리까지 스크롤 */
.av-image {
  display: block;
  max-width: none;
  height: auto;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .45);
  user-select: none;
  -webkit-user-drag: none;
}
.av-pages-wrap { display: flex; flex-direction: column; gap: 12px; }
.av-page {
  position: relative;
  width: 100%;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.av-canvas { display: block; width: 100%; height: 100%; border-radius: 3px; }

/* 불러오는 중 / 미리보기 불가 / 오류 안내 */
.av-status {
  position: absolute;
  left: 0;
  right: 0;
  top: 54px;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  pointer-events: none;
}
.av-status[hidden] { display: none; }
.av-status .av-btn { pointer-events: auto; }
.av-status-text { max-width: 520px; font-size: 15px; line-height: 1.7; color: #cbd5e1; white-space: pre-line; }
.av-status.is-big .av-status-text { font-size: 14px; }
.av-status-icon {
  min-width: 76px;
  padding: 18px 20px;
  border-radius: 16px;
  background: #1e293b;
  color: #93c5fd;
  font-size: 22px;
  font-weight: 800;
}
.av-status-name { max-width: 90vw; overflow-wrap: anywhere; font-size: 17px; font-weight: 700; color: #f8fafc; }

.av-hint {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .86);
  border: 1px solid rgba(148, 163, 184, .3);
  color: #f1f5f9;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}
.av-hint[hidden] { display: none; }
.av-hint.is-fading { animation: av-hint-fade 3.8s ease forwards; }
@keyframes av-hint-fade { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }

/* 안내 문구(토스트) -- 팝업 위에서도 보이도록 열려 있는 팝업 안에 붙는다 */
.av-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 2147483000;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(15, 23, 42, .92);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

@media (max-width: 768px) {
  .av-bar { gap: 6px; padding-left: 12px; padding-right: 8px; }
  .av-title { font-size: 14px; }
  .av-btn { min-width: 38px; height: 38px; padding: 0 9px; }
  .av-zoomtools { display: none; }         /* 폰은 두 손가락/두 번 탭으로 조작 -- 이름이 보이도록 -/＋ 버튼은 숨김 */
  .av-btn-download { padding: 0 11px; font-size: 13px; }
  .av-pages { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .av-hint.is-fading { animation: none; }
}

/* ---------- PDF: 왼쪽 쪽 목록 + 위쪽 확대/축소 ---------- */
.av-tools-left { gap: 8px; }
.av-tools-left .av-pages, .av-tools-left .av-zoomtools { padding-right: 4px; }
.av-tools-left .av-zoomtools { padding-left: 8px; border-left: 1px solid rgba(148, 163, 184, .28); }
.av-thumbtoggle { font-size: 17px; }
.av-thumbtoggle[hidden] { display: none; }
.av-thumbtoggle[aria-pressed="true"] { background: #1d4ed8; border-color: #3b82f6; }
.av-body { flex: 1 1 auto; min-height: 0; display: flex; }
.av-body > .av-scroller { flex: 1 1 auto; min-width: 0; }
.av-thumbs {
  flex: none;
  width: 168px;
  overflow-y: auto;
  padding: 12px 10px 24px;
  background: #0f172a;
  border-right: 1px solid rgba(148, 163, 184, .22);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}
.av-thumbs[hidden] { display: none; }
.av-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 6px 6px 4px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.av-thumb:hover { background: rgba(51, 65, 85, .55); }
.av-thumb:focus-visible { outline: 2px solid #60a5fa; outline-offset: 1px; }
.av-thumb.is-current { border-color: #3b82f6; background: rgba(37, 99, 235, .18); color: #e2e8f0; }
.av-thumb-img { display: block; width: 132px; max-width: 100%; background: #fff; border-radius: 2px; box-shadow: 0 3px 10px rgba(0, 0, 0, .45); overflow: hidden; }
.av-thumb-canvas { display: block; width: 100%; height: 100%; }
.av-thumb-no { font-weight: 700; }
@media (max-width: 768px) {
  .av-thumbs, .av-thumbtoggle { display: none !important; }  /* 폰은 화면이 좁아 목록 없이 스크롤로 */
}

/* ---------- 출력 ---------- */
#avPrintRoot { display: none; }
@media (max-width: 768px) { .av-btn-print { display: none; } }
@media print {
  @page { margin: 8mm; }
  html.av-printing body > *:not(#avPrintRoot) { display: none !important; }
  html.av-printing, html.av-printing body { background: #fff !important; overflow: visible !important; height: auto !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; }
  html.av-printing #avPrintRoot { display: block; }
  /* 한 쪽 = 용지 한 장. 높이를 용지 높이보다 살짝 작게 고정해 넘치거나 빈 장이 생기지 않게 한다. */
  #avPrintRoot .av-print-page { display: flex; align-items: center; justify-content: center; height: calc(100vh - 3mm); overflow: hidden; break-after: page; page-break-after: always; break-inside: avoid; }
  #avPrintRoot .av-print-page:last-child { break-after: auto; page-break-after: auto; }
  #avPrintRoot img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
}
