/* /var/www/html/assets/css/image-split.css : 이미지 분할 페이지 전용 스타일 */

.sp-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);
}

/* 분할 설정 */
.sp-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin: 18px 0 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.sp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sp-field label {
  font-size: 0.82rem;
  color: var(--muted);
}

.sp-field input[type="number"] {
  appearance: none;
  width: 120px;
  padding: 9px 10px;
  font-size: 0.9rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sp-field input:focus {
  outline: none;
  border-color: var(--text);
}

/* 버튼 (도구 공통) */
.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;
}

/* 분할 미리보기 무대 (이미지 + 자르는 선) */
.sp-stage {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 14px auto 0;
  border-radius: var(--radius);
  overflow: hidden;
  user-select: none;
}

.sp-stage[hidden] { display: none; }

.sp-stage img {
  display: block;
  max-width: 100%;
  height: auto;
}

.sp-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 자르는 선: 얇은 선 + 넓은 드래그 히트 영역 */
.sp-line {
  position: absolute;
  pointer-events: auto;
  z-index: 2;
  touch-action: none; /* 선 드래그 중 스크롤 방지 */
}

.sp-line-v {
  top: 0;
  height: 100%;
  width: 16px;
  margin-left: -8px;
  cursor: col-resize;
}

.sp-line-h {
  left: 0;
  width: 100%;
  height: 16px;
  margin-top: -8px;
  cursor: row-resize;
}

/* 선 자체(가운데) 표시 */
.sp-line::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}

.sp-line-v::after {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
}

.sp-line-h::after {
  top: 50%;
  left: 0;
  height: 2px;
  width: 100%;
  transform: translateY(-50%);
}

.sp-line.is-dragging::after {
  background: #4da3ff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}

/* 드래그 손잡이 */
.sp-line-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #4da3ff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
}

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

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

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

/* 조각 카드 그리드 */
.sp-grid {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

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

.sp-thumb {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: transparent;
}

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

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

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

.sp-item-dims {
  font-size: 0.8rem;
  color: var(--muted);
}

.sp-item-body .btn {
  padding: 8px 10px;
  font-size: 0.82rem;
}

/* 안내/FAQ 영역 */
.sp-guide {
  margin-top: 34px;
}

.sp-guide h2 {
  font-size: 1.15rem;
  margin: 0 0 12px;
}

.sp-guide h3 {
  font-size: 0.98rem;
  margin: 16px 0 4px;
}

.sp-guide p,
.sp-guide li {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.6;
}

.sp-guide ol,
.sp-guide ul {
  margin: 0;
  padding-left: 20px;
}

@media (max-width: 520px) {
  .sp-counter { margin-left: 0; width: 100%; }
  .sp-toolbar .btn { flex: 1; }
  .sp-field input[type="number"] { width: 100%; }
  .sp-field { flex: 1; }
}
