/* Google Docs Manuscript Viewer — three-column review interface. */

.viewer-page { display: flex; flex-direction: column; height: 100%; }

.viewer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.viewer-toolbar__group { display: flex; align-items: center; gap: var(--space-2); }
.viewer-toolbar__spacer { flex: 1; }
.viewer-zoom-value { font-size: 12.5px; color: var(--gray-600); min-width: 38px; text-align: center; }
.viewer-search-input {
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 180px;
}
.viewer-search-count { font-size: 12px; color: var(--gray-500); white-space: nowrap; }

.viewer-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 1px;
  background: var(--gray-200);
  border: var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  height: calc(100vh - 320px);
  min-height: 480px;
  overflow: hidden;
}
.viewer-shell.is-comments-collapsed { grid-template-columns: 280px minmax(0, 1fr) 0; }

.viewer-col {
  background: var(--white);
  overflow-y: auto;
  min-width: 0;
}
.viewer-col-left { padding: var(--space-4); }
.viewer-col-center { padding: 0; display: flex; flex-direction: column; }
.viewer-col-right { padding: 0; position: relative; }
.viewer-shell.is-comments-collapsed .viewer-col-right { overflow: visible; }

.viewer-expand-comments {
  display: none;
  position: absolute;
  top: var(--space-3);
  right: 0;
  background: var(--navy-900);
  color: var(--white);
  border: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  padding: 8px 6px;
  cursor: pointer;
  writing-mode: vertical-rl;
  font-size: 12px;
}
.viewer-shell.is-comments-collapsed .viewer-expand-comments { display: block; }

/* ---- Left column ---- */
.viewer-info-section { margin-bottom: var(--space-5); }
.viewer-info-section h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-500); margin-bottom: var(--space-2); }
.viewer-toc { list-style: none; padding: 0; margin: 0; }
.viewer-toc li { margin-bottom: 2px; }
.viewer-toc button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--gray-700);
  cursor: pointer;
}
.viewer-toc button:hover { background: var(--gray-100); }
.viewer-toc button.is-active { background: var(--accent-100); color: var(--accent-700); font-weight: 600; }
.viewer-toc .lvl-2 { padding-left: 18px; }
.viewer-toc .lvl-3 { padding-left: 30px; }
.viewer-toc .lvl-4, .viewer-toc .lvl-5, .viewer-toc .lvl-6 { padding-left: 42px; }

/* ---- Center: manuscript document ---- */
.doc-scroll { flex: 1; overflow-y: auto; padding: var(--space-6) var(--space-8); }
.doc-content {
  max-width: 720px;
  margin: 0 auto;
  font-size: calc(15px * var(--doc-zoom, 1));
  line-height: 1.7;
  color: var(--gray-800);
}
.doc-content .doc-title { font-family: var(--font-heading); font-size: calc(1.7em); color: var(--navy-900); margin: 0 0 0.3em; }
.doc-content .doc-subtitle { font-size: calc(1.2em); color: var(--gray-600); margin: 0 0 1em; font-weight: 400; }
.doc-content .doc-heading-1 { font-family: var(--font-heading); font-size: calc(1.4em); color: var(--navy-900); margin: 1.2em 0 0.5em; }
.doc-content .doc-heading-2 { font-family: var(--font-heading); font-size: calc(1.2em); color: var(--navy-900); margin: 1.1em 0 0.4em; }
.doc-content .doc-heading-3,
.doc-content .doc-heading-4,
.doc-content .doc-heading-5,
.doc-content .doc-heading-6 { font-size: calc(1.05em); font-weight: 700; color: var(--navy-800); margin: 1em 0 0.3em; }
.doc-content p.doc-paragraph { margin: 0 0 1em; }
.doc-content .align-left { text-align: left; }
.doc-content .align-center { text-align: center; }
.doc-content .align-right { text-align: right; }
.doc-content .align-justify { text-align: justify; }
.doc-content ul.doc-list, .doc-content ol.doc-list { margin: 0 0 1em; padding-left: 1.6em; }
.doc-content table.doc-table { border-collapse: collapse; width: 100%; margin: 0 0 1.4em; font-size: 0.92em; }
.doc-content table.doc-table td { border: 1px solid var(--gray-300); padding: 6px 10px; vertical-align: top; }
.doc-content mark.search-highlight { background: #fde68a; color: inherit; border-radius: 2px; }
.doc-content mark.search-highlight.is-current { background: #f59e0b; }

.doc-segment {
  position: relative;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin: 0 -4px;
}
.doc-segment:hover { background: var(--gray-50); }
.doc-segment.is-selected { background: var(--accent-100); outline: 1px dashed var(--accent-600); }
.doc-segment__comment-btn {
  display: none;
  position: absolute;
  right: -2px;
  top: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid var(--gray-300);
  background: var(--white);
  color: var(--gray-600);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.doc-segment:hover .doc-segment__comment-btn,
.doc-segment.is-selected .doc-segment__comment-btn { display: flex; }
/* A segment with existing comments always shows its marker (a filled,
   numbered badge) — not just on hover — since the marker itself is now
   the "there are comments here" signal, per the comment engine spec. */
.doc-segment__comment-btn.has-marker {
  display: flex;
  background: var(--accent-600);
  border-color: var(--accent-600);
  color: var(--white);
  font-weight: 700;
  font-size: 11px;
}
.doc-segment__comment-btn.has-marker:hover { background: var(--accent-700); }

/* ---- Right column: comments ---- */
.comments-panel { display: flex; flex-direction: column; height: 100%; }
.comments-panel__header {
  padding: var(--space-4);
  border-bottom: var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.comments-panel__header h3 { margin: 0; font-size: 14px; }
.comments-list { flex: 1; overflow-y: auto; padding: var(--space-3); }
.comment-thread {
  border: var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  cursor: pointer;
}
.comment-thread:hover { border-color: var(--gray-300); }
.comment-thread.is-active { border-color: var(--accent-600); background: var(--accent-100); }
.comment-thread__quote {
  font-size: 12px;
  color: var(--gray-500);
  font-style: italic;
  border-left: 2px solid var(--gray-300);
  padding-left: 8px;
  margin-bottom: 6px;
  max-height: 3em;
  overflow: hidden;
}
.comment-thread__meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--gray-500); margin-bottom: 4px; }
.comment-thread__body { font-size: 13px; color: var(--gray-800); }
.comment-edited-tag { font-size: 11px; color: var(--gray-400); font-style: italic; }
.comment-edit-textarea { width: 100%; min-height: 60px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); padding: 8px; font-size: 13px; resize: vertical; }
.comment-composer { border-top: var(--border); padding: var(--space-3); }
.comment-composer textarea {
  width: 100%;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 13px;
  resize: vertical;
  min-height: 60px;
}
.comment-composer__hint { font-size: 12px; color: var(--gray-500); margin: 6px 0; }

/* ---- District Evaluation: tabs, checklist, action bar ---- */
.viewer-col-right { display: flex; flex-direction: column; }
.eval-tabs { display: flex; border-bottom: var(--border); flex-shrink: 0; }
.eval-tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
}
.eval-tab.is-active { color: var(--accent-700); border-bottom-color: var(--accent-600); }
.eval-tab-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.eval-tab-body .comments-panel { flex: 1; }

.eval-panel { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.eval-panel__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.eval-panel__header h3 { margin: 0; font-size: 14px; }
.eval-panel__hint { margin: 0; font-size: 12px; color: var(--gray-500); }
.eval-criteria-list { display: flex; flex-direction: column; gap: var(--space-3); }
.eval-criterion { border: var(--border); border-radius: var(--radius-md); padding: var(--space-3); }
.eval-criterion__text { font-size: 13px; color: var(--gray-800); margin-bottom: 8px; }
.eval-criterion__order { color: var(--gray-400); font-weight: 600; }
.eval-criterion__options { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.eval-option {
  border: 1px solid var(--gray-300);
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font-size: 12px;
  cursor: pointer;
  color: var(--gray-600);
}
.eval-option:disabled { cursor: not-allowed; opacity: 0.7; }
.eval-option-compliant.is-selected { background: var(--status-green-bg); color: var(--status-green-fg); border-color: var(--status-green-fg); }
.eval-option-needs_correction.is-selected { background: var(--status-red-bg); color: var(--status-red-fg); border-color: var(--status-red-fg); }
.eval-option-not_applicable.is-selected { background: var(--status-gray-bg); color: var(--status-gray-fg); border-color: var(--gray-400); }
.eval-criterion__comment {
  width: 100%;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 12.5px;
  resize: vertical;
  min-height: 34px;
}

.eval-action-bar {
  border-top: var(--border);
  background: var(--white);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.eval-action-bar__buttons { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
.eval-action-message { font-size: 12.5px; padding: 6px 10px; border-radius: var(--radius-sm); }
.eval-action-message.is-ok { background: var(--status-green-bg); color: var(--status-green-fg); }
.eval-action-message.is-error { background: var(--status-red-bg); color: var(--status-red-fg); }
.eval-return-form { display: flex; flex-direction: column; gap: 8px; background: var(--gray-50); border-radius: var(--radius-md); padding: var(--space-3); }
.eval-return-form textarea { width: 100%; min-height: 60px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); padding: 8px; font-size: 13px; resize: vertical; }
.eval-return-form__actions { display: flex; justify-content: flex-end; gap: 8px; }

.btn-warn { background: var(--status-orange-bg); color: var(--status-orange-fg); border-color: transparent; }
.btn-warn:hover:not(:disabled) { filter: brightness(0.96); }
.btn-danger { background: var(--status-red-bg); color: var(--status-red-fg); border-color: transparent; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.96); }

.comment-thread__footer { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--gray-200); }
.comment-status { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray-400); }
.comment-status-resolved { color: var(--status-green-fg); }

/* ---- Editorial Screening: read-only district result, history, reviewer picker ---- */
.eval-criterion-readonly { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.eval-criterion-readonly .eval-criterion__text { flex: 1; margin-bottom: 0; min-width: 180px; }
.eval-criterion__readonly-comment { flex-basis: 100%; font-size: 12px; color: var(--gray-500); font-style: italic; }

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.history-item { border-left: 2px solid var(--gray-300); padding-left: 10px; }
.history-item__meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--gray-500); }
.history-item__transition { font-size: 13px; color: var(--gray-800); font-weight: 600; }
.history-item__reason { font-size: 12.5px; color: var(--gray-600); margin-top: 2px; }

.reviewer-picker { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.reviewer-picker__row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 2px; }
.reviewer-picker__row input { flex-shrink: 0; }
.reviewer-picker__deadline { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--gray-600); }
.reviewer-picker__deadline input { padding: 6px 8px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 13px; }

/* ---- Blind Peer Review: rating scale, review sections, replies ---- */
.rating-scale { display: flex; gap: 6px; margin-bottom: 4px; }
.rating-option {
  width: 30px; height: 30px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
}
.rating-option:disabled { cursor: not-allowed; opacity: 0.7; }
.rating-option.is-selected { background: var(--accent-600); color: var(--white); border-color: var(--accent-600); }
.rating-scale__label { font-size: 11.5px; color: var(--gray-500); }
.review-section-textarea { width: 100%; min-height: 70px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); padding: 8px; font-size: 13px; resize: vertical; margin-bottom: var(--space-3); }

.comment-replies { margin: 8px 0 0 14px; padding-left: 10px; border-left: 2px solid var(--gray-200); display: flex; flex-direction: column; gap: 8px; }
.comment-reply { font-size: 12.5px; }
.comment-reply-composer { margin-top: 8px; }
.comment-reply-composer textarea { width: 100%; min-height: 50px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); padding: 6px 8px; font-size: 12.5px; resize: vertical; }

/* ---- Editorial Decision Engine: anonymized review summary ---- */
.reviewer-summary-list { display: flex; flex-direction: column; gap: var(--space-3); }
.reviewer-summary-card { border: var(--border); border-radius: var(--radius-md); padding: var(--space-3); font-size: 13px; }
.reviewer-summary-card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.reviewer-summary-card__field { margin-top: 8px; }
.reviewer-summary-card__field h4 { margin: 0 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-500); }
.reviewer-summary-card__field p { margin: 0; color: var(--gray-700); white-space: pre-wrap; }
.reviewer-summary-card__field.is-confidential { background: var(--status-red-bg); border-radius: var(--radius-sm); padding: 6px 8px; }
.reviewer-summary-card__field.is-confidential h4 { color: var(--status-red-fg); }

/* ---- Editor Workflow Page: persistent nav + header + timeline + Action Panel ---- */
.workflow-page { display: flex; flex-direction: column; gap: var(--space-4); }
.workflow-page__backlink { align-self: flex-start; }

.workflow-header {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}
.workflow-header__title { margin: 0 0 var(--space-3); font-size: 20px; }
.workflow-header__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3) var(--space-4);
}
.workflow-header__field { display: flex; flex-direction: column; gap: 4px; }
.workflow-header__field span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-500); }
.workflow-header__field strong { font-size: 13.5px; color: var(--gray-800); font-weight: 600; }

.workflow-timeline-block {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  overflow-x: auto;
}

.workflow-body { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-4); align-items: start; }

.workflow-nav {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) 0;
}
.workflow-nav__group { margin-bottom: var(--space-3); }
.workflow-nav__group:last-child { margin-bottom: 0; }
.workflow-nav__group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  font-weight: 700;
  padding: 6px var(--space-4);
}
.workflow-nav__link {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  padding: 8px var(--space-4);
  font-size: 13.5px;
  color: var(--gray-700);
  cursor: pointer;
}
.workflow-nav__link:hover { background: var(--gray-50); }
.workflow-nav__link.is-active {
  background: var(--gray-100);
  border-left-color: var(--accent-600);
  color: var(--navy-900);
  font-weight: 600;
}

.workflow-content-col {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.workflow-content-col > .viewer-toolbar { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.workflow-content-col > .eval-panel:only-child { padding: var(--space-5); }

.workflow-submission-shell {
  grid-template-columns: 220px minmax(0, 1fr) 300px;
  border: 0;
  border-radius: 0;
  height: 65vh;
}

.workflow-action-panel {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.workflow-action-panel__title { margin: 0; padding: var(--space-3) var(--space-4); font-size: 13px; color: var(--gray-500); border-bottom: var(--border); }
.workflow-action-panel .eval-action-bar { border-top: 0; }

/* ---- Responsive: single column below 1100px ---- */
@media (max-width: 1100px) {
  .viewer-shell, .viewer-shell.is-comments-collapsed {
    grid-template-columns: 1fr;
    grid-auto-rows: min-content;
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .viewer-col { overflow-y: visible; max-height: none; }
  .viewer-col-center { min-height: 420px; }
  .doc-scroll { max-height: 60vh; overflow-y: auto; }
  .viewer-col-right { display: none; }
  .viewer-shell.is-comments-expanded-mobile .viewer-col-right { display: block; }
  .viewer-expand-comments { display: block; position: static; writing-mode: horizontal-tb; width: 100%; border-radius: 0; text-align: center; }
  .viewer-shell.is-comments-expanded-mobile .viewer-expand-comments { display: none; }

  .workflow-body { grid-template-columns: 1fr; }
  .workflow-nav { display: flex; overflow-x: auto; padding: var(--space-2); }
  .workflow-nav__group { display: flex; align-items: center; margin-bottom: 0; margin-right: var(--space-3); flex-shrink: 0; }
  .workflow-nav__group-label { padding: 0 var(--space-2) 0 0; }
  .workflow-nav__link { width: auto; white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
  .workflow-nav__link.is-active { border-left-color: transparent; border-bottom-color: var(--accent-600); }
  .workflow-submission-shell, .workflow-submission-shell.is-comments-collapsed { grid-template-columns: 1fr; height: auto; }
}
