/* @sian_report 고객 포털 (plan 072 R12 — 요구사항 추가 모델)
   좌: 시안 iframe (툴바 없음) / 우: [페이지 ▾ | PC·모바일] 한 줄 → 요구사항 추가 → 목록 → 제출 */
:root {
  --bg: #f4f5f7; --panel: #fff; --line: #e5e7eb; --ink: #111827; --muted: #6b7280;
  --brand: #2563eb; --brand-weak: #eff6ff; --warn: #d97706; --ok: #059669; --danger: #b91c1c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--ink); background: var(--bg); display: flex; flex-direction: column; height: 100vh;
}

/* layout: 좌 시안 / 우 패널 */
.od-main { flex: 1; display: grid; grid-template-columns: 1fr 420px; min-height: 0; }
.od-main[hidden] { display: none; } /* 가드(모바일·구형 브라우저)용 — 저자 display:grid가 UA [hidden]을 이기므로 명시 필요 */
.od-design { background: #fff; border-right: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; }
.od-panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); }

.od-frame-wrap { flex: 1; min-height: 0; overflow: auto; background: #fff; position: relative; }
.od-frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
/* 모바일 뷰: iframe 375px·중앙·회색 배경으로 디바이스 느낌 */
.od-design.is-mobile .od-frame-wrap { background: #e5e7eb; display: flex; justify-content: center; padding: 12px 0; }
.od-design.is-mobile .od-frame-wrap iframe { width: 375px; max-width: 100%; height: 100%; background: #fff; box-shadow: 0 2px 14px rgba(0,0,0,.16); }

/* 캡처 모드 안내 배너 — iframe 위 상단 고정. pointer-events는 버튼에만 줘서 시안 조작을 막지 않는다. */
.od-capture-hint {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; justify-content: center;
  padding: 9px 14px; background: rgba(37, 99, 235, .96); color: #fff;
  font-size: 12.5px; font-weight: 600; pointer-events: none;
}
.od-capture-hint[hidden] { display: none; }
.od-capture-hint b { text-decoration: underline; }
.od-capture-cancel {
  pointer-events: auto; font: inherit; font-size: 11.5px; font-weight: 700;
  padding: 4px 10px; border-radius: 6px; cursor: pointer;
  background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.5);
}
.od-capture-cancel:hover { background: rgba(255,255,255,.28); }
/* 캡처 모드에선 시안 위 커서를 십자로 (드래그 가능함을 알림) */
.od-design.is-capturing .od-frame-wrap iframe { cursor: crosshair; }

/* ── 우측 상단 컨트롤: 페이지 선택 + PC/모바일 (한 줄) ── */
.od-ctrl {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafafa;
}
.od-page-select {
  flex: 1; min-width: 0; font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); cursor: pointer;
}
.od-page-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-weak); }
.od-page-select[hidden] { display: none; }
.od-vp-bar { display: flex; gap: 4px; flex: none; }
.od-vp {
  font: inherit; font-size: 11.5px; font-weight: 600; padding: 6px 13px;
  border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 6px; cursor: pointer;
}
.od-vp.is-active { color: var(--brand); border-color: var(--brand); background: var(--brand-weak); }

.od-ctrl-sub {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  border-bottom: 1px solid var(--line); background: #fafafa; min-height: 26px;
}
.od-page-progress { font-size: 11px; color: var(--muted); }
.od-page-progress.is-complete { color: var(--ok); font-weight: 600; }
.od-deadline { margin-left: auto; font-size: 11px; color: var(--warn); font-weight: 600; }

/* ── 요구사항 추가 ── */
.od-add { padding: 12px; border-bottom: 1px solid var(--line); }
.od-add-btn {
  width: 100%; font: inherit; font-size: 13px; font-weight: 700; padding: 11px;
  border: 1.5px dashed var(--brand); border-radius: 9px; background: var(--brand-weak); color: var(--brand); cursor: pointer;
}
.od-add-btn:hover { background: #dbeafe; }
.od-add-btn[hidden] { display: none; }

.od-form { display: flex; flex-direction: column; gap: 9px; }
.od-form[hidden] { display: none; }
.od-form-target { display: flex; gap: 6px; align-items: center; }
.od-chip { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; }
.od-chip-page { color: var(--brand); background: var(--brand-weak); border: 1px solid #bfdbfe; }
.od-chip-vp { color: #7c3aed; background: #f3e8ff; border: 1px solid #e9d5ff; }

.od-shot-row { display: flex; align-items: center; gap: 8px; }
.od-shot-btn {
  font: inherit; font-size: 12px; font-weight: 600; padding: 7px 12px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); cursor: pointer;
}
.od-shot-btn:hover { border-color: var(--brand); color: var(--brand); }
.od-shot-btn.is-active { border-color: var(--brand); background: var(--brand); color: #fff; }
.od-shot-btn:disabled { opacity: .5; cursor: default; }
.od-shot-hint { font-size: 10.5px; color: var(--muted); }

.od-shot-preview { position: relative; }
.od-shot-preview[hidden] { display: none; }
.od-shot-preview img { max-width: 100%; max-height: 200px; display: block; border: 1px solid var(--line); border-radius: 8px; }
.od-shot-del {
  position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; line-height: 1;
  border: 0; border-radius: 50%; background: rgba(17,24,39,.72); color: #fff; font-size: 15px; cursor: pointer;
}
.od-shot-del:hover { background: var(--danger); }

.od-attach-row { display: flex; align-items: center; gap: 8px; }
.od-attach-btn {
  font-size: 12px; font-weight: 600; padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 7px; cursor: pointer; background: #fff; color: var(--ink);
}
.od-attach-btn:hover { border-color: var(--brand); color: var(--brand); }
.od-attach-hint { font-size: 10.5px; color: var(--muted); }

.od-file-list { display: flex; flex-direction: column; gap: 5px; }
.od-file-item {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 7px; font-size: 12px; background: #fff;
}
.od-file-thumb { width: 32px; height: 32px; object-fit: cover; border-radius: 5px; flex: none; }
.od-file-icon { font-size: 17px; flex: none; }
.od-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.od-file-size { color: var(--muted); font-size: 10.5px; flex: none; }
.od-file-del { border: 0; background: none; cursor: pointer; font-size: 15px; color: var(--muted); flex: none; }
.od-file-del:hover { color: var(--danger); }

.od-text {
  width: 100%; font: inherit; font-size: 13px; padding: 9px; border: 1px solid var(--line);
  border-radius: 8px; resize: vertical; line-height: 1.5;
}
.od-text:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-weak); }
.od-text.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 2px #fee2e2; }

.od-form-actions { display: flex; gap: 8px; }
.od-btn-primary {
  margin-left: auto; font: inherit; font-weight: 700; font-size: 13px; padding: 9px 18px;
  background: var(--brand); color: #fff; border: 0; border-radius: 8px; cursor: pointer;
}
.od-btn-primary:hover { background: #1d4ed8; }
.od-btn-primary:disabled { opacity: .6; cursor: default; }
.od-btn-ghost {
  font: inherit; font-size: 13px; padding: 9px 16px; background: none;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}

/* ── 저장된 요구사항 목록 ── */
.od-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.od-empty { font-size: 12.5px; color: var(--muted); text-align: center; padding: 26px 12px; line-height: 1.6; }
.od-req {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; background: #fff;
}
.od-req-top { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; }
.od-req-no { font-size: 11px; font-weight: 800; color: var(--muted); }
.od-req-tools { margin-left: auto; display: flex; gap: 4px; }
.od-req-tool {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: 10.5px; font-weight: 600; padding: 3px 8px; color: var(--muted);
}
.od-req-tool:hover { border-color: var(--brand); color: var(--brand); }
.od-req-tool.is-danger:hover { border-color: var(--danger); color: var(--danger); }
.od-req-shot { max-width: 100%; max-height: 140px; border: 1px solid var(--line); border-radius: 7px; display: block; margin-bottom: 7px; }
.od-req-text { font-size: 12.5px; line-height: 1.55; margin: 0; word-break: break-word; white-space: pre-wrap; }
.od-req-files { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.od-req-file { font-size: 10.5px; color: var(--muted); background: #f3f4f6; border-radius: 5px; padding: 3px 7px; }

/* ── 하단 액션 ── */
.od-actions { display: flex; align-items: center; gap: 12px; padding: 12px; border-top: 1px solid var(--line); }
.od-count { font-size: 12px; color: var(--muted); }
.od-submit {
  margin-left: auto; font: inherit; font-weight: 600; font-size: 13px; padding: 10px 18px;
  background: var(--brand); color: #fff; border: 0; border-radius: 8px; cursor: pointer;
}
.od-submit:hover { background: #1d4ed8; }
.od-submit:disabled { opacity: .6; cursor: default; }

/* 토스트 (저장·삭제 등 순간 피드백) */
.od-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  background: #111827; color: #fff; font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
  opacity: 0; pointer-events: none; z-index: 1000;
  transition: opacity .2s ease, transform .2s ease;
}
.od-toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.od-toast::before { content: "\2713"; margin-right: 7px; color: #34d399; font-weight: 700; }
.od-toast.is-error::before { content: "\26A0"; color: #fca5a5; }

/* confirm modal */
.od-modal { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 900; }
.od-modal[hidden] { display: none; }
.od-modal-card { background: #fff; border-radius: 14px; padding: 22px; max-width: 520px; width: 100%; max-height: 82vh; overflow: auto; }
.od-modal-card h2 { margin: 0 0 4px; font-size: 16px; }
.od-modal-sub { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.od-unseen { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 9px 11px;
  border: 1px solid #f2d08a; background: #fff8e8; border-radius: 8px; font-size: 12px; line-height: 1.45; color: #7a5a10; }
.od-unseen[hidden] { display: none; }
.od-unseen-text { flex: 1 1 auto; }
.od-unseen-go { flex: 0 0 auto; border: 1px solid #d9b45f; background: #fff; color: #7a5a10;
  border-radius: 6px; padding: 5px 9px; font-size: 11.5px; cursor: pointer; white-space: nowrap; }
.od-unseen-go:hover { background: #fdf3dd; }
.od-summary { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow: auto; }
.od-summary-item { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 12.5px; line-height: 1.5; }
.od-summary-meta { font-size: 10.5px; color: var(--muted); margin-bottom: 3px; }
.od-modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.od-modal-actions .od-submit { margin-left: auto; }
.od-done { text-align: center; padding: 10px; }

/* closed 화면 */
.od-closed { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.od-closed[hidden] { display: none; }
.od-closed-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; max-width: 440px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,.06); }
.od-closed-card h2 { margin: 0 0 10px; font-size: 18px; color: var(--ink); }
.od-closed-sub { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.od-closed-receipt { margin: 14px 0 0; font-size: 12px; color: var(--brand); font-weight: 600; }

/* 목록 조회 실패 — 빈 목록으로 위장하지 않고 그대로 세워둔다(portal.js renderListError) */
.od-list-error { display: flex; flex-direction: column; gap: 8px; margin: 12px; padding: 14px;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; }
.od-list-error b { font-size: 14px; color: var(--danger); }
.od-list-error-sub { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.od-list-error-diag { margin: 0; padding: 8px 10px; background: #fff; border: 1px solid var(--line);
  border-radius: 6px; font-size: 11px; color: var(--ink); white-space: pre-wrap; word-break: break-all;
  max-height: 110px; overflow: auto; }

/* PC 전용 가드 — 모바일·태블릿 접속 차단 화면 (portal.js isMobileDevice·구형 브라우저 가드도 재사용) */
.od-pconly { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--bg); }
.od-pconly[hidden] { display: none; }
.od-pconly-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 30px 22px;
  max-width: 420px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,.06); }
.od-pconly-card h2 { margin: 0 0 10px; font-size: 19px; color: var(--ink); }
.od-pconly-sub { margin: 0 0 16px; font-size: 14px; color: var(--muted); line-height: 1.65; }
.od-pconly-url { margin: 0 0 16px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; font-size: 12px; color: var(--ink); word-break: break-all; line-height: 1.5; user-select: all; }
.od-pconly .od-btn-primary { width: 100%; }

/* 좁은 데스크톱 창: 세로 스택 (모바일 기기는 위 가드가 이미 막는다 — 여긴 창을 줄인 PC 전용) */
@media (max-width: 860px) {
  .od-main { grid-template-columns: 1fr; grid-template-rows: 44vh 1fr; }
  .od-design { border-right: 0; border-bottom: 1px solid var(--line); }
  .od-panel { min-height: 0; }
}
