/* ====================================================
   AI 웹툰 스튜디오 — main.css
   HTML: 260224_character_generator_v6_rotated.html
   ==================================================== */

/* ── CSS 변수 ── */
:root {
  --bg: #f8f9fa;
  --panel: #ffffff;
  --text: #111;
  --muted: #495057;
  --blue: #5b8def;
  --green: #50c878;
  --red: #ef5b5b;
  --border: #dee2e6;
  --amber: #f5c66d;
  --sidebar-bg: #0d1117;
  --sidebar-border: #21262d;
  --accent: #6366f1;
}

/* ── 기본 리셋 ── */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  background: #f8f9fa;
  color: #111;
}

.container { max-width: 100%; margin: 0 auto; padding: 0; }

/* ── 앱 레이아웃 ── */
.app { display: grid; grid-template-columns: 150px 1fr; min-height: 100vh; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: -220px; top: 0; z-index: 1000;
    width: 220px; height: 100vh; transition: left .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }
  body.sidebar-open .sidebar { left: 0; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 999;
    background: rgba(0,0,0,.5); backdrop-filter: blur(2px);
  }
  body.sidebar-open .sidebar-overlay { display: block; }
  .sidebar-hamburger {
    display: flex !important;
    position: fixed; top: 12px; left: 12px; z-index: 998;
    width: 44px; height: 44px; border-radius: 10px;
    background: #0d1117; border: 1px solid #21262d;
    color: #e8ecf4; align-items: center; justify-content: center;
    cursor: pointer; font-size: 20px; box-shadow: 0 2px 12px rgba(0,0,0,.3);
  }
}
@media (min-width: 981px) {
  .sidebar-hamburger { display: none !important; }
}
@media (max-width: 980px) {
  .main { padding-top: 60px !important; }
}

/* ── 사이드바 ── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 16px 12px;
  background: linear-gradient(180deg, #0d1117 0%, #0a0e14 100%);
  color: #e8ecf4;
  backdrop-filter: blur(12px);
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
}

.sidebar .stepItem         { color: #8b95a8; }
.sidebar .stepItem.active  { color: #e8ecf4; }
.sidebar .stepItem .num    { color: #8b95a8; background: rgba(255,255,255,0.03); border-color: #21262d; }
.sidebar .stepItem.active .num { color: #6366f1; }
.sidebar .helpBox          { color: #8b95a8; background: rgba(255,255,255,0.02); border-color: #21262d; }
.sidebar .helpBox-studio   { color: #e8ecf4; font-weight: 700; text-align: center; }
.sidebar .helpBox-studio div { line-height: 1.5; }
.sidebar .stepItem .label  { font-size: 12px; line-height: 1.35; }
.sidebar .brand            { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* ── 브랜드 로고 ── */
.brand {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── 스텝 목록 ── */
.steps { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }

.stepItem {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(255, 255, 255, 0.02);
}

.stepItem:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateX(4px);
}

.stepItem .num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border);
  font-weight: 800;
  font-size: 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.25s ease;
}

.stepItem.active {
  border-color: rgba(99, 102, 241, 0.7);
  color: var(--text);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15) inset, 0 4px 12px rgba(99, 102, 241, 0.1);
}

.stepItem.active .num {
  border-color: rgba(99, 102, 241, 0.8);
  color: #6366f1;
  background: rgba(99, 102, 241, 0.15);
}

.stepItem .label { font-size: 15px; line-height: 1.4; font-weight: 500; }

.stepItem.done {
  border-color: #10b981 !important;
  background: linear-gradient(135deg, rgba(16,185,129,0.12) 0%, rgba(16,185,129,0.05) 100%) !important;
  color: #fff !important;
  box-shadow: 0 0 0 2px rgba(16,185,129,0.2) inset, 0 4px 16px rgba(16,185,129,0.15) !important;
}

.stepItem.done .label { color: #fff !important; }

.stepItem.done .num {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  border-color: #10b981 !important;
  color: white !important;
  font-weight: 900 !important;
  font-size: 16px !important;
  box-shadow: 0 2px 8px rgba(16,185,129,0.4) !important;
}

.stepItem.locked { opacity: 0.5; pointer-events: none; cursor: not-allowed; }

/* ── 메인 영역 ── */
.main { padding: 24px 32px; background: #f8f9fa; color: #111; }
.main-inner { max-width: 1320px; margin: 0 auto; }
.main .panel           { background: #fff; border-color: #dee2e6; }
.main label,
.main .muted,
.main .helpBox,
.main .sectionTitle    { color: #495057; }
.main input,
.main select,
.main .badge           { background: #fff; color: #111; border-color: #dee2e6; }
.main h1               { color: #111; }
.main .sampleCard,
.main .card,
.main .preview         { background: #f0f0f0; border-color: #dee2e6; }
.main .sampleLabel,
.main .status strong   { color: #111; }
.main .status          { color: #495057; }

/* ── 도움말 박스 ── */
.helpBox {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.02);
}

/* ── 공통 컴포넌트 ── */
h1 { font-size: 18px; margin: 6px 0 12px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

@media (min-width: 640px) { .grid    { grid-template-columns: 1fr 1fr; } }
@media (min-width: 640px) { .samples { grid-template-columns: 1fr 1fr 1fr; } }
@media (min-width: 640px) { .images  { grid-template-columns: 1fr 1fr; } }
@media (min-width: 640px) { .row2   { grid-template-columns: 2fr 1fr; } }

label { font-size: 12px; color: var(--muted); }

select, button {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f121a;
  color: var(--text);
}

button { font-weight: 800; border: none; cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }

.generate  { background: var(--blue); color: #06101d; }
.secondary { background: #2a3140; color: var(--text); }

.buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 10px; }

.twoSplit { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.twoSplit > button { width: 100%; }

@media (max-width: 640px) {
  .buttons { grid-template-columns: 1fr 1fr; }
  .buttons button:first-child { grid-column: 1 / -1; }
}

.status { margin-top: 10px; font-size: 14px; color: var(--muted); line-height: 1.35; }
.status strong { color: var(--text); }

/* ── 프로그레스바 ── */
.progress { height: 10px; background: #0b0e14; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.bar { height: 100%; width: 0%; background: var(--blue); transition: width .15s linear; }
.bar.pulse {
  width: 100% !important;
  background: linear-gradient(90deg, var(--blue), var(--amber), var(--blue));
  background-size: 200% 100%;
  animation: pulseMove 1.2s linear infinite;
}

@keyframes pulseMove { 0% { background-position: 0% 0%; } 100% { background-position: 200% 0%; } }
@keyframes shimmerMove { 0% { left: -100%; } 100% { left: 100%; } }

/* ── 섹션 타이틀 ── */
.sectionTitle { font-size: 16px; margin: 14px 0 8px; color: #111; font-weight: 800; }

/* ── 샘플 카드 ── */
.samples  { display: grid; grid-template-columns: repeat(3, 1fr) !important; gap: 10px; }
#styleSamples { display: grid; grid-template-columns: repeat(3, 1fr) !important; gap: 10px; }

.sampleCard { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: #0b0e14; }
.sampleCard.selected { outline: 3px solid var(--blue); }
.sampleCard img { width: 100%; display: block; aspect-ratio: 9/16; object-fit: contain; object-position: center; background: #0b0e14; }

.sampleLabel { padding: 8px 14px; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.sampleLabel > div:first-child,
.sampleCard .sampleLabel { font-size: 18px; font-weight: 800; color: var(--text); }
.sampleLabel span,
.sampleHint,
.sampleCard .sampleHint { font-size: 11px; color: var(--muted); font-weight: 500; }
.sampleCard .sampleLabel { padding: 8px 14px 4px 14px; }
.sampleCard .sampleHint  { padding: 0 14px 8px 14px; box-sizing: border-box; }

/* ── 이미지 카드 ── */
.images { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
@media (min-width: 980px) { .images { grid-template-columns: 1fr 1fr 1fr; } }

.card { border: 3px solid transparent; border-radius: 14px; overflow: hidden; }
.card.selected  { border-color: red; }
.card.confirmed { border-color: lime; }
.card img { width: 100%; display: block; aspect-ratio: 9/16; object-fit: contain; object-position: center; background: #0b0e14; }

.preview { margin-top: 10px; font-size: 12px; white-space: pre-wrap; background: #0b0e14; border: 1px dashed var(--border); border-radius: 10px; padding: 10px; }
.smallNote { font-size: 16px; color: #111; font-weight: 800; margin-top: 6px; }
.row2 { display: grid; grid-template-columns: 1fr; gap: 10px; }

.badge { display: inline-block; padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; color: var(--text); background: #0f121a; }

#preview { display: none !important; }

/* ── 확정 버튼 행 ── */
.styleConfirmRow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 6px; }
.infoConfirmRow  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 6px; }

.btnConfirmStyle, .btnConfirmInfo, .confirm {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  font-weight: 700;
  cursor: pointer;
  background: #16a34a !important;
  color: white !important;
}

.btnUnconfirmStyle, .btnUnconfirmInfo, .reset {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  font-weight: 700;
  cursor: pointer;
  background: #dc2626 !important;
  color: white !important;
}

.btnConfirmStyle:disabled,
.btnConfirmInfo:disabled,
.confirm:disabled { opacity: .45; cursor: not-allowed; }

.btnUnconfirmStyle:disabled,
.btnUnconfirmInfo:disabled,
.reset:disabled { opacity: .45; cursor: not-allowed; }

.styleConfirmHint { color: rgba(255,255,255,.72); font-size: 13px; }

/* ── 텍스트 유틸 ── */
.step5-hint, .hint, .subhint, .muted { opacity: 1 !important; color: #cfd8e3 !important; font-size: 14px !important; }

#novelTextStep5::placeholder { color: #6c757d; font-size: 16px; font-weight: 600; }
#novelTextStep5 { font-size: 14px; line-height: 1.55; }

.flex-start-wrap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.ghost-row { margin: 0 0 12px; }
.btn-primary { padding: 12px 24px; font-size: 16px; font-weight: 800; border: none; border-radius: 10px; cursor: pointer; background: var(--blue); color: #fff; }

/* ── ★ 캐릭터 구성 진행 박스 ── */
#charRefProgressBox {
  display: none;
  margin-bottom: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
  border: 1.5px solid #30363d;
  border-radius: 14px;
  color: #e8ecf4;
}

#charRefProgressBox .phase-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 6px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

#charRefProgressBox .phase-sub {
  font-size: 13px;
  color: #8b95a8;
  margin-bottom: 14px;
  line-height: 1.6;
  white-space: pre-line;
}

#charRefProgressBox .ref-bar-wrap {
  height: 10px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}

#charRefProgressBar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  transition: width 0.4s ease;
}

#charRefProgressBar.pulse {
  width: 100% !important;
  background: linear-gradient(90deg, #6366f1, #f5c66d, #6366f1);
  background-size: 200% 100%;
  animation: pulseMove 1.2s linear infinite;
}

#charRefCharList { display: flex; flex-direction: column; gap: 7px; max-height: 160px; overflow-y: auto; }

.char-ref-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #c9d1d9;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
}

.char-ref-item .char-icon   { font-size: 16px; width: 22px; text-align: center; }
.char-ref-item .char-name   { font-weight: 700; color: #fff; }
.char-ref-item .char-status { font-size: 12px; color: #8b95a8; margin-left: auto; }
.char-ref-item.done .char-status { color: #10b981; }
.char-ref-item.skip .char-status { color: #f5c66d; }
.char-ref-item.fail .char-status { color: #ef5b5b; }
.char-ref-item.active .char-name   { color: #a5b4fc; }
.char-ref-item.active .char-status { color: #a5b4fc; animation: blink 1s ease-in-out infinite; }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Step 4 탭 (1:4 비율) ── */
.step4-tabs { display: flex; gap: 0; margin-bottom: 16px; border-radius: 10px; overflow: hidden; border: 1.5px solid #e0e7ff; }
.step4-tabs .tab-btn { padding: 12px 0; font-size: 14px; font-weight: 700; border: none; cursor: pointer; transition: background .2s, color .2s; }
.step4-tabs .tab-btn:not(.active) { background: #f8f9ff; color: var(--muted); border-left: 1.5px solid #e0e7ff; }
.step4-tabs .tab-btn:first-child { border-left: none; }
.step4-tabs .tab-btn#tabBtnUpload { flex: 1; }
.step4-tabs .tab-btn#tabBtnAi    { flex: 4; }
.step4-tabs .tab-btn.active { background: #6366f1; color: #fff; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── 드래그 & 드롭 업로드 존 ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  transition: border-color .2s, background .2s;
}

.drop-zone:hover,
.drop-zone.dragover { border-color: #6366f1; background: rgba(99,102,241,.06); color: #6366f1; }

/* ── 업로드 후 미리보기 ── */
.upload-preview-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-top: 14px;
  flex-wrap: wrap;
  position: relative;
}

.upload-preview-row .preview-box { flex: 1; min-width: 120px; text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; }
.upload-preview-row .preview-box img { width: 100%; max-width: 160px; border-radius: 8px; margin-top: 6px; border: 1px solid var(--border); }
.upload-arrow { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 22px; color: var(--muted); pointer-events: none; }
.preview-left-col { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 120px; }

/* ── Step 4 회전 버튼 ── */
.rotate-btn-row { display: flex; justify-content: center; margin-top: 8px; }
.rotate-btn {
  padding: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: opacity .15s;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.rotate-btn:hover { opacity: 0.75; }

/* ── Step 5 미리보기 ── */
.step5-preview-wrap { text-align: center; margin-bottom: 16px; }
.step5-preview-wrap img {
  width: 100%;
  max-width: 416px;
  aspect-ratio: 832/1248;
  object-fit: contain;
  border-radius: 10px;
  border: 2px solid var(--border);
}

.step5-upper-warn {
  margin: 10px auto;
  max-width: 400px;
  padding: 10px 14px;
  background: rgba(255,193,7,.12);
  border: 1px solid rgba(255,193,7,.4);
  border-radius: 8px;
  color: #f5c66d;
  font-size: 13px;
  line-height: 1.6;
  text-align: left;
}

/* ── Step 4 AI 탭 배경제거 진행바 ── */
#rembgProgressWrap {
  display: none;
  margin-top: 16px;
  padding: 14px 18px;
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 12px;
}

/* ── Step 4 AI 탭: 캐러셀 ── */
.candidate-carousel {
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin: 6px 0;
  min-height: 220px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.candidate-grid {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  justify-content: flex-start;
  overflow: hidden;
  min-height: 200px;
  align-items: stretch;
}

.candidate-card {
  flex: 1 1 0;
  min-width: 0;
  cursor: pointer;
  border: 3px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color .2s;
  text-align: center;
  font-size: 12px;
  background: rgba(0,0,0,.04);
}

.candidate-card img { width: 100%; aspect-ratio: 832/1248; object-fit: cover; display: block; border-radius: 5px 5px 0 0; }
.candidate-card .candidate-label { padding: 4px 0 3px; color: var(--muted); font-weight: 400; }
.candidate-card.selected { border-color: #6366f1; }
.candidate-card.selected .candidate-label { color: #6366f1; font-weight: 700; }
.candidate-card:hover:not(.selected) { border-color: rgba(99,102,241,.4); }

.carousel-arrow {
  padding: 6px 8px;
  font-size: 16px;
  border: 1.5px solid #e0e7ff;
  border-radius: 50%;
  cursor: pointer;
  background: #f8f9ff;
  color: var(--text);
  flex-shrink: 0;
  flex-grow: 0;
  width: 32px;
  min-width: 32px;
  max-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .2s, border-color .2s, background .2s;
}
.carousel-arrow:hover:not(:disabled) { border-color: #6366f1; background: rgba(99,102,241,.08); }

.carousel-arrow:disabled { opacity: .25; cursor: not-allowed; }
