body {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  margin: 0;
  font-family: sans-serif;
  background-color: #f9f9f9;
  color: #333;
}

#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 240px;
  height: 100vh;
  background-color: #2c3e50;
  padding: 20px 20px 60px 20px;
  box-sizing: border-box;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #888 #2c3e50;
}

#sidebar::-webkit-scrollbar {
  width: 6px;
}

#sidebar::-webkit-scrollbar-track {
  background: #2c3e50;
}

#sidebar::-webkit-scrollbar-thumb {
  background-color: #888;
  border-radius: 3px;
}

#sidebar h1 {
  color: #ecf0f1;
  font-size: 20px;
  margin-bottom: 20px;
}

.nav-link {
  display: block;
  color: #bdc3c7;
  text-decoration: none;
  margin: 10px 0;
  font-weight: bold;
  padding: 10px 15px;
  border-radius: 10px;
  transition: background-color 0.3s, color 0.3s;
}

.nav-link:hover {
  color: #ffffff;
  background-color: #34495e;
}

.nav-link.active {
  background: #16a085;
  color: #fff !important;
  border-radius: 4px;
}

#sidebar-footer {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 200px;
  font-size: 12px;
  color: #7f8c8d;
  text-align: center;
  line-height: 1.4;
  background-color: #2c3e50;
}

#sidebar-footer a {
  color: #1abc9c;
  text-decoration: none;
}

#sidebar-footer a:hover {
  text-decoration: underline;
}

#content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-sizing: border-box;
  min-height: 100vh;
  margin-left: 240px;
  overflow-x: auto;
  min-width: 0; /* Allow shrinking below 900px */
}

.content-inner {
  max-width: 900px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

@media (max-width: 1200px) {
  #content {
    max-width: 98vw;
  }
}

@media (max-width: 940px) {
  #content {
    /* Keep margin-left: 240px; so content never jumps under sidebar */
    min-width: 0;
    padding: 10px;
  }
  .content-inner {
    max-width: 100vw;
    min-width: 0;
    width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 800px) {
  #content {
    overflow-x: auto;
  }
  .content-inner {
    width: 900px;
    min-width: 900px;
    max-width: 900px;
  }
}

.page-section {
  display: none;
  width: 100%;
}

.page-section.active {
  display: block;
  width: 100%;
}

.plot-container {
  margin: 20px 0;
  width: 100%;
}

.plot-container .plotly-graph-div {
  width: 100% !important;
  height: auto !important;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1em;
  background-color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
}

thead {
  background-color: #2c3e50;
  color: white;
}

th,
td {
  padding: 10px;
  border: 1px solid #ddd;
  text-align: left;
}

tr:nth-child(even) {
  background-color: #f2f2f2;
}

tbody tr:hover {
  background-color: #e8f0fe;
}

.dash-image {
  max-width: 100%;
  height: auto;
  margin: 1em 0;
}

.download-button {
  display: inline-block;
  padding: 0.5em 1em;
  margin: 1em 0;
  background-color: #2c3e50;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  font-weight: bold;
}

.download-button:hover {
  background-color: #547a9f;
}

/* Sortable Tables */
table.sortable th {
  cursor: pointer;
  position: relative;
  padding-right: 1.5em;
  user-select: none;
}

table.sortable th::after {
  content: "";
  position: absolute;
  right: 0.5em;
  font-size: 0.9em;
  pointer-events: none;
}

table.sortable th.sorted-asc::after {
  content: "\25B2";
}

table.sortable th.sorted-desc::after {
  content: "\25BC";
}

/* MiniPage Layout */
.minipage-row {
  display: flex;
  width: 100%;
  gap: 20px;
  margin-bottom: 20px;
  box-sizing: border-box;
}

.minipage-cell {
  flex: 1 1 0;
  min-width: 0;
  box-sizing: border-box;
  padding: 10px;
  overflow-x: auto;
}

.minipage-cell pre {
  flex: 0 1 auto;
  max-height: 400px;
  overflow: auto;
}

.minipage-cell h4 {
  margin-top: 0;
}

.minipage-cell .syntax-block {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.minipage-cell table {
  display: block;
  overflow-x: auto;
  width: 100%;
}

/* Syntax Blocks */
.syntax-block {
  position: relative;
  margin: 1em 0;
  background: #23272e;
  border-radius: 6px;
  overflow: auto;
  color: #f8f8f2;
}

.syntax-block pre {
  margin: 0;
  padding: 1em;
  background: none;
  color: inherit;
  font-family: 'Fira Mono', 'Consolas', monospace;
  font-size: 0.95em;
}

.code-toolbar {
  position: absolute;
  top: 6px;
  right: 12px;
  z-index: 2;
}

.copy-btn,
.view-raw-btn {
  color: #fff;
  background: #444;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.85em;
  text-decoration: none;
  margin-left: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.copy-btn:hover,
.view-raw-btn:hover {
  background: #1abc9c;
}

.table-wrapper {
  overflow-x: auto;
  width: 100%;
}

table, .syntax-block, pre {
  max-width: 100%;
  overflow-x: auto;
}

/* Sidebar Styles */
.sidebar-group { margin-bottom: 0; }
.sidebar-parent { cursor: pointer; font-weight: bold; display: flex; align-items: center; }
.sidebar-arrow {
  display: inline-block;
  margin-right: 6px;
}

/* By default, no transition */
.sidebar-children {
  margin-left: 18px;
  max-height: 0;
  overflow: hidden;
}

/* When open, show content */
.sidebar-group.open > .sidebar-children {
  max-height: none;
}

/* Enable transition only after page load */
body.sidebar-animate .sidebar-children {
  transition: max-height 0.25s cubic-bezier(.4,0,.2,1);
}

body.sidebar-animate .sidebar-arrow {
  transition: transform 0.2s;
}

.sidebar-title {
  display: block;
  font-size: 1.5em;
  font-weight: bold;
  margin-bottom: 1em;
  color: #fff;
  text-decoration: none;
  text-align: left;
  padding: 10px 15px;
  border-radius: 10px;
  background: none;
  transition: background-color 0.3s, color 0.3s;
}

.sidebar-title:hover {
  background-color: #34495e;
  color: #fff;
  text-decoration: none;
}

:root {
  --sidebar-width: 240px;      /* matches #sidebar width */
  --content-padding-x: 20px;    /* matches #content horizontal padding */
}

/* Pure-CSS triangle for sidebar arrow */
.sidebar-arrow {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid #bdc3c7; /* arrow color */
  margin-right: 6px;
}

/* Rotate when group is open (you already have this rule; keep it) */
body.sidebar-animate .sidebar-group.open .sidebar-arrow {
  transform: rotate(90deg);
  transform-origin: 30% 50%;
}
