/* =============================================================================
   SLIDER POSITIONING AND STYLES
   ============================================================================= */
#year-slider-immigration {
  position: fixed;
  bottom: 0.2vh;
  left: 25%;
  z-index: 2;
  background: transparent;
  padding: 10px;
  border-radius: 10px;
  width: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

#slider-immigration {
  width: 100%;
  height: 10px;
  background-color: #d5d0d0;
  border-radius: 5px;
  appearance: none;
  outline: none;
  position: relative;
}

#slider-immigration:focus {
  outline: none;
  box-shadow: none;
}

#slider-immigration::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 25px;
  background: #141313;
  cursor: pointer;
  border-radius: 40%;
  position: relative;
  transition: transform 0.2s ease-in-out;
}

#slider-immigration::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

#slider-immigration::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: black;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid white;
  transition: transform 0.2s ease-in-out;
}

#slider-immigration::-moz-range-thumb:hover {
  transform: scale(1.2);
}

/* =============================================================================
   SLIDER TICKS AND LABELS
   ============================================================================= */

.slider-ticks-container {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: #666;
  width: 100%;
}

.slider-tick-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 0;
}

.slider-tick {
  width: 1px;
  height: 8px;
  background-color: #666;
  margin-bottom: 4px;
}

.slider-label {
  font-size: 11px;
  color: #666;
}

/* =============================================================================
   CUSTOM ZOOM BUTTON
   ============================================================================= */

.custom-zoom-to-extent-button-immigration {
  position: absolute;
  bottom: 25%;
  right: 8px;
  cursor: pointer;
  background-color: rgb(255, 255, 255);
  border-radius: 6px;
  border: 1.5px solid #a1a0a0;
  padding: 5px;
  transition: background-color 0.2s ease;
}

.custom-zoom-to-extent-button-immigration img {
  width: 20px;
  height: 20px;
}

.custom-zoom-to-extent-button-immigration:focus {
  outline: none;
}

.custom-zoom-to-extent-button-immigration:hover {
  background-color: #e8e8e8;
}

.custom-zoom-to-extent-tooltip-immigration {
  position: absolute;
  bottom: 100%;
  right: 100%;
  transform: translateX(50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  border-radius: 4px;
  padding: 5px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.custom-zoom-to-extent-button-immigration:hover
  .custom-zoom-to-extent-tooltip-immigration {
  visibility: visible;
  opacity: 1;
}

/* =============================================================================
   MODAL STYLES
   ============================================================================= */

.modal-immigration {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content-immigration {
  background-color: #fff;
  margin: 15% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 40%;
  text-align: center;
  border-radius: 8px;
}

.close-button-immigration {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  position: relative;
  top: -20px;
}

/* =============================================================================
   LEGEND CONTAINER AND LAYOUT - COMPACT VERSION
   ============================================================================= */

.legend-immi-container {
  text-align: left;
  font-family: Arial, sans-serif;
  width: 100%;
  max-width: 18%; /* Reduced from 25% */
  padding: 6px; /* Reduced from 10px */
  background: transparent;
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(200, 198, 198, 0.25);
  border-radius: 8px;
  position: absolute;
  right: 0.5vw;
  top: 1%;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.legend-immi-container.collapsed {
  max-width: 28px; /* Reduced from 35px */
  padding: 3px; /* Reduced from 5px */
  min-height: auto;
}

.legend-immi-container.collapsed .legend-header {
  border-bottom: none;
  margin-bottom: 0;
  padding: 0;
  justify-content: center;
}

.legend-immi-container.collapsed .legend-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.legend-immi-container.collapsed .legend-title-content {
  display: none;
}

.legend-title-content {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px; /* Reduced from 8px */
  font-size: 14px; /* Reduced from 14px */
  font-weight: bold;
  color: #2c3e50;
}

.circle-items-wrapper {
  display: flex;
  justify-content: space-around;
  gap: 6px; /* Reduced from 10px */
  width: 100%;
}

/* =============================================================================
   LEGEND HEADER AND CONTROLS - COMPACT VERSION
   ============================================================================= */

.legend-header {
  display: flex;
  align-items: center;
  gap: 4px; /* Reduced from 8px */
  padding: 3px 0; /* Reduced from 5px 0 */
  border-bottom: 1px solid #eee;
  margin-bottom: 8px; /* Reduced from 15px */
  flex-wrap: wrap;
}

.legend-year-value {
  font-size: 10px; /* Reduced from 12px */
  color: #666;
}

.legend-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 1px; /* Reduced from 2px */
  border-radius: 3px;
  transition: all 0.2s ease;
  color: #666;
  font-size: 12px; /* Reduced from 14px */
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 16px; /* Reduced from 20px */
  height: 16px; /* Reduced from 20px */
  line-height: 1;
  margin-left: auto;
}

.legend-collapse-btn:hover {
  background-color: rgba(0, 0, 0, 0.1);
  color: #333;
  transform: scale(1.1);
}

.collapse-icon {
  font-size: 14px; /* Reduced from 16px */
  color: #666;
  transition: transform 0.3s ease;
  user-select: none;
}

.collapse-icon.expanded {
  transform: rotate(180deg);
}

/* =============================================================================
   LEGEND CONTENT AND TEXT - COMPACT VERSION
   ============================================================================= */

.legend-content {
  overflow: hidden;
  transition: all 0.3s ease;
  max-height: 300px;
  opacity: 1;
}

.legend-title {
  font-size: 11px; /* Reduced from 14px */
  font-weight: bold;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px; /* Reduced from 8px */
}

#legend-year {
  font-size: 11px; /* Reduced from 14px */
  margin: 3px 0 0 0; /* Reduced from 5px 0 0 0 */
  color: #555;
}

.legend-meta {
  display: flex;
  align-items: center;
  gap: 4px; /* Reduced from 6px */
  font-size: 10px; /* Reduced from 12px */
  color: #666;
}

/* =============================================================================
   LEGEND INTERACTIVE ELEMENTS
   ============================================================================= */

.info-icon {
  color: #007bff;
  text-decoration: none;
  font-size: 10px; /* Reduced from 12px */
  transition: color 0.2s ease;
}

.info-icon:hover {
  color: #0056b3;
}

#legend-warning-flag,
.warning-flag {
  cursor: pointer;
  margin-left: 5px;
  transition: color 0.2s ease;
  color: #dc3545;
  font-size: 10px; /* Reduced from 12px */
}

#legend-warning-flag:hover,
.warning-flag:hover {
  opacity: 0.8;
}

/* =============================================================================
   CIRCLE LEGEND STYLES - COMPACT VERSION
   ============================================================================= */

.circles-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px; /* Reduced from 15px */
  background: white;
  border-radius: 4px; /* Reduced from 6px */
  border: 1px solid #ddd;
  gap: 6px; /* Reduced from 10px */
}

.circle-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 35px; /* Reduced from 50px */
}

.circle {
  border: 1px solid #000;
  border-radius: 50%;
  opacity: 1;
  margin-bottom: 4px; /* Reduced from 8px */
}

.circle-label {
  font-size: 8px; /* Reduced from 10px */
  color: #333;
  font-weight: 500;
  text-align: center;
  line-height: 1.1; /* Reduced from 1.2 */
  white-space: nowrap;
}

/* Smaller circle sizes */
.circle-1 {
  width: 6px; /* Reduced from 8px */
  height: 6px;
  background-color: #ffffcc;
}
.circle-2 {
  width: 11px; /* Reduced from 16px */
  height: 11px;
  background-color: #a1dab4;
}
.circle-3 {
  width: 17px; /* Reduced from 24px */
  height: 17px;
  background-color: #41b6c4;
}
.circle-4 {
  width: 22px; /* Reduced from 32px */
  height: 22px;
  background-color: #2c7fb8;
}
.circle-5 {
  width: 28px; /* Reduced from 40px */
  height: 28px;
  background-color: #253494;
}

/* =============================================================================
   CHART CONTAINER AND COLLAPSIBLE FUNCTIONALITY (ORIGINAL)
   ============================================================================= */

#immi-chart {
  position: absolute;
  bottom: 5%;
  left: 0.5%;
  background-color: white;
  border: 2px solid #ccc;
  border-radius: 20px;
  padding: 10px;
  font-size: 12px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  height: 93%;
  width: 23%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Chart collapse functionality - matches legend pattern */
#immi-chart.collapsed {
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  flex: none !important;
  position: relative;
  bottom: 15%;
}

#immi-chart.collapsed .chart-content {
  padding: 15px 20px;
  margin: 0;
  flex: none;
  height: auto;
}

#immi-chart.collapsed .controls,
#immi-chart.collapsed .stats-summary,
#immi-chart.collapsed .chart-container {
  display: none !important;
}

#immi-chart.collapsed .chart-header {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* Chart expanded state styles */
#immi-chart.expanded {
  height: 93%;
}

#immi-chart.expanded .chart-content {
  display: flex;
  flex-direction: column;
}

#immi-chart.expanded .controls {
  display: flex; /* Restore original grid layout */
}

#immi-chart.expanded .stats-summary,
#immi-chart.expanded .chart-container {
  display: block;
}

#immi-chart.expanded .chart-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #eee;
}

/* =============================================================================
   CHART HTML STRUCTURE STYLES (ORIGINAL)
   ============================================================================= */

.chart-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #ddd;
  margin: 10px 0;
  flex: 1;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Styling for the main chart's header */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #eee;
  background-color: transparent;
  padding-left: 15px;
  padding-right: 15px;
}

/* Styling for the IMMIGRATION title within the chart's header */
.chart-header .chart-title {
  font-size: 12px;
  font-weight: 600;
  flex-grow: 1;
  text-align: center;
  color: #090909;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: Arial, sans-serif;
  margin: 0;
}

/* Styling for the collapse button within the chart's header */
.chart-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: #070707;
  font-size: 1.2em;
  flex-shrink: 0;
}

/* Chart form controls styling (ORIGINAL) */
.chart-year-select,
.chart-state-search,
.chart-top-countries {
  width: 100%;
  padding: 8px;
  border: 1px solid #f2f3f4;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  background: white;
  color: #333;
  outline: none;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.chart-history-button {
  background: rgb(5, 80, 133);
  color: white;
  border: none;
  padding: 4px 10px; /* Increased from 8px 15px */
  border-radius: 5px; /* Increased from 5px */
  cursor: pointer;
  font-size: 15px; /* Increased from 13px */
  font-weight: bold;
  margin-top: 32px;
  min-width: 30px; /* Added minimum width */
  min-height: 40px; /* Added minimum height */
}

.chart-history-button:hover {
  background: rgb(4, 60, 100);
}

.chart-history-button:disabled {
  background: #ccc;
  cursor: not-allowed;
  opacity: 0.6;
}

/* =============================================================================
   HISTORICAL CONTEXT MODAL STYLES
   ============================================================================= */

.historical-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  padding: 20px;
  box-sizing: border-box;
}

.historical-modal-content {
  background: white;
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  position: relative;
  margin-top: -50px;
}

.historical-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 25px 25px 15px 25px;
  border-bottom: 2px solid #3498db;
}

.historical-modal-header.national {
  border-bottom-color: #34495e;
}

.historical-modal-title {
  margin: 0;
  color: #2c3e50;
  font-size: 22px;
}

.historical-modal-subtitle {
  margin: 5px 0 0 0;
  color: #7f8c8d;
  font-size: 14px;
}

.historical-modal-badges {
  margin-top: 8px;
  font-size: 12px;
}

.historical-badge-immigration {
  background: #2ecc71;
  color: white;
  padding: 2px 6px;
  border-radius: 8px;
  margin-right: 4px;
}

.historical-badge-political {
  background: #9b59b6;
  color: white;
  padding: 2px 6px;
  border-radius: 8px;
  margin-right: 4px;
}

.historical-badge-legal {
  background: #e74c3c;
  color: white;
  padding: 2px 6px;
  border-radius: 8px;
}

.historical-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #95a5a6;
  padding: 5px;
  border-radius: 50%;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.historical-modal-body {
  padding: 0 25px 25px 25px;
}

.historical-story-item {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.historical-story-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.historical-story-title {
  margin: 0;
  color: #2c3e50;
  font-size: 18px;
}

.historical-story-badge {
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
  background: #3498db; /* Default blue for state-specific */
}

.historical-story-badge.historical-badge-immigration {
  background: #2ecc71; /* Green for USA immigration events */
}

.historical-story-badge.historical-badge-political {
  background: #9b59b6; /* Purple for National political events */
}

.historical-story-badge.historical-badge-legal {
  background: #e74c3c; /* Red for Policy/Legal events */
}

.historical-story-text {
  margin: 10px 0;
  line-height: 1.6;
  color: #34495e;
  font-size: 14px;
}

.historical-story-impact {
  background: #ecf0f1;
  padding: 10px;
  border-radius: 6px;
  margin-top: 10px;
}

.historical-impact-label {
  color: #27ae60;
  font-size: 13px;
  font-weight: bold;
}

.historical-impact-text {
  color: #2c3e50;
  font-size: 13px;
}

.historical-modal-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #ecf0f1;
}

.historical-modal-close-btn {
  background: #3498db;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
}

.historical-modal-close-btn.national {
  background: #34495e;
}

/* =============================================================================
   HISTORICAL CONTEXT MODAL MULTIMEDIA STYLES
   ============================================================================= */

.historical-video-container {
  margin: 15px 0;
}

.historical-video-iframe {
  width: 100%;
  height: 315px;
  border-radius: 8px;
  max-width: 560px;
}

.historical-images-container {
  margin: 15px 0;
}

.historical-image-wrapper {
  margin: 10px 0;
}

.historical-image {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: zoom-in;
  transition: transform 0.3s ease;
}

.historical-image.historical-image-zoomed {
  transform: scale(1.5);
  cursor: zoom-out;
}

.historical-resources-container {
  margin: 15px 0;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 6px;
}

.historical-resources-title {
  margin: 0 0 10px 0;
  color: #2c3e50;
  font-size: 14px;
}

.historical-resources-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.historical-resource-link {
  display: inline-block;
  background: #2ecc71;
  color: white;
  padding: 6px 12px;
  text-decoration: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  transition: background-color 0.2s ease;
}

.historical-resource-link:hover {
  background: #27ae60;
  color: white;
  text-decoration: none;
}

/* =============================================================================
   FORM CONTROLS (ORIGINAL)
   ============================================================================= */

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-group label {
  font-weight: bold;
  font-size: 13px;
  color: #333;
}

.control-group select,
.control-group input {
  width: 100%;
  padding: 8px;
  border: 1px solid #007bff;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  background: white;
  color: #333;
  outline: none;
  box-shadow: none;
}

.control-group select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.control-group button {
  background: rgb(5, 80, 133);
  color: white;
  border: none;
  padding: 12px 20px; /* Increased from 8px 15px */
  border-radius: 6px; /* Increased from 5px */
  cursor: pointer;
  font-size: 15px; /* Increased from 13px */
  font-weight: bold;
  margin-top: 27px;
  transition: background-color 0.2s ease;
  min-width: 120px; /* Added minimum width */
  min-height: 40px; /* Added minimum height */
}

.control-group button:hover {
  background: rgb(4, 60, 100);
}

.control-group button:disabled {
  background: #ccc;
  cursor: not-allowed;
  opacity: 0.6;
}

/* =============================================================================
   SEARCH DROPDOWN (ORIGINAL)
   ============================================================================= */

.search-dropdown-container {
  position: relative;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.2s;
  font-size: 13px;
  color: #34495e;
}

.search-item.search-item-special {
  font-weight: 600;
  color: #2c3e50;
}

.search-item:hover {
  background: #f8f9fa;
}

.search-item.selected {
  background: #e3f2fd;
  color: #1976d2;
}

.search-item:last-child {
  border-bottom: none;
}

.search-separator {
  height: 1px;
  background: #eee;
  margin: 4px 0;
}

.search-highlight {
  background: yellow;
  font-weight: bold;
}

/* =============================================================================
   EXTREMELY MINIMAL STATISTICS OVERVIEW SECTION
   ============================================================================= */

.stats-summary {
  margin-bottom: 1px; /* Extremely reduced from 3px */
}

.stats-summary h3 {
  margin: 0 0 1px 0; /* Extremely reduced from 2px */
  color: #2c3e50;
  font-size: 6px; /* Extremely reduced from 8px */
  font-weight: 600;
  line-height: 1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fit,
    minmax(25px, 1fr)
  ); /* Extremely reduced from 45px */
  gap: 1px; /* Extremely reduced from 2px */
}

.stat-item {
  text-align: center;
  padding: 0.5px; /* Extremely reduced from 1px */
  background: #f8f9fa;
  border-radius: 0px; /* Removed border radius */
  border: 1px solid #e9ecef;
}

.stat-value {
  font-size: 5px; /* Extremely reduced from 8px */
  font-weight: bold;
  color: #2c3e50;
  margin-bottom: 0px; /* Extremely reduced from 1px */
  line-height: 1;
}

.stat-label {
  font-size: 4px; /* Extremely reduced from 6px */
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0px; /* Removed letter spacing */
  line-height: 1;
}

.chart-container {
  position: relative;
  height: 410px; /* Increased from original 400px since overview is smaller */
  margin-top: 20px;
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

.disabled-tick {
  cursor: default !important;
}

.text-danger {
  color: #dc3545 !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

/* =============================================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================================= */

.legend-header:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
  border-radius: 4px;
}

.info-icon:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
  border-radius: 2px;
}

.legend-item:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
  border-radius: 4px;
}

/* =============================================================================
   HISTORICAL CONTEXT MODAL
   ============================================================================= */

#historical-context-modal > div::-webkit-scrollbar {
  display: none;
}

#historical-context-modal > div {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* =============================================================================
   ULTRA COMPACT RESPONSIVE DESIGN - TABLET (768px and below)
   ============================================================================= */

@media screen and (max-width: 768px) {
  #year-slider-immigration {
    width: 90%;
  }

  .legend-immi-container {
    max-width: 16%; /* Even smaller on tablet */
    width: 70%;
    right: 2%;
    padding: 4px;
  }

  .circles-container {
    padding: 6px;
    gap: 4px;
  }

  .circle-item {
    min-width: 28px;
  }

  .circle-label {
    font-size: 7px;
  }

  #immi-chart {
    width: 90%;
    left: 5%;
    bottom: 10%;
    height: 65%; /* Reduced from 75% */
    padding: 3px; /* Reduced from 6px */
  }

  #immi-chart.collapsed {
    height: auto;
    min-height: auto;
    max-height: auto;
  }
  #immi-chart.collapsed .bi.bi-arrows-angle-expand {
    position: absolute; /* or fixed depending on your layout */
    top: 10px; /* adjust as needed */
    right: 10px; /* adjust as needed */
    z-index: 999; /* make sure it's on top */
    background-color: #27ae60;
  }

  .chart-content {
    padding: 4px; /* Reduced from 8px */
  }

  .controls {
    gap: 3px; /* Reduced from 6px */
    grid-template-columns: repeat(
      auto-fit,
      minmax(60px, 1fr)
    ); /* Much smaller */
  }

  .stats-grid {
    gap: 0.5px; /* Extremely reduced from 1px */
    grid-template-columns: repeat(
      auto-fit,
      minmax(22px, 1fr)
    ); /* Extremely reduced from 35px */
  }

  .stat-item {
    padding: 0.5px; /* Minimal padding */
  }

  .stat-value {
    font-size: 4px; /* Extremely reduced from 7px */
  }

  .stat-label {
    font-size: 3px; /* Extremely reduced from 5px */
  }

  .stats-summary {
    margin-bottom: 1px; /* Extremely reduced from 2px */
  }

  .stats-summary h3 {
    font-size: 5px; /* Extremely reduced from 7px */
    margin-bottom: 0px; /* Extremely reduced from 1px */
  }

  .chart-container {
    height: 220px; /* Increased from 200px since overview is even smaller */
  }

  .legend-item {
    font-size: 12px;
  }

  .legend-symbol {
    width: 35px;
    height: 20px;
    margin-right: 8px;
  }

  .legend-header {
    padding: 8px 0;
  }

  .collapse-icon {
    font-size: 14px;
  }
}

/* =============================================================================
   ULTRA COMPACT RESPONSIVE DESIGN - MOBILE (480px and below)
   ============================================================================= */

@media screen and (max-width: 480px) {
  #year-slider-immigration {
    width: 95%;
  }

  .slider-label {
    font-size: 10px;
  }

  .slider-tick {
    height: 6px;
    margin: 0;
  }

  .legend-immi-container {
    max-width: 14%; /* Very small on mobile */
    width: 90%;
    right: 2%;
    top: 50px;
    padding: 3px;
  }

  .legend-immi-container.collapsed {
    max-width: 22px;
    padding: 2px;
  }

  .circles-container {
    padding: 4px;
    gap: 3px;
    min-height: 35px; /* Reduced from 45px */
  }

  .circle-item {
    min-width: 25px;
  }

  .circle-label {
    font-size: 6px;
  }

  /* Even smaller circles on mobile */
  .circle-1 {
    width: 4px;
    height: 4px;
  }
  .circle-2 {
    width: 8px;
    height: 8px;
  }
  .circle-3 {
    width: 12px;
    height: 12px;
  }
  .circle-4 {
    width: 16px;
    height: 16px;
  }
  .circle-5 {
    width: 20px;
    height: 20px;
  }

  #immi-chart {
    width: 95%;
    left: 2.5%;
    bottom: 15%;
    height: 55%; /* Reduced from 65% */
    padding: 2px; /* Reduced from 4px */
  }

  #immi-chart.collapsed {
    height: auto;
    min-height: auto;
    max-height: auto;
  }

  .chart-content {
    padding: 3px; /* Reduced from 6px */
  }

  .chart-header {
    margin-bottom: 4px; /* Reduced from 8px */
    padding-bottom: 3px; /* Reduced from 6px */
  }

  .controls {
    gap: 2px; /* Reduced from 4px */
    margin-bottom: 4px; /* Reduced from 8px */
    grid-template-columns: repeat(
      auto-fit,
      minmax(45px, 1fr)
    ); /* Much smaller */
  }

  .stats-summary {
    margin-bottom: 4px; /* Reduced from 8px */
  }

  .stats-summary h3 {
    font-size: 10px; /* Reduced from 12px */
    margin-bottom: 3px; /* Reduced from 6px */
  }

  .chart-container {
    height: 200px; /* Increased from 180px since overview is even smaller */
    margin-top: 1px; /* Reduced from 2px */
  }

  .stat-value {
    font-size: 10px; /* Reduced from 12px */
  }

  .stat-label {
    font-size: 7px; /* Reduced from 9px */
  }

  .stats-grid {
    grid-template-columns: repeat(
      auto-fit,
      minmax(40px, 1fr)
    ); /* Much smaller */
  }

  .legend-collapse-btn {
    min-width: 14px; /* Reduced from 18px */
    height: 14px; /* Reduced from 18px */
    font-size: 10px; /* Reduced from 12px */
    padding: 1px;
  }

  .legend-title {
    font-size: 10px; /* Reduced from 12px */
  }

  #legend-year {
    font-size: 10px; /* Reduced from 12px */
  }

  .legend-item {
    font-size: 9px; /* Reduced from 11px */
  }

  .legend-symbol {
    width: 30px;
    height: 18px;
    margin-right: 6px;
  }

  .normal-legend-container {
    padding: 10px;
  }

  /* Mobile adjustments for larger buttons */
  .chart-history-button,
  .control-group button {
    padding: 10px 16px; /* Slightly smaller on mobile */
    font-size: 14px; /* Slightly smaller font on mobile */
    min-width: 100px; /* Smaller minimum width on mobile */
    min-height: 36px; /* Smaller minimum height on mobile */
  }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
  .legend-immi-container {
    position: static;
    box-shadow: none;
    border: 1px solid #ccc;
    background: white;
  }

  .legend-content.collapsed {
    max-height: none;
    opacity: 1;
  }

  .collapse-icon {
    display: none;
  }

  .normal-legend-container {
    border: none;
    padding: 0;
  }

  #immi-chart {
    position: static;
    width: 100%;
    height: auto;
    box-shadow: none;
  }

  #immi-chart.collapsed {
    height: auto;
    max-height: none;
  }

  #immi-chart.collapsed .chart-header ~ * {
    display: block;
  }
}
#immi-chart.collapsed .chart-expand-btn {
  position: absolute;
  top: 20px; /* move it down */
}

/* =============================================================================
   EXPAND BUTTON (ORIGINAL)
   ============================================================================= */

.chart-expand-btn {
  position: absolute;
  top: 40px;
  right: 70px;
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
  font-size: 14px;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
}

.chart-expand-btn:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.1);
  color: #333;
}

.chart-expand-btn:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* =============================================================================
   CHART MODAL SCROLL HIDING
   ============================================================================= */

/* Hide scrollbar in chart expansion modal */
#chart-expansion-modal .historical-modal-content {
  overflow: hidden; /* Remove all scrollbars */
}

/* If you need scrolling but want to hide the scrollbar, use these instead: */
#chart-expansion-modal .historical-modal-content {
  /* For Webkit browsers (Chrome, Safari, Edge) */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* Internet Explorer 10+ */
}

#chart-expansion-modal .historical-modal-content::-webkit-scrollbar {
  display: none; /* Webkit browsers */
}

/* Alternative: Hide scrollbar but keep scroll functionality */
#chart-expansion-modal .historical-modal-content {
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

#chart-expansion-modal .historical-modal-content::-webkit-scrollbar {
  width: 0px;
  background: transparent; /* Chrome/Safari/Webkit */
}
