/* =========================================================
   FILE READER — ZAR / GENEBEAN COMPACT WIDGET MODE
   Left-anchored vertical tool + drawer-style dataset preview
========================================================= */

.module-file-reader {
  --panel-accent: 79 163 209;

  --fr-panel-border: rgba(79, 163, 209, 0.48);

  --fr-text-primary: rgba(243, 251, 255, 0.99);
  --fr-text-secondary: rgba(207, 229, 242, 0.88);
  --fr-text-muted: rgba(154, 178, 196, 0.68);

  --fr-label-color: rgba(205, 232, 246, 0.86);
  --fr-select-option-bg: #0f1724;

  --fr-btn-text: rgba(240, 250, 255, 0.98);
  --fr-btn-disabled-top: rgba(74, 84, 96, 0.58);
  --fr-btn-disabled-bottom: rgba(35, 44, 56, 0.72);
  --fr-btn-disabled-border: rgba(128, 144, 164, 0.30);

  --fr-table-header-bg: #162338;

  --fr-toolbar-width: 104px;
  --fr-collapsed-panel-width: 132px;
  --fr-preview-width: min(620px, calc(100vw - var(--app-rail-width, 0px) - 190px));

  width: auto;
  max-width: none;

  display: block;

  padding: 0;
  margin: 0;

  color: var(--fr-text-primary);
  box-sizing: border-box;
}

/* =========================================================
   MAIN PANEL
========================================================= */

.file-reader-panel {
  position: relative;

  width: auto;
  min-width: var(--fr-collapsed-panel-width);
  max-width: var(--fr-collapsed-panel-width);

  padding: 10px;

  border: 1px solid var(--fr-panel-border);
  border-radius: 16px;

  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.10), transparent 18%),
    radial-gradient(circle at 12% 0%, rgba(79, 163, 209, 0.32), transparent 44%),
    radial-gradient(circle at 82% 12%, rgba(132, 92, 255, 0.12), transparent 34%),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.022) 0px,
      rgba(255, 255, 255, 0.022) 1px,
      transparent 1px,
      transparent 7px
    ),
    linear-gradient(
      180deg,
      #1a2a40 0%,
      #101b2c 48%,
      #070d18 100%
    );

  color: var(--fr-text-primary);

  box-shadow:
    0 24px 68px rgba(0, 0, 0, 0.64),
    0 10px 28px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(79, 163, 209, 0.14),
    0 0 34px rgba(79, 163, 209, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -14px 28px rgba(0, 0, 0, 0.34);

  overflow: visible;

  transition:
    max-width 220ms ease,
    min-width 220ms ease;
}

/* Expanded preview widens panel */
.module-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-panel,
.zom-widget--genebean-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-panel {
  max-width: min(760px, calc(100vw - var(--app-rail-width, 0px) - 24px));
}

.file-reader-panel::after {
  content: "";
  position: absolute;
  inset: 0;

  border-radius: inherit;

  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), transparent 24%),
    radial-gradient(circle at 50% 100%, rgba(0,0,0,0.28), transparent 70%);

  pointer-events: none;

  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    inset 0 -1px 0 rgba(0, 0, 0, 0.52);
}
button#selectFile {
    border: 1px solid #253b57;
    background: linear-gradient(45deg, #1a2a43e6, #4070c18a);
}

/* =========================================================
   HEADER
========================================================= */

.module-file-reader .module-header {
  position: relative;
  z-index: 2;

  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;

  margin: 0 0 8px;
  padding: 4px 4px 0;
}

.file-reader-title-block {
  min-width: 0;
}

/* Title + canonical release version, mirroring the EMC / NQC header pattern. */
.file-reader-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.file-reader-version {
  color: var(--fr-text-secondary, rgba(138, 216, 255, 0.6));
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.file-reader-kicker {
  display: block;

  margin-bottom: 2px;

  color: rgba(138, 216, 255, 0.82);

  font-size: 0.58rem;
  line-height: 1;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-file-reader .module-header h2 {
  margin: 0;

  color: var(--fr-text-primary);

  font-size: 0.86rem;
  line-height: 1.1;
  font-weight: 850;
  letter-spacing: -0.01em;

  text-shadow:
    0 1px 0 rgba(0,0,0,0.7),
    0 0 14px rgba(79, 163, 209, 0.18);
}

.file-reader-window-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* =========================================================
   WINDOW ACTION BUTTONS
========================================================= */

.gb-file-reader-preview-toggle-btn,
.gb-file-reader-minimize-btn {
  position: relative;
  z-index: 30;

  width: 26px !important;
  height: 26px !important;
  min-height: 26px !important;

  display: grid;
  place-items: center;

  padding: 0 !important;

  border-radius: 999px !important;

  font-size: 0.78rem !important;
  line-height: 1 !important;
  font-weight: 900 !important;

  cursor: pointer;
}

/* =========================================================
   BODY — LEFT TOOL / RIGHT DRAWER PREVIEW
========================================================= */

.file-reader-body {
  position: relative;
  z-index: 2;

  display: grid;
  grid-template-columns: var(--fr-toolbar-width) 0fr;
  gap: 0;
  align-items: start;

  transition:
    grid-template-columns 220ms ease,
    gap 220ms ease;
}

.module-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-body,
.zom-widget--genebean-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-body {
  grid-template-columns: var(--fr-toolbar-width) minmax(0, 1fr);
  gap: 10px;
}

/* =========================================================
   LEFT VERTICAL TOOLBAR
========================================================= */

.file-reader-toolbar {
    align-items: self-end;
    display: flex;
    flex-direction: row;
    gap: 12px;
    width: var(--fr-toolbar-width);
    padding: 8px;
    margin: 0;
    border: 1px solid rgba(var(--panel-accent), 0.22);
    border-radius: 17px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.045)), radial-gradient(circle at 12% 0%, #082034), linear-gradient(180deg, #0d1a2b, #07101d);
    box-shadow: 0 10px 22px rgba(0,0,0,0.30),
    inset 0 1px 0 rgba(255,255,255,0.07),
    inset 0 -1px 0 rgba(0,0,0,0.45);
    box-sizing: border-box;
}
button#fileReaderSaveGBToxBtn {
    background: #18975542;
}
.file-reader-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
/*   min-width: 0; */
}

.module-file-reader label,
.file-reader-control label {
  font-size: 0.56rem;
  line-height: 1;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;

  color: var(--fr-label-color);
  text-shadow: 0 1px 0 rgba(0,0,0,0.55);
}

/* =========================================================
   COMPACT SELECT
========================================================= */

.module-file-reader select {
  width: 100%;
  min-width: 0;

  height: 28px;
  padding: 0 8px;

  border: 1px solid rgba(var(--panel-accent), 0.34);
  border-radius: 999px;

  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), transparent 32%),
    linear-gradient(
      180deg,
      rgba(var(--panel-accent), 0.16),
      #081321
    );

  color: var(--fr-text-primary);
  font-size: 0.7rem;
  font-weight: 700;

  color-scheme: dark;

  box-shadow:
    0 6px 13px rgba(0,0,0,0.24),
    inset 0 1px 0 rgba(255,255,255,0.10),
    inset 0 -1px 0 rgba(0,0,0,0.40);
}

.module-file-reader select:focus {
  outline: none;
  border-color: rgba(var(--panel-accent), 0.82);

  box-shadow:
    0 0 0 1px rgba(var(--panel-accent), 0.38),
    0 0 18px rgba(var(--panel-accent), 0.20),
    inset 0 1px 0 rgba(255,255,255,0.09);
}

.module-file-reader select option {
  background-color: var(--fr-select-option-bg);
  color: var(--fr-text-primary);
}

/* =========================================================
   COMPACT BUTTONS
========================================================= */

.module-file-reader button {
  --btn-accent: var(--panel-accent);

  min-height: 28px;
  padding: 0 9px;

  border: 1px solid rgba(var(--btn-accent), 0.50);
  border-radius: 999px;

  background:
    linear-gradient(180deg, rgba(255,255,255,0.18), transparent 34%),
    linear-gradient(
      180deg,
      rgba(var(--btn-accent), 0.82),
      rgba(34, 104, 145, 0.68)
    );

  color: var(--fr-btn-text);

  font-size: 0.68rem;
  line-height: 1;
  font-weight: 850;

  white-space: nowrap;

  cursor: pointer;

  text-shadow: 0 1px 0 rgba(0,0,0,0.45);

  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.30),
    0 0 14px rgba(var(--btn-accent), 0.11),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(0,0,0,0.25);

  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease,
    border-color 120ms ease;
}

.module-file-reader button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);

  border-color: rgba(var(--btn-accent), 0.70);
}

.module-file-reader button:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
  filter: brightness(0.96);
}

.module-file-reader button:disabled {
  background:
    linear-gradient(
      180deg,
      var(--fr-btn-disabled-top),
      var(--fr-btn-disabled-bottom)
    );

  border-color: var(--fr-btn-disabled-border);
  color: var(--fr-text-muted);

  cursor: not-allowed;

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05);

  opacity: 0.72;
}

#selectFile,
.file-reader-commit-btn {
  width: 100%;
  height: 28px;
}

/* =========================================================
   FILE NAME — TINY BADGE
========================================================= */

.file-reader-filename {
    gap: 10px;
    font-size: 0.65rem;
    min-width: 0;
    display: flex;
    align-items: center;
    height: 28px;
    padding: 0 8px;
    border: 1px solid rgba(var(--panel-accent), 0.18);
    border-radius: 12px;
    /* background: linear-gradient(180deg, rgba(255,255,255,0.032), transparent 36%),
    #050c16; */
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04),
    inset 0 0 14px rgba(0,0,0,0.34);
    overflow: hidden;
}
span.file-reader-current-file-shape.has-file {
    color: #8690f5;
}
#fileName {
  max-width: 100%;

  color: rgba(214, 238, 250, 0.78);

  font-size: 0.62rem;
  line-height: 1.2;
  font-weight: 700;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  user-select: text;
}

/* =========================================================
   RIGHT PREVIEW DRAWER
========================================================= */

.file-reader-preview {
  width: var(--fr-preview-width);
  min-width: 0;

  display: flex;
  flex-direction: column;
  gap: 8px;

  border: 1px solid rgba(var(--panel-accent), 0.26);
  border-radius: 18px;

  background:
    linear-gradient(135deg, rgba(255,255,255,0.05), transparent 22%),
    radial-gradient(circle at 18% 0%, rgba(var(--panel-accent), 0.14), transparent 58%),
    repeating-linear-gradient(
      135deg,
      rgba(255,255,255,0.014) 0px,
      rgba(255,255,255,0.014) 1px,
      transparent 1px,
      transparent 8px
    ),
    linear-gradient(180deg, #0f1b2c 0%, #08111f 55%, #040812 100%);

  padding: 8px;

  box-shadow:
    0 12px 26px rgba(0,0,0,0.38),
    inset 0 1px 0 rgba(255,255,255,0.07),
    inset 0 -1px 0 rgba(0,0,0,0.55),
    inset 0 -14px 24px rgba(0,0,0,0.20);

  box-sizing: border-box;

  overflow: hidden;

  opacity: 1;
  transform: translateX(0) scaleX(1);
  transform-origin: left center;

  transition:
    opacity 180ms ease,
    transform 220ms ease,
    width 220ms ease,
    padding 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease;
}

/*
  Drawer collapsed:
  - Do NOT use display:none.
  - JS applies aria-hidden + inert.
  - CSS visually closes it while keeping animation possible.
*/
.module-file-reader.is-file-reader-preview-collapsed .file-reader-preview,
.zom-widget--genebean-file-reader.is-file-reader-preview-collapsed .file-reader-preview,
.file-reader-preview.is-collapsed {
  width: 0;
  padding-left: 0;
  padding-right: 0;

  opacity: 0;
  transform: translateX(-8px) scaleX(0.96);

  border-color: transparent;
  box-shadow: none;

  pointer-events: none;
}

.module-file-reader.is-file-reader-preview-collapsed .file-reader-preview > *,
.zom-widget--genebean-file-reader.is-file-reader-preview-collapsed .file-reader-preview > *,
.file-reader-preview.is-collapsed > * {
  visibility: hidden;
}

.file-reader-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  padding: 0 2px 2px;

  color: rgba(226, 244, 255, 0.84);

  font-size: 0.68rem;
  line-height: 1;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.file-reader-preview-collapse-btn {
  min-height: 24px !important;
  height: 24px !important;
  padding: 0 9px !important;

  font-size: 0.62rem !important;
}

/* =========================================================
   TABLE OUTPUT
========================================================= */

#fileReaderOutputWrapper {
  display: none;
  min-width: 0;
}

#fileReaderOutput {
  max-height: 250px;
  min-height: 106px;

  overflow: auto;

  border: 1px solid rgba(var(--panel-accent), 0.30);
  border-radius: 13px;

  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), transparent 22%),
    repeating-linear-gradient(
      135deg,
      rgba(255,255,255,0.012) 0px,
      rgba(255,255,255,0.012) 1px,
      transparent 1px,
      transparent 8px
    ),
    linear-gradient(180deg, #0d1726 0%, #070e19 58%, #030711 100%);

  color: var(--fr-text-secondary);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.052),
    inset 0 -12px 22px rgba(0,0,0,0.32);

  scrollbar-width: thin;
  scrollbar-color: rgba(var(--panel-accent), 0.44) transparent;
}

#fileReaderOutput table {
  width: 100%;
  border-collapse: collapse;
}

.file-preview-table {
  width: 100%;
  border-collapse: collapse;

  font-size: 0.7rem;
  line-height: 1.3;
}

.file-preview-table th,
.file-preview-table td {
  padding: 5px 7px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.file-preview-table th {
  position: sticky;
  top: 0;
  z-index: 2;

  background:
    linear-gradient(180deg, rgba(255,255,255,0.065), transparent 28%),
    linear-gradient(180deg, #1b2d46, var(--fr-table-header-bg));

  color: var(--fr-text-primary);

  font-weight: 850;
  text-align: right;
}

.file-preview-table td {
  color: var(--fr-text-secondary);
  text-align: right;
}

.file-preview-table td:first-child,
.file-preview-table th:first-child {
  text-align: left;
  font-weight: 750;
}

.file-preview-table tr:hover td {
  background: rgba(var(--panel-accent), 0.10);
}

/* =========================================================
   PAGINATION
========================================================= */

.pagination-panel {
  display: none;

  flex-direction: column;
  gap: 6px;

  padding: 8px;

  border: 1px solid rgba(var(--panel-accent), 0.18);
  border-radius: 14px;

  background:
    linear-gradient(180deg, rgba(255,255,255,0.026), transparent 32%),
    #070f1b;

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.045),
    0 7px 15px rgba(0,0,0,0.22);
}

.pagination-core,
.pagination-jump {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.pagination-core {
  justify-content: space-between;
}

.pagination-indicator {
  color: rgba(226, 244, 255, 0.92);
  font-size: 0.68rem;
  font-weight: 850;
}

.pagination-input {
  display: inline-flex;
  align-items: center;
  gap: 5px;

  color: var(--fr-label-color);

  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pagination-input input {
  width: 58px;
  height: 26px;

  border: 1px solid rgba(var(--panel-accent), 0.28);
  border-radius: 999px;

  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 34%),
    #050c16;

  color: var(--fr-text-primary);

  text-align: center;
}

/* =========================================================
   WIDGET LAYER — START LEFT / TOP OF WORKSPACE
========================================================= */

.zom-widget-layer {
  position: fixed;
  z-index: 240;

  top: 5px;
  left: calc(var(--app-rail-width, 0px) + 5px);
  right: auto;
  bottom: auto;

  width: auto;
  max-width: calc(100vw - var(--app-rail-width, 0px) - 10px);
  max-height: calc(100dvh - 10px);

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

  pointer-events: none !important;
}

.zom-widget-layer[hidden] {
  display: none !important;
}

.zom-widget {
  pointer-events: none !important;
}

.zom-widget[hidden] {
  display: none !important;
}

.zom-widget--genebean-file-reader {
  width: auto;
  max-width: none;
  pointer-events: none !important;
}

/*
  Only the actual File Reader surface is interactive.
  The rest of the workspace remains scrollable/clickable.
*/
.zom-widget--genebean-file-reader .file-reader-panel {
  pointer-events: auto;
}

/* =========================================================
   MINIMIZED ICON
========================================================= */

.gb-file-reader-minimized {
  position: relative;

  width: 96px;
  height: 76px;

  display: grid;
  place-items: center;
  gap: 4px;

  padding: 10px;

  border: 1px solid rgba(79, 163, 209, 0.48);
  border-radius: 22px;

  background:
    radial-gradient(circle at 50% 18%, rgba(79, 163, 209, 0.32), transparent 60%),
    linear-gradient(180deg, #17283c 0%, #0d1827 58%, #060b14 100%);

  color: rgba(235, 249, 255, 0.96);

  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.62),
    0 0 32px rgba(79, 163, 209, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    inset 0 -12px 24px rgba(0, 0, 0, 0.28);

  cursor: pointer;
  user-select: none;
  pointer-events: auto;
}

.gb-file-reader-minimized[hidden] {
  display: none !important;
}

.gb-file-reader-minimized__icon,
.gb-file-reader-minimized__label {
  pointer-events: none;
}

.gb-file-reader-minimized__icon {
  width: 42px;
  height: 32px;

  display: grid;
  place-items: center;

  border: 1px solid rgba(138, 216, 255, 0.34);
  border-radius: 12px;

  background:
    linear-gradient(
      180deg,
      rgba(79, 163, 209, 0.20),
      rgba(79, 163, 209, 0.08)
    );

  color: rgba(138, 216, 255, 0.96);

  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.gb-file-reader-minimized__label {
  font-size: 0.68rem;
  line-height: 1;
  font-weight: 850;
  color: rgba(226, 246, 255, 0.86);
}

/* =========================================================
   DATASET AVAILABLE HINT
========================================================= */

.gb-file-reader-preview-toggle-btn.has-file-reader-preview-data {
  color: rgba(132, 255, 196, 0.98) !important;
  border-color: rgba(99, 255, 178, 0.58) !important;

  box-shadow:
    0 0 0 1px rgba(99, 255, 178, 0.16),
    0 0 18px rgba(99, 255, 178, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);

  animation: gb-file-reader-chevron-nudge 1.6s ease-in-out infinite;
}

.gb-file-reader-preview-toggle-btn.has-file-reader-preview-data::after {
  content: "";

  position: absolute;
  top: 4px;
  right: 4px;

  width: 7px;
  height: 7px;

  border-radius: 999px;

  background: #74ffb3;

  box-shadow:
    0 0 0 0 rgba(116, 255, 179, 0.7),
    0 0 10px rgba(116, 255, 179, 0.9);

  animation: gb-file-reader-green-pulse 1.25s ease-out infinite;
}

/* Stop hint once preview is expanded */
.module-file-reader:not(.is-file-reader-preview-collapsed)
.gb-file-reader-preview-toggle-btn.has-file-reader-preview-data,
.zom-widget--genebean-file-reader:not(.is-file-reader-preview-collapsed)
.gb-file-reader-preview-toggle-btn.has-file-reader-preview-data {
  animation: none;
}

.module-file-reader:not(.is-file-reader-preview-collapsed)
.gb-file-reader-preview-toggle-btn.has-file-reader-preview-data::after,
.zom-widget--genebean-file-reader:not(.is-file-reader-preview-collapsed)
.gb-file-reader-preview-toggle-btn.has-file-reader-preview-data::after {
  animation: none;
  opacity: 0.35;
}

/* =========================================================
   ANIMATIONS
========================================================= */

@keyframes gb-file-reader-green-pulse {
  0% {
    opacity: 1;
    transform: scale(0.88);
    box-shadow:
      0 0 0 0 rgba(116, 255, 179, 0.72),
      0 0 10px rgba(116, 255, 179, 0.9);
  }

  70% {
    opacity: 0.78;
    transform: scale(1);
    box-shadow:
      0 0 0 8px rgba(116, 255, 179, 0),
      0 0 14px rgba(116, 255, 179, 0.65);
  }

  100% {
    opacity: 1;
    transform: scale(0.88);
    box-shadow:
      0 0 0 0 rgba(116, 255, 179, 0),
      0 0 10px rgba(116, 255, 179, 0.9);
  }
}

@keyframes gb-file-reader-chevron-nudge {
  0%,
  100% {
    transform: translateX(0);
  }

  45% {
    transform: translateX(2px);
  }

  65% {
    transform: translateX(0);
  }
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 860px) {
  .file-reader-panel {
    max-width: min(220px, calc(100vw - 24px));
  }

  .module-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-panel,
  .zom-widget--genebean-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-panel {
    max-width: calc(100vw - 24px);
  }

  .file-reader-body,
  .module-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-body,
  .zom-widget--genebean-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-body {
    grid-template-columns: 1fr;
  }

  .file-reader-toolbar,
  .file-reader-preview {
    width: 100%;
  }

  .module-file-reader.is-file-reader-preview-collapsed .file-reader-preview,
  .zom-widget--genebean-file-reader.is-file-reader-preview-collapsed .file-reader-preview,
  .file-reader-preview.is-collapsed {
    width: 100%;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    transform: translateY(-6px);
  }
}

@media (max-width: 520px) {
  .zom-widget-layer {
    top: 5px;
    left: 5px;
    right: auto;

    max-width: calc(100vw - 10px);
    max-height: calc(100dvh - 10px);
  }

  .file-reader-panel {
    border-radius: 20px;
  }

  .module-file-reader select,
  .module-file-reader button {
    width: 100%;
  }

  #fileReaderOutput {
    max-height: 220px;
  }
}

.gb-marss-tool-slide .zom-widget-layer,
.gb-marss-tool-slide .zom-widget,
.gb-marss-tool-slide .zom-widget--genebean-file-reader {
  position: static !important;
  width: 100% !important;
  max-width: none !important;
  max-height: none !important;

  display: block !important;

  pointer-events: auto !important;
}

.gb-marss-tool-slide .zom-widget--genebean-file-reader .file-reader-panel {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;

  transform: none !important;
}

.gb-marss-tool-slide .module-file-reader {
  width: 100%;
}

.gb-marss-tool-slide .module-file-reader {
  --fr-collapsed-panel-width: 100%;
  --fr-preview-width: 100%;
}

.gb-marss-tool-slide .file-reader-body,
.gb-marss-tool-slide .module-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-body,
.gb-marss-tool-slide .zom-widget--genebean-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-body {
  grid-template-columns: 1fr;
  gap: 10px;
}

.gb-marss-tool-slide .file-reader-toolbar,
.gb-marss-tool-slide .file-reader-preview {
  width: 100%;
}
.gb-marss-tool-slide .zom-widget-layer,
.gb-marss-tool-slide .zom-widget,
.gb-marss-tool-slide .zom-widget--genebean-file-reader {
  position: static !important;
  inset: auto !important;

  width: 100% !important;
  max-width: none !important;
  max-height: none !important;

  display: block !important;

  pointer-events: auto !important;
}

.gb-marss-tool-slide .zom-widget--genebean-file-reader .file-reader-panel,
.gb-marss-tool-slide .file-reader-panel {
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;

  transform: none !important;
}

.gb-marss-tool-slide .module-file-reader {
  width: 100%;
  --fr-collapsed-panel-width: 100%;
  --fr-preview-width: 100%;
}

.gb-marss-tool-slide .file-reader-body,
.gb-marss-tool-slide .module-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-body,
.gb-marss-tool-slide .zom-widget--genebean-file-reader:not(.is-file-reader-preview-collapsed) .file-reader-body {
  grid-template-columns: 1fr;
  gap: 10px;
}

.gb-marss-tool-slide .file-reader-toolbar,
.gb-marss-tool-slide .file-reader-preview {
  width: 100%;
}

/* =========================================================
   FILE READER — COMPACT DATASET LABEL HANDLING
   Keep original look, but make long names manageable
========================================================= */

/* Restore the more compact proportions */
.module-file-reader {
  --fr-toolbar-width: 104px;
  --fr-collapsed-panel-width: 132px;
  --fr-preview-width: min(620px, calc(100vw - var(--app-rail-width, 0px) - 190px));
}

/* Keep the original compact toolbar feel */
.file-reader-toolbar {
  align-items: self-end;
  display: flex;
  flex-direction: row;
  gap: 12px;
  width: var(--fr-toolbar-width);
  padding: 8px;
  margin: 0;
  box-sizing: border-box;
}

/* Keep hidden dataset control truly hidden */
.file-reader-existing-dataset-control[hidden] {
  display: none !important;
}

/* Let select text truncate cleanly */
#fileReaderSource,
#fileReaderExistingDataset,
#fileType {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Current file badge:
   - compact by default
   - scrollable on hover if the filename is long
*/
.file-reader-filename {
  gap: 10px;
  font-size: 0.65rem;
  min-width: 0;

  display: flex;
  align-items: center;

  height: 28px;
  padding: 0 8px;

  border: 1px solid rgba(var(--panel-accent), 0.18);
  border-radius: 12px;

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    inset 0 0 14px rgba(0,0,0,0.34);

  overflow-x: hidden;
  overflow-y: hidden;
  white-space: nowrap;
}

/* Hide scrollbar until hover */
.file-reader-filename:not(:hover) {
  scrollbar-width: none;
}

.file-reader-filename:not(:hover)::-webkit-scrollbar {
  display: none;
}

/* Show tiny horizontal scrollbar only on hover */
.file-reader-filename:hover {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--panel-accent), 0.35) transparent;
}

.file-reader-filename:hover::-webkit-scrollbar {
  height: 5px;
}

.file-reader-filename:hover::-webkit-scrollbar-track {
  background: transparent;
}

.file-reader-filename:hover::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(var(--panel-accent), 0.35);
}

/* Make the filename itself expand naturally inside the scroll area */
.file-reader-current-file {
  display: inline-block;
  min-width: max-content;
  white-space: nowrap;
}

/* Keep the shape text visible but secondary */
.file-reader-current-file-shape {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* =========================================================
   CATALOGUE DATASET SOURCE LINK
========================================================= */

.file-reader-existing-dataset-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.file-reader-existing-dataset-row select {
  flex: 1 1 auto;
  min-width: 0;
}

.file-reader-dataset-source-link {
  cursor: pointer !important;
  flex: 0 0 28px;

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

  width: 28px;
  height: 28px;

  border: 1px solid rgba(var(--panel-accent), 0.38);
  border-radius: 999px;

  background:
    linear-gradient(
      180deg,
      rgba(var(--panel-accent), 0.18),
      rgba(8, 19, 33, 0.94)
    );

  color: var(--fr-text-primary);
  text-decoration: none;

  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;

  box-shadow:
    0 5px 12px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);

  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    transform 150ms ease;
}

.file-reader-dataset-source-link:hover,
.file-reader-dataset-source-link:focus-visible {
  border-color: rgba(var(--panel-accent), 0.85);
  color: #ffffff;
  transform: translateY(-1px);
  outline: none;
}

.file-reader-dataset-source-link[hidden] {
  display: none !important;
}

.file-reader-preview-collapse-btn,
[data-file-reader-preview-toggle] {
  display: none !important;
}

/* =========================================================
   FILE READER — LIGHT SCIENTIFIC INSTRUMENT SKIN

   Visual update only.
   Existing layout, collapse, preview and responsive rules remain.
========================================================= */

.module-file-reader {
  --panel-accent: 91 112 179;

  --fr-panel-border: rgba(72, 94, 157, 0.34);

  --fr-text-primary: #18213a;
  --fr-text-secondary: rgba(49, 62, 98, 0.82);
  --fr-text-muted: rgba(70, 82, 116, 0.52);

  --fr-label-color: rgba(67, 83, 126, 0.72);
  --fr-select-option-bg: #eef2fb;

  --fr-btn-text: #33436f;

  --fr-btn-disabled-top: rgba(231, 235, 244, 0.88);
  --fr-btn-disabled-bottom: rgba(212, 218, 232, 0.90);
  --fr-btn-disabled-border: rgba(95, 111, 151, 0.18);

  --fr-table-header-bg: #dfe6f5;
}

/* =========================================================
   MAIN PANEL
========================================================= */

.file-reader-panel {
  border-color: var(--fr-panel-border);

  background:
    linear-gradient(
      rgba(77, 101, 166, 0.04) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(77, 101, 166, 0.04) 1px,
      transparent 1px
    ),
    radial-gradient(
      circle at 12% 0%,
      rgba(139, 124, 255, 0.11),
      transparent 38%
    ),
    radial-gradient(
      circle at 86% 0%,
      rgba(127, 181, 255, 0.12),
      transparent 42%
    ),
    linear-gradient(
      155deg,
      rgba(250, 252, 255, 0.99),
      rgba(225, 232, 248, 0.98)
    );

  background-size:
    24px 24px,
    24px 24px,
    auto,
    auto,
    auto;

  color: var(--fr-text-primary);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94),
    inset 0 -1px 0 rgba(49, 66, 112, 0.10),
    0 0 0 1px rgba(7, 13, 30, 0.08);
}

.file-reader-panel::after {
  background:
    radial-gradient(
      ellipse at center,
      rgba(103, 125, 191, 0.045),
      transparent 70%
    );

  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.36);

  pointer-events: none;
}

/* =========================================================
   HEADER
========================================================= */

.file-reader-kicker {
  color: #55729f;
  text-shadow: none;
}

.module-file-reader .module-header h2 {
  color: #18213a;
  text-shadow: none;
}

/* =========================================================
   TOOLBAR
========================================================= */

.file-reader-toolbar {
  border-color: rgba(72, 94, 157, 0.22);

  background:
    radial-gradient(
      circle at 14% 0%,
      rgba(127, 181, 255, 0.10),
      transparent 46%
    ),
    linear-gradient(
      180deg,
      rgba(241, 245, 255, 0.96),
      rgba(219, 227, 245, 0.94)
    );

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    inset 0 -1px 0 rgba(47, 64, 110, 0.08);
}

.module-file-reader label,
.file-reader-control label {
  color: var(--fr-label-color);
  text-shadow: none;
}

/* =========================================================
   SELECTS
========================================================= */

.module-file-reader select {
  border-color: rgba(72, 94, 157, 0.26);

  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.96),
      rgba(222, 229, 245, 0.94)
    );

  color: #28375f;
  color-scheme: light;

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

.module-file-reader select:focus {
  border-color: rgba(91, 112, 179, 0.58);

  box-shadow:
    0 0 0 2px rgba(91, 112, 179, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.96);
}

.module-file-reader select option {
  background: var(--fr-select-option-bg);
  color: #18213a;
}

/* =========================================================
   BUTTONS
========================================================= */

.module-file-reader button {
  border-color: rgba(72, 94, 157, 0.30);

  background:
    radial-gradient(
      circle at 50% 0%,
      rgba(127, 181, 255, 0.12),
      transparent 70%
    ),
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.96),
      rgba(211, 221, 244, 0.94)
    );

  color: var(--fr-btn-text);
  text-shadow: none;

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94);
}

.module-file-reader button:hover:not(:disabled) {
  border-color: rgba(72, 94, 157, 0.52);
  filter: none;
}

.module-file-reader button:disabled {
  color: var(--fr-text-muted);
  box-shadow: none;
}

button#selectFile {
  border-color: rgba(72, 94, 157, 0.34);

  background:
    linear-gradient(
      180deg,
      rgba(238, 244, 255, 0.98),
      rgba(205, 218, 244, 0.96)
    );
}

button#fileReaderSaveGBToxBtn {
  border-color: rgba(84, 180, 151, 0.30);

  background:
    linear-gradient(
      180deg,
      rgba(226, 247, 239, 0.96),
      rgba(191, 229, 215, 0.94)
    );

  color: #315f53;
}

/* =========================================================
   CURRENT FILE BADGE
========================================================= */

.file-reader-filename {
  border-color: rgba(72, 94, 157, 0.18);

  background:
    rgba(239, 243, 252, 0.76);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.84);
}

#fileName {
  color: rgba(41, 55, 91, 0.78);
}

span.file-reader-current-file-shape.has-file {
  color: #5d68a8;
}

/* =========================================================
   PREVIEW DRAWER
========================================================= */

.file-reader-preview {
  border-color: rgba(72, 94, 157, 0.24);

  background:
    linear-gradient(
      rgba(77, 101, 166, 0.035) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(77, 101, 166, 0.035) 1px,
      transparent 1px
    ),
    radial-gradient(
      circle at 18% 0%,
      rgba(127, 181, 255, 0.10),
      transparent 52%
    ),
    linear-gradient(
      180deg,
      rgba(242, 246, 255, 0.97),
      rgba(221, 229, 246, 0.96)
    );

  background-size:
    22px 22px,
    22px 22px,
    auto,
    auto;

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.90),
    inset 0 -1px 0 rgba(47, 64, 110, 0.08);
}

.file-reader-preview-head {
  color: rgba(45, 59, 95, 0.80);
}

/* =========================================================
   TABLE OUTPUT
========================================================= */

#fileReaderOutput {
  border-color: rgba(72, 94, 157, 0.24);

  background:
    linear-gradient(
      rgba(77, 101, 166, 0.03) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(77, 101, 166, 0.03) 1px,
      transparent 1px
    ),
    rgba(247, 249, 254, 0.96);

  background-size:
    22px 22px,
    22px 22px,
    auto;

  color: var(--fr-text-secondary);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.94);

  scrollbar-color: rgba(91, 112, 179, 0.34) transparent;
}

.file-preview-table th,
.file-preview-table td {
  border-bottom-color: rgba(73, 91, 134, 0.10);
}

.file-preview-table th {
  background:
    linear-gradient(
      180deg,
      rgba(238, 243, 253, 0.98),
      var(--fr-table-header-bg)
    );

  color: #25345c;
}

.file-preview-table td {
  color: rgba(45, 58, 92, 0.80);
}

.file-preview-table tr:hover td {
  background: rgba(91, 112, 179, 0.08);
}

/* =========================================================
   PAGINATION
========================================================= */

.pagination-panel {
  border-color: rgba(72, 94, 157, 0.18);

  background:
    rgba(237, 242, 252, 0.92);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.pagination-indicator {
  color: #33436f;
}

.pagination-input {
  color: var(--fr-label-color);
}

.pagination-input input {
  border-color: rgba(72, 94, 157, 0.24);
  background: rgba(250, 252, 255, 0.96);
  color: #18213a;
}

/* =========================================================
   FILE READER — MOBILE LAYOUT REPAIR
   Append-only override.
   Keeps the existing light scientific instrument theme.
========================================================= */

@media (max-width: 768px) {

  /* -------------------------------------------------------
     MOBILE PANEL CONTAINMENT
  ------------------------------------------------------- */

  .gb-marss-tool-slide .module-file-reader,
  .gb-marss-tool-slide .zom-widget--genebean-file-reader,
  .gb-marss-tool-slide .file-reader-panel,
  .module-file-reader,
  .zom-widget--genebean-file-reader,
  .file-reader-panel {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .file-reader-panel {
    padding: 8px;
    overflow: hidden;
  }

  .module-file-reader {
    --fr-toolbar-width: 100%;
    --fr-collapsed-panel-width: 100%;
    --fr-preview-width: 100%;
  }

  /* -------------------------------------------------------
     HEADER
  ------------------------------------------------------- */

  .module-file-reader .module-header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding-inline: 4px;
  }

  .file-reader-title-block,
  .file-reader-window-actions {
    min-width: 0;
  }

  /* -------------------------------------------------------
     BODY STACK
  ------------------------------------------------------- */

  .file-reader-body,
  .module-file-reader:not(.is-file-reader-preview-collapsed)
  .file-reader-body,
  .zom-widget--genebean-file-reader:not(.is-file-reader-preview-collapsed)
  .file-reader-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px;
    min-width: 0;
  }

  /* -------------------------------------------------------
     TOOLBAR
     The controls remain compact, but wrap intentionally.
  ------------------------------------------------------- */

  .file-reader-toolbar {
    width: 100% !important;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.35fr) auto;
    align-items: end;
    gap: 8px;
    padding: 8px;
  }

  .file-reader-control {
    min-width: 0;
  }

  .file-reader-existing-dataset-control {
    min-width: 0;
  }

  .file-reader-existing-dataset-row {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    gap: 6px;
  }

  .module-file-reader select,
  #fileReaderSource,
  #fileReaderExistingDataset,
  #fileType {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .file-reader-dataset-source-link {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  /* -------------------------------------------------------
     PREVIEW DRAWER
  ------------------------------------------------------- */

  .file-reader-preview {
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
    padding: 8px;
    overflow: hidden;
  }

  .module-file-reader.is-file-reader-preview-collapsed
  .file-reader-preview,
  .zom-widget--genebean-file-reader.is-file-reader-preview-collapsed
  .file-reader-preview,
  .file-reader-preview.is-collapsed {
    width: 100% !important;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
  }

  /* -------------------------------------------------------
     TABLE PREVIEW
     The table scrolls inside its own viewport instead of
     forcing the whole module wider than the screen.
  ------------------------------------------------------- */

  #fileReaderOutputWrapper {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  #fileReaderOutput {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 220px;
    max-height: min(42dvh, 340px);

    overflow-x: auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;

    border-radius: 14px;
  }

  #fileReaderOutput table,
  .file-preview-table {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
  }

  .file-preview-table th,
  .file-preview-table td {
    min-width: 92px;
    padding: 7px 10px;
    font-size: 0.72rem;
  }

  .file-preview-table th:first-child,
  .file-preview-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 138px;
    max-width: 180px;
  }

  .file-preview-table th:first-child {
    z-index: 5;
    background:
      linear-gradient(
        180deg,
        rgba(238, 243, 253, 0.99),
        var(--fr-table-header-bg)
      );
  }

  .file-preview-table td:first-child {
    background: rgba(247, 249, 254, 0.98);
    box-shadow: 1px 0 0 rgba(73, 91, 134, 0.10);
  }

  .file-preview-table tr:hover td:first-child {
    background: rgba(234, 239, 251, 0.98);
  }

  /* -------------------------------------------------------
     PAGINATION
     Cancels the broad mobile "all buttons = 100%" rule.
  ------------------------------------------------------- */

  .pagination-panel {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    gap: 8px;
    padding: 8px;
    box-sizing: border-box;
  }

  .pagination-core {
    display: grid;
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
    gap: 6px;
    align-items: center;
  }

  .pagination-indicator {
    grid-column: 1 / -1;
    padding: 2px 2px 4px;
  }

  .pagination-core button,
  .pagination-jump button,
  .pagination-panel button {
    width: auto !important;
    min-width: 0;
    min-height: 34px;
    padding-inline: 10px;
  }

  .pagination-core button {
    width: 100% !important;
  }

  .pagination-jump {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
  }

  .pagination-input {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(64px, 1fr);
    gap: 8px;
    align-items: center;
  }

  .pagination-input input {
    width: 100%;
    min-width: 0;
    height: 34px;
    box-sizing: border-box;
  }

  .pagination-jump button {
    min-width: 64px;
  }
}

@media (max-width: 520px) {

  /* -------------------------------------------------------
     NARROW PHONE REFINEMENTS
  ------------------------------------------------------- */

  .file-reader-panel {
    border-radius: 18px;
  }

  .file-reader-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr);
  }

  .file-reader-toolbar > :nth-child(3),
  .file-reader-toolbar > .file-reader-control:last-child {
    grid-column: 1 / -1;
  }

  .file-reader-existing-dataset-row {
    grid-template-columns: minmax(0, 1fr) 36px;
  }

  .module-file-reader button {
    width: auto;
  }

  #selectFile,
  .file-reader-commit-btn {
    width: 100%;
  }

  #fileReaderOutput {
    min-height: 210px;
    max-height: min(40dvh, 300px);
  }

  .pagination-core {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pagination-core button {
    width: 100% !important;
  }

  .pagination-jump {
    grid-template-columns: minmax(0, 1fr) 64px;
  }
}

@media (max-width: 390px) {

  .file-reader-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .file-reader-toolbar > * {
    grid-column: 1 !important;
  }

  .pagination-core {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pagination-jump {
    grid-template-columns: 1fr;
  }

  .pagination-jump button {
    width: 100% !important;
  }
}

