/* ==========================================================================
   AI Novel Studio - Editor & Studio Workspace Styles
   ========================================================================== */

/* Layout Wrapper */
.studio-layout {
  display: grid;
  grid-template-columns: 280px 1fr 340px;
  height: calc(100vh - 64px);
  overflow: hidden;
  position: relative;
}

.studio-layout.zen-mode {
  grid-template-columns: 0 1fr 0;
}

.studio-layout.zen-mode .studio-sidebar-left,
.studio-layout.zen-mode .studio-sidebar-right {
  display: none;
}

/* Sidebar Left (Navigator) */
.studio-sidebar-left {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-tab-btn {
  flex: 1;
  padding: 12px 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.sidebar-tab-btn.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
  background: rgba(234, 179, 8, 0.05);
}

.sidebar-content-pane {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Project Tree & Chapter List */
.project-meta-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 16px;
}

.project-title-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.project-genre-badge {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}

.chapter-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-size: 0.88rem;
}

.chapter-item:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.chapter-item.active {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
  color: #fff;
  font-weight: 600;
}

.chapter-word-tag {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* Center Editor Canvas */
.studio-canvas {
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.canvas-header {
  padding: 12px 24px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chapter-title-input {
  background: transparent;
  border: none;
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  outline: none;
  width: 60%;
}
.chapter-title-input:focus {
  border-bottom: 1px dashed var(--accent-cyan);
}

.canvas-body {
  flex: 1;
  overflow-y: auto;
  padding: 30px 48px;
  position: relative;
}

.editor-paper {
  max-width: 820px;
  margin: 0 auto;
  min-height: 100%;
}

.novel-textarea {
  width: 100%;
  min-height: 500px;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-novel);
  font-size: 1.15rem;
  line-height: 1.85;
  color: #e2e8f0;
  resize: none;
}

/* Inline Ghost-Text Autocomplete Display */
.ghost-text-container {
  margin-top: -12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: rgba(234, 179, 8, 0.08);
  border-left: 3px solid var(--accent-gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: fadeIn 0.2s ease;
}

.ghost-text-content {
  font-family: var(--font-novel);
  font-size: 1.05rem;
  color: #fde047;
  font-style: italic;
  opacity: 0.9;
}

.ghost-text-hints {
  display: flex;
  gap: 8px;
}

.kbd-badge {
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #f8fafc;
}

/* Floating AI Action Bubble Menu */
.floating-ai-menu {
  position: absolute;
  background: #1e293b;
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: var(--shadow-md), var(--shadow-glow-cyan);
  border-radius: var(--radius-md);
  padding: 6px;
  display: none;
  gap: 6px;
  z-index: 500;
  animation: popIn 0.2s ease;
}

.floating-ai-menu.active {
  display: flex;
}

.floating-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.floating-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
}

/* Canvas Status Bar */
.canvas-statusbar {
  height: 38px;
  background: rgba(15, 23, 42, 0.9);
  border-top: 1px solid var(--border-subtle);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.statusbar-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Sidebar Right (Multi-Agent Activity & Lorebook & 7D Evaluation) */
.studio-sidebar-right {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Activity Stream */
.activity-stream {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 0.85rem;
  position: relative;
  transition: all 0.2s;
}

.activity-card.coordinator { border-left: 3px solid var(--accent-purple); }
.activity-card.architect { border-left: 3px solid var(--accent-cyan); }
.activity-card.writer { border-left: 3px solid var(--accent-gold); }
.activity-card.editor { border-left: 3px solid var(--accent-rose); }
.activity-card.arbiter { border-left: 3px solid var(--accent-emerald); }

.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.agent-tag {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.agent-tag.coordinator { color: var(--accent-purple); }
.agent-tag.architect { color: var(--accent-cyan); }
.agent-tag.writer { color: var(--accent-gold); }
.agent-tag.editor { color: var(--accent-rose); }
.agent-tag.arbiter { color: var(--accent-emerald); }

.activity-time {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.activity-body {
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 7D Radar & Score Card */
.score-7d-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.score-7d-overall {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.overall-score-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-gold);
  font-family: var(--font-title);
}

.score-bar-item {
  margin-bottom: 10px;
}

.score-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.progress-track {
  height: 6px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-gold));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* VietQR Payment Modal Specifics */
.vietqr-card {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  align-items: center;
}

.vietqr-img-wrapper {
  background: #fff;
  padding: 8px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.vietqr-img {
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.vietqr-info-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vietqr-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 6px;
}

.vietqr-info-row .label { color: var(--text-dim); }
.vietqr-info-row .val { font-weight: 600; color: #fff; }

.package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.package-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.package-card:hover, .package-card.active {
  border-color: var(--accent-gold);
  background: rgba(234, 179, 8, 0.1);
  transform: translateY(-2px);
}

.package-name { font-size: 0.9rem; font-weight: 700; color: #fff; }
.package-coins { font-size: 1.1rem; font-weight: 800; color: var(--accent-gold); margin: 4px 0; }
.package-price { font-size: 0.8rem; color: var(--text-dim); }

/* Novel Library Grid & Cards (Tủ Truyện) */
.novel-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  max-height: 480px;
  overflow-y: auto;
  padding: 4px;
}

.novel-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  position: relative;
}

.novel-card:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.novel-card.active-novel {
  border-color: var(--accent-gold);
  background: rgba(234, 179, 8, 0.06);
}

.novel-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.novel-card-genre {
  font-size: 0.72rem;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
}

.novel-card-active-tag {
  font-size: 0.7rem;
  color: #000;
  background: var(--accent-gold);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.novel-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.3;
}

.novel-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.novel-card-stats {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 8px;
}

.novel-card-actions {
  display: flex;
  gap: 8px;
}

/* Keyframe animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
