/* Document Viewer — tool-specific styles. Shared look comes from tokens.css +
   base.css. */

.viewer-main {
  max-width: 1100px;
}

.viewer-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--space-4);
  margin-top: var(--space-4);
  align-items: start;
}

/* Folder-tree navigation */
.doc-nav {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  max-height: 78vh;
  overflow: auto;
  position: sticky;
  top: var(--space-4);
}

.doc-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-tree .doc-tree {
  margin-left: var(--space-3); /* indent nested folders */
}

.doc-folder-name {
  margin: var(--space-3) 0 var(--space-1);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted-soft);
}

.doc-file {
  margin: 1px 0;
}

.doc-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.5rem;
  border: none;
  background: none;
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 0.9rem;
  line-height: 1.35;
  cursor: pointer;
}

.doc-link:hover {
  background: var(--color-accent-soft);
}

.doc-link.active {
  background: var(--color-accent);
  color: #fff;
}

/* Viewing pane */
.doc-pane {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.doc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.doc-current {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-view {
  padding: var(--space-5);
  min-height: 60vh;
}

.doc-view.showing-pdf {
  padding: 0;
  min-height: 0;
}

.doc-placeholder {
  text-align: center;
  padding: var(--space-6) 0;
}

.doc-pdf {
  display: block;
  width: 100%;
  height: 78vh;
  border: none;
}

/* mammoth-rendered docx content */
.doc-content {
  max-width: 46rem;
  margin: 0 auto;
  line-height: 1.6;
  color: var(--color-text);
}

.doc-content h1,
.doc-content h2,
.doc-content h3 {
  line-height: 1.25;
  margin: 1.4em 0 0.5em;
}

.doc-content h1 { font-size: 1.5rem; }
.doc-content h2 { font-size: 1.25rem; }
.doc-content h3 { font-size: 1.1rem; }

.doc-content p { margin: 0 0 0.8em; }

.doc-content ul,
.doc-content ol {
  margin: 0 0 0.8em;
  padding-left: 1.4em;
}

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

.doc-content table {
  border-collapse: collapse;
  margin: 0 0 0.8em;
}

.doc-content td,
.doc-content th {
  border: 1px solid var(--color-border);
  padding: 0.3rem 0.5rem;
}

/* Stack the nav above the pane on narrow screens */
@media (max-width: 720px) {
  .viewer-layout {
    grid-template-columns: 1fr;
  }
  .doc-nav {
    position: static;
    max-height: 40vh;
  }
}

/* Print: just the current document, none of the app chrome. */
@media print {
  @page {
    margin: 1.5cm;
  }

  .back-link,
  .doc-nav,
  .doc-toolbar,
  .viewer-main > h1,
  .viewer-main > .subtitle {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .viewer-layout,
  .doc-pane,
  .doc-view {
    display: block;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
    background: #fff;
  }

  .doc-content {
    max-width: none;
    color: #000;
  }
}
