/* 현장보드판 — 전체 스타일 */
:root {
  --bg: #f4f6f8;
  --panel-bg: #ffffff;
  --border: #dde3e9;
  --text: #1c2733;
  --muted: #6b7a89;
  --primary: #0b62d6;
  --primary-hover: #0a55ba;
  --danger: #d63a3a;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(16, 32, 48, 0.08);
  font-size: 15px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ── 상단바 ───────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { font-size: 28px; }
.brand h1 { margin: 0; font-size: 19px; }
.brand-sub { margin: 0; font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 버튼 ─────────────────────────────── */
.btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #eef2f6; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.linklike {
  background: none; border: none; padding: 0;
  color: var(--primary); cursor: pointer; font-size: inherit;
  text-decoration: underline;
}
.linklike.danger { color: var(--danger); }

/* ── 메인 3구역 ───────────────────────── */
#layout {
  flex: 1;
  display: grid;
  grid-template-columns: 230px 1fr 340px;
  min-height: 0;
}

/* ① 사진 목록 */
#photo-list {
  border-right: 1px solid var(--border);
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#dropzone {
  margin: 10px;
  padding: 18px 10px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
#dropzone.dragover, body.dragover #dropzone {
  border-color: var(--primary);
  background: #eaf2fd;
}
#dropzone p { margin: 4px 0; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

#thumb-grid {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.thumb-card {
  position: relative;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: #000;
}
.thumb-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(11, 98, 214, 0.25); }
.thumb-card img { display: block; width: 100%; height: 110px; object-fit: cover; }
.thumb-card .thumb-name {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 3px 6px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb-badges { position: absolute; top: 4px; left: 4px; display: flex; gap: 4px; }
.badge {
  font-size: 11px; padding: 1px 5px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
}
.thumb-tools {
  position: absolute; top: 4px; right: 4px;
  display: flex; gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.thumb-card:hover .thumb-tools { opacity: 1; }
.thumb-tools button {
  border: none; border-radius: 4px; cursor: pointer;
  width: 24px; height: 24px; font-size: 12px;
  background: rgba(255, 255, 255, 0.92);
}
.thumb-tools button:hover { background: #fff; }
.thumb-report-check {
  position: absolute; bottom: 24px; right: 4px;
  background: rgba(255,255,255,0.92); border-radius: 4px;
  padding: 1px 5px; font-size: 11px;
  display: flex; align-items: center; gap: 3px; cursor: pointer;
}
.thumb-card.drag-target-above { box-shadow: 0 -3px 0 0 var(--primary); }
.thumb-card.drag-target-below { box-shadow: 0 3px 0 0 var(--primary); }

#list-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}

/* ② 미리보기 */
#preview-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0; min-height: 0;
  padding: 14px;
}
#preview-empty { text-align: center; max-width: 460px; }
#preview-empty h2 { font-size: 17px; }
.empty-illust { font-size: 54px; }
.privacy-note {
  margin-top: 18px;
  padding: 10px 14px;
  background: #eef7ee;
  border: 1px solid #cfe7cf;
  border-radius: var(--radius);
  font-size: 13px;
  color: #29632c;
}
#preview-wrap {
  position: relative;
  max-width: 100%; max-height: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
#preview-canvas {
  max-width: 100%;
  box-shadow: 0 4px 18px rgba(16, 32, 48, 0.25);
  border-radius: 4px;
  touch-action: none;
}
#preview-canvas.over-board { cursor: move; }
#preview-canvas.over-handle { cursor: nwse-resize; }
#preview-hint { font-size: 12px; color: var(--muted); }

/* ③ 설정 패널 */
#panel {
  border-left: 1px solid var(--border);
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
#panel-tabs .tab {
  flex: 1;
  padding: 10px 2px;
  background: none; border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
#panel-tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab-page { display: none; flex: 1; overflow-y: auto; padding: 14px; }
.tab-page.active { display: block; }

/* 패널 공통 폼 */
.field-group { margin-bottom: 14px; }
.field-group > label, .opt-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
}
.tab-page input[type="text"], .tab-page select, dialog input[type="text"], dialog select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.tab-page input[type="text"]:focus { outline: 2px solid rgba(11, 98, 214, 0.35); }
.tab-page input[type="range"] { width: 100%; }
.tab-page input[type="color"] {
  width: 40px; height: 28px; padding: 0;
  border: 1px solid var(--border); border-radius: 4px;
  background: none; cursor: pointer;
}
.inline-row { display: flex; align-items: center; gap: 8px; }
.inline-row > * { flex-shrink: 0; }
.inline-row .grow { flex: 1; min-width: 0; }
.range-val { font-size: 12px; color: var(--muted); min-width: 38px; text-align: right; }

/* 필드 입력 탭 */
.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}
.mode-toggle button {
  flex: 1;
  padding: 8px;
  border: none;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}
.mode-toggle button.active { background: var(--primary); color: #fff; font-weight: 700; }
.mode-toggle button:disabled { opacity: 0.5; cursor: not-allowed; }
.quick-btns { display: flex; gap: 6px; margin-top: 5px; }
.override-mark { color: var(--primary); font-weight: 400; font-size: 12px; }
.field-note {
  padding: 8px 10px;
  background: #f4f8fe;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* 보드 디자인 탭 — 항목 관리 */
.field-mgr-row {
  display: flex; align-items: center; gap: 5px;
  margin-bottom: 6px;
}
.field-mgr-row input[type="text"] { flex: 1; min-width: 0; padding: 6px 8px; font-size: 13px; }
.field-mgr-row .icon-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 4px;
  width: 26px; height: 26px; cursor: pointer; font-size: 12px; padding: 0;
}
.field-mgr-row .icon-btn:hover { background: #eef2f6; }
.field-mgr-row .icon-btn:disabled { opacity: 0.35; cursor: default; }
.section-title {
  font-size: 13px; font-weight: 700;
  margin: 18px 0 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.section-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.pos-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.pos-grid button { padding: 7px 2px; font-size: 12px; }
.pos-grid button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 템플릿 탭 */
.tpl-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.tpl-card.current { border-color: var(--primary); background: #f4f8fe; }
.tpl-name { font-size: 14px; font-weight: 700; }
.tpl-meta { font-size: 11px; color: var(--muted); }
.tpl-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* 진행률 오버레이 */
#progress-overlay {
  position: fixed; inset: 0;
  background: rgba(12, 22, 33, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
.progress-box {
  background: #fff;
  border-radius: 12px;
  padding: 26px 30px;
  width: 340px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.progress-track {
  height: 10px;
  background: #e6ebf0;
  border-radius: 5px;
  overflow: hidden;
  margin: 14px 0 18px;
}
#progress-bar {
  height: 100%; width: 0%;
  background: var(--primary);
  transition: width 0.2s;
}

/* 다이얼로그 */
dialog {
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  padding: 22px;
  max-width: min(92vw, 900px);
  color: var(--text);
}
dialog::backdrop { background: rgba(12, 22, 33, 0.55); }
dialog h3 { margin-top: 0; }
dialog label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 10px; }
dialog label input, dialog label select { margin-top: 4px; font-weight: 400; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.help-list li { margin-bottom: 10px; font-size: 14px; line-height: 1.55; }

/* 사진대지 다이얼로그 */
.report-layout { display: flex; gap: 20px; }
.report-preview { flex: 1; min-width: 0; text-align: center; }
#report-canvas {
  width: 100%; max-width: 430px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: #fff;
}
.report-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }
.report-options { width: 260px; flex-shrink: 0; }
#report-captions { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; margin: 0 0 10px; }
#report-captions legend { font-size: 12px; font-weight: 700; padding: 0 4px; }
#report-captions label { display: flex; align-items: center; gap: 6px; font-weight: 400; margin-bottom: 4px; font-size: 13px; }

/* 토스트 */
#toast-container {
  position: fixed;
  bottom: 46px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 100;
  align-items: center;
}
.toast {
  background: #22303d;
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  display: flex; align-items: center; gap: 12px;
  animation: toast-in 0.25s;
  max-width: 90vw;
}
.toast.error { background: var(--danger); }
.toast .linklike { color: #9ec9ff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

#footer {
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-bg);
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 6px 18px;
  flex-wrap: wrap;
}
.footer-links { display: flex; gap: 2px 12px; flex-wrap: wrap; justify-content: center; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--primary); text-decoration: underline; }

/* 좁은 화면 (태블릿/모바일) — PC가 주 대상이지만 무너지지 않게 */
@media (max-width: 980px) {
  #layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(280px, 1fr) auto;
  }
  #photo-list { max-height: 220px; border-right: none; border-bottom: 1px solid var(--border); }
  #thumb-grid { flex-direction: row; flex-wrap: wrap; }
  .thumb-card { width: 130px; }
  #panel { border-left: none; border-top: 1px solid var(--border); max-height: 45vh; }
  .report-layout { flex-direction: column; }
  .report-options { width: auto; }
}
