/* PDF 페이지 회전/삭제 전용 스타일 */

:root {
  --danger: #ef4444;
}

/* 편집 섹션 */
.edit-section {
  margin-top: 1.5rem;
}

.edit-section[hidden] {
  display: none;
}

/* 파일 정보 바 */
.file-info-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.file-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 0.75rem;
  color: var(--text-sub);
}

.btn-change {
  padding: 0.35rem 0.75rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-sub);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}

.btn-change:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* 툴바 */
.toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.toolbar-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.toolbar-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.toolbar-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 0.25rem;
}

.edit-hint {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-bottom: 0.75rem;
}

/* 페이지 그리드 */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.page-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s, opacity 0.15s;
  position: relative;
}
.page-card:active { cursor: grabbing; }
.page-card.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

/* 드래그 핸들 (좌상단) */
.page-card .drag-handle {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  min-width: 28px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 5px;
  opacity: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.15s;
}
.page-card:hover .drag-handle { opacity: 0.9; }
.page-card .drag-handle:active { cursor: grabbing; }

/* 터치 디바이스: 핸들 항상 노출 + 크기 키움 */
@media (hover: none) {
  .page-card .drag-handle {
    opacity: 0.85;
    min-width: 36px;
    min-height: 36px;
    font-size: 1.05rem;
  }
}

/* 드롭 인디케이터 (좌/우) */
.page-card.drop-before::before,
.page-card.drop-after::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 2px;
  z-index: 3;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
}
.page-card.drop-before::before { left: -6px; }
.page-card.drop-after::after { right: -6px; }

.page-card:hover {
  border-color: var(--primary);
}

.page-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.25);
}

.page-card .thumb-wrapper {
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  height: 180px;
}

.page-card canvas {
  display: block;
  background: white;
  max-width: 100%;
  max-height: 100%;
  transition: transform 0.3s ease;
}

.page-card .page-label {
  text-align: center;
  padding: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-sub);
}

.page-card .deleted-overlay {
  position: absolute;
  inset: 0;
  background: rgba(239, 68, 68, 0.15);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--danger);
}

.page-card.deleted .deleted-overlay {
  display: flex;
}

.page-card.deleted canvas {
  opacity: 0.3;
}

.page-card.deleted .page-label {
  text-decoration: line-through;
  opacity: 0.5;
}

/* 저장 버튼 */
.btn-save {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-save:hover {
  background: var(--primary-hover);
}

.btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 진행 상태 (다른 구조: progress-bar / progress-fill) */
.progress-section {
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

/* 결과 */
.result-section {
  margin-top: 2rem;
}

.result-section[hidden] {
  display: none;
}

.result-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.result-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.result-detail {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.btn-download {
  padding: 0.5rem 1.2rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
  flex-shrink: 0;
}

.btn-download:hover {
  background: var(--primary-hover);
}

.btn-reset {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.6rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-sub);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-reset:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* 반응형 */
@media (max-width: 480px) {
  .page-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .result-card {
    flex-wrap: wrap;
  }

  .btn-download {
    width: 100%;
    text-align: center;
  }

  .toolbar {
    gap: 0.35rem;
  }

  .toolbar-btn {
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
  }
}
