:root {
  --bg: #f7f7f9;
  --panel: #ffffff;
  --border: #e0e0e0;
  --accent: #4c6ef5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, sans-serif;
}

/* Utility Classes */
.hidden {
  display: none !important;
}
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: var(--bg);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

/* Top Navigation Bar */
.navbar {
    background-color: #000000;
    padding: 2rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

.navbar {
    h1 {
        font-size: 2rem;
        margin-right: 450px;
    }
    a {
        font-size: 1.2rem;
        color: white;
        text-decoration: none;
        margin-right: 4rem;
    }
    a:hover {
        color: #ddd;
    }
}
/* Container for sidebar and main content */
.container {
    display: flex;
    height: calc(100vh - 70px);
    overflow: hidden;
    position: relative; /* allow absolutely positioned sidebar-related elements */
}

/* Left Sidebar Navigation */
.sidebar {
    width: 250px;
    flex: 0 0 250px;
    min-width: 10px;
    max-width: 275px;
    position: relative; /* for resizer handle */
    background-color: #ffffff;
    border-right: 1px solid #ddd;
    padding: 1rem 0;
    overflow: hidden;
    will-change: width;
    transition: width 180ms ease, flex-basis 180ms ease, padding 180ms ease;
}

/* Visually collapsed state: keep only a thin rail to drag */
.sidebar.sidebar-collapsed {
    padding: 0;
    border-right: none;
}

.sidebar.sidebar-collapsed > *:not(.sidebar-resizer) {
    display: none;
}

/* Draggable edge for sidebar resize */
.sidebar-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 100%;
    cursor: ew-resize;
    background: transparent;
}

html.dark-mode .sidebar-toggle:hover {
    background: #ffffff;
}

.sidebar a {
  font-size: 1.15rem;
    display: block;
    padding: 0.75rem 1.5rem;
    color: #333;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.3s;
}

.sidebar button {
    display: block;
    padding: 0.75rem 1.5rem;
    color: #333;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.3s;
}
.sidebar button:hover {
    background-color: #e9e9e9;
    border-left-color: #007bff;
}

.sidebar a:hover {
    background-color: #e9e9e9;
    border-left-color: #007bff;
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 3rem;
    padding-left: 10rem;
    padding-right: 10rem;
    overflow-y: auto;
    h2 {
        margin-top: 25px;
        margin-bottom: 15px;
    }
    p {
        margin-bottom: 10px;
    }
}


.controls select,
.controls button {
  margin-left: 4px;
}

.dashboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
  min-width: 0; /* Prevents flex item from overflowing */
}

.combined-section {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}

/* Category intro (above treemap): tutorial + category definitions */
.category-intro {
  margin-bottom: 16px;
}

.category-intro-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-intro-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #333;
}

#toggleCategoryIntro {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
}

#toggleCategoryIntro:hover {
  background: #f1f5f9;
}

.category-intro-body {
  margin-top: 12px;
  font-size: 16px;
}

.category-intro-body.hidden {
  display: none !important;
}

.category-intro-body h3 {
  margin: 12px 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.category-intro-lead {
  font-size: 16px;
  color: #555;
  margin: 8px 0 10px 0;
  line-height: 1.5;
}

.intro-divider {
  margin: 16px 0;
  border: none;
  border-top: 1px solid #e5e7eb;
}

.tutorial-bullets {
  font-size: 16px;
  padding-left: 18px;
  margin: 0 0 12px 0;
  line-height: 1.5;
  color: #333;
}

.tutorial-bullets li {
  margin-bottom: 4px;
}

.category-intro-lead code {
  font-size: 12px;
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
}

.category-descriptions {
  list-style: disc;
  margin: 0 0 0 20px;
  padding: 0;
}

.category-descriptions li {
  margin-bottom: 12px;
  padding-left: 8px;
  line-height: 1.5;
}

.category-descriptions li:last-child {
  margin-bottom: 0;
}

.category-descriptions .category-name {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: #333;
  margin-bottom: 2px;
}

.category-descriptions .category-desc {
  display: block;
  font-size: 12px;
  color: #666;
  line-height: 1.45;
  margin-left: 0;
}

.summary {
  /* No grid positioning needed - handled by combined-section */
}

.compare {
  /* No grid positioning needed - handled by combined-section */
}

#compareChart {
  width: 100%;
  min-height: 400px;
  overflow-x: auto;
}

#compareChart svg {
  display: block;
  margin: 0 auto;
}

.tooltip {
  position: absolute;
  z-index: 1000;
}

#recVis {
  width: 100%;
  min-height: 500px;
  overflow: visible;
}

#recVis svg {
  display: block;
  margin: 0 auto;
}

.network-controls {
  margin-bottom: 10px;
}

.network-controls select {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.links line {
  stroke-opacity: 0.3;
}

.nodes circle {
  cursor: pointer;
}

.nodes circle:hover {
  stroke-width: 3;
}

.labels text {
  fill: #333;
  font-weight: 500;
  pointer-events: none;
}

.settings {
  /* No grid positioning needed - handled by combined-section */
  display: flex;
  flex-direction: column;
}

.detail {
  /* No grid positioning needed - handled by combined-section */
  min-height: 300px;
}

.timeline {
  grid-column: 1;
}

/* Treemap Styles */
.treemap-section {
  flex: 0 0 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Treemap tutorial (collapsible, above controls) */
.treemap-tutorial {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

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

.tutorial-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.tutorial-lead {
  margin: 8px 0 10px;
  color: #444;
  font-size: 13px;
  line-height: 1.4;
}

.tutorial-bullets {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: #333;
  line-height: 1.5;
}

.tutorial-bullets li {
  margin-bottom: 4px;
}

.tutorial-bullets li:last-child {
  margin-bottom: 0;
}

#dismissTreemapTutorial {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: white;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
}

#dismissTreemapTutorial:hover {
  background: #f1f5f9;
}

.tutorial-show {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  background: transparent;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  color: #334155;
}

.tutorial-show:hover {
  color: #1e293b;
}

.treemap-controls {
  margin-bottom: 16px;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 4px;
}

.treemap-control-row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.treemap-control-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.treemap-control-row select,
.treemap-control-row input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
}

.treemap-control-row #searchBox {
  flex: 1;
  min-width: 200px;
}

.treemap-control-row button {
  padding: 6px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.treemap-control-row button:hover {
  opacity: 0.9;
}

.guided-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
  margin-bottom: 8px;
}

.guided-controls.hidden {
  display: none !important;
}

.guided-controls button {
  padding: 6px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}

.guided-controls button:hover {
  opacity: 0.9;
}

.breadcrumbs {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: #666;
}

.breadcrumb-item {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.breadcrumb-item:hover {
  background: #e9e9e9;
}

.breadcrumb-item.active {
  font-weight: 600;
  color: var(--accent);
}

.breadcrumb-separator {
  color: #999;
}

#treemapContainer {
  width: 100%;
  height: 920px;
  min-height: 600px;
  max-height: calc(100vh - 200px);
  position: relative;
  overflow: hidden; /* IMPORTANT: prevent overlay outside container */
  flex: 0 0 auto;
  border-width: 0cap;
}

/* Area Evidence Panel */
.area-evidence {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 320px;
  max-width: calc(100% - 24px);
  max-height: 420px;
  overflow: auto;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 12px;
  z-index: 10;
}

.area-evidence.hidden {
  display: none;
}

.area-evidence-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: #333;
  font-size: 13px;
}

.area-evidence-body {
  font-size: 12px;
  line-height: 1.6;
}

.area-evidence-row {
  font-size: 12px;
  color: #333;
  margin-bottom: 10px;
}

.area-evidence-platform {
  border-top: 1px solid #eee;
  padding-top: 8px;
  margin-top: 8px;
  font-size: 12px;
}

.area-evidence-platform strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: #333;
}

.area-evidence-eq {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  color: #555;
}

/* Setting Details Panel */
#settingDetails {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: auto;
  width: 320px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 32px);
  overflow: hidden; /* internal sections manage scrolling */
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.details-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: #f9f9f9;
}

.details-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  flex: 1;
}

.details-subtitle {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: #666;
  flex: 1;
}

.details-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.details-close:hover {
  background: #e0e0e0;
  color: #333;
}

.details-body {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  max-height: none; /* let max-height be controlled by #settingDetails */
}

.details-row {
  margin-bottom: 16px;
}

.details-row:last-child {
  margin-bottom: 0;
}

.details-row strong {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.details-row p {
  margin: 0;
  font-size: 14px;
  color: #333;
  line-height: 1.5;
}

.details-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: #f9f9f9;
}

.details-link {
  display: inline-block;
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s;
}

.details-link:hover {
  opacity: 0.9;
}

.details-link:disabled,
.details-link[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

#treemapContainer svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Detail view card styles */
.detail-card {
  pointer-events: all;
}

.detail-button {
  pointer-events: all;
  cursor: pointer;
}

.detail-button rect {
  pointer-events: all;
}

.detail-button text {
  pointer-events: none;
  user-select: none;
}

/* Button name tooltip - shows ONLY the button label */
.button-name-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  z-index: 10000;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}

.treemap-cell {
  cursor: pointer;
  stroke: #fff;
  stroke-width: 1.5;
  transition: opacity 0.2s;
}

.treemap-cell:hover {
  opacity: 0.8;
  stroke-width: 2;
}

/* Category header styles (minimal, data-first) */
.category-header-bg {
  fill: #f3f4f6;
  stroke: none;
  stroke-width: 0;
  pointer-events: none;
}

.category-header-icon {
  pointer-events: none;
  user-select: none;
}

.category-header-label {
  fill: #374151;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  user-select: none;
}

.category-click-overlay {
  fill: transparent;
  cursor: pointer;
  pointer-events: all;
}

.category-click-overlay:hover {
  fill: rgba(0, 0, 0, 0.05);
}

.treemap-label {
  pointer-events: none;
  font-size: 13px;
  font-weight: 600;
  fill: #ffffff;
  text-anchor: middle;
  /* text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8); */
  stroke: #000000;
  stroke-width: 0.5px;
  paint-order: stroke;
}

.treemap-label-small {
  font-size: 11px;
  font-weight: 600;
}

.treemap-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  pointer-events: none;
  z-index: 1000;
  max-width: 300px;
  line-height: 1.5;
}

.treemap-tooltip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  color: #fff;
}

.treemap-tooltip p {
  margin: 2px 0;
  font-size: 12px;
}

/* Treemap Legend Styles */
#treemapLegend {
  margin-top: 12px;
  position: relative;
  z-index: 1;
}

/* Legend inside the control bar (hotbar) */
.legend-in-hotbar {
  margin-top: 0;
  margin-left: 8px;
  flex: 0 0 auto;
}

.legend-in-hotbar .legend-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  flex-wrap: wrap;
}

.legend-in-hotbar .legend-section {
  min-width: 0;
  flex: 0 0 auto;
}

.legend-in-hotbar .legend-title {
  margin-bottom: 0;
  margin-right: 4px;
  font-size: 12px;
}

.legend-in-hotbar .legend-items {
  gap: 8px;
}

.legend-in-hotbar .legend-item {
  font-size: 11px;
}

.legend-in-hotbar .legend-color {
  width: 12px;
  height: 12px;
}

.legend-wrapper {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
}

.legend-section {
  flex: 1;
  min-width: 200px;
}

.legend-title {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 14px;
  color: #333;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #555;
}

.legend-color {
  width: 16px;
  height: 16px;
  border: 1px solid #ccc;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-platform-item {
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  color: #666;
}

.main-content {
  h2 {
    margin-top: 1;
    font-size: 2rem;
  }
  p {
    font-size: 1.3rem;
  }
}

.settings ul,
#settingsList {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  max-height: 400px;
  flex: 1;
}

#platformFilter {
  min-width: 150px;
  padding: 4px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
}

#platformFilter option {
  padding: 4px 8px;
}

.charts-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 30px;
  padding: 20px;
}

.charts-section {
  flex: 0 0 auto;
  overflow: visible;
}

@media (max-width: 1024px) {
  .charts-container {
    grid-template-columns: 1fr;
  }
}

.chart-panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 15px;
}

.chart-panel h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

/* Legend under stacked bar chart (Settings by Platform and Type) */
.stacked-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #eee;
  font-size: 11px;
  color: #333;
  width: 100%;
}

.stacked-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stacked-chart-legend-color {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 1px;
  flex-shrink: 0;
}

.stacked-chart-legend-label {
  white-space: nowrap;
}

.chart-subtitle {
  font-size: 12px;
  color: #666;
  margin: 0 0 15px 0;
  line-height: 1.4;
}

.treemap-callout {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #555;
  line-height: 1.5;
}

/* Custom dropdown for platform filter */
.custom-dropdown {
  position: relative;
  display: inline-block;
  width: 200px;
  margin-left: 4px;
}

.dropdown-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  min-height: 28px;
}

.dropdown-trigger:hover {
  border-color: #999;
}

.dropdown-trigger.active {
  border-color: #4c6ef5;
  box-shadow: 0 0 0 2px rgba(76, 110, 245, 0.1);
}

.dropdown-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #333;
}

.dropdown-caret {
  margin-left: 8px;
  font-size: 10px;
  color: #666;
  transition: transform 0.2s;
}

.dropdown-trigger.active .dropdown-caret {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: none;
  max-height: 300px;
  overflow-y: auto;
}

.dropdown-menu.open {
  display: block;
}

.dropdown-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

.dropdown-list li {
  padding: 0;
  margin: 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: #333;
}

.dropdown-item:hover {
  background: #f5f5f5;
}

.dropdown-item input[type="checkbox"] {
  margin-right: 8px;
  cursor: pointer;
}

.dropdown-item label {
  cursor: pointer;
  flex: 1;
  margin: 0;
}

#stackedPlatformChart,
#pieAreaChart {
  width: 100%;
  overflow-x: hidden;
  min-height: 400px;
  max-height: 500px;
  overflow-y: auto;
}

#stackedPlatformChart svg,
#pieAreaChart svg {
  max-width: 100%;
  display: block;
}

#categorySmallMultiples {
  min-height: 400px;
  max-height: 500px;
  overflow: auto;
}

.small-multiple {
  margin-bottom: 30px;
}

.small-multiple h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 10px 0;
  color: #555;
}

/* Scrollbar styling for settings list */
#settingsList::-webkit-scrollbar {
  width: 8px;
}

#settingsList::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

#settingsList::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

#settingsList::-webkit-scrollbar-thumb:hover {
  background: #555;
}

#settingsList li {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

#settingsList li:hover {
  background: #f1f3ff;
}

.controls button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
}

.quick-actions button {
  width: 100%;
  margin-top: 8px;
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
}
