.wrapper {
  min-height: calc(100vh - 52px);
}

.user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.user-menu .username {
  color: #e5e7eb;
  font-size: 1.1rem;
  font-weight: 500;
  text-decoration: none;
}

.user-menu .username:hover {
  color: #ffffff;
}

.user-menu .menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  min-width: 10rem;
  background: #111827;
  color: #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.25);
  border: 1px solid #1f2937;
  z-index: 9999;
}

.user-menu:hover .menu,
.user-menu:focus-within .menu {
  display: block;
}

.user-menu .menu a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: inherit;
  text-decoration: none;
}

.user-menu .menu a:hover {
  background: #1f2937;
}

.form-input {
  width: 100%;
  border: 1px solid #4b5563;
  border-radius: 0.5rem;
  background: #111827;
  color: #f9fafb;
  padding: 0.6rem 0.75rem;
}

.form-input:focus {
  outline: none;
  border-color: #38bdf8;
}

.form-button {
  border: 0;
  border-radius: 0.5rem;
  background: #0ea5e9;
  color: #ffffff;
  font-weight: 600;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
}

.form-button:hover {
  background: #0284c7;
}

.auth-shell {
  max-width: 44rem;
  margin: 2.5rem auto;
  padding: 0 1rem;
}

.auth-card {
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid #374151;
  border-radius: 0.75rem;
  padding: 1.5rem;
}

.content-shell {
  max-width: 72rem;
  margin: 2.5rem auto;
  padding: 0 1rem;
}

.content-shell-wide {
  width: calc(100vw - 2rem);
  max-width: none;
  margin: 1.25rem auto 2rem;
  padding: 0 0.5rem;
}

.content-card {
  background: rgba(17, 24, 39, 0.45);
  border: 1px solid #374151;
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  align-items: end;
}

.filter-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.dataset-card {
  border: 1px solid #374151;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.9rem;
  background: rgba(17, 24, 39, 0.6);
}

.config-block {
  max-height: 420px;
  overflow: auto;
  border: 1px solid #374151;
  border-radius: 0.75rem;
  padding: 1rem;
  background: #0b1220;
  color: #d1d5db;
  font-size: 0.84rem;
}

.jbrowse-shell {
  height: 88vh;
  min-height: 860px;
  border: 1px solid #374151;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #ffffff;
}

#jbrowseMount,
#jbrowseMount > div {
  height: 100%;
  margin: 0 !important;
  padding: 0 !important;
  background: var(--jbrowse-user-bg, #ffffff) !important;
  color: var(--jbrowse-user-fg, #111827) !important;
}

.jbrowse-shell [class*="MuiAppBar-root"] {
  background: var(--jbrowse-user-bg, #ffffff) !important;
  color: var(--jbrowse-user-fg, #111827) !important;
}

.jbrowse-shell [class*="MuiPaper-root"],
.jbrowse-shell [class*="MuiDrawer-paper"],
.jbrowse-shell [class*="MuiBox-root"] {
  background: var(--jbrowse-user-bg, #ffffff) !important;
  color: var(--jbrowse-user-fg, #111827) !important;
}

.jbrowse-shell [class*="MuiPaper-root"] > :first-child,
.jbrowse-shell [class*="MuiBox-root"] > :first-child {
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.browser-page h1,
.browser-page h2,
.browser-page p {
  color: #e5e7eb;
}

.browser-page h1 {
  font-size: 2.15rem;
  line-height: 1.15;
  font-weight: 700;
  margin: 0 0 0.75rem;
}

.browser-page h2 {
  font-size: 1.85rem;
  line-height: 1.2;
  font-weight: 700;
  margin: 1.4rem 0 0.6rem;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable .sort-arrow {
  font-size: 0.7em;
  opacity: 0.6;
  margin-left: 0.25rem;
  display: inline-block;
  transition: transform 0.15s ease;
}

th.sortable[data-sort-dir="asc"] .sort-arrow {
  transform: rotate(180deg);
  opacity: 0.9;
}

th.sortable[data-sort-dir="desc"] .sort-arrow {
  opacity: 0.9;
}

.jbrowse-shell [class*="MuiToolbar-root"] {
  padding-top: 6px;
  padding-bottom: 6px;
  align-items: center;
}

.jbrowse-shell [class*="RegionSelector"] {
  padding-top: 4px;
}

.jbrowse-shell [class*="RegionSelector"] [class*="MuiTypography-root"] {
  line-height: 1.2;
  transform: translateY(-3px);
}

.jbrowse-shell [class*="MuiFormControl-root"] {
  margin-top: -2px;
}

/* Toggle peak/annotation labels via classes on #jbrowseMount */
#jbrowseMount.hide-peak-labels [data-testid*="peaks_"] text,
#jbrowseMount.hide-peak-labels [data-trackid^="peaks_"] text,
#jbrowseMount.hide-peak-labels [data-track-id^="peaks_"] text,
#jbrowseMount.hide-peak-labels [data-testid*="peaks_"] svg text,
#jbrowseMount.hide-peak-labels [data-trackid^="peaks_"] svg text,
#jbrowseMount.hide-peak-labels [data-track-id^="peaks_"] svg text {
  display: none !important;
  visibility: hidden !important;
}

#jbrowseMount.hide-annotation-labels [data-testid*="annot_ref_"] text,
#jbrowseMount.hide-annotation-labels [data-trackid^="annot_ref_"] text,
#jbrowseMount.hide-annotation-labels [data-track-id^="annot_ref_"] text,
#jbrowseMount.hide-annotation-labels [data-testid*="annot_ref_"] svg text,
#jbrowseMount.hide-annotation-labels [data-trackid^="annot_ref_"] svg text,
#jbrowseMount.hide-annotation-labels [data-track-id^="annot_ref_"] svg text {
  display: none !important;
  visibility: hidden !important;
}

/* Ensure label text respects the user-selected foreground color */
#jbrowseMount svg text {
  fill: var(--jbrowse-user-fg, #111827) !important;
  stroke: none !important;
  paint-order: normal !important;
}

/* Apply line/grid colors for ticks and guides */
#jbrowseMount svg line,
#jbrowseMount svg path {
  stroke: var(--jbrowse-user-line, #111827) !important;
}

/* Prefer line color for grid/ruler dividers */
#jbrowseMount [class*="gridline"],
#jbrowseMount [class*="Gridline"],
#jbrowseMount [class*="gridLine"],
#jbrowseMount [class*="ruler"],
#jbrowseMount [class*="Ruler"] {
  stroke: var(--jbrowse-user-line, #111827) !important;
  border-color: var(--jbrowse-user-line, #111827) !important;
}

/* JBrowse tick marks (minor/major grid dividers) */
#jbrowseMount .css-i794sq-tick-minorTick,
#jbrowseMount .css-1qcgmte-tick-majorTick {
  border-color: var(--jbrowse-user-line, #111827) !important;
  background-color: var(--jbrowse-user-line, #111827) !important;
}

/* Peak feature color override */
#jbrowseMount [data-trackid^="peaks_"] svg rect,
#jbrowseMount [data-track-id^="peaks_"] svg rect,
#jbrowseMount [data-trackid^="peaks_"] svg path,
#jbrowseMount [data-track-id^="peaks_"] svg path,
#jbrowseMount [data-trackid^="peaks_"] svg polygon,
#jbrowseMount [data-track-id^="peaks_"] svg polygon,
#jbrowseMount [data-trackid^="peaks_"] svg line,
#jbrowseMount [data-track-id^="peaks_"] svg line,
#jbrowseMount [data-trackid^="peaks_"] svg g,
#jbrowseMount [data-track-id^="peaks_"] svg g,
#jbrowseMount [data-trackid^="peaks_"] svg * ,
#jbrowseMount [data-track-id^="peaks_"] svg * {
  fill: var(--jbrowse-peak-color, #f59e0b) !important;
  stroke: var(--jbrowse-peak-color, #f59e0b) !important;
}

/* Peak rectangles rendered by svgfeatures */
#jbrowseMount [data-testid="svgfeatures"] rect,
#jbrowseMount .css-1dmfa10-contentBlock [data-testid="svgfeatures"] rect {
  fill: var(--jbrowse-peak-color, #f59e0b) !important;
  stroke: var(--jbrowse-peak-color, #f59e0b) !important;
}

/* Lift the genome overview labels to sit inside the overview bar */
/* Let the specific overview label rule handle positioning */
.jbrowse-shell [class*="GenomeOverview"] svg text {
  dominant-baseline: middle;
}

/* If labels are still low, nudge the overview container upward */
.jbrowse-shell [class*="GenomeOverview"] {
  margin-top: -6px;
}

/* Darken/remove the tiny white border around JBrowse root */
.jbrowse-shell .css-jn2cxo-avoidParentStyle,
.jbrowse-shell .MuiScopedCssBaseline-root.css-1a34zhu {
  background: var(--jbrowse-user-bg, #ffffff) !important;
  border: 1px solid #1f2937 !important;
  box-shadow: none !important;
}

/* Nudge contig labels (chr1/chr2) into the overview bar */
.jbrowse-shell [class*="scalebarRefName"],
.jbrowse-shell [class*="scaleBarRefName"],
.jbrowse-shell [class*="scalebar"] [class*="RefName"] {
  transform: translateY(-0.5px) !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  line-height: 1.1 !important;
  color: var(--jbrowse-user-fg, #111827) !important;
}

/* Hide feature labels (peak names) in feature tracks */
.jbrowse-shell [class*="FeatureTrack"] svg text,
.jbrowse-shell [class*="featureLabel"],
.jbrowse-shell [class*="FeatureLabel"],
.jbrowse-shell .feature-label,
.jbrowse-shell .feature-label-text {
  display: none !important;
}

.browser-page p {
  font-size: 1.14rem;
  line-height: 1.7;
  margin: 0.55rem 0 0.8rem;
}

.legend-table-wrap {
  overflow: auto;
  border: 1px solid #374151;
  border-radius: 0.75rem;
}

.legend-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: auto;
}

.legend-table th,
.legend-table td {
  border-bottom: 1px solid #374151;
  padding: 0.5rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.legend-table thead th {
  background: #111827;
  color: #e5e7eb;
  position: sticky;
  top: 0;
}

.legend-table tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.03);
}

.legend-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.08);
}

.table-detail {
  max-width: 260px;
}

.table-detail__summary {
  cursor: pointer;
  color: #93c5fd;
  font-weight: 600;
  text-decoration: underline;
}

.table-detail__summary::-webkit-details-marker {
  display: none;
}

.table-detail__text {
  width: 100%;
  min-height: 4.5rem;
  resize: vertical;
  background: rgba(17, 24, 39, 0.4);
  color: inherit;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  padding: 0.4rem 0.5rem;
}

/*new for hiding datasets admin sections */

/* overall spacing between sections */
.admin-collapse {
  margin: 0.75rem 0;      /* controls space between the 4 options */
  padding: 0;
  border: 0;
  background: transparent;
}

/* summary row */
.admin-collapse > summary {
  cursor: pointer;
  font-weight: 700;

  display: flex;          /* makes alignment predictable */
  align-items: center;    /* centers arrow + text vertically */
  gap: 0.6rem;

  padding: 0.15rem 0;     /* keeps closed height tight */
  margin: 0;              /* kill any inherited margins */
  list-style: none;
  line-height: 1.2;       /* stabilizes vertical centering */
}

/* remove default marker */
.admin-collapse > summary::-webkit-details-marker {
  display: none;
}

/* arrow */
.admin-collapse > summary::before {
  content: "▸";

  width: 1.4rem;          /* fixed square box */
  height: 1.4rem;
  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 1.6rem;      /* arrow size */
  line-height: 1;

  transform: translateY(-20px);
  transform-origin: center;
  transition: transform 0.15s ease;
}

/* rotate arrow when open */
.admin-collapse[open] > summary::before {
  transform: translateY(-20px) rotate(90deg);
}

/* content spacing */
.admin-collapse > *:not(summary) {
  margin-top: 0.6rem;
}

/* IMPORTANT: remove extra margins inside details content */
.admin-collapse h1,
.admin-collapse h2,
.admin-collapse h3,
.admin-collapse form,
.admin-collapse p {
  margin-top: 0;
}

/* clear checkboxes */

.field-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.field-row > .form-input {
  flex: 1;
}

.clear-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  font-size: 0.95em;
  opacity: 0.9;
}
