/**
 * Document Viewer Enhancements
 * - Depth visualization with color bars
 * - Enhanced section numbering
 * - Improved TOC styling
 * - Admin restriction indicators
 */

/* ========================================
   DEPTH VISUALIZATION
   ======================================== */

.section-depth-indicator {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 0 4px 4px 0;
  transition: width 0.2s ease;
}

.section-card {
  position: relative;
  transition: all 0.2s ease;
}

/* Progressive indentation based on depth - BOLD visual hierarchy */
.section-card[data-depth="0"] {
  margin-left: 0;
  padding-left: 1.5rem;
}
.section-card[data-depth="1"] {
  margin-left: 2.5rem;
  padding-left: 1.5rem;
  border-left: 4px solid #0d6efd;
  background: #f8f9ff;
}
.section-card[data-depth="2"] {
  margin-left: 5rem;
  padding-left: 1.5rem;
  border-left: 4px solid #6610f2;
  background: #f9f7ff;
}
.section-card[data-depth="3"] {
  margin-left: 7.5rem;
  padding-left: 1.5rem;
  border-left: 4px solid #6f42c1;
  background: #faf8ff;
}
.section-card[data-depth="4"] {
  margin-left: 10rem;
  padding-left: 1.5rem;
  border-left: 4px solid #d63384;
  background: #fff5fa;
}
.section-card[data-depth="5"] {
  margin-left: 12.5rem;
  padding-left: 1.5rem;
  border-left: 4px solid #dc3545;
  background: #fff5f5;
}

/* Color scheme for depth levels (10 distinct colors) */
.section-card[data-depth="0"] .section-depth-indicator { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.section-card[data-depth="1"] .section-depth-indicator { background: linear-gradient(135deg, #48c6ef 0%, #6f86d6 100%); }
.section-card[data-depth="2"] .section-depth-indicator { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.section-card[data-depth="3"] .section-depth-indicator { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.section-card[data-depth="4"] .section-depth-indicator { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.section-card[data-depth="5"] .section-depth-indicator { background: linear-gradient(135deg, #30cfd0 0%, #330867 100%); }
.section-card[data-depth="6"] .section-depth-indicator { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); }
.section-card[data-depth="7"] .section-depth-indicator { background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%); }
.section-card[data-depth="8"] .section-depth-indicator { background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); }
.section-card[data-depth="9"] .section-depth-indicator { background: linear-gradient(135deg, #ff6e7f 0%, #bfe9ff 100%); }

/* Expand depth indicator on hover */
.section-card:hover .section-depth-indicator {
  width: 8px;
}

/* ========================================
   ADMIN RESTRICTIONS INDICATORS
   ======================================== */

.section-action-disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
  position: relative;
}

.section-action-disabled:hover::after {
  content: attr(data-disabled-reason);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 4px;
  z-index: 1000;
  margin-bottom: 8px;
  pointer-events: none;
}

.section-action-disabled:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  margin-bottom: 2px;
  pointer-events: none;
}

.admin-restriction-notice {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 4px;
  font-size: 14px;
}

.admin-restriction-notice i {
  color: #ffc107;
  margin-right: 8px;
}

/* ========================================
   ENHANCED SECTION NUMBERING
   ======================================== */

.section-auto-number {
  font-family: 'Courier New', monospace;
  font-weight: bold;
  color: #667eea;
  font-size: 14px;
  background: #f8f9fa;
  padding: 4px 8px;
  border-radius: 4px;
  margin-right: 8px;
  display: inline-block;
  min-width: 60px;
  text-align: center;
}

.section-citation-full {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 8px;
}

/* ========================================
   LAZY LOADING INDICATORS
   ======================================== */

.section-loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #6c757d;
}

.section-suggestions-container {
  min-height: 60px;
  position: relative;
}

.section-suggestions-placeholder {
  text-align: center;
  padding: 20px;
  color: #6c757d;
  font-style: italic;
  background: #f8f9fa;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.section-suggestions-placeholder:hover {
  background: #e9ecef;
}

.lazy-load-trigger {
  cursor: pointer;
  transition: all 0.2s ease;
}

.lazy-load-trigger:hover {
  background: #f0f8ff;
  border-color: #0066cc;
}

/* ========================================
   USER COMMENT HIGHLIGHTING (CMT-004)
   ======================================== */

/* Highlight user's own suggestions/comments with subtle background gradient */
.suggestion-item.my-suggestion {
  background: linear-gradient(to right, #e3f2fd 0%, #ffffff 100%);
  border-left: 4px solid #2196f3;
  box-shadow: 0 1px 3px rgba(33, 150, 243, 0.1);
}

/* Default suggestion style */
.suggestion-item {
  background: #ffffff;
  border-left: 4px solid transparent;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

/* "You" badge for user's own comments */
.you-badge {
  display: inline-block;
  background: #2196f3;
  color: #ffffff;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Hover effect for all suggestions */
.suggestion-item:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Enhanced hover for user's own comments */
.suggestion-item.my-suggestion:hover {
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.2);
  background: linear-gradient(to right, #e3f2fd 0%, #f8f9fa 100%);
}

/* ========================================
   WORKFLOW PROGRESSION BUTTON
   ======================================== */

.workflow-progression-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 24px;
  border-radius: 12px;
  margin: 24px 0;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.workflow-progression-section h4 {
  margin: 0 0 12px 0;
  font-size: 20px;
  font-weight: 600;
}

.workflow-progression-section p {
  margin: 0 0 16px 0;
  opacity: 0.95;
  font-size: 14px;
}

.btn-create-new-version {
  background: white;
  color: #667eea;
  border: none;
  padding: 12px 24px;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-create-new-version:hover {
  background: #f8f9fa;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-create-new-version i {
  margin-right: 8px;
}

/* ========================================
   STICKY TOC
   ======================================== */

.document-toc-sticky {
  position: sticky;
  top: 20px;
  z-index: 100;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
  /* Reduce depth indentation on mobile */
  .section-card[data-depth="0"] { padding-left: 1.5rem; }
  .section-card[data-depth="1"] { padding-left: 1.75rem; }
  .section-card[data-depth="2"] { padding-left: 2rem; }
  .section-card[data-depth="3"] { padding-left: 2.25rem; }
  .section-card[data-depth="4"],
  .section-card[data-depth="5"],
  .section-card[data-depth="6"],
  .section-card[data-depth="7"],
  .section-card[data-depth="8"],
  .section-card[data-depth="9"] { padding-left: 2.5rem; }

  .section-depth-indicator {
    width: 3px;
  }

  .section-card:hover .section-depth-indicator {
    width: 5px;
  }

  .document-toc-sticky {
    position: relative;
    top: 0;
  }

  .workflow-progression-section {
    padding: 16px;
  }

  .section-auto-number {
    min-width: 50px;
    font-size: 12px;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus states */
.toc-link:focus,
.section-card:focus-within {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .section-card,
  .section-depth-indicator,
  .lazy-load-trigger,
  .btn-create-new-version {
    transition: none;
  }

  html {
    scroll-behavior: auto;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .section-depth-indicator {
    border: 2px solid currentColor;
  }

  .section-auto-number {
    border: 1px solid currentColor;
  }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

/* Section cards - dark mode backgrounds */
[data-theme="dark"] .section-card[data-depth="1"] {
  background: var(--bg-secondary, #1a1f2e);
  border-left-color: #58a6ff;
}

[data-theme="dark"] .section-card[data-depth="2"] {
  background: var(--bg-tertiary, #252b3b);
  border-left-color: #a371f7;
}

[data-theme="dark"] .section-card[data-depth="3"] {
  background: var(--card-bg, #161b22);
  border-left-color: #bc8cff;
}

[data-theme="dark"] .section-card[data-depth="4"] {
  background: var(--bg-secondary, #1a1f2e);
  border-left-color: #ff7eb6;
}

[data-theme="dark"] .section-card[data-depth="5"] {
  background: var(--bg-tertiary, #252b3b);
  border-left-color: #ff7b72;
}

/* Admin restriction notice - dark mode */
[data-theme="dark"] .admin-restriction-notice {
  background: var(--warning-bg, #4d3800);
  border-left-color: var(--warning-text, #f0b429);
  color: var(--warning-text, #f0b429);
}

[data-theme="dark"] .admin-restriction-notice i {
  color: var(--warning-text, #f0b429);
}

/* Section auto-number - dark mode */
[data-theme="dark"] .section-auto-number {
  background: var(--bg-tertiary, #252b3b);
  color: #a371f7;
}

/* Section citation - dark mode */
[data-theme="dark"] .section-citation-full {
  color: var(--text-primary, #e6edf3);
}

/* Loading spinner - dark mode */
[data-theme="dark"] .section-loading-spinner {
  color: var(--text-secondary, #9ea7b8);
}

/* Suggestions placeholder - dark mode */
[data-theme="dark"] .section-suggestions-placeholder {
  background: var(--bg-secondary, #1a1f2e);
  color: var(--text-secondary, #9ea7b8);
}

[data-theme="dark"] .section-suggestions-placeholder:hover {
  background: var(--bg-tertiary, #252b3b);
}

/* Lazy load trigger - dark mode */
[data-theme="dark"] .lazy-load-trigger:hover {
  background: var(--bg-secondary, #1a1f2e);
  border-color: #58a6ff;
}

/* Suggestion items - dark mode */
[data-theme="dark"] .suggestion-item {
  background: var(--card-bg, #161b22);
  color: var(--text-primary, #e6edf3);
}

[data-theme="dark"] .suggestion-item.my-suggestion {
  background: linear-gradient(to right, #0d2847 0%, var(--card-bg, #161b22) 100%);
  border-left-color: #58a6ff;
}

[data-theme="dark"] .suggestion-item:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .suggestion-item.my-suggestion:hover {
  box-shadow: 0 2px 8px rgba(88, 166, 255, 0.3);
  background: linear-gradient(to right, #0d2847 0%, var(--bg-secondary, #1a1f2e) 100%);
}

/* You badge - dark mode (already uses theme-friendly colors) */
[data-theme="dark"] .you-badge {
  background: #58a6ff;
  color: #0d1117;
}

/* Workflow progression section - dark mode */
[data-theme="dark"] .workflow-progression-section {
  background: linear-gradient(135deg, #1e3a5f 0%, #2d1f5c 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .btn-create-new-version {
  background: var(--card-bg, #161b22);
  color: #a371f7;
}

[data-theme="dark"] .btn-create-new-version:hover {
  background: var(--bg-secondary, #1a1f2e);
}

/* TOC links - dark mode */
[data-theme="dark"] .toc-link {
  color: var(--text-primary, #e6edf3);
}

[data-theme="dark"] .toc-link:hover {
  color: #58a6ff;
}

/* Focus states - dark mode */
[data-theme="dark"] .toc-link:focus,
[data-theme="dark"] .section-card:focus-within {
  outline-color: #a371f7;
}

/* Document viewer containers - dark mode */
[data-theme="dark"] .document-viewer,
[data-theme="dark"] .document-content,
[data-theme="dark"] .section-content {
  background: var(--card-bg, #161b22);
  color: var(--text-primary, #e6edf3);
}

/* Navigation elements - dark mode */
[data-theme="dark"] .document-toc-sticky {
  background: var(--card-bg, #161b22);
  border-color: var(--border-color, #30363d);
}
