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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  background-color: #f5f5f5;
  color: #333;
  padding: 0;
  margin: 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

h1, h2, h3, h4 {
  color: #2c3e50;
  margin-bottom: 15px;
}

/* Header */
header {
  background-color: #2c3e50;
  color: white;
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
  color: white;
  margin-bottom: 5px;
  font-size: 2.2rem;
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.8;
}

/* Map and legend layout changed */
#mapAndLegendContainer {
  margin-bottom: 30px;
  display: flex;
  justify-content: center;
}

/* Map container - now contains the legend */
#mapContainer {
  position: relative;
  width: 100%;
  max-width: 650px; /* Adjusted to fit both map and legend */
  background-color: white;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Flex container for map and legend within map container */
#mapFlexContainer {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

/* Map wrapper - contains the actual SVG */
#mapWrapper {
  flex: 1;
  min-width: 300px;
}

/* SVG Map */
#map {
  width: 100%;
  max-height: 450px;
  height: auto;
  display: block;
}

/* Instructions */
/* Instructions Styling */
.instructions {
  background-color: #f9f9f9;
  padding: 8px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  margin-top: 20px;
  font-size: 1rem;
  color: #555;
  font-style: italic;
  text-align: center;
  max-width: 45%;
  transition: all 0.3s ease-in-out;
  margin-left: 20%;}

/* Hover effect */
.instructions:hover {
  background-color: #f1f1f1;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

/* Italics styling */
.instructions i {
  font-style: italic;
  color: #8b0000; /* Light blue color for the icon text */
}


/* Tooltip */
.tooltip {
  position: absolute;
  padding: 10px 15px;
  background-color: rgba(44, 62, 80, 0.9);
  color: white;
  border-radius: 4px;
  font-size: 14px;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  max-width: 200px;
}

.tooltip strong {
  display: block;
  margin-bottom: 5px;
  color: #3498db;
}

.tooltip.show {
  opacity: 1;
}

/* Heatmap Legend - now inside map container */
#heatmapLegend {
  flex: 0 0 170px; /* Further reduced width */
  padding: 12px;
  background-color: #f7f9fa; /* Lighter background to differentiate */
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1px solid #ecf0f1;
}

#heatmapLegend h2 {
  font-size: 1rem;
  margin-bottom: 10px;
}

/* Legend Item */
.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  margin-right: 8px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Chart Container */
#chartContainer {
  width: 100%;
  height: 380px;
  background-color: white;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 25px;
  position: relative;
}

#chartContainer2 {
  width: 100%;
  height: 380px;
  background-color: white;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 25px;
  position: relative;
}

/* Canvas for chart */
#barChart {
  height: 300px !important;
}

#barChart2 {
  height: 300px !important;
}

/* Candidate Legend */
#candidateLegend {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-top: 15px;
  padding: 12px;
  background-color: #f9f9f9;
  border-radius: 6px;
  font-size: 0.9rem;
}

/* Extra Info Box */
#extraInfo {
  width: 100%;
  background-color: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

.info-box {
  border-left: 5px solid #3498db;
  padding-left: 15px;
}

.info-box h3 {
  margin-top: 0;
  color: #2980b9;
}

/* Footer */
footer {
  background-color: #2c3e50;
  color: white;
  text-align: center;
  padding: 15px;
  margin-top: 30px;
  font-size: 0.9rem;
}

/* Loading animation */
.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #8b0000;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 2s linear infinite;
  margin: 20px auto;
}

#chartsContainer,
#candidateLegend,
#candidateLegend2,
#heatmapLegend,
#extraInfo {
  display: none;
}

#liveButton {
  background-color: red;
  color: white;
  padding: 2px 8px;
  font-size: 0.7em;
  border-radius: 5px;
  margin-left: 10px;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 50%, 100% {
      opacity: 1;
  }
  25%, 75% {
      opacity: 0;
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive Layout */
@media (max-width: 768px) {
  #mapFlexContainer {
    flex-direction: column;
  }
  
  #heatmapLegend {
    width: 100%;
    flex: none;
  }
  
  #chartContainer {
    height: 380px;
  }
  
  header h1 {
    font-size: 1.8rem;
  }
  
  .subtitle {
    font-size: 1rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
}

/* Small screens */
@media (max-width: 480px) {
  .container {
    padding: 10px;
  }
  
  #chartContainer {
    height: 320px;
    padding: 15px;
  }
  
  #barChart {
    height: 250px !important;
  }
  
  header h1 {
    font-size: 1.5rem;
  }
  
  h2 {
    font-size: 1.3rem;
  }
}

.charts-flex-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}

.chart-wrapper {
  flex: 1;
  min-width: 300px;
  padding: 15px;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
  .charts-flex-container {
    flex-direction: column;
  }
  
  .chart-wrapper {
    width: 100%;
  }
}