/* wrapper flessibile */
#stacked_bar_chart_container .chart-wrapper {
  position: relative;
  display: block;
  flex-direction: column;
  align-items: center;
  width: 100%;         
  max-width: 100%;      
}

/* svg responsive */
#stacked_bar_chart_container svg {
  font-size: 12px;
  fill: #222;
  display: block;
  width: 100% !important;
  height: auto !important;
}

/* legend */
#stacked_bar_chart_container .legend span {
  font-size: 13px;
  vertical-align: middle;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.15s ease-in-out;
}

#stacked_bar_chart_container .legend span.active {
  font-weight: 700;
  background: rgba(0,0,0,0.08);
  text-decoration: underline;
}

/* tooltip */
#stacked_bar_chart_container .tooltip {
  position: absolute;
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid #333;
  border-radius: 6px;
  pointer-events: none;
  font-size: 12px;
  color: #222;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  z-index: 99999;
  transition: opacity 0.1s ease-in-out;
}

/* interactive highlight */
#stacked_bar_chart_container rect {
  cursor: pointer;
  transition: opacity 0.15s ease-in-out;
}

#stacked_bar_chart_container g.layer {
  transition: opacity 0.15s ease-in-out;
}


/* =======================================
   Common Tooltip Base
   ======================================= */
.stacked-tooltip {
  position: absolute;
  pointer-events: none;
  transition: opacity 0.15s ease-in-out;
  z-index: 1000;
  opacity: 0;
}

.stacked-tooltip .tooltip-content {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  padding: 14px 18px;
  max-width: 260px;
}

/* Header Row */
.stacked-tooltip .tooltip-header {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.stacked-tooltip .tooltip-color-box {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
  margin-right: 10px;
}

.stacked-tooltip .tooltip-title {
  color: #333;
  font-size: 15px;
  font-weight: 600;
}

.stacked-tooltip .tooltip-value {
  color: #000;
  font-weight: 700;
  letter-spacing: -0.4px;
}

/* =======================================
   Legend Tooltip (light, compact)
   ======================================= */
.legend-tooltip .tooltip-content {
  padding: 14px 18px;
}

.legend-tooltip .tooltip-value {
  font-size: 22px;
}

/* =======================================
   Bar Tooltip (richer layout)
   ======================================= */
.bar-tooltip .tooltip-content {
  padding: 16px 20px;
}

.bar-tooltip .tooltip-region {
  color: #666;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bar-tooltip .tooltip-value {
  font-size: 26px;
}

/* Prevent overlapping: ensures topmost tooltip is above */
.stacked-tooltip {
  z-index: 2000;
}


/* Il div che ospita l'SVG deve poter allargarsi */
#stacked_bar_chart_svg {
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
}
