/* ===== ERP UPLOAD / FILE PREVIEW STANDARDIZATION ===== */

.image-preview-list {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-1);
  scroll-snap-type: x proximity;
}

.image-preview-item {
  flex: 0 0 140px;
  border: none;
  border-radius: var(--radius-ui);
  background: #fff;
  overflow: hidden;
  scroll-snap-align: start;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.image-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--height-sm);
  padding: 0 var(--space-2) 0 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  background: transparent;
  gap: var(--space-2);
}

.image-preview-label {
  display: flex;
  align-items: center;
  min-height: var(--height-sm);
  font-size: var(--font-size-base);
  color: #475569;
}

.image-preview-remove,
.image-preview-action {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: var(--font-size-sm);
  color: #6b7280;
  cursor: pointer;
}

.image-preview-remove:hover,
.image-preview-action:hover {
  color: #111827;
}

.image-preview-meta,
.image-preview-empty {
  display: flex;
  align-items: center;
  min-height: var(--height-sm);
  padding: 0 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  font-size: var(--font-size-sm);
  color: #6b7280;
  background: transparent;
}

.image-preview-empty {
  flex: 1 1 100%;
  min-height: 92px;
  justify-content: center;
  border: 2px dashed rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-ui, 8px);
  background: #fafbfc;
}

.image-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding: 10px var(--space-3);
  border: none;
  border-radius: var(--radius-ui, 8px);
  background: rgba(0, 0, 0, 0.03);
}

.image-preview-summary {
  min-width: 0;
  font-size: var(--font-size-sm);
  color: #6b7280;
}

.image-preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.image-preview-media {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
}

.image-preview-media img {
  display: block;
}

.upload-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
  color: transparent;
}

.upload-dropzone input[type="file"]::-webkit-file-upload-button {
  display: none;
}

.upload-dropzone input[type="file"]::file-selector-button {
  display: none;
}

.upload-dropzone.is-disabled {
  cursor: default;
  opacity: 0.6;
}

.upload-dropzone.is-disabled input[type="file"] {
  pointer-events: none;
}

.upload-dropzone.is-processing {
  opacity: 0.72;
}

.image-viewer-open {
  overflow: hidden;
}

.image-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
}

.image-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
}

.image-viewer-dialog {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100vw - 48px));
  height: min(88vh, 860px);
  margin: var(--space-6) auto;
  padding: 40px var(--space-6) var(--space-5);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--space-4);
}

.image-viewer-close {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--height-lg);
  height: var(--height-lg);
  border: 0;
  background: transparent;
  color: #fff;
  font-size: var(--font-size-3xl);
  cursor: pointer;
}

.image-viewer-count {
  display: flex;
  justify-content: center;
  color: #fff;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-heavy);
}

.image-viewer-main-wrap {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  gap: var(--space-4);
  min-height: 0;
  align-items: center;
}

.image-viewer-main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-viewer-main img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-ui);
  background: #111827;
}

.image-viewer-nav {
  width: var(--height-2xl);
  height: var(--height-2xl);
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.9);
  color: #111827;
  font-size: var(--font-size-3xl);
  cursor: pointer;
}

.image-viewer-thumbs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-1);
}

.image-viewer-thumb {
  flex: 0 0 84px;
  height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 0;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  overflow: hidden;
}

.image-viewer-thumb.is-active {
  border-color: #fff;
}

.image-viewer-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 900px) {
  .image-preview-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .image-viewer-dialog {
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
    margin: 10px auto;
    padding: 36px 12px 16px;
  }

  .image-viewer-main-wrap {
    grid-template-columns: 40px 1fr 40px;
    gap: var(--space-2);
  }

  .image-viewer-nav {
    width: var(--height-md);
    height: var(--height-md);
    font-size: var(--font-size-3xl);
  }

  .image-viewer-thumb {
    flex-basis: 64px;
    height: var(--height-xl);
  }
}

/* ─── 공통 썸네일 높이 규격 ──────────────────────────────────────────────── */

.image-preview-item img {
  width: 100%;
  height: 96px;
  object-fit: cover;
}

.image-preview-item.is-main {
  flex-basis: 180px;
}

.image-preview-item.is-main img {
  height: 120px;
}

.image-preview-media {
  cursor: zoom-in;
}

.image-preview-action.is-primary {
  color: #1b2a4a;
}

.image-preview-toolbar.is-view-only {
  justify-content: flex-start;
}

.image-preview-toolbar.is-view-only .image-preview-summary {
  color: var(--text-subtle, #6b7280);
}

/* ─── 비이미지 파일 확장자 박스 (PDF, DOCX 등) ──────────────────────────── */

.image-preview-filebox {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 96px;
  background: #f1f5f9;
  border-bottom: 1px solid #e5e7eb;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-heavy);
  color: #94a3b8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.image-preview-item.is-main .image-preview-filebox {
  height: 120px;
}

@media (max-width: 900px) {
  .image-preview-item {
    flex-basis: 128px;
  }

  .image-preview-item.is-main {
    flex-basis: 180px;
  }
}

/* ─── 드롭존 ─────────────────────────────────────────────────────────────── */

.upload-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 96px;
  padding: var(--space-5) var(--space-4);
  border: 2px dashed rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-ui, 8px);
  background: #fafbfc;
  cursor: pointer;
  transition: border-color var(--transition-normal), background var(--transition-normal), box-shadow var(--transition-normal);
}

.upload-dropzone:hover {
  border-color: rgba(27, 42, 74, 0.3);
  background: #f5f7fa;
  box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.06);
}

.upload-dropzone.is-dragover {
  border-color: #1b2a4a;
  background: #f0f4f9;
  box-shadow: 0 0 0 4px rgba(27, 42, 74, 0.1);
}

.upload-dropzone-icon {
  width: var(--space-8);
  height: var(--space-8);
  color: #94a3b8;
  transition: color var(--transition-normal);
}

.upload-dropzone:hover .upload-dropzone-icon { color: #1b2a4a; }

.upload-dropzone-text {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-strong);
  color: #64748b;
}

.upload-dropzone-sub {
  font-size: var(--font-size-sm);
  color: #94a3b8;
}

.panel--form form.ui-mode-view .upload-dropzone,
.panel--detail form.ui-mode-view .upload-dropzone {
  display: none;
}

.panel--form form.ui-mode-view .image-preview-list,
.panel--detail form.ui-mode-view .image-preview-list {
  gap: 6px;
}

.panel--form form.ui-mode-view .image-preview-item,
.panel--detail form.ui-mode-view .image-preview-item {
  flex-basis: 104px;
}

.panel--form form.ui-mode-view .image-preview-head,
.panel--detail form.ui-mode-view .image-preview-head {
  min-height: var(--height-xs);
  padding: 0 6px 0 var(--space-2);
}

.panel--form form.ui-mode-view .image-preview-label,
.panel--detail form.ui-mode-view .image-preview-label {
  min-height: var(--height-xs);
  font-size: var(--font-size-sm);
}

.panel--form form.ui-mode-view .image-preview-meta,
.panel--detail form.ui-mode-view .image-preview-meta {
  min-height: 22px;
  padding: 0 var(--space-2);
  font-size: var(--font-size-xs);
}

.panel--form form.ui-mode-view .image-preview-media img,
.panel--detail form.ui-mode-view .image-preview-media img {
  height: 72px;
  object-fit: cover;
}

.panel--form form.ui-mode-view .image-preview-item.is-main,
.panel--detail form.ui-mode-view .image-preview-item.is-main {
  flex-basis: 124px;
}

.panel--form form.ui-mode-view .image-preview-item.is-main img,
.panel--detail form.ui-mode-view .image-preview-item.is-main img {
  height: 72px;
}

.panel--form form.ui-mode-view .image-preview-filebox,
.panel--detail form.ui-mode-view .image-preview-filebox {
  height: 72px;
  font-size: var(--font-size-base);
}

.panel--form form.ui-mode-view .image-preview-toolbar,
.panel--detail form.ui-mode-view .image-preview-toolbar {
  margin-top: 6px;
}

/* 보기모드: 비우기 버튼 숨김, 서류/사진 없으면 toolbar 전체 숨김 */
.panel--form form.ui-mode-view .image-preview-toolbar button,
.panel--detail form.ui-mode-view .image-preview-toolbar button {
  display: none;
}

.panel--form form.ui-mode-view .image-preview-list:has(.image-preview-empty) + .image-preview-toolbar,
.panel--detail form.ui-mode-view .image-preview-list:has(.image-preview-empty) + .image-preview-toolbar {
  display: none;
}

/* ═══════════════════════════════
   간소화된 썸네일 그리드
═══════════════════════════════ */

.img-thumb-list {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.img-thumb-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-ui, 8px);
  overflow: hidden;
  background: #f1f3f4;
  border: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.img-thumb-item .img-thumb-media,
.img-thumb-item .image-preview-media {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.img-thumb-item .img-thumb-media img,
.img-thumb-item .image-preview-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.img-thumb-item .image-preview-filebox {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-heavy);
  color: #94a3b8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 0;
}

.img-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 1;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: var(--radius-circle);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: var(--font-size-md);
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-thumb-remove:hover {
  background: rgba(0, 0, 0, 0.75);
}

.img-thumb-footer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.img-thumb-summary {
  font-size: var(--font-size-sm);
  color: var(--text-subtle, #6b7280);
}

.img-thumb-list:empty + .img-thumb-footer .img-thumb-summary::after {
  content: '';
}

/* 보기모드: 전체삭제 숨김 */
.panel--form form.ui-mode-view .img-thumb-footer button,
.panel--detail form.ui-mode-view .img-thumb-footer button {
  display: none;
}

/* 보기모드: 사진 없으면 footer 숨김 */
.panel--form form.ui-mode-view .img-thumb-list:has(.image-preview-empty) + .img-thumb-footer,
.panel--detail form.ui-mode-view .img-thumb-list:has(.image-preview-empty) + .img-thumb-footer {
  display: none;
}

/* 빈 상태 - image-preview-empty는 기존 그대로 사용 */
.img-thumb-list .image-preview-empty {
  width: 100%;
  flex-basis: 100%;
}

/* ═════════ 업로드 센터 (jpkerp 스타일) ═════════ */
.up-schema-box { font-size:12px; color:#475569; padding:8px 10px; background:#f8fafc; border:1px solid #e2e8f0; border-radius:var(--radius-ui); line-height:1.5; max-height:120px; overflow:auto; }
.up-schema-actions { display:flex; gap:6px; margin-top:6px; }
.up-link-btn { display:inline-flex; align-items:center; gap:4px; padding:6px 10px; background:transparent; border:1px solid #e2e8f0; border-radius:var(--radius-ui); font-size:12px; color:#475569; cursor:pointer; }
.up-link-btn:hover { background:#f1f5f9; }
.up-source-tabs { display:flex; gap:4px; margin-bottom:8px; }
.up-source-tab { flex:1; padding:8px 0; background:#f8fafc; border:1px solid #e2e8f0; border-radius:var(--radius-ui); font-size:12px; font-weight:600; color:#64748b; cursor:pointer; }
.up-source-tab.is-active { background:var(--m-accent,#1b2a4a); border-color:var(--m-accent,#1b2a4a); color:#fff; }
.up-source-pane[hidden] { display:none; }
.up-sheet-hint { font-size:11px; color:#64748b; margin:4px 0 8px; }
.up-confirm-btn { display:inline-flex; align-items:center; gap:6px; padding:8px 14px; background:var(--m-accent,#1b2a4a); border:none; border-radius:var(--radius-ui); color:#fff; font-size:13px; font-weight:700; cursor:pointer; }
.up-confirm-btn:disabled { opacity:0.5; cursor:default; }
.up-reset-btn { padding:8px 14px; background:#f1f5f9; border:none; border-radius:var(--radius-ui); color:#64748b; font-size:13px; font-weight:700; cursor:pointer; }
.up-actions-row { display:flex; gap:6px; }
.up-drop { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; padding:32px; background:#f8fafc; border:1.5px dashed #cbd5e1; border-radius:var(--radius-ui); cursor:pointer; }
.up-drop:hover { background:#f1f5f9; border-color:var(--m-accent,#1b2a4a); }
.up-drop-text { font-size:13px; color:#64748b; }
.up-summary { font-size:12px; color:#475569; font-weight:600; }
.up-result-row { display:flex; align-items:center; justify-content:space-between; padding:6px 0; border-bottom:1px solid #f1f5f9; font-size:12px; }
.up-result-row.is-error { color:#ef4444; }
.up-result-row.is-warn { color:#f59e0b; }
.up-result-row.is-ok { color:#16a34a; }
.up-result-row.is-new { color:#0284c7; font-weight:600; }
.up-btn-inline { padding:4px 10px; background:#0284c7; color:#fff; border:none; border-radius:4px; font-size:11px; cursor:pointer; }
.up-btn-inline:hover { background:#0369a1; }
.up-newvm-list { margin-top:6px; padding:8px; background:#f0f9ff; border-radius:4px; max-height:120px; overflow-y:auto; }
.up-newvm-item { font-size:11px; color:#075985; padding:2px 0; }
.pls-table .up-row-error td { background:#fef2f2; }
.pls-table .up-row-warn td { background:#fffbeb; }
.pls-table .up-row-ok td { background:transparent; }
.up-cell-fix { display:inline-block; padding:2px 6px; background:#fef3c7; color:#b45309; border-radius:3px; font-size:10px; font-weight:700; margin-left:4px; }

/* 미리보기 표 — 글자 줄바꿈 막고 가로 스크롤 */
#upPreviewTable { table-layout:auto; width:auto; min-width:100%; }
#upPreviewTable th, #upPreviewTable td {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 200px;
  font-size: 12px;
  padding: 6px 10px;
}
#upPreviewTable th {
  background: #f8fafc;
  font-weight: 700;
  color: #475569;
}

/* 미리보기 표 강제 — 한 줄 노출 */
.pls-grid-panel .pls-table#upPreviewTable,
.pls-grid-panel .pls-table#upPreviewTable th,
.pls-grid-panel .pls-table#upPreviewTable td {
  white-space: nowrap !important;
  word-break: keep-all !important;
}
.pls-grid-panel .pls-table#upPreviewTable th,
.pls-grid-panel .pls-table#upPreviewTable td {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  padding: 6px 10px;
}
.pls-grid-panel:has(#upPreviewTable) .pls-grid-scroll {
  overflow-x: auto;
}

/* 인라인 셀 수정 */
.up-cell-edit { cursor: pointer; }
.up-cell-edit:hover { background: rgba(27,42,74,0.04); }
.up-cell-input { width: 100%; padding: 2px 6px; border: 1px solid #1b2a4a; border-radius: 3px; font-size: 12px; outline: none; background: #fff; }

/* 추천 칩 — 셀 아래 */
.up-cell-wrap { display: flex; flex-direction: column; gap: 4px; }
.up-cell-val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-cell-sugs { display: flex; flex-wrap: wrap; gap: 3px; }
.up-sug-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px;
  background: #ecfdf5; border: 1px solid #bbf7d0;
  border-radius: 3px; color: #15803d;
  font-size: 11px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.up-sug-chip:hover { background: #d1fae5; }
.up-sug-chip svg { color: #16a34a; }
.up-undo-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px; margin-right: 4px;
  background: #fef3c7; border: 1px solid #fde68a;
  border-radius: 3px; color: #92400e;
  font-size: 11px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.up-undo-chip:hover { background: #fde68a; }
.up-undo-chip svg { color: #b45309; }
.up-cell-edit.is-changed .up-cell-val { color: #b45309; font-weight: 600; }
.up-addvm-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px; margin-right: 4px;
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 3px; color: #1d4ed8;
  font-size: 11px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.up-addvm-chip:hover { background: #dbeafe; }
.up-addvm-chip svg { color: #2563eb; }

/* 차종마스터 인라인 추가 모달 */
.up-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.up-modal {
  background: #fff; border-radius: 8px; width: 420px; max-width: 92vw;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  display: flex; flex-direction: column;
}
.up-modal-head {
  padding: 14px 18px; font-size: 15px; font-weight: 700;
  border-bottom: 1px solid #e5e7eb;
}
.up-modal-body {
  padding: 16px 18px; display: flex; flex-direction: column; gap: 10px;
}
.up-modal-body label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: #475569; font-weight: 600;
}
.up-modal-body input {
  padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 4px;
  font-size: 13px; color: #0f172a;
}
.up-modal-body input:focus { outline: none; border-color: #2563eb; }
.up-modal-row { display: flex; gap: 10px; }
.up-modal-row label { flex: 1; }
.up-modal-hint { font-size: 11px; color: #94a3b8; }
.up-modal-actions {
  padding: 12px 18px; border-top: 1px solid #e5e7eb;
  display: flex; gap: 8px; justify-content: flex-end;
}
