/* ═══════════════════════════════════════════════════════════════════════════
   SCREENPLAY ENHANCEMENTS CSS
   Styles for: Polish Modal, Line Comments, Beat Analysis, Heatmap, Arc Tracker
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────
   1. POLISH MODAL (before/after dialogue comparison)
   ───────────────────────────────────────────────────────────────────────── */

.polish-modal {
  width: min(800px, 96vw) !important;
}

.polish-modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

.polish-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.polish-column h4 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-soft-gray);
  display: flex;
  align-items: center;
  gap: 8px;
}

.polish-text {
  padding: 16px;
  border-radius: 12px;
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 0.92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  min-height: 120px;
}

.polish-text--before {
  background: rgba(0,0,0,0.03);
  border: 1px solid var(--border-glass);
  color: var(--color-text);
}

.polish-text--after {
  background: linear-gradient(135deg, rgba(90,24,154,0.06), rgba(130,60,200,0.02));
  border: 1px solid rgba(90,24,154,0.2);
  color: var(--color-text);
}

body.dark .polish-text--before {
  background: rgba(255,255,255,0.03);
}

body.dark .polish-text--after {
  background: linear-gradient(135deg, rgba(90,24,154,0.15), rgba(130,60,200,0.08));
  border-color: rgba(90,24,154,0.4);
}

@media (max-width: 768px) {
  .polish-comparison {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   2. LINE-LEVEL COMMENTS (margin dots + thread popover)
   ───────────────────────────────────────────────────────────────────────── */

.sp-comment-dot {
  position: absolute;
  right: -32px;
  top: 50%;
  transform: translateY(-50%);
  
  width: 20px;
  height: 20px;
  border-radius: 50%;
  
  background: linear-gradient(135deg, #F5A623, #F76B1C);
  color: white;
  border: none;
  
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 10;
}

.sp-comment-dot:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1.15);
}

/* Comment Thread Popover */
.sp-comment-thread {
  position: fixed;
  width: 380px;
  max-width: calc(100vw - 40px);
  max-height: 500px;
  
  background: var(--bg-glass-card);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  
  display: flex;
  flex-direction: column;
  
  z-index: 5000;
}

body.dark .sp-comment-thread {
  background: rgba(20,15,35,0.97);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}

.sp-comment-thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(90,24,154,0.04);
}

body.dark .sp-comment-thread-header {
  background: rgba(90,24,154,0.12);
}

.sp-comment-thread-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
}

.sp-comment-thread-close {
  background: none;
  border: none;
  color: var(--color-soft-gray);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}

.sp-comment-thread-close:hover {
  color: var(--color-text);
  background: rgba(0,0,0,0.05);
}

.sp-comment-thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sp-comment-empty {
  text-align: center;
  color: var(--color-soft-gray);
  font-size: 0.85rem;
  padding: 20px;
}

.sp-comment-item {
  background: var(--bg-glass-panel);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 10px 12px;
}

.sp-comment-item--resolved {
  opacity: 0.5;
  border-color: rgba(40,167,69,0.3);
}

.sp-comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sp-comment-author {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-primary);
}

body.dark .sp-comment-author {
  color: var(--color-secondary);
}

.sp-comment-time {
  font-size: 0.7rem;
  color: var(--color-soft-gray);
}

.sp-comment-text {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--color-text);
  margin-bottom: 8px;
}

.sp-comment-replies {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 2px solid rgba(90,24,154,0.2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sp-comment-reply {
  font-size: 0.8rem;
  color: var(--color-text);
}

.sp-comment-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.sp-comment-action-btn {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--border-glass);
  border-radius: 6px;
  color: var(--color-text);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sp-comment-action-btn:hover {
  background: rgba(90,24,154,0.08);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.sp-comment-action-btn--danger:hover {
  background: rgba(220,53,69,0.08);
  border-color: #dc3545;
  color: #dc3545;
}

.sp-comment-thread-footer {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-glass);
}

.sp-comment-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--color-text);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.sp-comment-input:focus {
  border-color: var(--color-primary);
}

.sp-comment-send-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sp-comment-send-btn:hover {
  background: var(--color-dark-purple);
  transform: scale(1.05);
}

/* ─────────────────────────────────────────────────────────────────────────
   3. BEATS MODAL (story structure analysis)
   ───────────────────────────────────────────────────────────────────────── */

.beats-modal {
  width: min(600px, 96vw) !important;
}

.beats-modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

.beats-hint {
  font-size: 0.82rem;
  color: var(--color-soft-gray);
  margin: 0 0 16px;
  padding: 10px 14px;
  background: rgba(90,24,154,0.04);
  border-radius: 10px;
  border-left: 3px solid var(--color-primary);
}

body.dark .beats-hint {
  background: rgba(90,24,154,0.12);
}

.beats-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.beat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass-panel);
  transition: all 0.15s ease;
}

.beat-item:hover {
  box-shadow: 0 4px 16px rgba(90,24,154,0.1);
}

.beat-item--found .beat-icon {
  color: #28a745;
}

.beat-item--missing .beat-icon {
  color: #F5A623;
}

.beat-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.beat-content {
  flex: 1;
}

.beat-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 2px;
}

.beat-scene {
  font-size: 0.75rem;
  color: var(--color-soft-gray);
}

.beat-jump-btn {
  padding: 6px 12px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.beat-jump-btn:hover {
  background: var(--color-dark-purple);
  transform: translateY(-1px);
}

/* ─────────────────────────────────────────────────────────────────────────
   4. HEATMAP (scene intensity visualization)
   ───────────────────────────────────────────────────────────────────────── */

#heatmapContainer {
  padding: 20px;
}

.heatmap-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.heatmap-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--color-text);
}

.heatmap-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.heatmap-legend-dot--low   { background: #4A90E2; }
.heatmap-legend-dot--mid   { background: #F5A623; }
.heatmap-legend-dot--high  { background: #E94B3C; }

.heatmap-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 300px;
  padding: 20px;
  background: var(--bg-glass-panel);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  overflow-x: auto;
}

.heatmap-bar {
  flex: 1;
  min-width: 20px;
  max-width: 40px;
  border-radius: 4px 4px 0 0;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
}

.heatmap-bar:hover {
  transform: translateY(-4px);
  opacity: 0.8;
}

.heatmap-bar-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.heatmap-hint {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--color-soft-gray);
  text-align: center;
}

/* ─────────────────────────────────────────────────────────────────────────
   5. ARC TRACKER (character development)
   ───────────────────────────────────────────────────────────────────────── */

#arcTrackerContainer {
  padding: 20px;
}

.arc-tracker-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.arc-item {
  padding: 16px 18px;
  background: var(--bg-glass-panel);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  transition: box-shadow 0.15s ease;
}

.arc-item:hover {
  box-shadow: 0 4px 20px rgba(90,24,154,0.12);
}

.arc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 10px;
}

.arc-character-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
}

body.dark .arc-character-name {
  color: var(--color-secondary);
}

.arc-scene-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}

.arc-scene-badge {
  padding: 4px 10px;
  background: rgba(90,24,154,0.1);
  border-radius: 8px;
  color: var(--color-text);
  font-weight: 600;
}

.arc-summary {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--color-text);
  margin-bottom: 14px;
}

.arc-progress {
  position: relative;
  height: 8px;
  background: rgba(90,24,154,0.1);
  border-radius: 8px;
  overflow: hidden;
}

.arc-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-dark-purple));
  border-radius: 8px;
  transition: width 0.3s ease;
}

.arc-progress-dots {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.arc-progress-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--color-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.arc-progress-dot:hover {
  transform: scale(1.3);
}

.arc-progress-dot--first { background: #28a745; border-color: #28a745; }
.arc-progress-dot--mid   { background: #F5A623; border-color: #F5A623; }
.arc-progress-dot--final { background: #E94B3C; border-color: #E94B3C; }

/* ─────────────────────────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────────────────────────── */

/* Modal Tabs (for Stats and Report modals) */
.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(90,24,154,0.02);
}

.modal-tab-btn {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-soft-gray);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.modal-tab-btn:hover {
  color: var(--color-text);
  background: rgba(90,24,154,0.04);
}

.modal-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

body.dark .modal-tab-btn.active {
  color: var(--color-secondary);
  border-bottom-color: var(--color-secondary);
}

.modal-tab-content {
  display: none;
}

.modal-tab-content.active {
  display: block;
}

/* ─── Quick Comment Box (inline prompt from context menu) ─── */
.sp-quick-comment-box {
  position: absolute;
  z-index: 5500;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px;
  background: var(--bg-glass-card);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  min-width: 320px;
}

body.dark .sp-quick-comment-box {
  background: rgba(20,15,35,0.97);
}

.sp-comment-close-btn {
  background: rgba(0,0,0,0.06) !important;
}

body.dark .sp-comment-close-btn {
  background: rgba(255,255,255,0.08) !important;
}

@media (max-width: 768px) {
  .sp-comment-dot {
    right: -28px;
    width: 18px;
    height: 18px;
    font-size: 0.6rem;
  }

  .sp-comment-thread {
    width: calc(100vw - 20px);
    max-height: 70vh;
  }

  .heatmap-chart {
    height: 200px;
  }

  .arc-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
