/* ============================================
   BookPlatform - Book Creation Workflow
   Steps, search, interview chat, outline,
   generator progress, book reader/editor
   ============================================ */

/* =============================================
   1. WORKFLOW STEP INDICATOR
   ============================================= */
.workflow-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  font-family: 'Noto Sans KR', sans-serif;
  background-color: #0a0a0f;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  color: #888;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.step .step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #2a2a3a;
  background-color: #12121a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #888;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.step .step-label {
  transition: color 0.3s ease;
}

/* Connector line between steps */
.step + .step::before {
  content: '';
  display: block;
  width: 60px;
  height: 2px;
  background-color: #2a2a3a;
  margin: 0 0.75rem;
  flex-shrink: 0;
  transition: background-color 0.3s ease;
}

/* Active step */
.step.active .step-number {
  border-color: #6c5ce7;
  background: linear-gradient(135deg, #6c5ce7 0%, #a855f7 100%);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(108, 92, 231, 0.4);
}

.step.active .step-label {
  color: #e0e0e0;
}

/* Completed step */
.step.completed .step-number {
  border-color: #10b981;
  background-color: #10b981;
  color: #ffffff;
}

.step.completed .step-label {
  color: #10b981;
}

.step.completed + .step::before {
  background-color: #10b981;
}

/* =============================================
   2. SEARCH RESULTS
   ============================================= */
.search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  padding: 1rem 0;
  font-family: 'Noto Sans KR', sans-serif;
}

.search-card {
  background-color: #12121a;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.search-card:hover {
  border-color: #6c5ce7;
  transform: translateY(-2px);
}

.search-card h4 {
  margin: 0 0 0.375rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #e0e0e0;
  line-height: 1.4;
}

.search-card p {
  margin: 0;
  font-size: 0.8125rem;
  color: #888;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Reference book cards ---------- */
.reference-card {
  background-color: #12121a;
  border: 2px solid #2a2a3a;
  border-radius: 10px;
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  position: relative;
}

.reference-card:hover {
  border-color: #6c5ce7;
}

/* Checkbox indicator */
.reference-card::after {
  content: '';
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid #2a2a3a;
  background-color: #0a0a0f;
  transition: all 0.2s ease;
}

.reference-card.reference-selected {
  border-color: #6c5ce7;
  background-color: rgba(108, 92, 231, 0.06);
}

.reference-card.reference-selected::after {
  border-color: #6c5ce7;
  background: linear-gradient(135deg, #6c5ce7 0%, #a855f7 100%);
}

/* =============================================
   3. INTERVIEW CHAT UI
   ============================================= */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 600px;
  max-height: 70vh;
  background-color: #0a0a0f;
  border: 1px solid #2a2a3a;
  border-radius: 12px;
  overflow: hidden;
  font-family: 'Noto Sans KR', sans-serif;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: #2a2a3a;
  border-radius: 3px;
}

/* Chat bubble base */
.chat-bubble {
  max-width: 75%;
  padding: 0.875rem 1.125rem;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: #e0e0e0;
  word-wrap: break-word;
}

/* AI bubble - left aligned */
.chat-bubble-ai {
  align-self: flex-start;
  background-color: #1a1a2e;
  border: 1px solid #2a2a3a;
  border-bottom-left-radius: 4px;
}

/* User bubble - right aligned */
.chat-bubble-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #6c5ce7 0%, #a855f7 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

/* Chat input area */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid #2a2a3a;
  background-color: #12121a;
}

.chat-input-area input,
.chat-input-area textarea {
  flex: 1;
  padding: 0.75rem 1rem;
  background-color: #1a1a2e;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  color: #e0e0e0;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 0.9375rem;
  resize: none;
  transition: border-color 0.2s ease;
}

.chat-input-area input:focus,
.chat-input-area textarea:focus {
  outline: none;
  border-color: #6c5ce7;
}

.chat-input-area button {
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, #6c5ce7 0%, #a855f7 100%);
  border: none;
  border-radius: 8px;
  color: #ffffff;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}

.chat-input-area button:hover {
  opacity: 0.9;
}

/* =============================================
   4. OUTLINE EDITOR
   ============================================= */
.outline-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 0;
  font-family: 'Noto Sans KR', sans-serif;
}

.outline-chapter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background-color: #12121a;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.outline-chapter:hover {
  border-color: #6c5ce7;
}

.outline-chapter.dragging {
  opacity: 0.5;
  border-color: #a855f7;
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.2);
}

.chapter-drag-handle {
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: grab;
  padding: 0.25rem;
  color: #555;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.chapter-drag-handle:hover {
  color: #a855f7;
}

.chapter-drag-handle::before,
.chapter-drag-handle::after {
  content: '⠿';
  font-size: 1rem;
  line-height: 0.5;
}

.chapter-drag-handle::after {
  display: none;
}

.outline-chapter .chapter-number {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background-color: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #6c5ce7;
  flex-shrink: 0;
}

.outline-chapter .chapter-title {
  flex: 1;
  font-size: 0.9375rem;
  color: #e0e0e0;
  font-weight: 500;
}

.outline-chapter .chapter-actions {
  display: flex;
  gap: 0.375rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.outline-chapter:hover .chapter-actions {
  opacity: 1;
}

.outline-chapter .chapter-actions button {
  padding: 0.375rem 0.5rem;
  background: none;
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  color: #888;
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.outline-chapter .chapter-actions button:hover {
  color: #a855f7;
  border-color: #a855f7;
}

/* =============================================
   5. CHAPTER GENERATOR PROGRESS
   ============================================= */
.generator-progress {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.5rem 0;
  font-family: 'Noto Sans KR', sans-serif;
}

.chapter-progress-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background-color: #12121a;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
}

.chapter-progress-item .progress-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
  background-color: #1a1a2e;
  color: #888;
}

.chapter-progress-item.pending .progress-icon {
  background-color: #1a1a2e;
  color: #555;
}

.chapter-progress-item.generating .progress-icon {
  background-color: rgba(108, 92, 231, 0.15);
  color: #6c5ce7;
  animation: pulse-glow 1.5s ease-in-out infinite;
}

.chapter-progress-item.completed .progress-icon {
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.chapter-progress-item.error .progress-icon {
  background-color: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0); }
  50%      { box-shadow: 0 0 12px 4px rgba(108, 92, 231, 0.3); }
}

.chapter-progress-item .progress-info {
  flex: 1;
  min-width: 0;
}

.chapter-progress-item .progress-info h4 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #e0e0e0;
}

.chapter-progress-item .progress-info p {
  margin: 0.125rem 0 0;
  font-size: 0.75rem;
  color: #888;
}

.chapter-progress-item .progress-bar {
  width: 120px;
  height: 4px;
  background-color: #1a1a2e;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 0;
}

.chapter-progress-item .progress-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #6c5ce7 0%, #a855f7 100%);
  transition: width 0.6s ease;
}

/* =============================================
   6. BOOK READER / EDITOR WITH SIDEBAR
   ============================================= */
.book-reader {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: calc(100vh - 80px);
  background-color: #0a0a0f;
  font-family: 'Noto Sans KR', sans-serif;
  border: 1px solid #2a2a3a;
  border-radius: 12px;
  overflow: hidden;
}

/* Sidebar chapter list */
.reader-sidebar {
  background-color: #12121a;
  border-right: 1px solid #2a2a3a;
  overflow-y: auto;
  padding: 1.25rem 0;
}

.reader-sidebar::-webkit-scrollbar {
  width: 4px;
}

.reader-sidebar::-webkit-scrollbar-thumb {
  background-color: #2a2a3a;
  border-radius: 2px;
}

.reader-sidebar h3 {
  padding: 0 1.25rem;
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.reader-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.reader-sidebar li {
  margin: 0;
}

.reader-sidebar li a {
  display: block;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  color: #888;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.reader-sidebar li a:hover {
  color: #e0e0e0;
  background-color: rgba(108, 92, 231, 0.06);
}

.reader-sidebar li a.active {
  color: #a855f7;
  background-color: rgba(108, 92, 231, 0.08);
  border-left-color: #6c5ce7;
  font-weight: 500;
}

/* Reader content area */
.reader-content {
  overflow-y: auto;
  padding: 2.5rem 3rem;
}

.reader-content::-webkit-scrollbar {
  width: 6px;
}

.reader-content::-webkit-scrollbar-thumb {
  background-color: #2a2a3a;
  border-radius: 3px;
}

.reader-content h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 1.5rem;
}

.reader-content h2 {
  font-size: 1.375rem;
  font-weight: 600;
  color: #e0e0e0;
  margin: 2rem 0 1rem;
}

.reader-content p {
  font-size: 1rem;
  color: #e0e0e0;
  line-height: 1.85;
  margin: 0 0 1.25rem;
}

/* Chapter editor (editable area) */
.chapter-editor {
  min-height: 300px;
  padding: 1.5rem;
  background-color: #12121a;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  color: #e0e0e0;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 1rem;
  line-height: 1.85;
  outline: none;
  transition: border-color 0.2s ease;
}

.chapter-editor:focus {
  border-color: #6c5ce7;
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.chapter-editor:empty::before {
  content: attr(data-placeholder);
  color: #555;
}

/* =============================================
   7. RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .workflow-steps {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .step + .step::before {
    width: 30px;
  }

  .step .step-label {
    display: none;
  }

  .chat-container {
    height: 500px;
  }

  .chat-bubble {
    max-width: 88%;
  }

  .book-reader {
    grid-template-columns: 1fr;
    height: auto;
  }

  .reader-sidebar {
    border-right: none;
    border-bottom: 1px solid #2a2a3a;
    max-height: 200px;
  }

  .reader-content {
    padding: 1.5rem;
  }

  .search-results {
    grid-template-columns: 1fr;
  }
}
