/* ============================================================
   photo.css — 관련사진 페이지 스타일
   ============================================================ */

/* ──────────────────────────────
   사진 오버레이 (전체 화면)
────────────────────────────── */
.photo-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 8000;
  background: #f0f0f0;
  flex-direction: column;
  overflow: hidden;
}
.photo-overlay.on { display: flex; }

/* ── 툴바 ── */
.photo-toolbar {
  background: #1a3a5c; color: #fff;
  height: 50px; flex-shrink: 0;
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 16px; gap: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.photo-toolbar-title {
  font-size: 15px; font-weight: 700; white-space: nowrap;
}
.photo-biz-name {
  font-size: 13px; color: rgba(255,255,255,.85);
  flex: 1; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.photo-toolbar-btns { display: flex; gap: 8px; flex-shrink: 0; }

/* ── 본문 스크롤 영역 ── */
.photo-body {
  flex: 1; overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

/* ── 사진 페이지 (A4 모사) ── */
.photo-page {
  background: #fff;
  width: 794px; max-width: 100%;
  margin: 0 auto 20px;
  padding: 20px 22px 24px;
  box-shadow: 0 3px 16px rgba(0,0,0,.18);
}

/* ── 관련사진 제목 블록 ── */
.photo-page-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.photo-page-header-title {
  font-size: 15px; font-weight: 900;
  color: #111; letter-spacing: 1px;
}

/* ── 업체명 부제 ── */
.photo-subtitle {
  text-align: center;
  font-size: 12px; font-weight: 600;
  color: #333; margin-bottom: 10px;
  border: 1px solid #ccc; padding: 4px 0;
  background: #fafafa;
}

/* ── 사진 그리드: 2열 4행 = 8칸 ── */
.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── 사진 셀 ── */
.photo-cell {
  display: flex; flex-direction: column;
  border: 1.5px solid #bbb;
  background: #f9f9f9;
  overflow: hidden;
}

/* ── 사진 박스 (고정 높이, object-fit cover) ── */
.photo-img-box {
  width: 100%; height: 160px;
  position: relative;
  background: #ffffff;
  cursor: pointer;
  overflow: hidden;
}
.photo-img-box img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
/* 플레이스홀더: absolute로 박스 전체 중앙 */
.photo-img-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; color: #aaa;
  font-size: 12px; text-align: center;
  pointer-events: none;
  user-select: none;
}
.photo-img-placeholder .ph-icon { font-size: 36px; opacity: .6; }

/* 사진 있을 때 플레이스홀더 숨김 */
.photo-img-box.has-photo .photo-img-placeholder { display: none; }

/* 사진 삭제 버튼 */
.photo-del-btn {
  display: none;
  position: absolute; top: 5px; right: 5px;
  background: rgba(0,0,0,.55); color: #fff;
  border: none; border-radius: 50%;
  width: 26px; height: 26px; font-size: 14px;
  cursor: pointer; align-items: center; justify-content: center;
  z-index: 2;
}
.photo-img-box.has-photo .photo-del-btn { display: flex; }

/* ── 설명 칸 ── */
.photo-caption-box {
  border-top: 1px solid #ccc;
  background: #fff;
  min-height: 32px;
  display: flex; align-items: center;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 11.5px; color: #222;
  white-space: pre-wrap; word-break: break-all;
  line-height: 1.4;
}
.photo-caption-box.empty { color: #aaa; font-style: italic; }
.photo-caption-box:hover { background: #f5f8ff; }

/* ── 페이지 추가 버튼 ── */
.photo-add-page-btn {
  display: block;
  width: 794px; max-width: 100%;
  margin: 0 auto 20px;
  padding: 12px;
  border: 2px dashed #aaa; border-radius: 8px;
  background: #fafafa; color: #666;
  font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: center;
  transition: background .15s, border-color .15s;
}
.photo-add-page-btn:hover { background: #eef5ff; border-color: #2471a3; color: #2471a3; }


/* ──────────────────────────────
   크롭 모달
────────────────────────────── */
.crop-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.75); z-index: 9500;
  align-items: center; justify-content: center;
}
.crop-overlay.on { display: flex; }

.crop-modal {
  background: #fff; border-radius: 12px;
  width: min(92vw, 680px);
  max-height: 92vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
.crop-modal-hd {
  background: #1a3a5c; color: #fff;
  padding: 10px 16px;
  display: flex; align-items: center;
  justify-content: space-between;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.crop-modal-bd {
  flex: 1; overflow: hidden;
  display: flex; align-items: center;
  justify-content: center;
  background: #1a1a1a;
  min-height: 300px; position: relative;
}

/* 크롭 캔버스 컨테이너 */
#cropContainer {
  position: relative;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#cropCanvas {
  display: block;
  /* 소스 이미지 표시 */
}
/* 크롭 영역 오버레이 */
#cropBox {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.5);
  cursor: move;
  box-sizing: border-box;
}
/* 크롭박스 모서리 핸들 */
.crop-handle {
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border: 2px solid #1a3a5c;
  border-radius: 2px;
}
.crop-handle.nw { top: -7px; left: -7px; cursor: nw-resize; }
.crop-handle.ne { top: -7px; right: -7px; cursor: ne-resize; }
.crop-handle.sw { bottom: -7px; left: -7px; cursor: sw-resize; }
.crop-handle.se { bottom: -7px; right: -7px; cursor: se-resize; }
/* 크롭 가이드 라인 (3×3) */
#cropBox::before,
#cropBox::after {
  content: '';
  position: absolute;
  border-color: rgba(255,255,255,.35);
  border-style: solid;
  pointer-events: none;
}
#cropBox::before {
  /* 수직 2줄 */
  top: 0; bottom: 0;
  left: 33.33%; right: 33.33%;
  border-width: 0 1px;
}
#cropBox::after {
  /* 수평 2줄 */
  left: 0; right: 0;
  top: 33.33%; bottom: 33.33%;
  border-width: 1px 0;
}

.crop-modal-ft {
  padding: 10px 16px;
  display: flex; justify-content: space-between;
  align-items: center;
  background: #f5f5f5;
  gap: 10px; flex-shrink: 0;
}
.crop-info {
  font-size: 11px; color: #666;
}
.crop-ft-btns { display: flex; gap: 8px; }

/* 크롭 회전 버튼 */
.crop-rotate-btn {
  background: #fff; border: 1.5px solid #bbb;
  border-radius: 6px; padding: 6px 12px;
  font-size: 12px; cursor: pointer;
  transition: background .12s;
}
.crop-rotate-btn:hover { background: #eee; }


/* ──────────────────────────────
   설명 입력 모달
────────────────────────────── */
.caption-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 9600;
  align-items: center; justify-content: center;
}
.caption-overlay.on { display: flex; }
.caption-modal {
  background: #fff; border-radius: 10px;
  width: min(90vw, 480px);
  box-shadow: 0 6px 30px rgba(0,0,0,.35);
  overflow: hidden;
}
.caption-modal-hd {
  background: #1a3a5c; color: #fff;
  padding: 10px 16px; font-size: 14px; font-weight: 700;
}
.caption-modal-bd { padding: 14px 16px; }
.caption-textarea {
  width: 100%; min-height: 70px;
  border: 1.5px solid #ccc; border-radius: 6px;
  padding: 8px 10px; font-size: 14px;
  font-family: '맑은 고딕', 'Malgun Gothic', sans-serif;
  line-height: 1.5; resize: none; outline: none;
  box-sizing: border-box;
}
.caption-textarea:focus { border-color: #1a3a5c; }
.caption-modal-ft {
  padding: 10px 16px;
  display: flex; justify-content: flex-end;
  gap: 8px; background: #f5f5f5;
}


/* ──────────────────────────────
   인쇄 — 기본: 사진 오버레이 완전 숨김
   (점검표 인쇄 시 사진 페이지가 겹치지 않도록)
   사진 전용 인쇄는 body.print-photo 클래스로 제어
────────────────────────────── */
@media print {

  /* ① 기본 인쇄: 사진 오버레이 숨김 */
  .photo-overlay { display: none !important; }

  /* ② 사진 전용 인쇄 (body.print-photo) */
  body.print-photo .page-wrap,
  body.print-photo .toolbar { display: none !important; }

  body.print-photo .photo-overlay {
    display: block !important;
    position: static !important;
    background: #fff !important;
    overflow: visible !important;
  }

  body.print-photo .photo-toolbar,
  body.print-photo .photo-add-page-btn,
  body.print-photo .photo-del-btn,
  body.print-photo .photo-caption-box:hover { display: none !important; }

  body.print-photo .photo-body {
    overflow: visible !important;
    padding: 0 !important;
  }

  body.print-photo .photo-page {
    box-shadow: none !important;
    break-after: page;
    margin: 0 auto !important;
    width: 100% !important;
    padding: 16px !important;
  }

  body.print-photo .photo-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }

  body.print-photo .photo-img-box {
    cursor: default !important;
    background: #fff !important;
    height: 160px !important;
  }

  body.print-photo .photo-caption-box {
    cursor: default !important;
  }
}
