/* /var/www/html/assets/css/background-remover.css : 배경 제거 페이지 전용 스타일 */

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

/* 업로드 드롭존 */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
  padding: 28px 20px;
  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-icon {
  width: 44px;
  height: 44px;
  border: 2px solid currentColor;
  border-radius: 10px;
  position: relative;
  opacity: 0.85;
}

.dropzone-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 22%;
  width: 3px;
  height: 46%;
  background: currentColor;
  transform: translateX(-50%);
}

.dropzone-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 22%;
  width: 16px;
  height: 16px;
  border-left: 3px solid currentColor;
  border-top: 3px solid currentColor;
  transform: translate(-50%, 0) rotate(45deg);
}

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

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

/* 상단 도구 바 */
.bg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0 6px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

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

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

.btn-primary {
  background: var(--text);
  color: #111;
  border-color: var(--text);
}

.btn-primary:hover:not(:disabled) {
  background: #ffffff;
}

.btn-ghost {
  background: transparent;
}

.bg-counter {
  margin-left: auto;
  font-size: 0.88rem;
  color: var(--muted);
}

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

/* 이미지 카드 그리드 */
.bg-grid {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

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

/* 투명 배경 표시용 체커보드 */
.bg-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  /* 투명 배경 (카드의 어두운 배경이 그대로 비침) */
  background: transparent;
}

.bg-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* 처리 상태 배지 */
.bg-status {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
}

.bg-status[data-status="done"] { background: #1f7a3d; }
.bg-status[data-status="processing"] { background: #9a6a00; }
.bg-status[data-status="error"] { background: #a32020; }

.bg-item-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
}

.bg-item-name {
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bg-item-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bg-item-actions-row {
  display: flex;
  gap: 8px;
}

.bg-item-actions .btn {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.82rem;
  white-space: nowrap;
}

/* 처리중 스피너 */
.bg-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(0, 0, 0, 0.18);
  border-top-color: #333;
  border-radius: 50%;
  animation: bg-spin 0.8s linear infinite;
}

@keyframes bg-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 520px) {
  .bg-counter { margin-left: 0; width: 100%; }
  .btn { flex: 1; }
}

/* ---------- 수동 배경 제거 편집기 ---------- */
.bg-editor {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.68);
}

.bg-editor[hidden] { display: none; }

.bg-editor-panel {
  width: min(640px, 100%);
  max-height: 92vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text);
}

.bg-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bg-editor-head h2 { margin: 0; font-size: 1.1rem; }

.bg-editor-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.bg-editor-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.bg-editor-canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  /* 이미지 해상도와 무관하게 정사각형 표시 영역 */
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 70vh;
  overflow: hidden;
  border-radius: var(--radius);
  /* 격자 없이 투명 처리 (지워진 영역은 뒤 패널 배경이 그대로 비침) */
  background: transparent;
}

#editor-canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  cursor: crosshair;
}

/* 스포이드 확대 루페 (기본 우측 하단, 하단 영역이면 우측 상단으로 이동) */
.bg-loupe {
  position: absolute;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 5;
  image-rendering: pixelated;
}

.bg-loupe[hidden] { display: none; }

.bg-editor-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.bg-ctl {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text);
}

.bg-ctl-range { flex: 1; min-width: 220px; }
.bg-ctl-range input[type="range"] { flex: 1; }

.bg-swatch {
  appearance: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.bg-swatch:hover {
  border-color: var(--text);
  transform: scale(1.08);
}

.bg-swatch.is-active {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28);
}

.bg-editor-actions {
  display: flex;
  gap: 10px;
}

.bg-editor-actions .btn { flex: 1; }
