/* Document Viewer — v2.33.0-v5 */

.doc-viewer-meta { display: none !important; }

.doc-viewer {
  position: relative;
  margin: 16px 0 24px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fafafa;
  overflow: hidden;
}

/* Toolbar */
.doc-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  font-size: 13px;
  color: #555;
}

.doc-viewer-toolbar .doc-viewer-title {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-viewer-toolbar .doc-viewer-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #fff;
}

.doc-viewer-badge[data-format=".pdf"] { background: #d32f2f; }
.doc-viewer-badge[data-format=".docx"] { background: #1565c0; }
.doc-viewer-badge[data-format=".xlsx"] { background: #2e7d32; }
.doc-viewer-badge[data-format=".pptx"] { background: #e65100; }

.doc-viewer-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.doc-viewer-btn:hover {
  background: #eee;
  text-decoration: none;
  color: #333;
}

/* Content area */
.doc-viewer-content {
  min-height: 200px;
  max-height: 80vh;
  overflow: auto;
  padding: 0;
  opacity: 1;
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: #c0c0c0 transparent;
}

/* Webkit (Chrome, Edge, Safari) */
.doc-viewer-content::-webkit-scrollbar { width: 6px; height: 6px; }
.doc-viewer-content::-webkit-scrollbar-track { background: transparent; }
.doc-viewer-content::-webkit-scrollbar-thumb {
  background: #c0c0c0;
  border-radius: 3px;
}
.doc-viewer-content::-webkit-scrollbar-thumb:hover { background: #999; }

/* Nested scrollable areas (xlsx tables, text) */
.doc-viewer-content > div { scrollbar-width: thin; scrollbar-color: #c0c0c0 transparent; }
.doc-viewer-content > div::-webkit-scrollbar { width: 6px; height: 6px; }
.doc-viewer-content > div::-webkit-scrollbar-track { background: transparent; }
.doc-viewer-content > div::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 3px; }
.doc-viewer-content > div::-webkit-scrollbar-thumb:hover { background: #999; }

/* Loading */
.doc-viewer-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: #888;
  font-size: 14px;
}

.doc-viewer-loading::before {
  content: '';
  width: 20px;
  height: 20px;
  margin-right: 8px;
  border: 2px solid #ccc;
  border-top-color: #1976d2;
  border-radius: 50%;
  animation: doc-viewer-spin 0.8s linear infinite;
}

@keyframes doc-viewer-spin {
  to { transform: rotate(360deg); }
}

/* Error */
.doc-viewer-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: #c62828;
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

/* PDF viewer */
.doc-viewer-pdf canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
}

.doc-viewer-pdf .pdf-page {
  position: relative;
  margin-bottom: 4px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.doc-viewer-pdf-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px;
  background: #f5f5f5;
  border-top: 1px solid #e0e0e0;
  font-size: 13px;
}

/* DOCX viewer */
.doc-viewer-docx {
  padding: 24px 32px;
  background: #ffffff;
  color: #212121;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
}

.doc-viewer-docx table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  background: #ffffff;
  color: #212121;
}

.doc-viewer-docx table td,
.doc-viewer-docx table th {
  border: 1px solid #d0d0d0;
  padding: 6px 10px;
  color: #212121;
  background: #ffffff;
}

.doc-viewer-docx table th {
  background: #f5f5f5;
  font-weight: 600;
}

.doc-viewer-docx img {
  max-width: 100%;
  height: auto;
}

/* DOCX dark mode */
.theme--dark .doc-viewer-docx,
.theme--dark .doc-viewer-docx table,
.theme--dark .doc-viewer-docx table td {
  background: #1e1e1e;
  color: #e0e0e0;
  border-color: #3a3a3a;
}

.theme--dark .doc-viewer-docx table th {
  background: #2d2d2d;
  color: #ffffff;
  border-color: #3a3a3a;
}

/* XLSX viewer — light mode defaults */
.doc-viewer-xlsx {
  overflow: auto;
  background: #ffffff;
  color: #212121;
}

.doc-viewer-xlsx table {
  border-collapse: collapse;
  width: auto;
  min-width: 100%;
  font-size: 13px;
  background: #ffffff;
  color: #212121;
}

/* XLSX from SheetJS has no explicit thead/tbody — style all cells uniformly */
.doc-viewer-xlsx td,
.doc-viewer-xlsx th {
  padding: 6px 10px;
  border: 1px solid #d0d0d0;
  white-space: nowrap;
  background: #ffffff;
  color: #212121;
  text-align: left;
  vertical-align: top;
}

.doc-viewer-xlsx thead th,
.doc-viewer-xlsx tr:first-child td {
  position: sticky;
  top: 0;
  background: #e3f2fd;
  font-weight: 600;
  border: 1px solid #bbdefb;
  color: #0d47a1;
  z-index: 1;
}

.doc-viewer-xlsx tr:nth-child(even) td {
  background: #f8f9fa;
}

.doc-viewer-xlsx tr:hover td {
  background: #fff9c4;
}

/* Dark mode support — Vuetify adds .theme--dark to body */
.theme--dark .doc-viewer-xlsx,
.theme--dark .doc-viewer-xlsx table,
.theme--dark .doc-viewer-xlsx td,
.theme--dark .doc-viewer-xlsx th {
  background: #1e1e1e;
  color: #e0e0e0;
  border-color: #3a3a3a;
}

.theme--dark .doc-viewer-xlsx thead th,
.theme--dark .doc-viewer-xlsx tr:first-child td {
  background: #0d47a1;
  color: #ffffff;
  border-color: #1976d2;
}

.theme--dark .doc-viewer-xlsx tr:nth-child(even) td {
  background: #262626;
}

.theme--dark .doc-viewer-xlsx tr:hover td {
  background: #3a3a00;
}

.doc-viewer-xlsx-tabs {
  display: flex;
  gap: 0;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  overflow-x: auto;
}

.doc-viewer-xlsx-tab {
  padding: 6px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: #666;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.doc-viewer-xlsx-tab.active {
  color: #1976d2;
  border-bottom-color: #1976d2;
  font-weight: 500;
}

/* Toggle button — CSS chevron icon */
.doc-viewer-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  flex-shrink: 0;
}

.doc-viewer-toggle::before {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.25s ease;
}

.doc-viewer-collapsed .doc-viewer-toggle::before {
  transform: rotate(-45deg) translateY(-1px);
}

/* Animated collapse/expand */
.doc-viewer-collapsed .doc-viewer-content {
  overflow: hidden;
  opacity: 0;
  min-height: 0;
  transition: height 0.3s ease, opacity 0.25s ease;
}

.doc-viewer:not(.doc-viewer-collapsed) .doc-viewer-content {
  transition: height 0.3s ease, opacity 0.25s ease;
}

/* Collapsed state: remove bottom border from toolbar */
.doc-viewer-collapsed .doc-viewer-toolbar {
  border-bottom: none;
}

/* Text/Markdown viewer */
.doc-viewer-text {
  overflow: auto;
}

.doc-viewer-text-content {
  margin: 0;
  padding: 16px 20px;
  background: #fff;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #333;
}

/* Badge colors for additional formats */
.doc-viewer-badge[data-format=".doc"] { background: #1565c0; }
.doc-viewer-badge[data-format=".odt"] { background: #1565c0; }
.doc-viewer-badge[data-format=".rtf"] { background: #1565c0; }
.doc-viewer-badge[data-format=".xls"] { background: #2e7d32; }
.doc-viewer-badge[data-format=".ods"] { background: #2e7d32; }
.doc-viewer-badge[data-format=".ppt"] { background: #e65100; }
.doc-viewer-badge[data-format=".odp"] { background: #e65100; }
.doc-viewer-badge[data-format=".csv"] { background: #2e7d32; }
.doc-viewer-badge[data-format=".tsv"] { background: #2e7d32; }
.doc-viewer-badge[data-format=".md"] { background: #546e7a; }
.doc-viewer-badge[data-format=".txt"] { background: #757575; }

/* Fallback download */
.doc-viewer-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.doc-viewer-fallback-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.doc-viewer-fallback p {
  color: #666;
  margin: 4px 0 16px;
}

/* ── Dark Theme ─────────────────────────────────────────── */
/* Wiki.js adds .theme--dark on <body> when dark theme is active */

.theme--dark .doc-viewer {
  border-color: #424242;
  background: #1e1e1e;
}

.theme--dark .doc-viewer-toolbar {
  background: #2d2d2d;
  border-bottom-color: #424242;
  color: #ccc;
}

.theme--dark .doc-viewer-btn {
  border-color: #555;
  background: #333;
  color: #ddd;
}

.theme--dark .doc-viewer-btn:hover {
  background: #444;
  color: #fff;
}

.theme--dark .doc-viewer-loading {
  color: #999;
}

.theme--dark .doc-viewer-loading::before {
  border-color: #555;
  border-top-color: #64b5f6;
}

.theme--dark .doc-viewer-error {
  color: #ef9a9a;
}

/* DOCX dark */
.theme--dark .doc-viewer-docx {
  background: #1e1e1e;
  color: #e0e0e0;
}

.theme--dark .doc-viewer-docx table td,
.theme--dark .doc-viewer-docx table th {
  border-color: #424242;
}

.theme--dark .doc-viewer-docx a {
  color: #64b5f6;
}

/* XLSX dark */
.theme--dark .doc-viewer-xlsx thead th {
  background: #1a3a5c;
  border-color: #2a4a6c;
  color: #e0e0e0;
}

.theme--dark .doc-viewer-xlsx tbody td {
  border-color: #333;
  color: #ddd;
}

.theme--dark .doc-viewer-xlsx tbody tr:nth-child(even) {
  background: #252525;
}

.theme--dark .doc-viewer-xlsx tbody tr:hover {
  background: #1a3a5c;
}

.theme--dark .doc-viewer-xlsx-tabs {
  background: #2d2d2d;
  border-bottom-color: #424242;
}

.theme--dark .doc-viewer-xlsx-tab {
  color: #999;
}

.theme--dark .doc-viewer-xlsx-tab.active {
  color: #64b5f6;
  border-bottom-color: #64b5f6;
}

/* PDF dark — iframe background */
.theme--dark .doc-viewer-pdf {
  background: #1e1e1e;
}

.theme--dark .doc-viewer-pdf-nav {
  background: #2d2d2d;
  border-top-color: #424242;
}

/* Scrollbar dark */
.theme--dark .doc-viewer-content { scrollbar-color: #555 transparent; }
.theme--dark .doc-viewer-content::-webkit-scrollbar-thumb { background: #555; }
.theme--dark .doc-viewer-content::-webkit-scrollbar-thumb:hover { background: #777; }
.theme--dark .doc-viewer-content > div { scrollbar-color: #555 transparent; }
.theme--dark .doc-viewer-content > div::-webkit-scrollbar-thumb { background: #555; }
.theme--dark .doc-viewer-content > div::-webkit-scrollbar-thumb:hover { background: #777; }

/* Text dark */
.theme--dark .doc-viewer-text-content {
  background: #1e1e1e;
  color: #d4d4d4;
}

/* Fallback dark */
.theme--dark .doc-viewer-fallback p {
  color: #999;
}
