:root {
  --page-bg: #f8f9fa;
  --card-bg: #3c4556;
  --info-bg: #2d3544;
  --text-primary: #ffffff;
  --text-secondary: #cdd5e0;
  --border-color: #5d677a;
  --hover-bg: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Montserrat", Arial, sans-serif;
  background-color: var(--page-bg);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  overflow-x: hidden;
  overflow-y: scroll;
  /* Force vertical scrollbar to stop flickering loop */
}

.dashboard-container {
  width: 100%;
  max-width: 1250px;
  /* Increased to allow a broader chart */
  background-color: var(--card-bg);
  border-radius: 0;
  padding: 1.5rem 1.5rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

header {
  margin-bottom: 1rem;
  position: relative;
  padding-left: 20px;
}

h1 {
  font-family: "Montserrat", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
}

.percentage-label {
  position: absolute;
  left: 45px;
  /* Aligned with desktop Y-axis numbers */
  top: 5px;
  /* Above the chartArea top */
  font-size: 11px;
  color: #cdd5e0;
  z-index: 10;
}

.y-axis-label {
  position: absolute;
  top: 35px;
  left: 0px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Dashboard Side-by-Side Content Layout */
.dashboard-content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  /* Compacted sidebar to win chart space */
  gap: 1.5rem 1rem;
  align-items: stretch;
}

.chart-wrapper {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  min-height: 480px;
  position: relative;
  margin-left: -5px;
}

#line_chart {
  width: 100%;
  height: 100%;
}

.custom-legends-container {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-left: 1.5rem;
  border-left: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.legend-column {
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

.legend-column h3 {
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  border-bottom: none;
  padding-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: opacity 0.3s ease;
  cursor: pointer;
  /* Also indicate grouped items below */
}

.legend-column[data-group="starters"] h3 {
  color: #dc4570;
}

.legend-column[data-group="doorstromers"] h3 {
  color: #74bce0;
}

.legend-column[data-group="niet-kopers"] h3 {
  color: #fdc100;
}

.legend-column ul {
  padding-left: 0 !important;
  margin-bottom: 0 !important;
}

.legend-graph-list {
  list-style: none;
}

.legend-graph-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.3rem 0.5rem;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
  border-radius: 4px;
  margin-bottom: 0.15rem;
  gap: 0.5rem;
}

.legend-graph-item:hover,
.legend-graph-item.active-item {
  background-color: var(--hover-bg);
}

.color-box {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  align-self: center;
}

.profile-name {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  display: flex;
  align-items: center;
  line-height: normal;
}

/* Dimming feature for columns - Group hover */
.dashboard-container.group-hover-active .legend-column:not(.hovered-group) {
  opacity: 0.4;
}

/* Info Bar Bottom Style */
.info-bar {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-top: 0;
  background-color: var(--info-bg);
  border: 1px solid var(--border-color);
  border-radius: 0;
  /* Balanced padding for desktop (768px and up) */
  height: 180px;
  padding: 1.25rem 1.5rem 1.25rem 1.5rem;
  margin: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  /* Prevent horizontal scroll */
  overflow-wrap: break-word;
  /* Ensure text stays within bounds */
}

/* Custom scrollbar to keep it looking premium when needed */
.info-bar::-webkit-scrollbar {
  width: 8px;
  /* Slightly wider */
}

.info-bar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  /* Visible track */
}

.info-bar::-webkit-scrollbar-thumb {
  background-color: #7a8ba3;
  /* Brighter, more contrast */
  border-radius: 10px;
}

.info-bar h2 {
  font-family: "Montserrat", sans-serif;
  font-size: 0.9rem;
  color: #ffffff;
  margin-bottom: 0.2rem;
  font-weight: 700;
}

.info-bar p {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

/* Intermediate screen adjustments (Tablet/Small Laptop) */
@media screen and (max-width: 970px) {
  .dashboard-content-layout {
    grid-template-columns: minmax(0, 1fr) 190px;
    gap: 1rem 0.75rem;
  }

  .custom-legends-container {
    padding-left: 0.5rem;
    gap: 0.7rem;
  }

  .legend-column h3 {
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
  }

  .legend-graph-item {
    font-size: 12px;
    padding: 0.2rem 0.4rem;
  }

  .color-box {
    width: 8px;
    height: 8px;
    margin-right: 0.4rem;
  }

  .chart-wrapper {
    min-height: 400px;
  }

  .dashboard-container {
    padding: 1rem 0.35rem;
    /* Minimized horizontal space on mobile to the limit */
    border-radius: 0;
  }
}

/* Responsive adjustments (Mobile) */
@media screen and (max-width: 768px) {
  .dashboard-content-layout {
    display: grid;
    grid-template-columns: 110px 1fr;
    /* Pushing the limit for text space */
    gap: 1rem 0.25rem;
  }

  .custom-legends-container {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    border-left: none;
    padding-left: 0;
    border-top: none;
    padding-top: 0;
    gap: 0.5rem;
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  .legend-column:last-child {
    margin-top: auto;
    /* Pushes the Niet-kopers group to the absolute bottom */
  }

  .legend-column:last-child .legend-graph-item:last-child {
    margin-bottom: 0 !important;
  }

  body {
    padding: 1rem 0;
    /* Remove body side padding on mobile */
  }

  .dashboard-container {
    padding: 1rem 0.35rem;
    /* slight margin to avoid "te krap" feeling */
    border-radius: 0;
  }

  .percentage-label {
    left: 26px;
    /* Aligned with mobile Y-axis numbers */
  }

  .legend-column h3 {
    font-size: 0.7rem;
    margin-bottom: 0.2rem;
    margin-top: 0.4rem;
  }

  .legend-graph-item {
    font-size: 10px;
    padding: 0.1rem 0.15rem;
    /* Ultra tight padding */
    line-height: 1.1;
    margin-bottom: 0.05rem;
  }

  .color-box {
    width: 8px;
    height: 8px;
    margin-right: 0.4rem;
  }

  .chart-wrapper {
    grid-column: 1 / span 2;
    grid-row: 1;
    height: 200px;
    /* Reduced further to 200px for more compact mobile view */
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
  }

  h1 {
    font-size: 1.15rem;
  }

  /* Info bar always visible on mobile too, right column */
  .info-bar {
    grid-column: 2;
    grid-row: 2;
    display: block !important;
    margin-top: 0;
    /* Force info box to match legend's height and scroll if needed */
    height: 0;
    min-height: 100%;
    max-height: none;
    padding: 0.35rem 0.55rem 0.35rem 0.55rem;
  }

  .info-bar h2 {
    font-size: 0.8rem;
  }

  .info-bar p {
    font-size: 11px;
  }

  /* Thinner scrollbar for small mobile info-bar */
  .info-bar::-webkit-scrollbar {
    width: 5px;
  }
}

/* Comparison Header styling outside media query */
.comparison-header {
  width: 100%;
  max-width: 1250px;
  margin: 0 auto 2rem auto;
  text-align: left;
}

.comparison-header h2 {
  font-family: "Montserrat", sans-serif;
  color: #3c4556;
  /* Dark HDN blue for text on light background */
  margin-bottom: 1rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.responsive-img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  display: block;
}
