/* ==========================================================================
   多 Agent 科研绘图工作台 — Stylesheet
   ========================================================================== */

:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-soft: #fbfbfa;
  --ink: #2c2a29;
  --muted: #73706c;
  --line: #e6e2db;
  --teal: #2c5e43;
  --teal-deep: #1b3d2b;
  --amber: #c07c1e;
  --red: #b42318;
  --shadow: 0 12px 32px rgba(44, 40, 36, 0.03);
  --border-radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar styling */
.sidebar {
  width: 320px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex-shrink: 0;
  max-height: 100vh;
  overflow-y: auto;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 36px;
  height: 36px;
  background: var(--teal);
  color: #fff;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
  flex-shrink: 0;
}

.brand h1 {
  font-family: "Noto Serif SC", serif;
  font-size: 16px;
  font-weight: 700;
}

.brand p {
  font-size: 11px;
  color: var(--muted);
}

/* Form panel styling */
.config-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.input-field input[type="text"],
.input-field select,
.input-field textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  outline: none;
}

.input-field input:focus,
.input-field select:focus,
.input-field textarea:focus {
  border-color: var(--teal);
  background: #fff;
}

.input-field textarea {
  height: 120px;
  resize: none;
}

.input-field textarea.compact-textarea {
  height: 62px;
  min-height: 62px;
}

.fields-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Journal pills style */
.journal-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.journal-pill {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}

.journal-pill:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.journal-pill.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

/* Files Upload Layout */
fieldset {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

fieldset legend {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 0 6px;
  text-transform: uppercase;
}

.publication-locker {
  background: #f8faf7;
  border-color: #d9e4da;
}

.upload-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-item label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.file-upload-box {
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  position: relative;
}

.file-upload-box input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-box span {
  font-size: 11.5px;
  color: var(--teal);
  font-weight: 600;
}

.file-display-label {
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  margin-top: 2px;
}

.reference-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.reference-preview-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  height: 60px;
  background: #fff;
}

.reference-preview-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Agent flow info */
.agent-architecture-box {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.agent-architecture-box h4 {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.architecture-flow {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.architecture-flow span {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* Main Workspace */
.main-workspace {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 100vh;
}

/* Status Bar Banner */
.status-bar {
  background: rgba(44, 94, 67, 0.05);
  border: 1px solid rgba(44, 94, 67, 0.15);
  border-radius: var(--border-radius);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--teal-deep);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.status-bar.error {
  background: rgba(180, 35, 24, 0.05);
  border-color: rgba(180, 35, 24, 0.15);
  color: var(--red);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--teal);
  padding: 2px 8px;
  border-radius: 4px;
}

.topbar h2 {
  font-family: "Noto Serif SC", serif;
  font-size: 22px;
  color: var(--ink);
}

.actions {
  display: flex;
  gap: 10px;
}

.btn {
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn--primary {
  background: var(--teal);
  color: #fff;
}

.btn--primary:hover {
  background: var(--teal-deep);
}

.btn--secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn--secondary:hover {
  background: var(--surface-soft);
}

.btn--small {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.btn--block {
  width: 100%;
  height: 42px;
}

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 6px;
}

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

/* Grid workspace panels */
.workspace-panels-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.panel-head h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.status-chip {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
}

.empty-state {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 30px;
  background: var(--surface-soft);
  border: 1px dashed var(--line);
  border-radius: 6px;
}

/* Canvas output section */
.canvas-preview-wrapper {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 280px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.figure-preview {
  max-width: 100%;
  max-height: 480px;
  display: block;
}

.figure-preview-pdf {
  width: 100%;
  height: min(68vh, 720px);
  min-height: 480px;
  border: 0;
  background: #fff;
}

.preview-empty-note {
  font-size: 13px;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.explanation-text {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
}

/* Insights grid columns */
.insights-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 768px) {
  .insights-row {
    grid-template-columns: 1fr;
  }
}

.bullet-list-block {
  font-size: 13.5px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Critique Grid analysis style */
.interpretation-summary {
  font-size: 13.5px;
  color: var(--muted);
}

.interpretation-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .interpretation-details-grid {
    grid-template-columns: 1fr;
  }
}

.critique-box {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
}

.critique-box h4 {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--teal);
  margin-bottom: 6px;
}

.critique-box div {
  font-size: 12.5px;
  color: var(--ink);
}

/* Auto reviewer reports */
.reviews-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
}

@media (max-width: 1000px) {
  .reviews-row {
    grid-template-columns: 1fr;
  }
}

.review-score-area {
  font-size: 14px;
}

.review-details-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.strengths-col h4,
.issues-col h4,
.recs-block h4,
.signals-block h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

.recs-block,
.signals-block {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.signals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

/* QC Checklist styling */
.qc-status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 6px;
}

.qc-badge {
  font-family: monospace;
  font-weight: 700;
  background: var(--teal);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
}

.qc-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.session-store-panel h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.memory-notes {
  font-size: 12.5px;
  color: var(--ink);
}

/* Candidates list comparison */
.candidates-comparison-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Trace Logs */
.trace-logs {
  max-height: 200px;
  overflow-y: auto;
}

.trace-row {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
}

.trace-row:last-child {
  border-bottom: none;
}

.trace-agent {
  font-weight: 700;
  color: var(--teal);
}

.trace-summary {
  flex: 1;
  margin: 0 16px;
}

.trace-meta {
  color: var(--muted);
}

/* Code Preview */
.code-preview-panel pre {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  overflow-x: auto;
  font-family: monospace;
  font-size: 12.5px;
  max-height: 360px;
}

/* App Footer */
.app-footer {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
