/*
  Jupyter notebook rendering styles for Forgejo.
  Applied when notebookjs renders .ipynb files.
*/

/* === Notebook container === */
.nb-notebook {
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.nb-worksheet {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* === Cell base === */
.nb-cell {
  border-bottom: 1px solid var(--color-input-border, #E5E7EB);
  padding: 12px 16px;
}

.nb-cell:last-child {
  border-bottom: none;
}

/* === Code cells === */
.nb-code-cell {
  padding: 0;
}

.nb-code-cell .nb-input {
  background: var(--color-code-bg, #FAFBFC);
  border-bottom: 1px solid var(--color-input-border, #E5E7EB);
}

.nb-code-cell .nb-input pre {
  margin: 0;
  padding: 12px 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}

.nb-code-cell .nb-input code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

/* Execution count / prompt number */
.nb-input[data-prompt-number]::before {
  content: "In [" attr(data-prompt-number) "]:";
  display: block;
  padding: 8px 16px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--color-text-light-2, #6b7280);
}

.nb-output[data-prompt-number]::before {
  content: "Out [" attr(data-prompt-number) "]:";
  display: block;
  padding: 8px 16px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--color-text-light-2, #6b7280);
}

/* === Output cells === */
.nb-output {
  padding: 8px 16px;
}

.nb-output pre {
  margin: 0;
  padding: 8px 0;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Stream output (stdout/stderr) */
.nb-stdout pre,
.nb-stderr pre {
  margin: 0;
  padding: 4px 0;
}

.nb-stderr pre {
  color: #dc2626;
}

/* Error/traceback output */
.nb-pyerr {
  background: #fef2f2;
  border-radius: 4px;
  padding: 8px;
  overflow-x: auto;
}

/* === Text output === */
.nb-text-output {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* === HTML output === */
.nb-html-output {
  padding: 4px 0;
  overflow-x: auto;
}

.nb-html-output table {
  border-collapse: collapse;
  margin: 8px 0;
}

.nb-html-output table th,
.nb-html-output table td {
  border: 1px solid var(--color-input-border, #E5E7EB);
  padding: 6px 12px;
  text-align: left;
  font-size: 13px;
}

.nb-html-output table th {
  background: var(--color-box-header, #F5F7FA);
  font-weight: 600;
}

.nb-html-output table tr:nth-child(even) {
  background: var(--color-box-body, #FAFBFC);
}

/* === Image output === */
.nb-image-output {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 8px 0;
}

/* === SVG output === */
.nb-svg-output {
  max-width: 100%;
  overflow-x: auto;
}

.nb-svg-output svg {
  max-width: 100%;
  height: auto;
}

/* === Markdown cells === */
.nb-markdown-cell {
  padding: 12px 16px;
  line-height: 1.6;
  color: var(--color-text, #1F2937);
}

.nb-markdown-cell h1,
.nb-markdown-cell h2,
.nb-markdown-cell h3,
.nb-markdown-cell h4,
.nb-markdown-cell h5,
.nb-markdown-cell h6 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-weight: 600;
  line-height: 1.3;
}

.nb-markdown-cell h1 { font-size: 1.6em; }
.nb-markdown-cell h2 { font-size: 1.35em; }
.nb-markdown-cell h3 { font-size: 1.15em; }
.nb-markdown-cell h4 { font-size: 1em; }

.nb-markdown-cell h1:first-child,
.nb-markdown-cell h2:first-child,
.nb-markdown-cell h3:first-child {
  margin-top: 0;
}

.nb-markdown-cell p {
  margin: 0.6em 0;
}

.nb-markdown-cell ul,
.nb-markdown-cell ol {
  padding-left: 2em;
  margin: 0.5em 0;
}

.nb-markdown-cell code {
  background: var(--color-code-bg, #FAFBFC);
  border: 1px solid var(--color-input-border, #E5E7EB);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.nb-markdown-cell pre code {
  display: block;
  padding: 12px;
  overflow-x: auto;
  border: none;
  border-radius: 4px;
}

.nb-markdown-cell blockquote {
  border-left: 3px solid var(--color-primary, #593196);
  margin: 0.5em 0;
  padding: 0.25em 1em;
  color: var(--color-text-light-1, #4b5563);
}

.nb-markdown-cell table {
  border-collapse: collapse;
  margin: 0.5em 0;
}

.nb-markdown-cell table th,
.nb-markdown-cell table td {
  border: 1px solid var(--color-input-border, #E5E7EB);
  padding: 6px 12px;
}

.nb-markdown-cell table th {
  background: var(--color-box-header, #F5F7FA);
  font-weight: 600;
}

.nb-markdown-cell img {
  max-width: 100%;
  height: auto;
}

/* === LaTeX output === */
.nb-latex-output {
  padding: 8px 0;
  overflow-x: auto;
}

/* === Empty output (hide) === */
.nb-empty-output {
  display: none;
}

/* === Raw cells === */
.nb-raw-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  background: var(--color-code-bg, #FAFBFC);
}

/* === Loading state === */
.notebook-loading {
  padding: 24px 16px;
  text-align: center;
  color: var(--color-text-light-2, #6b7280);
  font-size: 14px;
}

/* === Toggle for raw JSON view === */
.notebook-toggle-raw {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--color-text-light-2, #6b7280);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--color-input-border, #E5E7EB);
  background: var(--color-box-body, #FAFBFC);
}

.notebook-toggle-raw:hover {
  background: var(--color-box-body-highlight, #E5E7EB);
}
