/* Color scheme matches grapegenomics2.com's assets/css/main.css theme
   variables -- kept separate here since this page is embedded via
   <iframe> and can't see the parent site's stylesheet. Keep these values
   in sync if the parent theme changes.
   Light is the default regardless of OS preference; it only switches via
   the explicit toggle below (grapegenomics2.com's #theme-toggle button,
   through the shared localStorage 'theme' key -- see index.html's inline
   script and main.js's storage-event listener). */
:root {
  --color-bg: #f5f4f0;
  --color-bg-alt: #eceae5;
  --color-text: rgba(28, 29, 38, 0.85);
  --color-text-bright: #1c1d26;
  --color-accent: #e44c65;
  --color-accent-hover: #e76278;
  --color-border: rgba(28, 29, 38, 0.3);
  --color-border-subtle: rgba(28, 29, 38, 0.15);
  --color-highlight: rgba(28, 29, 38, 0.075);
  --sidebar-width: 300px;
}

html.light-mode {
  --color-bg: #f5f4f0;
  --color-bg-alt: #eceae5;
  --color-text: rgba(28, 29, 38, 0.85);
  --color-text-bright: #1c1d26;
  --color-border: rgba(28, 29, 38, 0.3);
  --color-border-subtle: rgba(28, 29, 38, 0.15);
  --color-highlight: rgba(28, 29, 38, 0.075);
}

html.dark-mode {
  --color-bg: #1c1d26;
  --color-bg-alt: #272833;
  --color-text: rgba(255, 255, 255, 0.85);
  --color-text-bright: #ffffff;
  --color-border: rgba(255, 255, 255, 0.3);
  --color-border-subtle: rgba(255, 255, 255, 0.15);
  --color-highlight: rgba(255, 255, 255, 0.075);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Roboto", Helvetica, sans-serif;
  font-weight: 300;
  background: var(--color-bg);
  color: var(--color-text);
}

header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border-subtle);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-bright);
  margin: 0;
}

.funding-note {
  font-size: 11px;
  font-weight: 300;
  color: var(--color-text);
  opacity: 0.75;
  margin: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-controls label {
  font-size: 13px;
  color: var(--color-text);
}

#dataset-select {
  font-size: 14px;
  padding: 4px 8px;
}

select,
input,
button {
  font-family: inherit;
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.layout {
  display: flex;
  align-items: flex-start;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 auto;
  padding: 16px;
  border-right: 1px solid var(--color-border-subtle);
}

.sidebar label {
  display: block;
  font-weight: 400;
  font-size: 13px;
  color: var(--color-text-bright);
  margin: 16px 0 6px;
}

.sidebar label:first-child {
  margin-top: 0;
}

.notes {
  font-size: 12px;
  color: var(--color-text);
  opacity: 0.75;
  margin-top: 20px;
}

.notes strong {
  color: var(--color-text-bright);
  opacity: 1;
}

.notes ul {
  margin: 6px 0;
  padding-left: 18px;
}

#gene-status-notes {
  margin-top: 10px;
  white-space: pre-line;
  word-break: break-word;
}

.link-button {
  background: none;
  border: none;
  color: var(--color-accent);
  font-size: 12px;
  padding: 6px 0;
  cursor: pointer;
  text-align: left;
}

.link-button:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

#bulk-genes-panel {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--color-border-subtle);
  border-radius: 4px;
  background: var(--color-bg-alt);
}

#bulk-genes-input {
  width: 100%;
  font-family: inherit;
  font-size: 12px;
  padding: 6px;
  resize: vertical;
  box-sizing: border-box;
}

.bulk-genes-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.file-upload-label {
  font-size: 12px;
  color: var(--color-text);
  opacity: 0.8;
  cursor: pointer;
}

.file-upload-label input[type="file"] {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  max-width: 100%;
}

#bulk-genes-status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--color-text);
  opacity: 0.85;
  white-space: pre-line;
  word-break: break-word;
}

#marker-genes-panel #marker-genes-reset {
  display: block;
  margin-bottom: 4px;
}

.marker-genes-list {
  margin-top: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.marker-group {
  margin-bottom: 8px;
}

.marker-group-title {
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-bright);
  opacity: 0.9;
  margin-bottom: 3px;
}

.marker-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.marker-chip {
  font-family: inherit;
  font-size: 11px;
  padding: 2px 7px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
}

.marker-chip:hover {
  border-color: var(--color-accent);
  color: var(--color-text-bright);
}

.marker-chip.selected {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
  opacity: 0.85;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 16px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border-subtle);
  margin-bottom: 12px;
}

[hidden] {
  display: none !important;
}

.tab-button {
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--color-text);
  cursor: pointer;
  font-size: 14px;
  border-bottom: 2px solid transparent;
}

.tab-button.active {
  border-bottom-color: var(--color-accent);
  color: var(--color-text-bright);
  font-weight: 400;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Heatmaps/dot plots with many columns (regulon activity, AllOrgans) size
   their .plot-container wider than this panel in px (see heatmap.js /
   dotplot.js) so every x-axis label gets room instead of Plotly silently
   skipping most of them -- this lets the panel scroll horizontally to reach
   them all, mirroring the original app's .scroll-container. */
#heatmap,
#dotplot,
#regulon-heatmap {
  overflow-x: auto;
}

.tab-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.tab-toolbar label {
  font-size: 13px;
  color: var(--color-text);
  margin-left: 8px;
}

/* This page lives in an iframe sized to 72.5vh by the parent site's
   .iframecont rule -- 100vh here resolves against that box, not the
   browser window, so the subtracted amount only needs to cover this
   page's own header+tabs chrome (~100px), not a full-page layout's. */
.plot-container {
  width: 100%;
  height: calc(100vh - 110px);
  min-height: 320px;
  white-space: pre-line;
}

.search-box {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 4px;
  background: var(--color-bg-alt);
}

.search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.chip {
  background: var(--color-highlight);
  color: var(--color-text-bright);
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chip button {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
}

.search-input {
  width: 100%;
  border: none;
  outline: none;
  background: none;
  color: var(--color-text);
  font-size: 13px;
  padding: 4px;
}

.search-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-subtle);
  border-top: none;
  z-index: 10;
}

.search-menu-item {
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
}

.search-menu-item:hover {
  background: var(--color-highlight);
}

#celltype-filter {
  max-height: 180px;
  overflow-y: auto;
  font-size: 13px;
}

#celltype-filter label {
  font-weight: 300;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}

button.action {
  font-size: 13px;
  padding: 6px 10px;
  margin-top: 8px;
  margin-right: 6px;
  cursor: pointer;
}

button.action:hover {
  border-color: var(--color-accent);
  color: var(--color-text-bright);
}

.targets-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

.targets-table th,
.targets-table td {
  border: 1px solid var(--color-border-subtle);
  padding: 4px 8px;
  text-align: left;
  vertical-align: top;
}

.targets-table th {
  color: var(--color-text-bright);
}

.status-message {
  padding: 40px;
  text-align: center;
  color: var(--color-text);
  opacity: 0.6;
}

#help-button {
  margin-left: auto;
}

#help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#help-panel {
  position: relative;
  width: min(560px, 90vw);
  max-height: 80vh;
  overflow-y: auto;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 20px 24px;
}

#help-panel h2 {
  margin-top: 0;
  font-size: 16px;
  color: var(--color-text-bright);
}

#help-panel h3 {
  font-size: 14px;
  color: var(--color-text-bright);
  margin: 20px 0 6px;
}

#help-panel h3:first-of-type {
  margin-top: 0;
}

#help-panel p,
#help-panel li {
  font-size: 13px;
  line-height: 1.5;
}

#help-panel ul {
  margin: 6px 0;
  padding-left: 20px;
}

#help-panel code {
  background: var(--color-bg-alt);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 12px;
}

#help-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text);
  padding: 4px 8px;
}

#help-close:hover {
  color: var(--color-text-bright);
}
