/* /var/www/html/assets/css/html-preview.css : HTML 파일 미리보기 페이지 전용 스타일 */

.hp-tool {
  margin-top: 8px;
}

/* ---- 작업 영역: 파일 / 코드 / 미리보기 3분할 ---- */
.hp-workspace {
  display: grid;
  grid-template-columns: minmax(170px, 230px) 1fr 1fr;
  gap: 14px;
  align-items: stretch;
}

.hp-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  overflow: hidden;
}

/* 카드 헤더: 제목 + 액션 버튼 */
.hp-pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.hp-pane-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.hp-pane-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

/* 헤더용 소형 버튼 */
.hp-mini-btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.hp-mini-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--text);
}

.hp-mini-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 데스크톱/모바일 세그먼트 버튼 */
.hp-vp-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.hp-vp {
  appearance: none;
  border: 0;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}

.hp-vp + .hp-vp {
  border-left: 1px solid var(--line);
}

.hp-vp:hover {
  background: rgba(255, 255, 255, 0.08);
}

.hp-vp.is-active {
  background: var(--text);
  color: #111;
}

/* 자동 미리보기 토글 */
.hp-auto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
}

.hp-auto input {
  width: 15px;
  height: 15px;
  accent-color: var(--text);
}

/* ---- 파일 목록 패널 ---- */
.hp-tree {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow: auto;
  flex: 1;
  min-height: 120px;
}

.hp-tree-item {
  display: flex;
  align-items: stretch;
  border-radius: 6px;
}

.hp-tree-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.hp-tree-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.35;
  word-break: break-all;
  cursor: pointer;
}

.hp-tree-btn::before {
  content: attr(data-tag);
  margin-right: 6px;
  opacity: 0.6;
}

.hp-tree-btn.kind-html::before { content: "H"; color: #e08a5a; }
.hp-tree-btn.kind-css::before { content: "C"; color: #5aa9e0; }
.hp-tree-btn.kind-js::before { content: "J"; color: #e0c25a; }
.hp-tree-btn.kind-text::before { content: "T"; color: #9aa0a6; }
.hp-tree-btn.kind-image::before { content: "I"; color: #8bd08b; }
.hp-tree-btn.kind-video::before { content: "V"; color: #c58be0; }
.hp-tree-btn.kind-binary::before { content: "\2022"; color: #8f9aa6; }

.hp-tree-item.is-current .hp-tree-btn {
  background: rgba(255, 255, 255, 0.12);
  font-weight: 700;
}

.hp-tree-item.is-preview .hp-tree-btn {
  box-shadow: inset 2px 0 0 var(--text);
}

/* 파일 삭제 버튼 */
.hp-tree-del {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 9px;
  font-size: 1.05rem;
  line-height: 1;
  border-radius: 6px;
  opacity: 0.5;
  transition: opacity 0.12s ease, color 0.12s ease;
}

.hp-tree-item:hover .hp-tree-del {
  opacity: 1;
}

.hp-tree-del:hover {
  color: #ff9b9b;
  opacity: 1;
}

/* 폴더 계층 */
.hp-tree-sub {
  list-style: none;
  margin: 0;
  padding-left: 12px;
}

.hp-tree-dir-label {
  padding: 6px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  cursor: default;
}

.hp-tree-dir-label::before {
  content: "\25BE";
  margin-right: 6px;
  opacity: 0.7;
}

/* 드래그 이동 */
.hp-tree-item.is-dragging {
  opacity: 0.45;
}

.hp-tree.is-drop,
.hp-tree-dir.is-drop {
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--text);
  background: rgba(255, 255, 255, 0.06);
}

/* 인라인 이름 변경 입력 */
.hp-tree-rename {
  flex: 1;
  min-width: 0;
  margin: 2px 4px;
  padding: 4px 6px;
  border: 1px solid var(--text);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  outline: none;
}

.hp-tree-rename-dir {
  display: block;
  width: calc(100% - 8px);
  flex: none;
}

/* 삭제 확인 모달 */
.hp-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
}

.hp-modal-panel {
  width: 100%;
  max-width: 360px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  box-shadow: var(--shadow);
}

.hp-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.hp-modal-text {
  margin: 10px 0 14px;
  font-size: 0.9rem;
  color: var(--text);
  word-break: break-all;
}

.hp-modal-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.hp-modal-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--text);
}

.hp-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.hp-mini-btn.hp-danger {
  color: #ff9b9b;
  border-color: rgba(255, 120, 120, 0.5);
}

.hp-mini-btn.hp-danger:hover:not(:disabled) {
  background: rgba(255, 90, 90, 0.15);
  border-color: #ff9b9b;
}

/* 파일 카드 하단: 파일·폴더 추가 칸 */
.hp-drop-mini {
  border-top: 1px solid var(--line);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 14px 12px;
  text-align: center;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.dropzone-title {
  font-weight: 700;
  font-size: 0.85rem;
}

.dropzone-sub {
  font-size: 0.76rem;
  color: var(--muted);
}

.hp-drop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hp-drop-actions .hp-mini-btn {
  flex: 1 1 auto;
}

/* ---- 코드 편집 영역 ---- */
.hp-code {
  flex: 1;
  min-height: 420px;
  width: 100%;
  resize: vertical;
  padding: 14px;
  border: 0;
  outline: none;
  color: var(--text);
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
  line-height: 1.5;
  tab-size: 2;
}

.hp-code::placeholder {
  color: var(--muted);
}

/* ---- 미리보기 프레임: 폭 전환 시 가운데 정렬 + 스크롤 ---- */
.hp-preview-frame {
  flex: 1;
  min-height: 420px;
  display: flex;
  justify-content: center;
  overflow: auto;
  background: #ffffff;
}

.hp-preview-frame iframe {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border: 0;
  background: #ffffff;
}

/* 폭 제한 모드(모바일)일 때 프레임 안에서 지정 폭 유지 */
.hp-preview-frame.is-constrained iframe {
  width: var(--vp-width, 100%);
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px var(--line-dark);
}

.hp-note {
  min-height: 1.2em;
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.hp-note.is-error {
  color: #ff9b9b;
}

/* ---- 반응형 ---- */
/* 중간 화면: 파일 카드를 코드/미리보기 위로 이동 */
@media (max-width: 980px) {
  .hp-workspace {
    grid-template-columns: 1fr 1fr;
  }

  .hp-pane-files {
    grid-column: 1 / -1;
  }

  .hp-tree {
    max-height: 200px;
  }
}

/* 모바일: 상하 배치 */
@media (max-width: 640px) {
  .hp-workspace {
    grid-template-columns: 1fr;
  }

  .hp-code,
  .hp-preview-frame,
  .hp-preview-frame iframe {
    min-height: 320px;
  }

  .hp-pane-head {
    flex-wrap: wrap;
  }

  .hp-pane-actions {
    width: 100%;
    margin-left: 0;
  }
}
