/* code-viewer.css — Expandable code/data panel styles */

.code-viewer {
  margin-top: 0.75em;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fafaf8;
  overflow: hidden;
  font-size: 0.82rem;
}

.code-viewer[hidden] {
  display: none;
}

/* Toolbar: tabs + run controls */
.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #ddd;
  background: #f0f0ec;
}

.viewer-tabs {
  display: flex;
}

.viewer-tabs .tab {
  padding: 0.4em 1em;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.78rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  color: #555;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.viewer-tabs .tab:hover {
  color: #1a1a1a;
}

.viewer-tabs .tab.active {
  color: #1a1a1a;
  border-bottom-color: #b33;
  font-weight: 600;
}

.run-controls {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding-right: 0.75em;
}

.run-all-btn {
  padding: 0.25em 0.8em;
  background: #2a6e2a;
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 0.72rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.02em;
}
.run-all-btn:hover {
  background: #1e5a1e;
}
.run-all-btn:disabled {
  background: #999;
  cursor: not-allowed;
}

.run-status {
  font-size: 0.7rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  color: #555;
  white-space: nowrap;
}

/* Panels */
.viewer-panel {
  padding: 1em;
  max-height: 600px;
  overflow: auto;
}

.viewer-panel[hidden] {
  display: none;
}

/* --- Notebook cells --- */
.notebook-cell {
  margin-bottom: 0.75em;
  padding-bottom: 0.75em;
  border-bottom: 1px solid #eee;
}
.notebook-cell:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* Markdown cells */
.markdown-cell {
  padding: 0.5em 0.75em;
  color: #333;
  line-height: 1.55;
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.82rem;
  background: #f8f8f4;
  border-radius: 3px;
  border-left: 3px solid #c9c9c0;
}
.markdown-cell h3 {
  font-size: 1rem;
  margin: 0.3em 0 0.2em;
  font-style: normal;
}
.markdown-cell h4 {
  font-size: 0.92rem;
  margin: 0.2em 0 0.15em;
  color: #333;
}
.markdown-cell h5 {
  font-size: 0.85rem;
  margin: 0.2em 0 0.1em;
}
.markdown-cell p {
  margin: 0.3em 0;
}
.markdown-cell ul {
  margin: 0.3em 0;
  padding-left: 1.3em;
}
.markdown-cell li {
  margin-bottom: 0.15em;
}
.markdown-cell code {
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  background: #eee;
  padding: 0.1em 0.3em;
  border-radius: 2px;
  font-size: 0.9em;
}

/* Code cells */
.code-cell {
  position: relative;
}
.code-cell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.3em;
}
.code-cell-label {
  font-size: 0.7rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.code-cell pre {
  margin: 0;
  padding: 0.75em;
  background: #f5f5f0;
  border-radius: 3px;
  overflow-x: auto;
  font-size: 0.78rem;
  line-height: 1.5;
  tab-size: 4;
}
.code-cell code {
  font-family: 'IBM Plex Mono', 'Menlo', 'Consolas', monospace;
}

/* Cell execution state indicators */
.notebook-cell.running {
  border-left: 3px solid #e6a817;
}
.notebook-cell.executed {
  border-left: 3px solid #2a6e2a;
}
.notebook-cell.error {
  border-left: 3px solid #c33;
}

/* Cell output area */
.cell-output {
  margin-top: 0.5em;
}
.cell-output:empty {
  display: none;
}

.cell-stdout {
  margin: 0;
  padding: 0.6em 0.75em;
  background: #f5f5f0;
  color: #1a1a1a;
  border-radius: 3px;
  font-size: 0.75rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.cell-error {
  margin: 0;
  padding: 0.6em 0.75em;
  background: #2e1a1a;
  color: #ff9999;
  border-radius: 3px;
  font-size: 0.75rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
}

.cell-figure {
  display: block;
  max-width: 100%;
  margin: 0.5em auto;
  border-radius: 3px;
}

.cell-ok {
  display: inline-block;
  padding: 0.2em 0.5em;
  font-size: 0.72rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  color: #2a6e2a;
}

.cell-running {
  display: inline-block;
  padding: 0.2em 0.5em;
  font-size: 0.72rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  color: #e6a817;
}

/* Data table */
.data-table-wrapper {
  overflow: auto;
  max-height: 400px;
  max-width: 100%;
  width: fit-content;
  margin-bottom: 0.75em;
}

.data-table {
  border-collapse: collapse;
  font-size: 0.75rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  white-space: nowrap;
}

.data-table th,
.data-table td {
  padding: 0.3em 0.6em;
  border: 1px solid #ddd;
  text-align: right;
}

.data-table th {
  background: #f0f0ec;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td {
  background: #fff;
}

.data-table tr:hover td {
  background: #f9f9f5;
}

.data-info {
  font-size: 0.72rem;
  color: #999;
  margin-bottom: 0.5em;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
}

.download-link {
  display: inline-block;
  font-size: 0.75rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  color: #256;
  text-decoration: none;
  border-bottom: 1px dotted #256;
}
.download-link:hover {
  border-bottom-style: solid;
}

/* --- Protocols (Robotics Code) tab --- */
.protocols-intro {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #333;
  margin-bottom: 1em;
  padding: 0.5em 0;
}
.protocols-intro a {
  color: #256;
  text-decoration: none;
  border-bottom: 1px dotted #256;
}
.protocols-intro a:hover {
  border-bottom-style: solid;
}

.protocol-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 1em;
  border: 1px solid #ddd;
  border-radius: 3px;
  overflow: hidden;
}

.protocol-item {
  display: block;
  width: 100%;
  padding: 0.5em 0.75em;
  background: #fff;
  border: none;
  border-bottom: 1px solid #eee;
  border-left: 3px solid transparent;
  font-size: 0.78rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  color: #333;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.protocol-item:last-child {
  border-bottom: none;
}
.protocol-item:hover {
  background: #f5f5f0;
  color: #1a1a1a;
}
.protocol-item.active {
  background: #faf8f5;
  border-left-color: #b33;
  color: #1a1a1a;
  font-weight: 600;
}

.protocol-source pre {
  margin: 0;
  padding: 0.75em;
  background: #f5f5f0;
  border-radius: 3px;
  overflow-x: hidden;
  white-space: pre-wrap !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 0.75rem;
  line-height: 1.5;
  tab-size: 4;
}
.protocol-source code {
  font-family: 'IBM Plex Mono', 'Menlo', 'Consolas', monospace;
  white-space: pre-wrap !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* --- Behavior tracking plots viewer --- */
.behavior-viewer {
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  font-size: 0.78rem;
}

.behavior-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  margin-bottom: 0.75em;
}

.behavior-group-btn {
  padding: 0.3em 0.7em;
  background: #f0f0ec;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 0.72rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  color: #555;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.behavior-group-btn:hover {
  background: #e8e8e4;
  color: #1a1a1a;
}
.behavior-group-btn.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

.behavior-plot-types {
  display: flex;
  gap: 0;
  margin-bottom: 0.75em;
  border: 1px solid #ddd;
  border-radius: 3px;
  overflow: hidden;
  width: fit-content;
}

.behavior-plot-type {
  padding: 0.3em 0.8em;
  background: #fff;
  border: none;
  border-right: 1px solid #ddd;
  font-size: 0.72rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  color: #555;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.behavior-plot-type:last-child {
  border-right: none;
}
.behavior-plot-type:hover {
  background: #f5f5f0;
  color: #1a1a1a;
}
.behavior-plot-type.active {
  background: #1a1a1a;
  color: #fff;
}

.behavior-content {
  display: flex;
  gap: 0.75em;
  min-height: 300px;
}

.behavior-list {
  flex: 0 0 220px;
  max-height: 450px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
}

.behavior-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0.4em 0.6em;
  background: #fff;
  border: none;
  border-bottom: 1px solid #eee;
  border-left: 3px solid transparent;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, border-color 0.1s;
}
.behavior-item:last-child {
  border-bottom: none;
}
.behavior-item:hover {
  background: #f5f5f0;
}
.behavior-item.active {
  background: #faf8f5;
  border-left-color: #b33;
}

.behavior-item-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.behavior-item-metrics {
  font-size: 0.66rem;
  color: #888;
  margin-top: 0.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.behavior-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 0.5em;
  min-height: 300px;
}
.behavior-preview img {
  max-width: 100%;
  max-height: 440px;
  object-fit: contain;
}

.behavior-preview-empty {
  color: #999;
  font-size: 0.78rem;
  padding: 2em;
}
.behavior-arm-sequence {
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  font-size: 0.78rem;
  color: #333;
  line-height: 1.6;
  padding: 0.5em 0;
  word-break: break-word;
  user-select: all;
  width: 100%;
}
.behavior-arm-sequence-label {
  font-weight: 600;
  color: #555;
}

/* --- Representative Videos tab --- */
.behavior-videos {
  display: flex;
  flex-direction: column;
  gap: 1.25em;
}

.behavior-video-card {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1em;
  background: #fff;
}

.behavior-video-card h4 {
  margin: 0 0 0.6em;
  font-size: 0.82rem;
  font-family: 'IBM Plex Mono', 'Menlo', monospace;
  font-weight: 600;
  color: #1a1a1a;
}

.behavior-video-card video {
  display: block;
  width: 100%;
  max-width: 420px;
  border-radius: 3px;
  background: #000;
}

.behavior-video-card p {
  margin: 0.6em 0 0;
  font-size: 0.78rem;
  font-family: 'Merriweather', Georgia, serif;
  line-height: 1.5;
  color: #555;
}
