:root {
  --gap: 20px;
  --pad: 12px;
  --radius: 12px;
  --border: #d6dbe3;
  --bg: #eceff3;
  --primary: #00b4d8;
  --primary-hover: #0077b6;
  --muted: #666;
}

/* Base */
body {
  font-family: "Dosis", sans-serif;
  background: #f4f4f9;
  color: #333;
  margin: 0;
  padding: 10px;
}
header {
  background: #005f73;
  color: #fff;
  padding: 10px 20px;
  font-size: 15px;
  text-align: center;
}
header h2 {
  margin: 0;
}
main {
  margin-top: 8px;
}

/* ================== TOP MENU ================== */
.topmenu {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--gap);
  align-items: stretch;
  width: 100%;
}

.topmenu .toolbar {
  background: #e0e0e0;
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04) inset;
  padding: var(--pad) 14px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.topmenu .row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.topmenu .group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.topmenu .muted {
  color: var(--muted);
  font-size: 13px;
}

.topmenu label,
.topmenu select,
.topmenu input[type="text"],
.topmenu input[type="number"],
.topmenu input[type="date"],
.topmenu input[type="range"] {
  display: inline-flex;
  width: auto;
  margin: 0;
  font-size: 14px;
  align-items: center;
}

.topmenu #numpackets,
.topmenu #prescaler {
  width: 56px;
}

.topmenu .primary-btn {
  padding: 10px 14px;
  font-size: 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.topmenu .primary-btn:hover {
  background: var(--primary-hover);
}

.topmenu .pill-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #cfd3d8;
  background: #fff;
  cursor: pointer;
}

/* Info icon */
#infoButton {
  width: 28px;
  height: 28px;
  border: 0px;
  border-radius: 6px;
  background: url("images/info-button.png") center/cover no-repeat;
  cursor: pointer;
}

/* For the collapse button */
.collapse-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  text-align: center;
  margin: 10px 0px 0px 0px !important;
  padding: 5px;
  display: block; /* Ensure it spans the full width for better click target */
}

#dataSource {
  display: none;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap; /* prevent overflow */
}

#databaseElements,
#deviceElements {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

/* Transport buttons */
#play,
#stop {
  width: 46px;
  height: 46px;
  border: 0px;
  border-radius: 10px;
  background: center/cover no-repeat;
  cursor: pointer;
  transition: filter 0.2s ease;
}

#play {
  background-image: url("images/play.png");
}

#stop {
  background-image: url("images/stop-button.png");
}

#play:hover,
#stop:hover {
  filter: brightness(0.9);
}

/* BPM section */
#bpmLabel,
#bpmText {
  font-weight: 600;
}

#bpmText {
  font-size: 16px;
}

#speedOptions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#playbackContainer {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 30px;
}

/* Playback toolbar width */
.toolbar-transport {
  min-width: 380px;
  justify-content: center;
}

.rightPlot {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 300px;
  border-radius: 5px;
  /* min-height: 400px; */
}

.volumeContainer {
  margin-left: 0px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.volumeContainer label {
  font-size: 14px;
  font-weight: bold;
}

.volumeContainer input[type="range"] {
  width: 100%;
}

.removeModule {
  width: 30px;
  height: 30px;
  color: black;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease, filter 0.3s ease;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  padding: 0;
  margin: 5px 10px 5px 5px;
  background: transparent;
}

.moduleTopOptions {
  margin-top: 30px;
  display: flex;
  justify-content: space-between;
  align-items: left;
  height: 80px;
}

.removeModule::before {
  content: "×"; /* This creates the X symbol */
  font-size: 20px;
  color: black;
  font: optional;
  line-height: 1;
}

/* LEFT SIDE: All menu items */
.leftMenu {
  width: 220px;
  flex-shrink: 0;
  background-color: #e0e0e0;
  padding: 18px;
  border-radius: 5px;
  position: relative;
}

/* Screen Reader utility (like blind or low-vision users) */
.u-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

/* Responsive: stack bars on narrow screens */
@media (max-width: 1100px) {
  .topmenu {
    grid-template-columns: 1fr;
  }
  .toolbar-transport {
    min-width: 0;
  }
}


/* ================== MODULES / PLOT (unchanged) ================== */
/* Adjusted layout for module options */
.moduleDataOptions {
  display: flex; /* Use flexbox to arrange children horizontally */
  flex-direction: column;
  gap: 10px; /* Add space between the children */
  margin-bottom: 15px; /* Add space below the options for visual clarity */
}

.sensorsContainer,
.readingsContainer {
  flex: 1; /* Make each container take up equal space */
  display: flex; /* Optional: Flexbox within each container if you want finer control */
  flex-direction: column; /* Keep label and select in vertical alignment */
  gap: 5px; /* Space between label and select */
  width: 100%;
}

.sensorsContainer label,
.readingsContainer label {
  font-size: 14px;
  font-weight: bold;
  margin: 0;
}

.sensorsContainer select,
.readingsContainer select {
  width: 100%;
  padding: 8px;
  border: 1px solid #999;
  border-radius: 3px;
  background-color: #fff;
}

.moduleBottomOptions {
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  background-color: #f4f4f4;
  margin-top: 10px;
  display: none; /* Initially hidden */
}

.moduleBottomOptions label {
  font-size: 13px;
  font-weight: bold;
  margin-top: 10px;
  margin-bottom: 5px;
}

.moduleBottomOptions select {
  width: 100%;
  padding: 5px;
  border: 1px solid #999;
  border-radius: 3px;
  background-color: #fff;
  margin-bottom: 10px;
}

.plot {
  flex: 1;
  min-height: 0;
  border-radius: 8px;
  background-color: #fff;
  border: 1px solid #ccc;
  margin-top: 0px; /* Spacing between the top options and the plot */
}

/* Maintain flexbox styling for module layout */
#modulesContainer {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 2.5px;
}

.soundModule {
  display: flex;
  gap: 2.5px;
  background-color: none;
  padding: 0;
  margin-bottom: 0;
  position: relative;
  align-items: stretch;
}

.moduleOptions {
  display: flex;
  justify-content: space-between;
}

.moduleOptions > * {
  flex-grow: 1;
  margin: 0 10px;
}

#addModule {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 8px auto;
  width: 100%;
  height: 40px;
  background-color: #e0e0e0;
  color: #333; 
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  flex-shrink: 0;
  border: none;
  border-radius: 5px;
  position: relative;
  background-image: none;
  padding: 0 10px; 
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Style for the image inside button */
#addModule .add-icon {
  height: 1em; 
  width: auto; 
  vertical-align: middle; 
}

#addModule:hover {
  background-color: #cfcdcd; 
  filter: none; 
}